babylon.max.js 6.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487
  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"] = InterpolateValueAction;
  2287. /***/ }),
  2288. /***/ "./Animations/animatable.ts":
  2289. /*!**********************************!*\
  2290. !*** ./Animations/animatable.ts ***!
  2291. \**********************************/
  2292. /*! exports provided: Animatable */
  2293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2294. "use strict";
  2295. __webpack_require__.r(__webpack_exports__);
  2296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2297. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2298. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2300. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2302. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2303. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2304. /**
  2305. * Class used to store an actual running animation
  2306. */
  2307. var Animatable = /** @class */ (function () {
  2308. /**
  2309. * Creates a new Animatable
  2310. * @param scene defines the hosting scene
  2311. * @param target defines the target object
  2312. * @param fromFrame defines the starting frame number (default is 0)
  2313. * @param toFrame defines the ending frame number (default is 100)
  2314. * @param loopAnimation defines if the animation must loop (default is false)
  2315. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2316. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2317. * @param animations defines a group of animation to add to the new Animatable
  2318. * @param onAnimationLoop defines a callback to call when animation loops
  2319. */
  2320. function Animatable(scene,
  2321. /** defines the target object */
  2322. target,
  2323. /** defines the starting frame number (default is 0) */
  2324. fromFrame,
  2325. /** defines the ending frame number (default is 100) */
  2326. toFrame,
  2327. /** defines if the animation must loop (default is false) */
  2328. loopAnimation, speedRatio,
  2329. /** defines a callback to call when animation ends if it is not looping */
  2330. onAnimationEnd, animations,
  2331. /** defines a callback to call when animation loops */
  2332. onAnimationLoop) {
  2333. if (fromFrame === void 0) { fromFrame = 0; }
  2334. if (toFrame === void 0) { toFrame = 100; }
  2335. if (loopAnimation === void 0) { loopAnimation = false; }
  2336. if (speedRatio === void 0) { speedRatio = 1.0; }
  2337. this.target = target;
  2338. this.fromFrame = fromFrame;
  2339. this.toFrame = toFrame;
  2340. this.loopAnimation = loopAnimation;
  2341. this.onAnimationEnd = onAnimationEnd;
  2342. this.onAnimationLoop = onAnimationLoop;
  2343. this._localDelayOffset = null;
  2344. this._pausedDelay = null;
  2345. this._runtimeAnimations = new Array();
  2346. this._paused = false;
  2347. this._speedRatio = 1;
  2348. this._weight = -1.0;
  2349. /**
  2350. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2351. * This will only apply for non looping animation (default is true)
  2352. */
  2353. this.disposeOnEnd = true;
  2354. /**
  2355. * Gets a boolean indicating if the animation has started
  2356. */
  2357. this.animationStarted = false;
  2358. /**
  2359. * Observer raised when the animation ends
  2360. */
  2361. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. /**
  2363. * Observer raised when the animation loops
  2364. */
  2365. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2366. this._scene = scene;
  2367. if (animations) {
  2368. this.appendAnimations(target, animations);
  2369. }
  2370. this._speedRatio = speedRatio;
  2371. scene._activeAnimatables.push(this);
  2372. }
  2373. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2374. /**
  2375. * Gets the root Animatable used to synchronize and normalize animations
  2376. */
  2377. get: function () {
  2378. return this._syncRoot;
  2379. },
  2380. enumerable: true,
  2381. configurable: true
  2382. });
  2383. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2384. /**
  2385. * Gets the current frame of the first RuntimeAnimation
  2386. * Used to synchronize Animatables
  2387. */
  2388. get: function () {
  2389. if (this._runtimeAnimations.length === 0) {
  2390. return 0;
  2391. }
  2392. return this._runtimeAnimations[0].currentFrame;
  2393. },
  2394. enumerable: true,
  2395. configurable: true
  2396. });
  2397. Object.defineProperty(Animatable.prototype, "weight", {
  2398. /**
  2399. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2400. */
  2401. get: function () {
  2402. return this._weight;
  2403. },
  2404. set: function (value) {
  2405. if (value === -1) { // -1 is ok and means no weight
  2406. this._weight = -1;
  2407. return;
  2408. }
  2409. // Else weight must be in [0, 1] range
  2410. this._weight = Math.min(Math.max(value, 0), 1.0);
  2411. },
  2412. enumerable: true,
  2413. configurable: true
  2414. });
  2415. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2416. /**
  2417. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2418. */
  2419. get: function () {
  2420. return this._speedRatio;
  2421. },
  2422. set: function (value) {
  2423. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2424. var animation = this._runtimeAnimations[index];
  2425. animation._prepareForSpeedRatioChange(value);
  2426. }
  2427. this._speedRatio = value;
  2428. },
  2429. enumerable: true,
  2430. configurable: true
  2431. });
  2432. // Methods
  2433. /**
  2434. * Synchronize and normalize current Animatable with a source Animatable
  2435. * This is useful when using animation weights and when animations are not of the same length
  2436. * @param root defines the root Animatable to synchronize with
  2437. * @returns the current Animatable
  2438. */
  2439. Animatable.prototype.syncWith = function (root) {
  2440. this._syncRoot = root;
  2441. if (root) {
  2442. // Make sure this animatable will animate after the root
  2443. var index = this._scene._activeAnimatables.indexOf(this);
  2444. if (index > -1) {
  2445. this._scene._activeAnimatables.splice(index, 1);
  2446. this._scene._activeAnimatables.push(this);
  2447. }
  2448. }
  2449. return this;
  2450. };
  2451. /**
  2452. * Gets the list of runtime animations
  2453. * @returns an array of RuntimeAnimation
  2454. */
  2455. Animatable.prototype.getAnimations = function () {
  2456. return this._runtimeAnimations;
  2457. };
  2458. /**
  2459. * Adds more animations to the current animatable
  2460. * @param target defines the target of the animations
  2461. * @param animations defines the new animations to add
  2462. */
  2463. Animatable.prototype.appendAnimations = function (target, animations) {
  2464. for (var index = 0; index < animations.length; index++) {
  2465. var animation = animations[index];
  2466. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this));
  2467. }
  2468. };
  2469. /**
  2470. * Gets the source animation for a specific property
  2471. * @param property defines the propertyu to look for
  2472. * @returns null or the source animation for the given property
  2473. */
  2474. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2475. var runtimeAnimations = this._runtimeAnimations;
  2476. for (var index = 0; index < runtimeAnimations.length; index++) {
  2477. if (runtimeAnimations[index].animation.targetProperty === property) {
  2478. return runtimeAnimations[index].animation;
  2479. }
  2480. }
  2481. return null;
  2482. };
  2483. /**
  2484. * Gets the runtime animation for a specific property
  2485. * @param property defines the propertyu to look for
  2486. * @returns null or the runtime animation for the given property
  2487. */
  2488. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2489. var runtimeAnimations = this._runtimeAnimations;
  2490. for (var index = 0; index < runtimeAnimations.length; index++) {
  2491. if (runtimeAnimations[index].animation.targetProperty === property) {
  2492. return runtimeAnimations[index];
  2493. }
  2494. }
  2495. return null;
  2496. };
  2497. /**
  2498. * Resets the animatable to its original state
  2499. */
  2500. Animatable.prototype.reset = function () {
  2501. var runtimeAnimations = this._runtimeAnimations;
  2502. for (var index = 0; index < runtimeAnimations.length; index++) {
  2503. runtimeAnimations[index].reset(true);
  2504. }
  2505. this._localDelayOffset = null;
  2506. this._pausedDelay = null;
  2507. };
  2508. /**
  2509. * Allows the animatable to blend with current running animations
  2510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2511. * @param blendingSpeed defines the blending speed to use
  2512. */
  2513. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2514. var runtimeAnimations = this._runtimeAnimations;
  2515. for (var index = 0; index < runtimeAnimations.length; index++) {
  2516. runtimeAnimations[index].animation.enableBlending = true;
  2517. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2518. }
  2519. };
  2520. /**
  2521. * Disable animation blending
  2522. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2523. */
  2524. Animatable.prototype.disableBlending = function () {
  2525. var runtimeAnimations = this._runtimeAnimations;
  2526. for (var index = 0; index < runtimeAnimations.length; index++) {
  2527. runtimeAnimations[index].animation.enableBlending = false;
  2528. }
  2529. };
  2530. /**
  2531. * Jump directly to a given frame
  2532. * @param frame defines the frame to jump to
  2533. */
  2534. Animatable.prototype.goToFrame = function (frame) {
  2535. var runtimeAnimations = this._runtimeAnimations;
  2536. if (runtimeAnimations[0]) {
  2537. var fps = runtimeAnimations[0].animation.framePerSecond;
  2538. var currentFrame = runtimeAnimations[0].currentFrame;
  2539. var adjustTime = frame - currentFrame;
  2540. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2541. if (this._localDelayOffset === null) {
  2542. this._localDelayOffset = 0;
  2543. }
  2544. this._localDelayOffset -= delay;
  2545. }
  2546. for (var index = 0; index < runtimeAnimations.length; index++) {
  2547. runtimeAnimations[index].goToFrame(frame);
  2548. }
  2549. };
  2550. /**
  2551. * Pause the animation
  2552. */
  2553. Animatable.prototype.pause = function () {
  2554. if (this._paused) {
  2555. return;
  2556. }
  2557. this._paused = true;
  2558. };
  2559. /**
  2560. * Restart the animation
  2561. */
  2562. Animatable.prototype.restart = function () {
  2563. this._paused = false;
  2564. };
  2565. Animatable.prototype._raiseOnAnimationEnd = function () {
  2566. if (this.onAnimationEnd) {
  2567. this.onAnimationEnd();
  2568. }
  2569. this.onAnimationEndObservable.notifyObservers(this);
  2570. };
  2571. /**
  2572. * Stop and delete the current animation
  2573. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2574. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2575. */
  2576. Animatable.prototype.stop = function (animationName, targetMask) {
  2577. if (animationName || targetMask) {
  2578. var idx = this._scene._activeAnimatables.indexOf(this);
  2579. if (idx > -1) {
  2580. var runtimeAnimations = this._runtimeAnimations;
  2581. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2582. var runtimeAnimation = runtimeAnimations[index];
  2583. if (animationName && runtimeAnimation.animation.name != animationName) {
  2584. continue;
  2585. }
  2586. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2587. continue;
  2588. }
  2589. runtimeAnimation.dispose();
  2590. runtimeAnimations.splice(index, 1);
  2591. }
  2592. if (runtimeAnimations.length == 0) {
  2593. this._scene._activeAnimatables.splice(idx, 1);
  2594. this._raiseOnAnimationEnd();
  2595. }
  2596. }
  2597. }
  2598. else {
  2599. var index = this._scene._activeAnimatables.indexOf(this);
  2600. if (index > -1) {
  2601. this._scene._activeAnimatables.splice(index, 1);
  2602. var runtimeAnimations = this._runtimeAnimations;
  2603. for (var index = 0; index < runtimeAnimations.length; index++) {
  2604. runtimeAnimations[index].dispose();
  2605. }
  2606. this._raiseOnAnimationEnd();
  2607. }
  2608. }
  2609. };
  2610. /**
  2611. * Wait asynchronously for the animation to end
  2612. * @returns a promise which will be fullfilled when the animation ends
  2613. */
  2614. Animatable.prototype.waitAsync = function () {
  2615. var _this = this;
  2616. return new Promise(function (resolve, reject) {
  2617. _this.onAnimationEndObservable.add(function () {
  2618. resolve(_this);
  2619. }, undefined, undefined, _this, true);
  2620. });
  2621. };
  2622. /** @hidden */
  2623. Animatable.prototype._animate = function (delay) {
  2624. var _this = this;
  2625. if (this._paused) {
  2626. this.animationStarted = false;
  2627. if (this._pausedDelay === null) {
  2628. this._pausedDelay = delay;
  2629. }
  2630. return true;
  2631. }
  2632. if (this._localDelayOffset === null) {
  2633. this._localDelayOffset = delay;
  2634. this._pausedDelay = null;
  2635. }
  2636. else if (this._pausedDelay !== null) {
  2637. this._localDelayOffset += delay - this._pausedDelay;
  2638. this._pausedDelay = null;
  2639. }
  2640. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2641. return true;
  2642. }
  2643. // Animating
  2644. var running = false;
  2645. var runtimeAnimations = this._runtimeAnimations;
  2646. var index;
  2647. for (index = 0; index < runtimeAnimations.length; index++) {
  2648. var animation = runtimeAnimations[index];
  2649. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2650. _this.onAnimationLoopObservable.notifyObservers(_this);
  2651. if (_this.onAnimationLoop) {
  2652. _this.onAnimationLoop();
  2653. }
  2654. });
  2655. running = running || isRunning;
  2656. }
  2657. this.animationStarted = running;
  2658. if (!running) {
  2659. if (this.disposeOnEnd) {
  2660. // Remove from active animatables
  2661. index = this._scene._activeAnimatables.indexOf(this);
  2662. this._scene._activeAnimatables.splice(index, 1);
  2663. // Dispose all runtime animations
  2664. for (index = 0; index < runtimeAnimations.length; index++) {
  2665. runtimeAnimations[index].dispose();
  2666. }
  2667. }
  2668. this._raiseOnAnimationEnd();
  2669. if (this.disposeOnEnd) {
  2670. this.onAnimationEnd = null;
  2671. this.onAnimationLoop = null;
  2672. this.onAnimationLoopObservable.clear();
  2673. this.onAnimationEndObservable.clear();
  2674. }
  2675. }
  2676. return running;
  2677. };
  2678. return Animatable;
  2679. }());
  2680. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2681. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  2682. return;
  2683. }
  2684. // Getting time
  2685. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2686. if (!this._animationTimeLast) {
  2687. if (this._pendingData.length > 0) {
  2688. return;
  2689. }
  2690. this._animationTimeLast = now;
  2691. }
  2692. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2693. this._animationTime += deltaTime;
  2694. this._animationTimeLast = now;
  2695. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2696. this._activeAnimatables[index]._animate(this._animationTime);
  2697. }
  2698. // Late animation bindings
  2699. this._processLateAnimationBindings();
  2700. };
  2701. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2702. if (weight === void 0) { weight = 1.0; }
  2703. if (speedRatio === void 0) { speedRatio = 1.0; }
  2704. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2705. returnedAnimatable.weight = weight;
  2706. return returnedAnimatable;
  2707. };
  2708. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2709. if (speedRatio === void 0) { speedRatio = 1.0; }
  2710. if (stopCurrent === void 0) { stopCurrent = true; }
  2711. if (from > to && speedRatio > 0) {
  2712. speedRatio *= -1;
  2713. }
  2714. if (stopCurrent) {
  2715. this.stopAnimation(target, undefined, targetMask);
  2716. }
  2717. if (!animatable) {
  2718. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2719. }
  2720. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2721. // Local animations
  2722. if (target.animations && shouldRunTargetAnimations) {
  2723. animatable.appendAnimations(target, target.animations);
  2724. }
  2725. // Children animations
  2726. if (target.getAnimatables) {
  2727. var animatables = target.getAnimatables();
  2728. for (var index = 0; index < animatables.length; index++) {
  2729. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2730. }
  2731. }
  2732. animatable.reset();
  2733. return animatable;
  2734. };
  2735. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2736. if (speedRatio === void 0) { speedRatio = 1.0; }
  2737. if (stopCurrent === void 0) { stopCurrent = true; }
  2738. var children = target.getDescendants(directDescendantsOnly);
  2739. var result = [];
  2740. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2741. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2742. var child = children_1[_i];
  2743. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2744. }
  2745. return result;
  2746. };
  2747. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2748. if (speedRatio === undefined) {
  2749. speedRatio = 1.0;
  2750. }
  2751. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2752. return animatable;
  2753. };
  2754. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2755. var children = target.getDescendants(directDescendantsOnly);
  2756. var result = [];
  2757. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2758. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2759. var child = children_2[_i];
  2760. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2761. }
  2762. return result;
  2763. };
  2764. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2765. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2766. if (this._activeAnimatables[index].target === target) {
  2767. return this._activeAnimatables[index];
  2768. }
  2769. }
  2770. return null;
  2771. };
  2772. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2773. var result = [];
  2774. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2775. if (this._activeAnimatables[index].target === target) {
  2776. result.push(this._activeAnimatables[index]);
  2777. }
  2778. }
  2779. return result;
  2780. };
  2781. /**
  2782. * Will stop the animation of the given target
  2783. * @param target - the target
  2784. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2785. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2786. */
  2787. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2788. var animatables = this.getAllAnimatablesByTarget(target);
  2789. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2790. var animatable = animatables_1[_i];
  2791. animatable.stop(animationName, targetMask);
  2792. }
  2793. };
  2794. /**
  2795. * Stops and removes all animations that have been applied to the scene
  2796. */
  2797. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2798. if (this._activeAnimatables) {
  2799. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2800. this._activeAnimatables[i].stop();
  2801. }
  2802. this._activeAnimatables = [];
  2803. }
  2804. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2805. var group = _a[_i];
  2806. group.stop();
  2807. }
  2808. };
  2809. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2810. var target = runtimeAnimation.target;
  2811. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2812. if (!target._lateAnimationHolders) {
  2813. target._lateAnimationHolders = {};
  2814. }
  2815. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2816. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2817. totalWeight: 0,
  2818. animations: [],
  2819. originalValue: originalValue
  2820. };
  2821. }
  2822. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2823. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2824. };
  2825. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2826. var normalizer = 1.0;
  2827. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2828. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2829. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2830. var startIndex = 0;
  2831. var originalAnimation = holder.animations[0];
  2832. var originalValue = holder.originalValue;
  2833. var scale = 1;
  2834. if (holder.totalWeight < 1.0) {
  2835. // We need to mix the original value in
  2836. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2837. scale = 1.0 - holder.totalWeight;
  2838. }
  2839. else {
  2840. startIndex = 1;
  2841. // We need to normalize the weights
  2842. normalizer = holder.totalWeight;
  2843. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2844. scale = originalAnimation.weight / normalizer;
  2845. if (scale == 1) {
  2846. return originalAnimation.currentValue;
  2847. }
  2848. }
  2849. finalScaling.scaleInPlace(scale);
  2850. finalPosition.scaleInPlace(scale);
  2851. finalQuaternion.scaleInPlace(scale);
  2852. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2853. var runtimeAnimation = holder.animations[animIndex];
  2854. var scale = runtimeAnimation.weight / normalizer;
  2855. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2856. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2857. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2858. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2859. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2860. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2861. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2862. }
  2863. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  2864. return originalAnimation._workValue;
  2865. };
  2866. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2867. var originalAnimation = holder.animations[0];
  2868. var originalValue = holder.originalValue;
  2869. if (holder.animations.length === 1) {
  2870. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2871. return refQuaternion;
  2872. }
  2873. var normalizer = 1.0;
  2874. var quaternions;
  2875. var weights;
  2876. if (holder.totalWeight < 1.0) {
  2877. var scale = 1.0 - holder.totalWeight;
  2878. quaternions = [];
  2879. weights = [];
  2880. quaternions.push(originalValue);
  2881. weights.push(scale);
  2882. }
  2883. else {
  2884. if (holder.animations.length === 2) { // Slerp as soon as we can
  2885. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2886. return refQuaternion;
  2887. }
  2888. quaternions = [];
  2889. weights = [];
  2890. normalizer = holder.totalWeight;
  2891. }
  2892. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2893. var runtimeAnimation = holder.animations[animIndex];
  2894. quaternions.push(runtimeAnimation.currentValue);
  2895. weights.push(runtimeAnimation.weight / normalizer);
  2896. }
  2897. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2898. var cumulativeAmount = 0;
  2899. var cumulativeQuaternion = null;
  2900. for (var index = 0; index < quaternions.length;) {
  2901. if (!cumulativeQuaternion) {
  2902. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2903. cumulativeQuaternion = refQuaternion;
  2904. cumulativeAmount = weights[index] + weights[index + 1];
  2905. index += 2;
  2906. continue;
  2907. }
  2908. cumulativeAmount += weights[index];
  2909. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2910. index++;
  2911. }
  2912. return cumulativeQuaternion;
  2913. };
  2914. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2915. if (!this._registeredForLateAnimationBindings.length) {
  2916. return;
  2917. }
  2918. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2919. var target = this._registeredForLateAnimationBindings.data[index];
  2920. for (var path in target._lateAnimationHolders) {
  2921. var holder = target._lateAnimationHolders[path];
  2922. var originalAnimation = holder.animations[0];
  2923. var originalValue = holder.originalValue;
  2924. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2925. var finalValue = target[path];
  2926. if (matrixDecomposeMode) {
  2927. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2928. }
  2929. else {
  2930. var quaternionMode = originalValue.w !== undefined;
  2931. if (quaternionMode) {
  2932. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2933. }
  2934. else {
  2935. var startIndex = 0;
  2936. var normalizer = 1.0;
  2937. if (holder.totalWeight < 1.0) {
  2938. // We need to mix the original value in
  2939. if (originalValue.scale) {
  2940. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2941. }
  2942. else {
  2943. finalValue = originalValue * (1.0 - holder.totalWeight);
  2944. }
  2945. }
  2946. else {
  2947. // We need to normalize the weights
  2948. normalizer = holder.totalWeight;
  2949. var scale_1 = originalAnimation.weight / normalizer;
  2950. if (scale_1 !== 1) {
  2951. if (originalAnimation.currentValue.scale) {
  2952. finalValue = originalAnimation.currentValue.scale(scale_1);
  2953. }
  2954. else {
  2955. finalValue = originalAnimation.currentValue * scale_1;
  2956. }
  2957. }
  2958. else {
  2959. finalValue = originalAnimation.currentValue;
  2960. }
  2961. startIndex = 1;
  2962. }
  2963. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2964. var runtimeAnimation = holder.animations[animIndex];
  2965. var scale = runtimeAnimation.weight / normalizer;
  2966. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2967. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2968. }
  2969. else {
  2970. finalValue += runtimeAnimation.currentValue * scale;
  2971. }
  2972. }
  2973. }
  2974. }
  2975. target[path] = finalValue;
  2976. }
  2977. target._lateAnimationHolders = {};
  2978. }
  2979. this._registeredForLateAnimationBindings.reset();
  2980. };
  2981. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2982. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2983. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2984. // all animation may be coming from a library skeleton, so may need to create animation
  2985. if (this.animations.length === 0) {
  2986. this.animations.push(new _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  2987. this.animations[0].setKeys([]);
  2988. }
  2989. // get animation info / verify there is such a range from the source bone
  2990. var sourceRange = source.animations[0].getRange(rangeName);
  2991. if (!sourceRange) {
  2992. return false;
  2993. }
  2994. var from = sourceRange.from;
  2995. var to = sourceRange.to;
  2996. var sourceKeys = source.animations[0].getKeys();
  2997. // rescaling prep
  2998. var sourceBoneLength = source.length;
  2999. var sourceParent = source.getParent();
  3000. var parent = this.getParent();
  3001. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3002. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3003. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3004. var destKeys = this.animations[0].getKeys();
  3005. // loop vars declaration
  3006. var orig;
  3007. var origTranslation;
  3008. var mat;
  3009. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3010. orig = sourceKeys[key];
  3011. if (orig.frame >= from && orig.frame <= to) {
  3012. if (rescaleAsRequired) {
  3013. mat = orig.value.clone();
  3014. // scale based on parent ratio, when bone has parent
  3015. if (parentScalingReqd) {
  3016. origTranslation = mat.getTranslation();
  3017. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3018. // scale based on skeleton dimension ratio when root bone, and value is passed
  3019. }
  3020. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3021. origTranslation = mat.getTranslation();
  3022. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3023. // use original when root bone, and no data for skelDimensionsRatio
  3024. }
  3025. else {
  3026. mat = orig.value;
  3027. }
  3028. }
  3029. else {
  3030. mat = orig.value;
  3031. }
  3032. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3033. }
  3034. }
  3035. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3036. return true;
  3037. };
  3038. /***/ }),
  3039. /***/ "./Animations/animation.ts":
  3040. /*!*********************************!*\
  3041. !*** ./Animations/animation.ts ***!
  3042. \*********************************/
  3043. /*! exports provided: Animation */
  3044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3045. "use strict";
  3046. __webpack_require__.r(__webpack_exports__);
  3047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3049. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3050. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3051. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3052. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3053. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3054. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3055. /**
  3056. * Class used to store any kind of animation
  3057. */
  3058. var Animation = /** @class */ (function () {
  3059. /**
  3060. * Initializes the animation
  3061. * @param name Name of the animation
  3062. * @param targetProperty Property to animate
  3063. * @param framePerSecond The frames per second of the animation
  3064. * @param dataType The data type of the animation
  3065. * @param loopMode The loop mode of the animation
  3066. * @param enableBlending Specifies if blending should be enabled
  3067. */
  3068. function Animation(
  3069. /**Name of the animation */
  3070. name,
  3071. /**Property to animate */
  3072. targetProperty,
  3073. /**The frames per second of the animation */
  3074. framePerSecond,
  3075. /**The data type of the animation */
  3076. dataType,
  3077. /**The loop mode of the animation */
  3078. loopMode,
  3079. /**Specifies if blending should be enabled */
  3080. enableBlending) {
  3081. this.name = name;
  3082. this.targetProperty = targetProperty;
  3083. this.framePerSecond = framePerSecond;
  3084. this.dataType = dataType;
  3085. this.loopMode = loopMode;
  3086. this.enableBlending = enableBlending;
  3087. /**
  3088. * @hidden Internal use only
  3089. */
  3090. this._runtimeAnimations = new Array();
  3091. /**
  3092. * The set of event that will be linked to this animation
  3093. */
  3094. this._events = new Array();
  3095. /**
  3096. * Stores the blending speed of the animation
  3097. */
  3098. this.blendingSpeed = 0.01;
  3099. /**
  3100. * Stores the animation ranges for the animation
  3101. */
  3102. this._ranges = {};
  3103. this.targetPropertyPath = targetProperty.split(".");
  3104. this.dataType = dataType;
  3105. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3106. }
  3107. /**
  3108. * @hidden Internal use
  3109. */
  3110. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3111. var dataType = undefined;
  3112. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3113. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3114. }
  3115. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3116. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3117. }
  3118. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3119. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3120. }
  3121. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3122. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3123. }
  3124. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3125. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3126. }
  3127. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3128. dataType = Animation.ANIMATIONTYPE_SIZE;
  3129. }
  3130. if (dataType == undefined) {
  3131. return null;
  3132. }
  3133. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3134. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3135. animation.setKeys(keys);
  3136. if (easingFunction !== undefined) {
  3137. animation.setEasingFunction(easingFunction);
  3138. }
  3139. return animation;
  3140. };
  3141. /**
  3142. * Sets up an animation
  3143. * @param property The property to animate
  3144. * @param animationType The animation type to apply
  3145. * @param framePerSecond The frames per second of the animation
  3146. * @param easingFunction The easing function used in the animation
  3147. * @returns The created animation
  3148. */
  3149. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3150. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3151. animation.setEasingFunction(easingFunction);
  3152. return animation;
  3153. };
  3154. /**
  3155. * Create and start an animation on a node
  3156. * @param name defines the name of the global animation that will be run on all nodes
  3157. * @param node defines the root node where the animation will take place
  3158. * @param targetProperty defines property to animate
  3159. * @param framePerSecond defines the number of frame per second yo use
  3160. * @param totalFrame defines the number of frames in total
  3161. * @param from defines the initial value
  3162. * @param to defines the final value
  3163. * @param loopMode defines which loop mode you want to use (off by default)
  3164. * @param easingFunction defines the easing function to use (linear by default)
  3165. * @param onAnimationEnd defines the callback to call when animation end
  3166. * @returns the animatable created for this animation
  3167. */
  3168. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3169. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3170. if (!animation) {
  3171. return null;
  3172. }
  3173. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3174. };
  3175. /**
  3176. * Create and start an animation on a node and its descendants
  3177. * @param name defines the name of the global animation that will be run on all nodes
  3178. * @param node defines the root node where the animation will take place
  3179. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  3180. * @param targetProperty defines property to animate
  3181. * @param framePerSecond defines the number of frame per second to use
  3182. * @param totalFrame defines the number of frames in total
  3183. * @param from defines the initial value
  3184. * @param to defines the final value
  3185. * @param loopMode defines which loop mode you want to use (off by default)
  3186. * @param easingFunction defines the easing function to use (linear by default)
  3187. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3188. * @returns the list of animatables created for all nodes
  3189. * @example https://www.babylonjs-playground.com/#MH0VLI
  3190. */
  3191. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3192. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3193. if (!animation) {
  3194. return null;
  3195. }
  3196. var scene = node.getScene();
  3197. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3198. };
  3199. /**
  3200. * Creates a new animation, merges it with the existing animations and starts it
  3201. * @param name Name of the animation
  3202. * @param node Node which contains the scene that begins the animations
  3203. * @param targetProperty Specifies which property to animate
  3204. * @param framePerSecond The frames per second of the animation
  3205. * @param totalFrame The total number of frames
  3206. * @param from The frame at the beginning of the animation
  3207. * @param to The frame at the end of the animation
  3208. * @param loopMode Specifies the loop mode of the animation
  3209. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3210. * @param onAnimationEnd Callback to run once the animation is complete
  3211. * @returns Nullable animation
  3212. */
  3213. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3214. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3215. if (!animation) {
  3216. return null;
  3217. }
  3218. node.animations.push(animation);
  3219. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3220. };
  3221. /**
  3222. * Transition property of an host to the target Value
  3223. * @param property The property to transition
  3224. * @param targetValue The target Value of the property
  3225. * @param host The object where the property to animate belongs
  3226. * @param scene Scene used to run the animation
  3227. * @param frameRate Framerate (in frame/s) to use
  3228. * @param transition The transition type we want to use
  3229. * @param duration The duration of the animation, in milliseconds
  3230. * @param onAnimationEnd Callback trigger at the end of the animation
  3231. * @returns Nullable animation
  3232. */
  3233. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3234. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3235. if (duration <= 0) {
  3236. host[property] = targetValue;
  3237. if (onAnimationEnd) {
  3238. onAnimationEnd();
  3239. }
  3240. return null;
  3241. }
  3242. var endFrame = frameRate * (duration / 1000);
  3243. transition.setKeys([{
  3244. frame: 0,
  3245. value: host[property].clone ? host[property].clone() : host[property]
  3246. },
  3247. {
  3248. frame: endFrame,
  3249. value: targetValue
  3250. }]);
  3251. if (!host.animations) {
  3252. host.animations = [];
  3253. }
  3254. host.animations.push(transition);
  3255. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3256. animation.onAnimationEnd = onAnimationEnd;
  3257. return animation;
  3258. };
  3259. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3260. /**
  3261. * Return the array of runtime animations currently using this animation
  3262. */
  3263. get: function () {
  3264. return this._runtimeAnimations;
  3265. },
  3266. enumerable: true,
  3267. configurable: true
  3268. });
  3269. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3270. /**
  3271. * Specifies if any of the runtime animations are currently running
  3272. */
  3273. get: function () {
  3274. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3275. var runtimeAnimation = _a[_i];
  3276. if (!runtimeAnimation.isStopped) {
  3277. return true;
  3278. }
  3279. }
  3280. return false;
  3281. },
  3282. enumerable: true,
  3283. configurable: true
  3284. });
  3285. // Methods
  3286. /**
  3287. * Converts the animation to a string
  3288. * @param fullDetails support for multiple levels of logging within scene loading
  3289. * @returns String form of the animation
  3290. */
  3291. Animation.prototype.toString = function (fullDetails) {
  3292. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3293. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3294. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3295. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3296. if (fullDetails) {
  3297. ret += ", Ranges: {";
  3298. var first = true;
  3299. for (var name in this._ranges) {
  3300. if (first) {
  3301. ret += ", ";
  3302. first = false;
  3303. }
  3304. ret += name;
  3305. }
  3306. ret += "}";
  3307. }
  3308. return ret;
  3309. };
  3310. /**
  3311. * Add an event to this animation
  3312. * @param event Event to add
  3313. */
  3314. Animation.prototype.addEvent = function (event) {
  3315. this._events.push(event);
  3316. };
  3317. /**
  3318. * Remove all events found at the given frame
  3319. * @param frame The frame to remove events from
  3320. */
  3321. Animation.prototype.removeEvents = function (frame) {
  3322. for (var index = 0; index < this._events.length; index++) {
  3323. if (this._events[index].frame === frame) {
  3324. this._events.splice(index, 1);
  3325. index--;
  3326. }
  3327. }
  3328. };
  3329. /**
  3330. * Retrieves all the events from the animation
  3331. * @returns Events from the animation
  3332. */
  3333. Animation.prototype.getEvents = function () {
  3334. return this._events;
  3335. };
  3336. /**
  3337. * Creates an animation range
  3338. * @param name Name of the animation range
  3339. * @param from Starting frame of the animation range
  3340. * @param to Ending frame of the animation
  3341. */
  3342. Animation.prototype.createRange = function (name, from, to) {
  3343. // check name not already in use; could happen for bones after serialized
  3344. if (!this._ranges[name]) {
  3345. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3346. }
  3347. };
  3348. /**
  3349. * Deletes an animation range by name
  3350. * @param name Name of the animation range to delete
  3351. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3352. */
  3353. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3354. if (deleteFrames === void 0) { deleteFrames = true; }
  3355. var range = this._ranges[name];
  3356. if (!range) {
  3357. return;
  3358. }
  3359. if (deleteFrames) {
  3360. var from = range.from;
  3361. var to = range.to;
  3362. // this loop MUST go high to low for multiple splices to work
  3363. for (var key = this._keys.length - 1; key >= 0; key--) {
  3364. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3365. this._keys.splice(key, 1);
  3366. }
  3367. }
  3368. }
  3369. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3370. };
  3371. /**
  3372. * Gets the animation range by name, or null if not defined
  3373. * @param name Name of the animation range
  3374. * @returns Nullable animation range
  3375. */
  3376. Animation.prototype.getRange = function (name) {
  3377. return this._ranges[name];
  3378. };
  3379. /**
  3380. * Gets the key frames from the animation
  3381. * @returns The key frames of the animation
  3382. */
  3383. Animation.prototype.getKeys = function () {
  3384. return this._keys;
  3385. };
  3386. /**
  3387. * Gets the highest frame rate of the animation
  3388. * @returns Highest frame rate of the animation
  3389. */
  3390. Animation.prototype.getHighestFrame = function () {
  3391. var ret = 0;
  3392. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3393. if (ret < this._keys[key].frame) {
  3394. ret = this._keys[key].frame;
  3395. }
  3396. }
  3397. return ret;
  3398. };
  3399. /**
  3400. * Gets the easing function of the animation
  3401. * @returns Easing function of the animation
  3402. */
  3403. Animation.prototype.getEasingFunction = function () {
  3404. return this._easingFunction;
  3405. };
  3406. /**
  3407. * Sets the easing function of the animation
  3408. * @param easingFunction A custom mathematical formula for animation
  3409. */
  3410. Animation.prototype.setEasingFunction = function (easingFunction) {
  3411. this._easingFunction = easingFunction;
  3412. };
  3413. /**
  3414. * Interpolates a scalar linearly
  3415. * @param startValue Start value of the animation curve
  3416. * @param endValue End value of the animation curve
  3417. * @param gradient Scalar amount to interpolate
  3418. * @returns Interpolated scalar value
  3419. */
  3420. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3421. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3422. };
  3423. /**
  3424. * Interpolates a scalar cubically
  3425. * @param startValue Start value of the animation curve
  3426. * @param outTangent End tangent of the animation
  3427. * @param endValue End value of the animation curve
  3428. * @param inTangent Start tangent of the animation curve
  3429. * @param gradient Scalar amount to interpolate
  3430. * @returns Interpolated scalar value
  3431. */
  3432. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3433. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3434. };
  3435. /**
  3436. * Interpolates a quaternion using a spherical linear interpolation
  3437. * @param startValue Start value of the animation curve
  3438. * @param endValue End value of the animation curve
  3439. * @param gradient Scalar amount to interpolate
  3440. * @returns Interpolated quaternion value
  3441. */
  3442. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3443. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3444. };
  3445. /**
  3446. * Interpolates a quaternion cubically
  3447. * @param startValue Start value of the animation curve
  3448. * @param outTangent End tangent of the animation curve
  3449. * @param endValue End value of the animation curve
  3450. * @param inTangent Start tangent of the animation curve
  3451. * @param gradient Scalar amount to interpolate
  3452. * @returns Interpolated quaternion value
  3453. */
  3454. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3455. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3456. };
  3457. /**
  3458. * Interpolates a Vector3 linearl
  3459. * @param startValue Start value of the animation curve
  3460. * @param endValue End value of the animation curve
  3461. * @param gradient Scalar amount to interpolate
  3462. * @returns Interpolated scalar value
  3463. */
  3464. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3465. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3466. };
  3467. /**
  3468. * Interpolates a Vector3 cubically
  3469. * @param startValue Start value of the animation curve
  3470. * @param outTangent End tangent of the animation
  3471. * @param endValue End value of the animation curve
  3472. * @param inTangent Start tangent of the animation curve
  3473. * @param gradient Scalar amount to interpolate
  3474. * @returns InterpolatedVector3 value
  3475. */
  3476. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3477. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3478. };
  3479. /**
  3480. * Interpolates a Vector2 linearly
  3481. * @param startValue Start value of the animation curve
  3482. * @param endValue End value of the animation curve
  3483. * @param gradient Scalar amount to interpolate
  3484. * @returns Interpolated Vector2 value
  3485. */
  3486. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3487. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3488. };
  3489. /**
  3490. * Interpolates a Vector2 cubically
  3491. * @param startValue Start value of the animation curve
  3492. * @param outTangent End tangent of the animation
  3493. * @param endValue End value of the animation curve
  3494. * @param inTangent Start tangent of the animation curve
  3495. * @param gradient Scalar amount to interpolate
  3496. * @returns Interpolated Vector2 value
  3497. */
  3498. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3499. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3500. };
  3501. /**
  3502. * Interpolates a size linearly
  3503. * @param startValue Start value of the animation curve
  3504. * @param endValue End value of the animation curve
  3505. * @param gradient Scalar amount to interpolate
  3506. * @returns Interpolated Size value
  3507. */
  3508. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3509. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3510. };
  3511. /**
  3512. * Interpolates a Color3 linearly
  3513. * @param startValue Start value of the animation curve
  3514. * @param endValue End value of the animation curve
  3515. * @param gradient Scalar amount to interpolate
  3516. * @returns Interpolated Color3 value
  3517. */
  3518. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3519. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3520. };
  3521. /**
  3522. * @hidden Internal use only
  3523. */
  3524. Animation.prototype._getKeyValue = function (value) {
  3525. if (typeof value === "function") {
  3526. return value();
  3527. }
  3528. return value;
  3529. };
  3530. /**
  3531. * @hidden Internal use only
  3532. */
  3533. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3534. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3535. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3536. }
  3537. var keys = this.getKeys();
  3538. if (keys.length === 1) {
  3539. return this._getKeyValue(keys[0].value);
  3540. }
  3541. // Try to get a hash to find the right key
  3542. var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
  3543. if (keys[startKeyIndex].frame >= currentFrame) {
  3544. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3545. startKeyIndex--;
  3546. }
  3547. }
  3548. for (var key = startKeyIndex; key < keys.length; key++) {
  3549. var endKey = keys[key + 1];
  3550. if (endKey.frame >= currentFrame) {
  3551. var startKey = keys[key];
  3552. var startValue = this._getKeyValue(startKey.value);
  3553. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3554. return startValue;
  3555. }
  3556. var endValue = this._getKeyValue(endKey.value);
  3557. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3558. var frameDelta = endKey.frame - startKey.frame;
  3559. // gradient : percent of currentFrame between the frame inf and the frame sup
  3560. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3561. // check for easingFunction and correction of gradient
  3562. var easingFunction = this.getEasingFunction();
  3563. if (easingFunction != null) {
  3564. gradient = easingFunction.ease(gradient);
  3565. }
  3566. switch (this.dataType) {
  3567. // Float
  3568. case Animation.ANIMATIONTYPE_FLOAT:
  3569. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3570. switch (loopMode) {
  3571. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3572. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3573. return floatValue;
  3574. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3575. return offsetValue * repeatCount + floatValue;
  3576. }
  3577. break;
  3578. // Quaternion
  3579. case Animation.ANIMATIONTYPE_QUATERNION:
  3580. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3581. switch (loopMode) {
  3582. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3583. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3584. return quatValue;
  3585. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3586. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3587. }
  3588. return quatValue;
  3589. // Vector3
  3590. case Animation.ANIMATIONTYPE_VECTOR3:
  3591. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3592. switch (loopMode) {
  3593. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3594. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3595. return vec3Value;
  3596. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3597. return vec3Value.add(offsetValue.scale(repeatCount));
  3598. }
  3599. // Vector2
  3600. case Animation.ANIMATIONTYPE_VECTOR2:
  3601. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3602. switch (loopMode) {
  3603. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3604. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3605. return vec2Value;
  3606. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3607. return vec2Value.add(offsetValue.scale(repeatCount));
  3608. }
  3609. // Size
  3610. case Animation.ANIMATIONTYPE_SIZE:
  3611. switch (loopMode) {
  3612. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3613. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3614. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3615. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3616. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3617. }
  3618. // Color3
  3619. case Animation.ANIMATIONTYPE_COLOR3:
  3620. switch (loopMode) {
  3621. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3622. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3623. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3624. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3625. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3626. }
  3627. // Matrix
  3628. case Animation.ANIMATIONTYPE_MATRIX:
  3629. switch (loopMode) {
  3630. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3631. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3632. if (Animation.AllowMatricesInterpolation) {
  3633. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3634. }
  3635. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3636. return startValue;
  3637. }
  3638. default:
  3639. break;
  3640. }
  3641. break;
  3642. }
  3643. }
  3644. return this._getKeyValue(keys[keys.length - 1].value);
  3645. };
  3646. /**
  3647. * Defines the function to use to interpolate matrices
  3648. * @param startValue defines the start matrix
  3649. * @param endValue defines the end matrix
  3650. * @param gradient defines the gradient between both matrices
  3651. * @param result defines an optional target matrix where to store the interpolation
  3652. * @returns the interpolated matrix
  3653. */
  3654. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3655. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3656. if (result) {
  3657. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3658. return result;
  3659. }
  3660. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3661. }
  3662. if (result) {
  3663. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3664. return result;
  3665. }
  3666. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3667. };
  3668. /**
  3669. * Makes a copy of the animation
  3670. * @returns Cloned animation
  3671. */
  3672. Animation.prototype.clone = function () {
  3673. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3674. clone.enableBlending = this.enableBlending;
  3675. clone.blendingSpeed = this.blendingSpeed;
  3676. if (this._keys) {
  3677. clone.setKeys(this._keys);
  3678. }
  3679. if (this._ranges) {
  3680. clone._ranges = {};
  3681. for (var name in this._ranges) {
  3682. var range = this._ranges[name];
  3683. if (!range) {
  3684. continue;
  3685. }
  3686. clone._ranges[name] = range.clone();
  3687. }
  3688. }
  3689. return clone;
  3690. };
  3691. /**
  3692. * Sets the key frames of the animation
  3693. * @param values The animation key frames to set
  3694. */
  3695. Animation.prototype.setKeys = function (values) {
  3696. this._keys = values.slice(0);
  3697. };
  3698. /**
  3699. * Serializes the animation to an object
  3700. * @returns Serialized object
  3701. */
  3702. Animation.prototype.serialize = function () {
  3703. var serializationObject = {};
  3704. serializationObject.name = this.name;
  3705. serializationObject.property = this.targetProperty;
  3706. serializationObject.framePerSecond = this.framePerSecond;
  3707. serializationObject.dataType = this.dataType;
  3708. serializationObject.loopBehavior = this.loopMode;
  3709. serializationObject.enableBlending = this.enableBlending;
  3710. serializationObject.blendingSpeed = this.blendingSpeed;
  3711. var dataType = this.dataType;
  3712. serializationObject.keys = [];
  3713. var keys = this.getKeys();
  3714. for (var index = 0; index < keys.length; index++) {
  3715. var animationKey = keys[index];
  3716. var key = {};
  3717. key.frame = animationKey.frame;
  3718. switch (dataType) {
  3719. case Animation.ANIMATIONTYPE_FLOAT:
  3720. key.values = [animationKey.value];
  3721. break;
  3722. case Animation.ANIMATIONTYPE_QUATERNION:
  3723. case Animation.ANIMATIONTYPE_MATRIX:
  3724. case Animation.ANIMATIONTYPE_VECTOR3:
  3725. case Animation.ANIMATIONTYPE_COLOR3:
  3726. key.values = animationKey.value.asArray();
  3727. break;
  3728. }
  3729. serializationObject.keys.push(key);
  3730. }
  3731. serializationObject.ranges = [];
  3732. for (var name in this._ranges) {
  3733. var source = this._ranges[name];
  3734. if (!source) {
  3735. continue;
  3736. }
  3737. var range = {};
  3738. range.name = name;
  3739. range.from = source.from;
  3740. range.to = source.to;
  3741. serializationObject.ranges.push(range);
  3742. }
  3743. return serializationObject;
  3744. };
  3745. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3746. /**
  3747. * Get the float animation type
  3748. */
  3749. get: function () {
  3750. return Animation._ANIMATIONTYPE_FLOAT;
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3756. /**
  3757. * Get the Vector3 animation type
  3758. */
  3759. get: function () {
  3760. return Animation._ANIMATIONTYPE_VECTOR3;
  3761. },
  3762. enumerable: true,
  3763. configurable: true
  3764. });
  3765. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3766. /**
  3767. * Get the Vector2 animation type
  3768. */
  3769. get: function () {
  3770. return Animation._ANIMATIONTYPE_VECTOR2;
  3771. },
  3772. enumerable: true,
  3773. configurable: true
  3774. });
  3775. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3776. /**
  3777. * Get the Size animation type
  3778. */
  3779. get: function () {
  3780. return Animation._ANIMATIONTYPE_SIZE;
  3781. },
  3782. enumerable: true,
  3783. configurable: true
  3784. });
  3785. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3786. /**
  3787. * Get the Quaternion animation type
  3788. */
  3789. get: function () {
  3790. return Animation._ANIMATIONTYPE_QUATERNION;
  3791. },
  3792. enumerable: true,
  3793. configurable: true
  3794. });
  3795. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3796. /**
  3797. * Get the Matrix animation type
  3798. */
  3799. get: function () {
  3800. return Animation._ANIMATIONTYPE_MATRIX;
  3801. },
  3802. enumerable: true,
  3803. configurable: true
  3804. });
  3805. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3806. /**
  3807. * Get the Color3 animation type
  3808. */
  3809. get: function () {
  3810. return Animation._ANIMATIONTYPE_COLOR3;
  3811. },
  3812. enumerable: true,
  3813. configurable: true
  3814. });
  3815. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3816. /**
  3817. * Get the Relative Loop Mode
  3818. */
  3819. get: function () {
  3820. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3826. /**
  3827. * Get the Cycle Loop Mode
  3828. */
  3829. get: function () {
  3830. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3831. },
  3832. enumerable: true,
  3833. configurable: true
  3834. });
  3835. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3836. /**
  3837. * Get the Constant Loop Mode
  3838. */
  3839. get: function () {
  3840. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3841. },
  3842. enumerable: true,
  3843. configurable: true
  3844. });
  3845. /** @hidden */
  3846. Animation._UniversalLerp = function (left, right, amount) {
  3847. var constructor = left.constructor;
  3848. if (constructor.Lerp) { // Lerp supported
  3849. return constructor.Lerp(left, right, amount);
  3850. }
  3851. else if (constructor.Slerp) { // Slerp supported
  3852. return constructor.Slerp(left, right, amount);
  3853. }
  3854. else if (left.toFixed) { // Number
  3855. return left * (1.0 - amount) + amount * right;
  3856. }
  3857. else { // Blending not supported
  3858. return right;
  3859. }
  3860. };
  3861. /**
  3862. * Parses an animation object and creates an animation
  3863. * @param parsedAnimation Parsed animation object
  3864. * @returns Animation object
  3865. */
  3866. Animation.Parse = function (parsedAnimation) {
  3867. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3868. var dataType = parsedAnimation.dataType;
  3869. var keys = [];
  3870. var data;
  3871. var index;
  3872. if (parsedAnimation.enableBlending) {
  3873. animation.enableBlending = parsedAnimation.enableBlending;
  3874. }
  3875. if (parsedAnimation.blendingSpeed) {
  3876. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3877. }
  3878. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3879. var key = parsedAnimation.keys[index];
  3880. var inTangent;
  3881. var outTangent;
  3882. switch (dataType) {
  3883. case Animation.ANIMATIONTYPE_FLOAT:
  3884. data = key.values[0];
  3885. if (key.values.length >= 1) {
  3886. inTangent = key.values[1];
  3887. }
  3888. if (key.values.length >= 2) {
  3889. outTangent = key.values[2];
  3890. }
  3891. break;
  3892. case Animation.ANIMATIONTYPE_QUATERNION:
  3893. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3894. if (key.values.length >= 8) {
  3895. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3896. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3897. inTangent = _inTangent;
  3898. }
  3899. }
  3900. if (key.values.length >= 12) {
  3901. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3902. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3903. outTangent = _outTangent;
  3904. }
  3905. }
  3906. break;
  3907. case Animation.ANIMATIONTYPE_MATRIX:
  3908. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3909. break;
  3910. case Animation.ANIMATIONTYPE_COLOR3:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3912. break;
  3913. case Animation.ANIMATIONTYPE_VECTOR3:
  3914. default:
  3915. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3916. break;
  3917. }
  3918. var keyData = {};
  3919. keyData.frame = key.frame;
  3920. keyData.value = data;
  3921. if (inTangent != undefined) {
  3922. keyData.inTangent = inTangent;
  3923. }
  3924. if (outTangent != undefined) {
  3925. keyData.outTangent = outTangent;
  3926. }
  3927. keys.push(keyData);
  3928. }
  3929. animation.setKeys(keys);
  3930. if (parsedAnimation.ranges) {
  3931. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3932. data = parsedAnimation.ranges[index];
  3933. animation.createRange(data.name, data.from, data.to);
  3934. }
  3935. }
  3936. return animation;
  3937. };
  3938. /**
  3939. * Appends the serialized animations from the source animations
  3940. * @param source Source containing the animations
  3941. * @param destination Target to store the animations
  3942. */
  3943. Animation.AppendSerializedAnimations = function (source, destination) {
  3944. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3945. };
  3946. /**
  3947. * Use matrix interpolation instead of using direct key value when animating matrices
  3948. */
  3949. Animation.AllowMatricesInterpolation = false;
  3950. /**
  3951. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3952. */
  3953. Animation.AllowMatrixDecomposeForInterpolation = true;
  3954. // Statics
  3955. /**
  3956. * Float animation type
  3957. */
  3958. Animation._ANIMATIONTYPE_FLOAT = 0;
  3959. /**
  3960. * Vector3 animation type
  3961. */
  3962. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3963. /**
  3964. * Quaternion animation type
  3965. */
  3966. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3967. /**
  3968. * Matrix animation type
  3969. */
  3970. Animation._ANIMATIONTYPE_MATRIX = 3;
  3971. /**
  3972. * Color3 animation type
  3973. */
  3974. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3975. /**
  3976. * Vector2 animation type
  3977. */
  3978. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3979. /**
  3980. * Size animation type
  3981. */
  3982. Animation._ANIMATIONTYPE_SIZE = 6;
  3983. /**
  3984. * Relative Loop Mode
  3985. */
  3986. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3987. /**
  3988. * Cycle Loop Mode
  3989. */
  3990. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3991. /**
  3992. * Constant Loop Mode
  3993. */
  3994. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3995. return Animation;
  3996. }());
  3997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3998. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3999. /***/ }),
  4000. /***/ "./Animations/animationEvent.ts":
  4001. /*!**************************************!*\
  4002. !*** ./Animations/animationEvent.ts ***!
  4003. \**************************************/
  4004. /*! exports provided: AnimationEvent */
  4005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4006. "use strict";
  4007. __webpack_require__.r(__webpack_exports__);
  4008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4009. /**
  4010. * Composed of a frame, and an action function
  4011. */
  4012. var AnimationEvent = /** @class */ (function () {
  4013. /**
  4014. * Initializes the animation event
  4015. * @param frame The frame for which the event is triggered
  4016. * @param action The event to perform when triggered
  4017. * @param onlyOnce Specifies if the event should be triggered only once
  4018. */
  4019. function AnimationEvent(
  4020. /** The frame for which the event is triggered **/
  4021. frame,
  4022. /** The event to perform when triggered **/
  4023. action,
  4024. /** Specifies if the event should be triggered only once**/
  4025. onlyOnce) {
  4026. this.frame = frame;
  4027. this.action = action;
  4028. this.onlyOnce = onlyOnce;
  4029. /**
  4030. * Specifies if the animation event is done
  4031. */
  4032. this.isDone = false;
  4033. }
  4034. /** @hidden */
  4035. AnimationEvent.prototype._clone = function () {
  4036. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4037. };
  4038. return AnimationEvent;
  4039. }());
  4040. /***/ }),
  4041. /***/ "./Animations/animationGroup.ts":
  4042. /*!**************************************!*\
  4043. !*** ./Animations/animationGroup.ts ***!
  4044. \**************************************/
  4045. /*! exports provided: TargetedAnimation, AnimationGroup */
  4046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4047. "use strict";
  4048. __webpack_require__.r(__webpack_exports__);
  4049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4051. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4053. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4054. /**
  4055. * This class defines the direct association between an animation and a target
  4056. */
  4057. var TargetedAnimation = /** @class */ (function () {
  4058. function TargetedAnimation() {
  4059. }
  4060. return TargetedAnimation;
  4061. }());
  4062. /**
  4063. * Use this class to create coordinated animations on multiple targets
  4064. */
  4065. var AnimationGroup = /** @class */ (function () {
  4066. /**
  4067. * Instantiates a new Animation Group.
  4068. * This helps managing several animations at once.
  4069. * @see http://doc.babylonjs.com/how_to/group
  4070. * @param name Defines the name of the group
  4071. * @param scene Defines the scene the group belongs to
  4072. */
  4073. function AnimationGroup(
  4074. /** The name of the animation group */
  4075. name, scene) {
  4076. if (scene === void 0) { scene = null; }
  4077. this.name = name;
  4078. this._targetedAnimations = new Array();
  4079. this._animatables = new Array();
  4080. this._from = Number.MAX_VALUE;
  4081. this._to = -Number.MAX_VALUE;
  4082. this._speedRatio = 1;
  4083. /**
  4084. * This observable will notify when one animation have ended
  4085. */
  4086. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4087. /**
  4088. * Observer raised when one animation loops
  4089. */
  4090. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4091. /**
  4092. * This observable will notify when all animations have ended.
  4093. */
  4094. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4095. /**
  4096. * This observable will notify when all animations have paused.
  4097. */
  4098. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4099. /**
  4100. * This observable will notify when all animations are playing.
  4101. */
  4102. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4103. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4104. this.uniqueId = this._scene.getUniqueId();
  4105. this._scene.animationGroups.push(this);
  4106. }
  4107. Object.defineProperty(AnimationGroup.prototype, "from", {
  4108. /**
  4109. * Gets the first frame
  4110. */
  4111. get: function () {
  4112. return this._from;
  4113. },
  4114. enumerable: true,
  4115. configurable: true
  4116. });
  4117. Object.defineProperty(AnimationGroup.prototype, "to", {
  4118. /**
  4119. * Gets the last frame
  4120. */
  4121. get: function () {
  4122. return this._to;
  4123. },
  4124. enumerable: true,
  4125. configurable: true
  4126. });
  4127. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4128. /**
  4129. * Define if the animations are started
  4130. */
  4131. get: function () {
  4132. return this._isStarted;
  4133. },
  4134. enumerable: true,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4138. /**
  4139. * Gets a value indicating that the current group is playing
  4140. */
  4141. get: function () {
  4142. return this._isStarted && !this._isPaused;
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4148. /**
  4149. * Gets or sets the speed ratio to use for all animations
  4150. */
  4151. get: function () {
  4152. return this._speedRatio;
  4153. },
  4154. /**
  4155. * Gets or sets the speed ratio to use for all animations
  4156. */
  4157. set: function (value) {
  4158. if (this._speedRatio === value) {
  4159. return;
  4160. }
  4161. this._speedRatio = value;
  4162. for (var index = 0; index < this._animatables.length; index++) {
  4163. var animatable = this._animatables[index];
  4164. animatable.speedRatio = this._speedRatio;
  4165. }
  4166. },
  4167. enumerable: true,
  4168. configurable: true
  4169. });
  4170. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4171. /**
  4172. * Gets the targeted animations for this animation group
  4173. */
  4174. get: function () {
  4175. return this._targetedAnimations;
  4176. },
  4177. enumerable: true,
  4178. configurable: true
  4179. });
  4180. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4181. /**
  4182. * returning the list of animatables controlled by this animation group.
  4183. */
  4184. get: function () {
  4185. return this._animatables;
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. /**
  4191. * Add an animation (with its target) in the group
  4192. * @param animation defines the animation we want to add
  4193. * @param target defines the target of the animation
  4194. * @returns the TargetedAnimation object
  4195. */
  4196. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4197. var targetedAnimation = {
  4198. animation: animation,
  4199. target: target
  4200. };
  4201. var keys = animation.getKeys();
  4202. if (this._from > keys[0].frame) {
  4203. this._from = keys[0].frame;
  4204. }
  4205. if (this._to < keys[keys.length - 1].frame) {
  4206. this._to = keys[keys.length - 1].frame;
  4207. }
  4208. this._targetedAnimations.push(targetedAnimation);
  4209. return targetedAnimation;
  4210. };
  4211. /**
  4212. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4213. * It can add constant keys at begin or end
  4214. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4215. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4216. * @returns the animation group
  4217. */
  4218. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4219. if (beginFrame === void 0) { beginFrame = null; }
  4220. if (endFrame === void 0) { endFrame = null; }
  4221. if (beginFrame == null) {
  4222. beginFrame = this._from;
  4223. }
  4224. if (endFrame == null) {
  4225. endFrame = this._to;
  4226. }
  4227. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4228. var targetedAnimation = this._targetedAnimations[index];
  4229. var keys = targetedAnimation.animation.getKeys();
  4230. var startKey = keys[0];
  4231. var endKey = keys[keys.length - 1];
  4232. if (startKey.frame > beginFrame) {
  4233. var newKey = {
  4234. frame: beginFrame,
  4235. value: startKey.value,
  4236. inTangent: startKey.inTangent,
  4237. outTangent: startKey.outTangent,
  4238. interpolation: startKey.interpolation
  4239. };
  4240. keys.splice(0, 0, newKey);
  4241. }
  4242. if (endKey.frame < endFrame) {
  4243. var newKey = {
  4244. frame: endFrame,
  4245. value: endKey.value,
  4246. inTangent: endKey.outTangent,
  4247. outTangent: endKey.outTangent,
  4248. interpolation: endKey.interpolation
  4249. };
  4250. keys.push(newKey);
  4251. }
  4252. }
  4253. this._from = beginFrame;
  4254. this._to = endFrame;
  4255. return this;
  4256. };
  4257. /**
  4258. * Start all animations on given targets
  4259. * @param loop defines if animations must loop
  4260. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4261. * @param from defines the from key (optional)
  4262. * @param to defines the to key (optional)
  4263. * @returns the current animation group
  4264. */
  4265. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4266. var _this = this;
  4267. if (loop === void 0) { loop = false; }
  4268. if (speedRatio === void 0) { speedRatio = 1; }
  4269. if (this._isStarted || this._targetedAnimations.length === 0) {
  4270. return this;
  4271. }
  4272. var _loop_1 = function (targetedAnimation) {
  4273. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4274. animatable.onAnimationEnd = function () {
  4275. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4276. _this._checkAnimationGroupEnded(animatable);
  4277. };
  4278. animatable.onAnimationLoop = function () {
  4279. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4280. };
  4281. this_1._animatables.push(animatable);
  4282. };
  4283. var this_1 = this;
  4284. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4285. var targetedAnimation = _a[_i];
  4286. _loop_1(targetedAnimation);
  4287. }
  4288. this._speedRatio = speedRatio;
  4289. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4290. this._speedRatio = -speedRatio;
  4291. }
  4292. this._isStarted = true;
  4293. this._isPaused = false;
  4294. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4295. return this;
  4296. };
  4297. /**
  4298. * Pause all animations
  4299. * @returns the animation group
  4300. */
  4301. AnimationGroup.prototype.pause = function () {
  4302. if (!this._isStarted) {
  4303. return this;
  4304. }
  4305. this._isPaused = true;
  4306. for (var index = 0; index < this._animatables.length; index++) {
  4307. var animatable = this._animatables[index];
  4308. animatable.pause();
  4309. }
  4310. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4311. return this;
  4312. };
  4313. /**
  4314. * Play all animations to initial state
  4315. * This function will start() the animations if they were not started or will restart() them if they were paused
  4316. * @param loop defines if animations must loop
  4317. * @returns the animation group
  4318. */
  4319. AnimationGroup.prototype.play = function (loop) {
  4320. // only if all animatables are ready and exist
  4321. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4322. if (loop !== undefined) {
  4323. for (var index = 0; index < this._animatables.length; index++) {
  4324. var animatable = this._animatables[index];
  4325. animatable.loopAnimation = loop;
  4326. }
  4327. }
  4328. this.restart();
  4329. }
  4330. else {
  4331. this.stop();
  4332. this.start(loop, this._speedRatio);
  4333. }
  4334. this._isPaused = false;
  4335. return this;
  4336. };
  4337. /**
  4338. * Reset all animations to initial state
  4339. * @returns the animation group
  4340. */
  4341. AnimationGroup.prototype.reset = function () {
  4342. if (!this._isStarted) {
  4343. return this;
  4344. }
  4345. for (var index = 0; index < this._animatables.length; index++) {
  4346. var animatable = this._animatables[index];
  4347. animatable.reset();
  4348. }
  4349. return this;
  4350. };
  4351. /**
  4352. * Restart animations from key 0
  4353. * @returns the animation group
  4354. */
  4355. AnimationGroup.prototype.restart = function () {
  4356. if (!this._isStarted) {
  4357. return this;
  4358. }
  4359. for (var index = 0; index < this._animatables.length; index++) {
  4360. var animatable = this._animatables[index];
  4361. animatable.restart();
  4362. }
  4363. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4364. return this;
  4365. };
  4366. /**
  4367. * Stop all animations
  4368. * @returns the animation group
  4369. */
  4370. AnimationGroup.prototype.stop = function () {
  4371. if (!this._isStarted) {
  4372. return this;
  4373. }
  4374. var list = this._animatables.slice();
  4375. for (var index = 0; index < list.length; index++) {
  4376. list[index].stop();
  4377. }
  4378. this._isStarted = false;
  4379. return this;
  4380. };
  4381. /**
  4382. * Set animation weight for all animatables
  4383. * @param weight defines the weight to use
  4384. * @return the animationGroup
  4385. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4386. */
  4387. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4388. for (var index = 0; index < this._animatables.length; index++) {
  4389. var animatable = this._animatables[index];
  4390. animatable.weight = weight;
  4391. }
  4392. return this;
  4393. };
  4394. /**
  4395. * Synchronize and normalize all animatables with a source animatable
  4396. * @param root defines the root animatable to synchronize with
  4397. * @return the animationGroup
  4398. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4399. */
  4400. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4401. for (var index = 0; index < this._animatables.length; index++) {
  4402. var animatable = this._animatables[index];
  4403. animatable.syncWith(root);
  4404. }
  4405. return this;
  4406. };
  4407. /**
  4408. * Goes to a specific frame in this animation group
  4409. * @param frame the frame number to go to
  4410. * @return the animationGroup
  4411. */
  4412. AnimationGroup.prototype.goToFrame = function (frame) {
  4413. if (!this._isStarted) {
  4414. return this;
  4415. }
  4416. for (var index = 0; index < this._animatables.length; index++) {
  4417. var animatable = this._animatables[index];
  4418. animatable.goToFrame(frame);
  4419. }
  4420. return this;
  4421. };
  4422. /**
  4423. * Dispose all associated resources
  4424. */
  4425. AnimationGroup.prototype.dispose = function () {
  4426. this._targetedAnimations = [];
  4427. this._animatables = [];
  4428. var index = this._scene.animationGroups.indexOf(this);
  4429. if (index > -1) {
  4430. this._scene.animationGroups.splice(index, 1);
  4431. }
  4432. this.onAnimationEndObservable.clear();
  4433. this.onAnimationGroupEndObservable.clear();
  4434. this.onAnimationGroupPauseObservable.clear();
  4435. this.onAnimationGroupPlayObservable.clear();
  4436. this.onAnimationLoopObservable.clear();
  4437. };
  4438. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4439. // animatable should be taken out of the array
  4440. var idx = this._animatables.indexOf(animatable);
  4441. if (idx > -1) {
  4442. this._animatables.splice(idx, 1);
  4443. }
  4444. // all animatables were removed? animation group ended!
  4445. if (this._animatables.length === 0) {
  4446. this._isStarted = false;
  4447. this.onAnimationGroupEndObservable.notifyObservers(this);
  4448. }
  4449. };
  4450. /**
  4451. * Clone the current animation group and returns a copy
  4452. * @param newName defines the name of the new group
  4453. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4454. * @returns the new aniamtion group
  4455. */
  4456. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4457. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4458. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4459. var targetAnimation = _a[_i];
  4460. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4461. }
  4462. return newGroup;
  4463. };
  4464. // Statics
  4465. /**
  4466. * Returns a new AnimationGroup object parsed from the source provided.
  4467. * @param parsedAnimationGroup defines the source
  4468. * @param scene defines the scene that will receive the animationGroup
  4469. * @returns a new AnimationGroup
  4470. */
  4471. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4472. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4473. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4474. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4475. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4476. var id = targetedAnimation.targetId;
  4477. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4478. var morphTarget = scene.getMorphTargetById(id);
  4479. if (morphTarget) {
  4480. animationGroup.addTargetedAnimation(animation, morphTarget);
  4481. }
  4482. }
  4483. else {
  4484. var targetNode = scene.getNodeByID(id);
  4485. if (targetNode != null) {
  4486. animationGroup.addTargetedAnimation(animation, targetNode);
  4487. }
  4488. }
  4489. }
  4490. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4491. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4492. }
  4493. return animationGroup;
  4494. };
  4495. /**
  4496. * Returns the string "AnimationGroup"
  4497. * @returns "AnimationGroup"
  4498. */
  4499. AnimationGroup.prototype.getClassName = function () {
  4500. return "AnimationGroup";
  4501. };
  4502. /**
  4503. * Creates a detailled string about the object
  4504. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4505. * @returns a string representing the object
  4506. */
  4507. AnimationGroup.prototype.toString = function (fullDetails) {
  4508. var ret = "Name: " + this.name;
  4509. ret += ", type: " + this.getClassName();
  4510. if (fullDetails) {
  4511. ret += ", from: " + this._from;
  4512. ret += ", to: " + this._to;
  4513. ret += ", isStarted: " + this._isStarted;
  4514. ret += ", speedRatio: " + this._speedRatio;
  4515. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4516. ret += ", animatables length: " + this._animatables;
  4517. }
  4518. return ret;
  4519. };
  4520. return AnimationGroup;
  4521. }());
  4522. /***/ }),
  4523. /***/ "./Animations/animationKey.ts":
  4524. /*!************************************!*\
  4525. !*** ./Animations/animationKey.ts ***!
  4526. \************************************/
  4527. /*! exports provided: AnimationKeyInterpolation */
  4528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4529. "use strict";
  4530. __webpack_require__.r(__webpack_exports__);
  4531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4532. /**
  4533. * Enum for the animation key frame interpolation type
  4534. */
  4535. var AnimationKeyInterpolation;
  4536. (function (AnimationKeyInterpolation) {
  4537. /**
  4538. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4539. */
  4540. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4541. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4542. /***/ }),
  4543. /***/ "./Animations/animationPropertiesOverride.ts":
  4544. /*!***************************************************!*\
  4545. !*** ./Animations/animationPropertiesOverride.ts ***!
  4546. \***************************************************/
  4547. /*! exports provided: AnimationPropertiesOverride */
  4548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4549. "use strict";
  4550. __webpack_require__.r(__webpack_exports__);
  4551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4552. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4553. /**
  4554. * Class used to override all child animations of a given target
  4555. */
  4556. var AnimationPropertiesOverride = /** @class */ (function () {
  4557. function AnimationPropertiesOverride() {
  4558. /**
  4559. * Gets or sets a value indicating if animation blending must be used
  4560. */
  4561. this.enableBlending = false;
  4562. /**
  4563. * Gets or sets the blending speed to use when enableBlending is true
  4564. */
  4565. this.blendingSpeed = 0.01;
  4566. /**
  4567. * Gets or sets the default loop mode to use
  4568. */
  4569. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4570. }
  4571. return AnimationPropertiesOverride;
  4572. }());
  4573. /***/ }),
  4574. /***/ "./Animations/animationRange.ts":
  4575. /*!**************************************!*\
  4576. !*** ./Animations/animationRange.ts ***!
  4577. \**************************************/
  4578. /*! exports provided: AnimationRange */
  4579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4580. "use strict";
  4581. __webpack_require__.r(__webpack_exports__);
  4582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4583. /**
  4584. * Represents the range of an animation
  4585. */
  4586. var AnimationRange = /** @class */ (function () {
  4587. /**
  4588. * Initializes the range of an animation
  4589. * @param name The name of the animation range
  4590. * @param from The starting frame of the animation
  4591. * @param to The ending frame of the animation
  4592. */
  4593. function AnimationRange(
  4594. /**The name of the animation range**/
  4595. name,
  4596. /**The starting frame of the animation */
  4597. from,
  4598. /**The ending frame of the animation*/
  4599. to) {
  4600. this.name = name;
  4601. this.from = from;
  4602. this.to = to;
  4603. }
  4604. /**
  4605. * Makes a copy of the animation range
  4606. * @returns A copy of the animation range
  4607. */
  4608. AnimationRange.prototype.clone = function () {
  4609. return new AnimationRange(this.name, this.from, this.to);
  4610. };
  4611. return AnimationRange;
  4612. }());
  4613. /***/ }),
  4614. /***/ "./Animations/easing.ts":
  4615. /*!******************************!*\
  4616. !*** ./Animations/easing.ts ***!
  4617. \******************************/
  4618. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4620. "use strict";
  4621. __webpack_require__.r(__webpack_exports__);
  4622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4636. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4637. /**
  4638. * Base class used for every default easing function.
  4639. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4640. */
  4641. var EasingFunction = /** @class */ (function () {
  4642. function EasingFunction() {
  4643. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4644. }
  4645. /**
  4646. * Sets the easing mode of the current function.
  4647. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4648. */
  4649. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4650. var n = Math.min(Math.max(easingMode, 0), 2);
  4651. this._easingMode = n;
  4652. };
  4653. /**
  4654. * Gets the current easing mode.
  4655. * @returns the easing mode
  4656. */
  4657. EasingFunction.prototype.getEasingMode = function () {
  4658. return this._easingMode;
  4659. };
  4660. /**
  4661. * @hidden
  4662. */
  4663. EasingFunction.prototype.easeInCore = function (gradient) {
  4664. throw new Error('You must implement this method');
  4665. };
  4666. /**
  4667. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4668. * of the easing function.
  4669. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4670. * @returns the corresponding value on the curve defined by the easing function
  4671. */
  4672. EasingFunction.prototype.ease = function (gradient) {
  4673. switch (this._easingMode) {
  4674. case EasingFunction.EASINGMODE_EASEIN:
  4675. return this.easeInCore(gradient);
  4676. case EasingFunction.EASINGMODE_EASEOUT:
  4677. return (1 - this.easeInCore(1 - gradient));
  4678. }
  4679. if (gradient >= 0.5) {
  4680. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4681. }
  4682. return (this.easeInCore(gradient * 2) * 0.5);
  4683. };
  4684. /**
  4685. * Interpolation follows the mathematical formula associated with the easing function.
  4686. */
  4687. EasingFunction.EASINGMODE_EASEIN = 0;
  4688. /**
  4689. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4690. */
  4691. EasingFunction.EASINGMODE_EASEOUT = 1;
  4692. /**
  4693. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4694. */
  4695. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4696. return EasingFunction;
  4697. }());
  4698. /**
  4699. * Easing function with a circle shape (see link below).
  4700. * @see https://easings.net/#easeInCirc
  4701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4702. */
  4703. var CircleEase = /** @class */ (function (_super) {
  4704. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4705. function CircleEase() {
  4706. return _super !== null && _super.apply(this, arguments) || this;
  4707. }
  4708. /** @hidden */
  4709. CircleEase.prototype.easeInCore = function (gradient) {
  4710. gradient = Math.max(0, Math.min(1, gradient));
  4711. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4712. };
  4713. return CircleEase;
  4714. }(EasingFunction));
  4715. /**
  4716. * Easing function with a ease back shape (see link below).
  4717. * @see https://easings.net/#easeInBack
  4718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4719. */
  4720. var BackEase = /** @class */ (function (_super) {
  4721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4722. /**
  4723. * Instantiates a back ease easing
  4724. * @see https://easings.net/#easeInBack
  4725. * @param amplitude Defines the amplitude of the function
  4726. */
  4727. function BackEase(
  4728. /** Defines the amplitude of the function */
  4729. amplitude) {
  4730. if (amplitude === void 0) { amplitude = 1; }
  4731. var _this = _super.call(this) || this;
  4732. _this.amplitude = amplitude;
  4733. return _this;
  4734. }
  4735. /** @hidden */
  4736. BackEase.prototype.easeInCore = function (gradient) {
  4737. var num = Math.max(0, this.amplitude);
  4738. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4739. };
  4740. return BackEase;
  4741. }(EasingFunction));
  4742. /**
  4743. * Easing function with a bouncing shape (see link below).
  4744. * @see https://easings.net/#easeInBounce
  4745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4746. */
  4747. var BounceEase = /** @class */ (function (_super) {
  4748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4749. /**
  4750. * Instantiates a bounce easing
  4751. * @see https://easings.net/#easeInBounce
  4752. * @param bounces Defines the number of bounces
  4753. * @param bounciness Defines the amplitude of the bounce
  4754. */
  4755. function BounceEase(
  4756. /** Defines the number of bounces */
  4757. bounces,
  4758. /** Defines the amplitude of the bounce */
  4759. bounciness) {
  4760. if (bounces === void 0) { bounces = 3; }
  4761. if (bounciness === void 0) { bounciness = 2; }
  4762. var _this = _super.call(this) || this;
  4763. _this.bounces = bounces;
  4764. _this.bounciness = bounciness;
  4765. return _this;
  4766. }
  4767. /** @hidden */
  4768. BounceEase.prototype.easeInCore = function (gradient) {
  4769. var y = Math.max(0.0, this.bounces);
  4770. var bounciness = this.bounciness;
  4771. if (bounciness <= 1.0) {
  4772. bounciness = 1.001;
  4773. }
  4774. var num9 = Math.pow(bounciness, y);
  4775. var num5 = 1.0 - bounciness;
  4776. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4777. var num15 = gradient * num4;
  4778. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4779. var num3 = Math.floor(num65);
  4780. var num13 = num3 + 1.0;
  4781. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4782. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4783. var num7 = (num8 + num12) * 0.5;
  4784. var num6 = gradient - num7;
  4785. var num2 = num7 - num8;
  4786. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4787. };
  4788. return BounceEase;
  4789. }(EasingFunction));
  4790. /**
  4791. * Easing function with a power of 3 shape (see link below).
  4792. * @see https://easings.net/#easeInCubic
  4793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4794. */
  4795. var CubicEase = /** @class */ (function (_super) {
  4796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4797. function CubicEase() {
  4798. return _super !== null && _super.apply(this, arguments) || this;
  4799. }
  4800. /** @hidden */
  4801. CubicEase.prototype.easeInCore = function (gradient) {
  4802. return (gradient * gradient * gradient);
  4803. };
  4804. return CubicEase;
  4805. }(EasingFunction));
  4806. /**
  4807. * Easing function with an elastic shape (see link below).
  4808. * @see https://easings.net/#easeInElastic
  4809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4810. */
  4811. var ElasticEase = /** @class */ (function (_super) {
  4812. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4813. /**
  4814. * Instantiates an elastic easing function
  4815. * @see https://easings.net/#easeInElastic
  4816. * @param oscillations Defines the number of oscillations
  4817. * @param springiness Defines the amplitude of the oscillations
  4818. */
  4819. function ElasticEase(
  4820. /** Defines the number of oscillations*/
  4821. oscillations,
  4822. /** Defines the amplitude of the oscillations*/
  4823. springiness) {
  4824. if (oscillations === void 0) { oscillations = 3; }
  4825. if (springiness === void 0) { springiness = 3; }
  4826. var _this = _super.call(this) || this;
  4827. _this.oscillations = oscillations;
  4828. _this.springiness = springiness;
  4829. return _this;
  4830. }
  4831. /** @hidden */
  4832. ElasticEase.prototype.easeInCore = function (gradient) {
  4833. var num2;
  4834. var num3 = Math.max(0.0, this.oscillations);
  4835. var num = Math.max(0.0, this.springiness);
  4836. if (num == 0) {
  4837. num2 = gradient;
  4838. }
  4839. else {
  4840. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4841. }
  4842. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4843. };
  4844. return ElasticEase;
  4845. }(EasingFunction));
  4846. /**
  4847. * Easing function with an exponential shape (see link below).
  4848. * @see https://easings.net/#easeInExpo
  4849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4850. */
  4851. var ExponentialEase = /** @class */ (function (_super) {
  4852. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4853. /**
  4854. * Instantiates an exponential easing function
  4855. * @see https://easings.net/#easeInExpo
  4856. * @param exponent Defines the exponent of the function
  4857. */
  4858. function ExponentialEase(
  4859. /** Defines the exponent of the function */
  4860. exponent) {
  4861. if (exponent === void 0) { exponent = 2; }
  4862. var _this = _super.call(this) || this;
  4863. _this.exponent = exponent;
  4864. return _this;
  4865. }
  4866. /** @hidden */
  4867. ExponentialEase.prototype.easeInCore = function (gradient) {
  4868. if (this.exponent <= 0) {
  4869. return gradient;
  4870. }
  4871. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4872. };
  4873. return ExponentialEase;
  4874. }(EasingFunction));
  4875. /**
  4876. * Easing function with a power shape (see link below).
  4877. * @see https://easings.net/#easeInQuad
  4878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4879. */
  4880. var PowerEase = /** @class */ (function (_super) {
  4881. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4882. /**
  4883. * Instantiates an power base easing function
  4884. * @see https://easings.net/#easeInQuad
  4885. * @param power Defines the power of the function
  4886. */
  4887. function PowerEase(
  4888. /** Defines the power of the function */
  4889. power) {
  4890. if (power === void 0) { power = 2; }
  4891. var _this = _super.call(this) || this;
  4892. _this.power = power;
  4893. return _this;
  4894. }
  4895. /** @hidden */
  4896. PowerEase.prototype.easeInCore = function (gradient) {
  4897. var y = Math.max(0.0, this.power);
  4898. return Math.pow(gradient, y);
  4899. };
  4900. return PowerEase;
  4901. }(EasingFunction));
  4902. /**
  4903. * Easing function with a power of 2 shape (see link below).
  4904. * @see https://easings.net/#easeInQuad
  4905. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4906. */
  4907. var QuadraticEase = /** @class */ (function (_super) {
  4908. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4909. function QuadraticEase() {
  4910. return _super !== null && _super.apply(this, arguments) || this;
  4911. }
  4912. /** @hidden */
  4913. QuadraticEase.prototype.easeInCore = function (gradient) {
  4914. return (gradient * gradient);
  4915. };
  4916. return QuadraticEase;
  4917. }(EasingFunction));
  4918. /**
  4919. * Easing function with a power of 4 shape (see link below).
  4920. * @see https://easings.net/#easeInQuart
  4921. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4922. */
  4923. var QuarticEase = /** @class */ (function (_super) {
  4924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4925. function QuarticEase() {
  4926. return _super !== null && _super.apply(this, arguments) || this;
  4927. }
  4928. /** @hidden */
  4929. QuarticEase.prototype.easeInCore = function (gradient) {
  4930. return (gradient * gradient * gradient * gradient);
  4931. };
  4932. return QuarticEase;
  4933. }(EasingFunction));
  4934. /**
  4935. * Easing function with a power of 5 shape (see link below).
  4936. * @see https://easings.net/#easeInQuint
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. var QuinticEase = /** @class */ (function (_super) {
  4940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4941. function QuinticEase() {
  4942. return _super !== null && _super.apply(this, arguments) || this;
  4943. }
  4944. /** @hidden */
  4945. QuinticEase.prototype.easeInCore = function (gradient) {
  4946. return (gradient * gradient * gradient * gradient * gradient);
  4947. };
  4948. return QuinticEase;
  4949. }(EasingFunction));
  4950. /**
  4951. * Easing function with a sin shape (see link below).
  4952. * @see https://easings.net/#easeInSine
  4953. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4954. */
  4955. var SineEase = /** @class */ (function (_super) {
  4956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4957. function SineEase() {
  4958. return _super !== null && _super.apply(this, arguments) || this;
  4959. }
  4960. /** @hidden */
  4961. SineEase.prototype.easeInCore = function (gradient) {
  4962. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4963. };
  4964. return SineEase;
  4965. }(EasingFunction));
  4966. /**
  4967. * Easing function with a bezier shape (see link below).
  4968. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. var BezierCurveEase = /** @class */ (function (_super) {
  4972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4973. /**
  4974. * Instantiates a bezier function
  4975. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4976. * @param x1 Defines the x component of the start tangent in the bezier curve
  4977. * @param y1 Defines the y component of the start tangent in the bezier curve
  4978. * @param x2 Defines the x component of the end tangent in the bezier curve
  4979. * @param y2 Defines the y component of the end tangent in the bezier curve
  4980. */
  4981. function BezierCurveEase(
  4982. /** Defines the x component of the start tangent in the bezier curve */
  4983. x1,
  4984. /** Defines the y component of the start tangent in the bezier curve */
  4985. y1,
  4986. /** Defines the x component of the end tangent in the bezier curve */
  4987. x2,
  4988. /** Defines the y component of the end tangent in the bezier curve */
  4989. y2) {
  4990. if (x1 === void 0) { x1 = 0; }
  4991. if (y1 === void 0) { y1 = 0; }
  4992. if (x2 === void 0) { x2 = 1; }
  4993. if (y2 === void 0) { y2 = 1; }
  4994. var _this = _super.call(this) || this;
  4995. _this.x1 = x1;
  4996. _this.y1 = y1;
  4997. _this.x2 = x2;
  4998. _this.y2 = y2;
  4999. return _this;
  5000. }
  5001. /** @hidden */
  5002. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5003. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5004. };
  5005. return BezierCurveEase;
  5006. }(EasingFunction));
  5007. /***/ }),
  5008. /***/ "./Animations/index.ts":
  5009. /*!*****************************!*\
  5010. !*** ./Animations/index.ts ***!
  5011. \*****************************/
  5012. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5014. "use strict";
  5015. __webpack_require__.r(__webpack_exports__);
  5016. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5018. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5020. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5023. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5025. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5039. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5041. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5043. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5045. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5047. /***/ }),
  5048. /***/ "./Animations/runtimeAnimation.ts":
  5049. /*!****************************************!*\
  5050. !*** ./Animations/runtimeAnimation.ts ***!
  5051. \****************************************/
  5052. /*! exports provided: RuntimeAnimation */
  5053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5054. "use strict";
  5055. __webpack_require__.r(__webpack_exports__);
  5056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5058. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5059. // Static values to help the garbage collector
  5060. // Quaternion
  5061. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5062. // Vector3
  5063. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5064. // Vector2
  5065. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5066. // Size
  5067. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5068. // Color3
  5069. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5070. /**
  5071. * Defines a runtime animation
  5072. */
  5073. var RuntimeAnimation = /** @class */ (function () {
  5074. /**
  5075. * Create a new RuntimeAnimation object
  5076. * @param target defines the target of the animation
  5077. * @param animation defines the source animation object
  5078. * @param scene defines the hosting scene
  5079. * @param host defines the initiating Animatable
  5080. */
  5081. function RuntimeAnimation(target, animation, scene, host) {
  5082. var _this = this;
  5083. this._events = new Array();
  5084. /**
  5085. * The current frame of the runtime animation
  5086. */
  5087. this._currentFrame = 0;
  5088. /**
  5089. * The original value of the runtime animation
  5090. */
  5091. this._originalValue = new Array();
  5092. /**
  5093. * The offsets cache of the runtime animation
  5094. */
  5095. this._offsetsCache = {};
  5096. /**
  5097. * The high limits cache of the runtime animation
  5098. */
  5099. this._highLimitsCache = {};
  5100. /**
  5101. * Specifies if the runtime animation has been stopped
  5102. */
  5103. this._stopped = false;
  5104. /**
  5105. * The blending factor of the runtime animation
  5106. */
  5107. this._blendingFactor = 0;
  5108. /**
  5109. * The target path of the runtime animation
  5110. */
  5111. this._targetPath = "";
  5112. /**
  5113. * The weight of the runtime animation
  5114. */
  5115. this._weight = 1.0;
  5116. /**
  5117. * The ratio offset of the runtime animation
  5118. */
  5119. this._ratioOffset = 0;
  5120. /**
  5121. * The previous delay of the runtime animation
  5122. */
  5123. this._previousDelay = 0;
  5124. /**
  5125. * The previous ratio of the runtime animation
  5126. */
  5127. this._previousRatio = 0;
  5128. this._animation = animation;
  5129. this._target = target;
  5130. this._scene = scene;
  5131. this._host = host;
  5132. animation._runtimeAnimations.push(this);
  5133. // Cloning events locally
  5134. var events = animation.getEvents();
  5135. if (events && events.length > 0) {
  5136. events.forEach(function (e) {
  5137. _this._events.push(e._clone());
  5138. });
  5139. }
  5140. }
  5141. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5142. /**
  5143. * Gets the current frame of the runtime animation
  5144. */
  5145. get: function () {
  5146. return this._currentFrame;
  5147. },
  5148. enumerable: true,
  5149. configurable: true
  5150. });
  5151. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5152. /**
  5153. * Gets the weight of the runtime animation
  5154. */
  5155. get: function () {
  5156. return this._weight;
  5157. },
  5158. enumerable: true,
  5159. configurable: true
  5160. });
  5161. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5162. /**
  5163. * Gets the current value of the runtime animation
  5164. */
  5165. get: function () {
  5166. return this._currentValue;
  5167. },
  5168. enumerable: true,
  5169. configurable: true
  5170. });
  5171. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5172. /**
  5173. * Gets the target path of the runtime animation
  5174. */
  5175. get: function () {
  5176. return this._targetPath;
  5177. },
  5178. enumerable: true,
  5179. configurable: true
  5180. });
  5181. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5182. /**
  5183. * Gets the actual target of the runtime animation
  5184. */
  5185. get: function () {
  5186. return this._activeTarget;
  5187. },
  5188. enumerable: true,
  5189. configurable: true
  5190. });
  5191. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5192. /**
  5193. * Gets the animation from the runtime animation
  5194. */
  5195. get: function () {
  5196. return this._animation;
  5197. },
  5198. enumerable: true,
  5199. configurable: true
  5200. });
  5201. /**
  5202. * Resets the runtime animation to the beginning
  5203. * @param restoreOriginal defines whether to restore the target property to the original value
  5204. */
  5205. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5206. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5207. if (restoreOriginal) {
  5208. if (this._target instanceof Array) {
  5209. var index = 0;
  5210. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5211. var target = _a[_i];
  5212. if (this._originalValue[index] !== undefined) {
  5213. this._setValue(target, this._originalValue[index], -1);
  5214. }
  5215. index++;
  5216. }
  5217. }
  5218. else {
  5219. if (this._originalValue[0] !== undefined) {
  5220. this._setValue(this._target, this._originalValue[0], -1);
  5221. }
  5222. }
  5223. }
  5224. this._offsetsCache = {};
  5225. this._highLimitsCache = {};
  5226. this._currentFrame = 0;
  5227. this._blendingFactor = 0;
  5228. this._originalValue = new Array();
  5229. // Events
  5230. for (var index = 0; index < this._events.length; index++) {
  5231. this._events[index].isDone = false;
  5232. }
  5233. };
  5234. /**
  5235. * Specifies if the runtime animation is stopped
  5236. * @returns Boolean specifying if the runtime animation is stopped
  5237. */
  5238. RuntimeAnimation.prototype.isStopped = function () {
  5239. return this._stopped;
  5240. };
  5241. /**
  5242. * Disposes of the runtime animation
  5243. */
  5244. RuntimeAnimation.prototype.dispose = function () {
  5245. var index = this._animation.runtimeAnimations.indexOf(this);
  5246. if (index > -1) {
  5247. this._animation.runtimeAnimations.splice(index, 1);
  5248. }
  5249. };
  5250. /**
  5251. * Interpolates the animation from the current frame
  5252. * @param currentFrame The frame to interpolate the animation to
  5253. * @param repeatCount The number of times that the animation should loop
  5254. * @param loopMode The type of looping mode to use
  5255. * @param offsetValue Animation offset value
  5256. * @param highLimitValue The high limit value
  5257. * @returns The interpolated value
  5258. */
  5259. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5260. this._currentFrame = currentFrame;
  5261. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5262. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5263. }
  5264. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5265. };
  5266. /**
  5267. * Apply the interpolated value to the target
  5268. * @param currentValue defines the value computed by the animation
  5269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5270. */
  5271. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5272. if (weight === void 0) { weight = 1.0; }
  5273. if (this._target instanceof Array) {
  5274. var index = 0;
  5275. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5276. var target = _a[_i];
  5277. this._setValue(target, currentValue, weight, index);
  5278. index++;
  5279. }
  5280. }
  5281. else {
  5282. this._setValue(this._target, currentValue, weight);
  5283. }
  5284. };
  5285. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5286. if (targetIndex === void 0) { targetIndex = 0; }
  5287. // Set value
  5288. var path;
  5289. var destination;
  5290. var targetPropertyPath = this._animation.targetPropertyPath;
  5291. if (targetPropertyPath.length > 1) {
  5292. var property = target[targetPropertyPath[0]];
  5293. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5294. property = property[targetPropertyPath[index]];
  5295. }
  5296. path = targetPropertyPath[targetPropertyPath.length - 1];
  5297. destination = property;
  5298. }
  5299. else {
  5300. path = targetPropertyPath[0];
  5301. destination = target;
  5302. }
  5303. this._targetPath = path;
  5304. this._activeTarget = destination;
  5305. this._weight = weight;
  5306. if (this._originalValue[targetIndex] === undefined) {
  5307. var originalValue = void 0;
  5308. if (destination.getRestPose && path === "_matrix") { // For bones
  5309. originalValue = destination.getRestPose();
  5310. }
  5311. else {
  5312. originalValue = destination[path];
  5313. }
  5314. if (originalValue && originalValue.clone) {
  5315. this._originalValue[targetIndex] = originalValue.clone();
  5316. }
  5317. else {
  5318. this._originalValue[targetIndex] = originalValue;
  5319. }
  5320. }
  5321. // Blending
  5322. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5323. if (enableBlending && this._blendingFactor <= 1.0) {
  5324. if (!this._originalBlendValue) {
  5325. var originalValue = destination[path];
  5326. if (originalValue.clone) {
  5327. this._originalBlendValue = originalValue.clone();
  5328. }
  5329. else {
  5330. this._originalBlendValue = originalValue;
  5331. }
  5332. }
  5333. if (this._originalBlendValue.m) { // Matrix
  5334. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5335. if (this._currentValue) {
  5336. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5337. }
  5338. else {
  5339. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5340. }
  5341. }
  5342. else {
  5343. if (this._currentValue) {
  5344. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5345. }
  5346. else {
  5347. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5348. }
  5349. }
  5350. }
  5351. else {
  5352. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5353. }
  5354. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5355. this._blendingFactor += blendingSpeed;
  5356. }
  5357. else {
  5358. this._currentValue = currentValue;
  5359. }
  5360. if (weight !== -1.0) {
  5361. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5362. }
  5363. else {
  5364. destination[path] = this._currentValue;
  5365. }
  5366. if (target.markAsDirty) {
  5367. target.markAsDirty(this._animation.targetProperty);
  5368. }
  5369. };
  5370. /**
  5371. * Gets the loop pmode of the runtime animation
  5372. * @returns Loop Mode
  5373. */
  5374. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5375. if (this._target && this._target.animationPropertiesOverride) {
  5376. return this._target.animationPropertiesOverride.loopMode;
  5377. }
  5378. return this._animation.loopMode;
  5379. };
  5380. /**
  5381. * Move the current animation to a given frame
  5382. * @param frame defines the frame to move to
  5383. */
  5384. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5385. var keys = this._animation.getKeys();
  5386. if (frame < keys[0].frame) {
  5387. frame = keys[0].frame;
  5388. }
  5389. else if (frame > keys[keys.length - 1].frame) {
  5390. frame = keys[keys.length - 1].frame;
  5391. }
  5392. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5393. this.setValue(currentValue, -1);
  5394. };
  5395. /**
  5396. * @hidden Internal use only
  5397. */
  5398. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5399. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5400. this._ratioOffset = this._previousRatio - newRatio;
  5401. };
  5402. /**
  5403. * Execute the current animation
  5404. * @param delay defines the delay to add to the current frame
  5405. * @param from defines the lower bound of the animation range
  5406. * @param to defines the upper bound of the animation range
  5407. * @param loop defines if the current animation must loop
  5408. * @param speedRatio defines the current speed ratio
  5409. * @param weight defines the weight of the animation (default is -1 so no weight)
  5410. * @param onLoop optional callback called when animation loops
  5411. * @returns a boolean indicating if the animation is running
  5412. */
  5413. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5414. if (weight === void 0) { weight = -1.0; }
  5415. var targetPropertyPath = this._animation.targetPropertyPath;
  5416. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5417. this._stopped = true;
  5418. return false;
  5419. }
  5420. var returnValue = true;
  5421. var keys = this._animation.getKeys();
  5422. var min = keys[0].frame;
  5423. var max = keys[keys.length - 1].frame;
  5424. // Add a start key at frame 0 if missing
  5425. if (min !== 0) {
  5426. var newKey = { frame: 0, value: keys[0].value };
  5427. keys.splice(0, 0, newKey);
  5428. }
  5429. // Check limits
  5430. if (from < min || from > max) {
  5431. from = min;
  5432. }
  5433. if (to < min || to > max) {
  5434. to = max;
  5435. }
  5436. var range = to - from;
  5437. var offsetValue;
  5438. // Compute ratio which represents the frame delta between from and to
  5439. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5440. var highLimitValue = 0;
  5441. this._previousDelay = delay;
  5442. this._previousRatio = ratio;
  5443. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5444. returnValue = false;
  5445. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5446. }
  5447. else {
  5448. // Get max value if required
  5449. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5450. var keyOffset = to.toString() + from.toString();
  5451. if (!this._offsetsCache[keyOffset]) {
  5452. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5453. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5454. switch (this._animation.dataType) {
  5455. // Float
  5456. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5457. this._offsetsCache[keyOffset] = toValue - fromValue;
  5458. break;
  5459. // Quaternion
  5460. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5461. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5462. break;
  5463. // Vector3
  5464. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5465. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5466. // Vector2
  5467. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5468. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5469. // Size
  5470. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5471. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5472. // Color3
  5473. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5474. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5475. default:
  5476. break;
  5477. }
  5478. this._highLimitsCache[keyOffset] = toValue;
  5479. }
  5480. highLimitValue = this._highLimitsCache[keyOffset];
  5481. offsetValue = this._offsetsCache[keyOffset];
  5482. }
  5483. }
  5484. if (offsetValue === undefined) {
  5485. switch (this._animation.dataType) {
  5486. // Float
  5487. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5488. offsetValue = 0;
  5489. break;
  5490. // Quaternion
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5492. offsetValue = _staticOffsetValueQuaternion;
  5493. break;
  5494. // Vector3
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5496. offsetValue = _staticOffsetValueVector3;
  5497. break;
  5498. // Vector2
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5500. offsetValue = _staticOffsetValueVector2;
  5501. break;
  5502. // Size
  5503. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5504. offsetValue = _staticOffsetValueSize;
  5505. break;
  5506. // Color3
  5507. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5508. offsetValue = _staticOffsetValueColor3;
  5509. }
  5510. }
  5511. // Compute value
  5512. var currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5513. // Need to normalize?
  5514. if (this._host && this._host.syncRoot) {
  5515. var syncRoot = this._host.syncRoot;
  5516. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5517. currentFrame = from + (to - from) * hostNormalizedFrame;
  5518. }
  5519. // Reset events if looping
  5520. var events = this._events;
  5521. if (range > 0 && this.currentFrame > currentFrame ||
  5522. range < 0 && this.currentFrame < currentFrame) {
  5523. if (onLoop) {
  5524. onLoop();
  5525. }
  5526. // Need to reset animation events
  5527. for (var index = 0; index < events.length; index++) {
  5528. if (!events[index].onlyOnce) {
  5529. // reset event, the animation is looping
  5530. events[index].isDone = false;
  5531. }
  5532. }
  5533. }
  5534. var repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5535. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5536. // Set value
  5537. this.setValue(currentValue, weight);
  5538. // Check events
  5539. for (var index = 0; index < events.length; index++) {
  5540. // Make sure current frame has passed event frame and that event frame is within the current range
  5541. // Also, handle both forward and reverse animations
  5542. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5543. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5544. var event = events[index];
  5545. if (!event.isDone) {
  5546. // If event should be done only once, remove it.
  5547. if (event.onlyOnce) {
  5548. events.splice(index, 1);
  5549. index--;
  5550. }
  5551. event.isDone = true;
  5552. event.action(currentFrame);
  5553. } // Don't do anything if the event has already be done.
  5554. }
  5555. }
  5556. if (!returnValue) {
  5557. this._stopped = true;
  5558. }
  5559. return returnValue;
  5560. };
  5561. return RuntimeAnimation;
  5562. }());
  5563. /***/ }),
  5564. /***/ "./Audio/analyser.ts":
  5565. /*!***************************!*\
  5566. !*** ./Audio/analyser.ts ***!
  5567. \***************************/
  5568. /*! exports provided: Analyser */
  5569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5570. "use strict";
  5571. __webpack_require__.r(__webpack_exports__);
  5572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5573. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5574. /**
  5575. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5577. */
  5578. var Analyser = /** @class */ (function () {
  5579. /**
  5580. * Creates a new analyser
  5581. * @param scene defines hosting scene
  5582. */
  5583. function Analyser(scene) {
  5584. /**
  5585. * Gets or sets the smoothing
  5586. * @ignorenaming
  5587. */
  5588. this.SMOOTHING = 0.75;
  5589. /**
  5590. * Gets or sets the FFT table size
  5591. * @ignorenaming
  5592. */
  5593. this.FFT_SIZE = 512;
  5594. /**
  5595. * Gets or sets the bar graph amplitude
  5596. * @ignorenaming
  5597. */
  5598. this.BARGRAPHAMPLITUDE = 256;
  5599. /**
  5600. * Gets or sets the position of the debug canvas
  5601. * @ignorenaming
  5602. */
  5603. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5604. /**
  5605. * Gets or sets the debug canvas size
  5606. * @ignorenaming
  5607. */
  5608. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5609. this._scene = scene;
  5610. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5611. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5612. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5613. this._webAudioAnalyser.minDecibels = -140;
  5614. this._webAudioAnalyser.maxDecibels = 0;
  5615. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5616. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5617. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5618. }
  5619. }
  5620. /**
  5621. * Get the number of data values you will have to play with for the visualization
  5622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5623. * @returns a number
  5624. */
  5625. Analyser.prototype.getFrequencyBinCount = function () {
  5626. if (this._audioEngine.canUseWebAudio) {
  5627. return this._webAudioAnalyser.frequencyBinCount;
  5628. }
  5629. else {
  5630. return 0;
  5631. }
  5632. };
  5633. /**
  5634. * Gets the current frequency data as a byte array
  5635. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5636. * @returns a Uint8Array
  5637. */
  5638. Analyser.prototype.getByteFrequencyData = function () {
  5639. if (this._audioEngine.canUseWebAudio) {
  5640. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5641. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5642. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5643. }
  5644. return this._byteFreqs;
  5645. };
  5646. /**
  5647. * Gets the current waveform as a byte array
  5648. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5649. * @returns a Uint8Array
  5650. */
  5651. Analyser.prototype.getByteTimeDomainData = function () {
  5652. if (this._audioEngine.canUseWebAudio) {
  5653. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5654. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5655. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5656. }
  5657. return this._byteTime;
  5658. };
  5659. /**
  5660. * Gets the current frequency data as a float array
  5661. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5662. * @returns a Float32Array
  5663. */
  5664. Analyser.prototype.getFloatFrequencyData = function () {
  5665. if (this._audioEngine.canUseWebAudio) {
  5666. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5667. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5668. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5669. }
  5670. return this._floatFreqs;
  5671. };
  5672. /**
  5673. * Renders the debug canvas
  5674. */
  5675. Analyser.prototype.drawDebugCanvas = function () {
  5676. var _this = this;
  5677. if (this._audioEngine.canUseWebAudio) {
  5678. if (!this._debugCanvas) {
  5679. this._debugCanvas = document.createElement("canvas");
  5680. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5681. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5682. this._debugCanvas.style.position = "absolute";
  5683. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5684. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5685. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5686. document.body.appendChild(this._debugCanvas);
  5687. this._registerFunc = function () {
  5688. _this.drawDebugCanvas();
  5689. };
  5690. this._scene.registerBeforeRender(this._registerFunc);
  5691. }
  5692. if (this._registerFunc && this._debugCanvasContext) {
  5693. var workingArray = this.getByteFrequencyData();
  5694. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5695. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5696. // Draw the frequency domain chart.
  5697. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5698. var value = workingArray[i];
  5699. var percent = value / this.BARGRAPHAMPLITUDE;
  5700. var height = this.DEBUGCANVASSIZE.height * percent;
  5701. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5702. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5703. var hue = i / this.getFrequencyBinCount() * 360;
  5704. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5705. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5706. }
  5707. }
  5708. }
  5709. };
  5710. /**
  5711. * Stops rendering the debug canvas and removes it
  5712. */
  5713. Analyser.prototype.stopDebugCanvas = function () {
  5714. if (this._debugCanvas) {
  5715. if (this._registerFunc) {
  5716. this._scene.unregisterBeforeRender(this._registerFunc);
  5717. this._registerFunc = null;
  5718. }
  5719. document.body.removeChild(this._debugCanvas);
  5720. this._debugCanvas = null;
  5721. this._debugCanvasContext = null;
  5722. }
  5723. };
  5724. /**
  5725. * Connects two audio nodes
  5726. * @param inputAudioNode defines first node to connect
  5727. * @param outputAudioNode defines second node to connect
  5728. */
  5729. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5730. if (this._audioEngine.canUseWebAudio) {
  5731. inputAudioNode.connect(this._webAudioAnalyser);
  5732. this._webAudioAnalyser.connect(outputAudioNode);
  5733. }
  5734. };
  5735. /**
  5736. * Releases all associated resources
  5737. */
  5738. Analyser.prototype.dispose = function () {
  5739. if (this._audioEngine.canUseWebAudio) {
  5740. this._webAudioAnalyser.disconnect();
  5741. }
  5742. };
  5743. return Analyser;
  5744. }());
  5745. /***/ }),
  5746. /***/ "./Audio/audioEngine.ts":
  5747. /*!******************************!*\
  5748. !*** ./Audio/audioEngine.ts ***!
  5749. \******************************/
  5750. /*! exports provided: AudioEngine */
  5751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5752. "use strict";
  5753. __webpack_require__.r(__webpack_exports__);
  5754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5755. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5756. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5757. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5758. // Sets the default audio engine to Babylon.js
  5759. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5760. /**
  5761. * This represents the default audio engine used in babylon.
  5762. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5764. */
  5765. var AudioEngine = /** @class */ (function () {
  5766. /**
  5767. * Instantiates a new audio engine.
  5768. *
  5769. * There should be only one per page as some browsers restrict the number
  5770. * of audio contexts you can create.
  5771. * @param hostElement defines the host element where to display the mute icon if necessary
  5772. */
  5773. function AudioEngine(hostElement) {
  5774. if (hostElement === void 0) { hostElement = null; }
  5775. var _this = this;
  5776. this._audioContext = null;
  5777. this._audioContextInitialized = false;
  5778. this._muteButton = null;
  5779. /**
  5780. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5781. */
  5782. this.canUseWebAudio = false;
  5783. /**
  5784. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5785. * @ignoreNaming
  5786. */
  5787. this.WarnedWebAudioUnsupported = false;
  5788. /**
  5789. * Gets whether or not mp3 are supported by your browser.
  5790. */
  5791. this.isMP3supported = false;
  5792. /**
  5793. * Gets whether or not ogg are supported by your browser.
  5794. */
  5795. this.isOGGsupported = false;
  5796. /**
  5797. * Gets whether audio has been unlocked on the device.
  5798. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5799. * a user interaction has happened.
  5800. */
  5801. this.unlocked = true;
  5802. /**
  5803. * Defines if the audio engine relies on a custom unlocked button.
  5804. * In this case, the embedded button will not be displayed.
  5805. */
  5806. this.useCustomUnlockedButton = false;
  5807. /**
  5808. * Event raised when audio has been unlocked on the browser.
  5809. */
  5810. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5811. /**
  5812. * Event raised when audio has been locked on the browser.
  5813. */
  5814. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5815. this._tryToRun = false;
  5816. this._onResize = function () {
  5817. _this._moveButtonToTopLeft();
  5818. };
  5819. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5820. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5821. this.canUseWebAudio = true;
  5822. }
  5823. var audioElem = document.createElement('audio');
  5824. this._hostElement = hostElement;
  5825. try {
  5826. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5827. this.isMP3supported = true;
  5828. }
  5829. }
  5830. catch (e) {
  5831. // protect error during capability check.
  5832. }
  5833. try {
  5834. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5835. this.isOGGsupported = true;
  5836. }
  5837. }
  5838. catch (e) {
  5839. // protect error during capability check.
  5840. }
  5841. }
  5842. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5843. /**
  5844. * Gets the current AudioContext if available.
  5845. */
  5846. get: function () {
  5847. if (!this._audioContextInitialized) {
  5848. this._initializeAudioContext();
  5849. }
  5850. else {
  5851. if (!this.unlocked && !this._muteButton) {
  5852. this._displayMuteButton();
  5853. }
  5854. }
  5855. return this._audioContext;
  5856. },
  5857. enumerable: true,
  5858. configurable: true
  5859. });
  5860. /**
  5861. * Flags the audio engine in Locked state.
  5862. * This happens due to new browser policies preventing audio to autoplay.
  5863. */
  5864. AudioEngine.prototype.lock = function () {
  5865. this._triggerSuspendedState();
  5866. };
  5867. /**
  5868. * Unlocks the audio engine once a user action has been done on the dom.
  5869. * This is helpful to resume play once browser policies have been satisfied.
  5870. */
  5871. AudioEngine.prototype.unlock = function () {
  5872. this._triggerRunningState();
  5873. };
  5874. AudioEngine.prototype._resumeAudioContext = function () {
  5875. var result;
  5876. if (this._audioContext.resume) {
  5877. result = this._audioContext.resume();
  5878. }
  5879. return result || Promise.resolve();
  5880. };
  5881. AudioEngine.prototype._initializeAudioContext = function () {
  5882. try {
  5883. if (this.canUseWebAudio) {
  5884. this._audioContext = new AudioContext();
  5885. // create a global volume gain node
  5886. this.masterGain = this._audioContext.createGain();
  5887. this.masterGain.gain.value = 1;
  5888. this.masterGain.connect(this._audioContext.destination);
  5889. this._audioContextInitialized = true;
  5890. if (this._audioContext.state === "running") {
  5891. // Do not wait for the promise to unlock.
  5892. this._triggerRunningState();
  5893. }
  5894. }
  5895. }
  5896. catch (e) {
  5897. this.canUseWebAudio = false;
  5898. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5899. }
  5900. };
  5901. AudioEngine.prototype._triggerRunningState = function () {
  5902. var _this = this;
  5903. if (this._tryToRun) {
  5904. return;
  5905. }
  5906. this._tryToRun = true;
  5907. this._resumeAudioContext()
  5908. .then(function () {
  5909. _this._tryToRun = false;
  5910. if (_this._muteButton) {
  5911. _this._hideMuteButton();
  5912. }
  5913. }).catch(function () {
  5914. _this._tryToRun = false;
  5915. _this.unlocked = false;
  5916. });
  5917. // Notify users that the audio stack is unlocked/unmuted
  5918. this.unlocked = true;
  5919. this.onAudioUnlockedObservable.notifyObservers(this);
  5920. };
  5921. AudioEngine.prototype._triggerSuspendedState = function () {
  5922. this.unlocked = false;
  5923. this.onAudioLockedObservable.notifyObservers(this);
  5924. this._displayMuteButton();
  5925. };
  5926. AudioEngine.prototype._displayMuteButton = function () {
  5927. var _this = this;
  5928. if (this.useCustomUnlockedButton || this._muteButton) {
  5929. return;
  5930. }
  5931. this._muteButton = document.createElement("BUTTON");
  5932. this._muteButton.className = "babylonUnmuteIcon";
  5933. this._muteButton.id = "babylonUnmuteIconBtn";
  5934. this._muteButton.title = "Unmute";
  5935. var css = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }";
  5936. var style = document.createElement('style');
  5937. style.appendChild(document.createTextNode(css));
  5938. document.getElementsByTagName('head')[0].appendChild(style);
  5939. document.body.appendChild(this._muteButton);
  5940. this._moveButtonToTopLeft();
  5941. this._muteButton.addEventListener('touchend', function () {
  5942. _this._triggerRunningState();
  5943. }, true);
  5944. this._muteButton.addEventListener('click', function () {
  5945. _this._triggerRunningState();
  5946. }, true);
  5947. window.addEventListener("resize", this._onResize);
  5948. };
  5949. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5950. if (this._hostElement && this._muteButton) {
  5951. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5952. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5953. }
  5954. };
  5955. AudioEngine.prototype._hideMuteButton = function () {
  5956. if (this._muteButton) {
  5957. document.body.removeChild(this._muteButton);
  5958. this._muteButton = null;
  5959. }
  5960. };
  5961. /**
  5962. * Destroy and release the resources associated with the audio ccontext.
  5963. */
  5964. AudioEngine.prototype.dispose = function () {
  5965. if (this.canUseWebAudio && this._audioContextInitialized) {
  5966. if (this._connectedAnalyser && this._audioContext) {
  5967. this._connectedAnalyser.stopDebugCanvas();
  5968. this._connectedAnalyser.dispose();
  5969. this.masterGain.disconnect();
  5970. this.masterGain.connect(this._audioContext.destination);
  5971. this._connectedAnalyser = null;
  5972. }
  5973. this.masterGain.gain.value = 1;
  5974. }
  5975. this.WarnedWebAudioUnsupported = false;
  5976. this._hideMuteButton();
  5977. window.removeEventListener("resize", this._onResize);
  5978. this.onAudioUnlockedObservable.clear();
  5979. this.onAudioLockedObservable.clear();
  5980. };
  5981. /**
  5982. * Gets the global volume sets on the master gain.
  5983. * @returns the global volume if set or -1 otherwise
  5984. */
  5985. AudioEngine.prototype.getGlobalVolume = function () {
  5986. if (this.canUseWebAudio && this._audioContextInitialized) {
  5987. return this.masterGain.gain.value;
  5988. }
  5989. else {
  5990. return -1;
  5991. }
  5992. };
  5993. /**
  5994. * Sets the global volume of your experience (sets on the master gain).
  5995. * @param newVolume Defines the new global volume of the application
  5996. */
  5997. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5998. if (this.canUseWebAudio && this._audioContextInitialized) {
  5999. this.masterGain.gain.value = newVolume;
  6000. }
  6001. };
  6002. /**
  6003. * Connect the audio engine to an audio analyser allowing some amazing
  6004. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6006. * @param analyser The analyser to connect to the engine
  6007. */
  6008. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6009. if (this._connectedAnalyser) {
  6010. this._connectedAnalyser.stopDebugCanvas();
  6011. }
  6012. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6013. this._connectedAnalyser = analyser;
  6014. this.masterGain.disconnect();
  6015. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6016. }
  6017. };
  6018. return AudioEngine;
  6019. }());
  6020. /***/ }),
  6021. /***/ "./Audio/audioSceneComponent.ts":
  6022. /*!**************************************!*\
  6023. !*** ./Audio/audioSceneComponent.ts ***!
  6024. \**************************************/
  6025. /*! exports provided: AudioSceneComponent */
  6026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6027. "use strict";
  6028. __webpack_require__.r(__webpack_exports__);
  6029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6030. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6031. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6032. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6033. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6034. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6035. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6036. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6037. // Adds the parser to the scene parsers.
  6038. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6039. // TODO: add sound
  6040. var loadedSounds = [];
  6041. var loadedSound;
  6042. container.sounds = container.sounds || [];
  6043. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6044. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6045. var parsedSound = parsedData.sounds[index];
  6046. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6047. if (!parsedSound.url) {
  6048. parsedSound.url = parsedSound.name;
  6049. }
  6050. if (!loadedSounds[parsedSound.url]) {
  6051. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6052. loadedSounds[parsedSound.url] = loadedSound;
  6053. container.sounds.push(loadedSound);
  6054. }
  6055. else {
  6056. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6057. }
  6058. }
  6059. else {
  6060. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6061. }
  6062. }
  6063. }
  6064. loadedSounds = [];
  6065. });
  6066. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6067. get: function () {
  6068. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6069. if (!compo) {
  6070. compo = new AudioSceneComponent(this);
  6071. this._addComponent(compo);
  6072. }
  6073. if (!this._mainSoundTrack) {
  6074. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6075. }
  6076. return this._mainSoundTrack;
  6077. },
  6078. enumerable: true,
  6079. configurable: true
  6080. });
  6081. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6082. var index;
  6083. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6084. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6085. return this.mainSoundTrack.soundCollection[index];
  6086. }
  6087. }
  6088. if (this.soundTracks) {
  6089. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6090. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6091. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6092. return this.soundTracks[sdIndex].soundCollection[index];
  6093. }
  6094. }
  6095. }
  6096. }
  6097. return null;
  6098. };
  6099. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6100. get: function () {
  6101. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6102. if (!compo) {
  6103. compo = new AudioSceneComponent(this);
  6104. this._addComponent(compo);
  6105. }
  6106. return compo.audioEnabled;
  6107. },
  6108. set: function (value) {
  6109. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6110. if (!compo) {
  6111. compo = new AudioSceneComponent(this);
  6112. this._addComponent(compo);
  6113. }
  6114. if (value) {
  6115. compo.enableAudio();
  6116. }
  6117. else {
  6118. compo.disableAudio();
  6119. }
  6120. },
  6121. enumerable: true,
  6122. configurable: true
  6123. });
  6124. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6125. get: function () {
  6126. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6127. if (!compo) {
  6128. compo = new AudioSceneComponent(this);
  6129. this._addComponent(compo);
  6130. }
  6131. return compo.headphone;
  6132. },
  6133. set: function (value) {
  6134. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6135. if (!compo) {
  6136. compo = new AudioSceneComponent(this);
  6137. this._addComponent(compo);
  6138. }
  6139. if (value) {
  6140. compo.switchAudioModeForHeadphones();
  6141. }
  6142. else {
  6143. compo.switchAudioModeForNormalSpeakers();
  6144. }
  6145. },
  6146. enumerable: true,
  6147. configurable: true
  6148. });
  6149. /**
  6150. * Defines the sound scene component responsible to manage any sounds
  6151. * in a given scene.
  6152. */
  6153. var AudioSceneComponent = /** @class */ (function () {
  6154. /**
  6155. * Creates a new instance of the component for the given scene
  6156. * @param scene Defines the scene to register the component in
  6157. */
  6158. function AudioSceneComponent(scene) {
  6159. /**
  6160. * The component name helpfull to identify the component in the list of scene components.
  6161. */
  6162. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6163. this._audioEnabled = true;
  6164. this._headphone = false;
  6165. this.scene = scene;
  6166. scene.soundTracks = new Array();
  6167. scene.sounds = new Array();
  6168. }
  6169. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6170. /**
  6171. * Gets whether audio is enabled or not.
  6172. * Please use related enable/disable method to switch state.
  6173. */
  6174. get: function () {
  6175. return this._audioEnabled;
  6176. },
  6177. enumerable: true,
  6178. configurable: true
  6179. });
  6180. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6181. /**
  6182. * Gets whether audio is outputing to headphone or not.
  6183. * Please use the according Switch methods to change output.
  6184. */
  6185. get: function () {
  6186. return this._headphone;
  6187. },
  6188. enumerable: true,
  6189. configurable: true
  6190. });
  6191. /**
  6192. * Registers the component in a given scene
  6193. */
  6194. AudioSceneComponent.prototype.register = function () {
  6195. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6196. };
  6197. /**
  6198. * Rebuilds the elements related to this component in case of
  6199. * context lost for instance.
  6200. */
  6201. AudioSceneComponent.prototype.rebuild = function () {
  6202. // Nothing to do here. (Not rendering related)
  6203. };
  6204. /**
  6205. * Serializes the component data to the specified json object
  6206. * @param serializationObject The object to serialize to
  6207. */
  6208. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6209. serializationObject.sounds = [];
  6210. if (this.scene.soundTracks) {
  6211. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6212. var soundtrack = this.scene.soundTracks[index];
  6213. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6214. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6215. }
  6216. }
  6217. }
  6218. };
  6219. /**
  6220. * Adds all the element from the container to the scene
  6221. * @param container the container holding the elements
  6222. */
  6223. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6224. var _this = this;
  6225. if (!container.sounds) {
  6226. return;
  6227. }
  6228. container.sounds.forEach(function (sound) {
  6229. sound.play();
  6230. sound.autoplay = true;
  6231. _this.scene.mainSoundTrack.AddSound(sound);
  6232. });
  6233. };
  6234. /**
  6235. * Removes all the elements in the container from the scene
  6236. * @param container contains the elements to remove
  6237. */
  6238. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  6239. var _this = this;
  6240. if (!container.sounds) {
  6241. return;
  6242. }
  6243. container.sounds.forEach(function (sound) {
  6244. sound.stop();
  6245. sound.autoplay = false;
  6246. _this.scene.mainSoundTrack.RemoveSound(sound);
  6247. });
  6248. };
  6249. /**
  6250. * Disposes the component and the associated ressources.
  6251. */
  6252. AudioSceneComponent.prototype.dispose = function () {
  6253. var scene = this.scene;
  6254. if (scene._mainSoundTrack) {
  6255. scene.mainSoundTrack.dispose();
  6256. }
  6257. if (scene.soundTracks) {
  6258. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6259. scene.soundTracks[scIndex].dispose();
  6260. }
  6261. }
  6262. };
  6263. /**
  6264. * Disables audio in the associated scene.
  6265. */
  6266. AudioSceneComponent.prototype.disableAudio = function () {
  6267. var scene = this.scene;
  6268. this._audioEnabled = false;
  6269. var i;
  6270. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6271. scene.mainSoundTrack.soundCollection[i].pause();
  6272. }
  6273. if (scene.soundTracks) {
  6274. for (i = 0; i < scene.soundTracks.length; i++) {
  6275. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6276. scene.soundTracks[i].soundCollection[j].pause();
  6277. }
  6278. }
  6279. }
  6280. };
  6281. /**
  6282. * Enables audio in the associated scene.
  6283. */
  6284. AudioSceneComponent.prototype.enableAudio = function () {
  6285. var scene = this.scene;
  6286. this._audioEnabled = true;
  6287. var i;
  6288. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6289. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6290. scene.mainSoundTrack.soundCollection[i].play();
  6291. }
  6292. }
  6293. if (scene.soundTracks) {
  6294. for (i = 0; i < scene.soundTracks.length; i++) {
  6295. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6296. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6297. scene.soundTracks[i].soundCollection[j].play();
  6298. }
  6299. }
  6300. }
  6301. }
  6302. };
  6303. /**
  6304. * Switch audio to headphone output.
  6305. */
  6306. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6307. var scene = this.scene;
  6308. this._headphone = true;
  6309. scene.mainSoundTrack.switchPanningModelToHRTF();
  6310. if (scene.soundTracks) {
  6311. for (var i = 0; i < scene.soundTracks.length; i++) {
  6312. scene.soundTracks[i].switchPanningModelToHRTF();
  6313. }
  6314. }
  6315. };
  6316. /**
  6317. * Switch audio to normal speakers.
  6318. */
  6319. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6320. var scene = this.scene;
  6321. this._headphone = false;
  6322. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6323. if (scene.soundTracks) {
  6324. for (var i = 0; i < scene.soundTracks.length; i++) {
  6325. scene.soundTracks[i].switchPanningModelToEqualPower();
  6326. }
  6327. }
  6328. };
  6329. AudioSceneComponent.prototype._afterRender = function () {
  6330. var scene = this.scene;
  6331. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6332. return;
  6333. }
  6334. var listeningCamera;
  6335. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6336. if (scene.activeCameras.length > 0) {
  6337. listeningCamera = scene.activeCameras[0];
  6338. }
  6339. else {
  6340. listeningCamera = scene.activeCamera;
  6341. }
  6342. if (listeningCamera && audioEngine.audioContext) {
  6343. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6344. // for VR cameras
  6345. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6346. listeningCamera = listeningCamera.rigCameras[0];
  6347. }
  6348. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6349. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6350. cameraDirection.normalize();
  6351. // To avoid some errors on GearVR
  6352. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6353. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6354. }
  6355. var i;
  6356. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6357. var sound = scene.mainSoundTrack.soundCollection[i];
  6358. if (sound.useCustomAttenuation) {
  6359. sound.updateDistanceFromListener();
  6360. }
  6361. }
  6362. if (scene.soundTracks) {
  6363. for (i = 0; i < scene.soundTracks.length; i++) {
  6364. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6365. sound = scene.soundTracks[i].soundCollection[j];
  6366. if (sound.useCustomAttenuation) {
  6367. sound.updateDistanceFromListener();
  6368. }
  6369. }
  6370. }
  6371. }
  6372. }
  6373. };
  6374. return AudioSceneComponent;
  6375. }());
  6376. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6377. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6378. if (!compo) {
  6379. compo = new AudioSceneComponent(scene);
  6380. scene._addComponent(compo);
  6381. }
  6382. };
  6383. /***/ }),
  6384. /***/ "./Audio/index.ts":
  6385. /*!************************!*\
  6386. !*** ./Audio/index.ts ***!
  6387. \************************/
  6388. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6390. "use strict";
  6391. __webpack_require__.r(__webpack_exports__);
  6392. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6394. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6396. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6398. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6400. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6402. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6404. /***/ }),
  6405. /***/ "./Audio/sound.ts":
  6406. /*!************************!*\
  6407. !*** ./Audio/sound.ts ***!
  6408. \************************/
  6409. /*! exports provided: Sound */
  6410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6411. "use strict";
  6412. __webpack_require__.r(__webpack_exports__);
  6413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6414. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6415. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6416. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6417. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6418. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6419. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6420. /**
  6421. * Defines a sound that can be played in the application.
  6422. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6424. */
  6425. var Sound = /** @class */ (function () {
  6426. /**
  6427. * Create a sound and attach it to a scene
  6428. * @param name Name of your sound
  6429. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6430. * @param scene defines the scene the sound belongs to
  6431. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6432. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6433. */
  6434. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6435. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6436. var _this = this;
  6437. /**
  6438. * Does the sound autoplay once loaded.
  6439. */
  6440. this.autoplay = false;
  6441. /**
  6442. * Does the sound loop after it finishes playing once.
  6443. */
  6444. this.loop = false;
  6445. /**
  6446. * Does the sound use a custom attenuation curve to simulate the falloff
  6447. * happening when the source gets further away from the camera.
  6448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6449. */
  6450. this.useCustomAttenuation = false;
  6451. /**
  6452. * Is this sound currently played.
  6453. */
  6454. this.isPlaying = false;
  6455. /**
  6456. * Is this sound currently paused.
  6457. */
  6458. this.isPaused = false;
  6459. /**
  6460. * Does this sound enables spatial sound.
  6461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6462. */
  6463. this.spatialSound = false;
  6464. /**
  6465. * Define the reference distance the sound should be heard perfectly.
  6466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6467. */
  6468. this.refDistance = 1;
  6469. /**
  6470. * Define the roll off factor of spatial sounds.
  6471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6472. */
  6473. this.rolloffFactor = 1;
  6474. /**
  6475. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6477. */
  6478. this.maxDistance = 100;
  6479. /**
  6480. * Define the distance attenuation model the sound will follow.
  6481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6482. */
  6483. this.distanceModel = "linear";
  6484. /**
  6485. * Observable event when the current playing sound finishes.
  6486. */
  6487. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6488. this._panningModel = "equalpower";
  6489. this._playbackRate = 1;
  6490. this._streaming = false;
  6491. this._startTime = 0;
  6492. this._startOffset = 0;
  6493. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6494. /** @hidden */
  6495. this._positionInEmitterSpace = false;
  6496. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6497. this._volume = 1;
  6498. this._isReadyToPlay = false;
  6499. this._isDirectional = false;
  6500. // Used if you'd like to create a directional sound.
  6501. // If not set, the sound will be omnidirectional
  6502. this._coneInnerAngle = 360;
  6503. this._coneOuterAngle = 360;
  6504. this._coneOuterGain = 0;
  6505. this._isOutputConnected = false;
  6506. this._urlType = "Unknown";
  6507. this.name = name;
  6508. this._scene = scene;
  6509. Sound._SceneComponentInitialization(scene);
  6510. this._readyToPlayCallback = readyToPlayCallback;
  6511. // Default custom attenuation function is a linear attenuation
  6512. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6513. if (currentDistance < maxDistance) {
  6514. return currentVolume * (1 - currentDistance / maxDistance);
  6515. }
  6516. else {
  6517. return 0;
  6518. }
  6519. };
  6520. if (options) {
  6521. this.autoplay = options.autoplay || false;
  6522. this.loop = options.loop || false;
  6523. // if volume === 0, we need another way to check this option
  6524. if (options.volume !== undefined) {
  6525. this._volume = options.volume;
  6526. }
  6527. this.spatialSound = options.spatialSound || false;
  6528. this.maxDistance = options.maxDistance || 100;
  6529. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6530. this.rolloffFactor = options.rolloffFactor || 1;
  6531. this.refDistance = options.refDistance || 1;
  6532. this.distanceModel = options.distanceModel || "linear";
  6533. this._playbackRate = options.playbackRate || 1;
  6534. this._streaming = options.streaming || false;
  6535. }
  6536. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6537. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6538. this._soundGain.gain.value = this._volume;
  6539. this._inputAudioNode = this._soundGain;
  6540. this._outputAudioNode = this._soundGain;
  6541. if (this.spatialSound) {
  6542. this._createSpatialParameters();
  6543. }
  6544. this._scene.mainSoundTrack.AddSound(this);
  6545. var validParameter = true;
  6546. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6547. if (urlOrArrayBuffer) {
  6548. try {
  6549. if (typeof (urlOrArrayBuffer) === "string") {
  6550. this._urlType = "String";
  6551. }
  6552. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6553. this._urlType = "ArrayBuffer";
  6554. }
  6555. else if (urlOrArrayBuffer instanceof MediaStream) {
  6556. this._urlType = "MediaStream";
  6557. }
  6558. else if (Array.isArray(urlOrArrayBuffer)) {
  6559. this._urlType = "Array";
  6560. }
  6561. var urls = [];
  6562. var codecSupportedFound = false;
  6563. switch (this._urlType) {
  6564. case "MediaStream":
  6565. this._streaming = true;
  6566. this._isReadyToPlay = true;
  6567. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6568. if (this.autoplay) {
  6569. this.play();
  6570. }
  6571. if (this._readyToPlayCallback) {
  6572. this._readyToPlayCallback();
  6573. }
  6574. break;
  6575. case "ArrayBuffer":
  6576. if (urlOrArrayBuffer.byteLength > 0) {
  6577. codecSupportedFound = true;
  6578. this._soundLoaded(urlOrArrayBuffer);
  6579. }
  6580. break;
  6581. case "String":
  6582. urls.push(urlOrArrayBuffer);
  6583. case "Array":
  6584. if (urls.length === 0) {
  6585. urls = urlOrArrayBuffer;
  6586. }
  6587. // If we found a supported format, we load it immediately and stop the loop
  6588. for (var i = 0; i < urls.length; i++) {
  6589. var url = urls[i];
  6590. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6591. codecSupportedFound = true;
  6592. }
  6593. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6594. codecSupportedFound = true;
  6595. }
  6596. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6597. codecSupportedFound = true;
  6598. }
  6599. if (url.indexOf("blob:") !== -1) {
  6600. codecSupportedFound = true;
  6601. }
  6602. if (codecSupportedFound) {
  6603. // Loading sound using XHR2
  6604. if (!this._streaming) {
  6605. this._scene._loadFile(url, function (data) {
  6606. _this._soundLoaded(data);
  6607. }, undefined, true, true, function (exception) {
  6608. if (exception) {
  6609. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6610. }
  6611. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6612. _this._scene.mainSoundTrack.RemoveSound(_this);
  6613. });
  6614. }
  6615. // Streaming sound using HTML5 Audio tag
  6616. else {
  6617. this._htmlAudioElement = new Audio(url);
  6618. this._htmlAudioElement.controls = false;
  6619. this._htmlAudioElement.loop = this.loop;
  6620. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6621. this._htmlAudioElement.preload = "auto";
  6622. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6623. _this._isReadyToPlay = true;
  6624. if (_this.autoplay) {
  6625. _this.play();
  6626. }
  6627. if (_this._readyToPlayCallback) {
  6628. _this._readyToPlayCallback();
  6629. }
  6630. });
  6631. document.body.appendChild(this._htmlAudioElement);
  6632. this._htmlAudioElement.load();
  6633. }
  6634. break;
  6635. }
  6636. }
  6637. break;
  6638. default:
  6639. validParameter = false;
  6640. break;
  6641. }
  6642. if (!validParameter) {
  6643. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
  6644. }
  6645. else {
  6646. if (!codecSupportedFound) {
  6647. this._isReadyToPlay = true;
  6648. // Simulating a ready to play event to avoid breaking code path
  6649. if (this._readyToPlayCallback) {
  6650. window.setTimeout(function () {
  6651. if (_this._readyToPlayCallback) {
  6652. _this._readyToPlayCallback();
  6653. }
  6654. }, 1000);
  6655. }
  6656. }
  6657. }
  6658. }
  6659. catch (ex) {
  6660. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6661. this._scene.mainSoundTrack.RemoveSound(this);
  6662. }
  6663. }
  6664. }
  6665. else {
  6666. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6667. this._scene.mainSoundTrack.AddSound(this);
  6668. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6669. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6670. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6671. }
  6672. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6673. if (this._readyToPlayCallback) {
  6674. window.setTimeout(function () {
  6675. if (_this._readyToPlayCallback) {
  6676. _this._readyToPlayCallback();
  6677. }
  6678. }, 1000);
  6679. }
  6680. }
  6681. }
  6682. /**
  6683. * Release the sound and its associated resources
  6684. */
  6685. Sound.prototype.dispose = function () {
  6686. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6687. if (this.isPlaying) {
  6688. this.stop();
  6689. }
  6690. this._isReadyToPlay = false;
  6691. if (this.soundTrackId === -1) {
  6692. this._scene.mainSoundTrack.RemoveSound(this);
  6693. }
  6694. else if (this._scene.soundTracks) {
  6695. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6696. }
  6697. if (this._soundGain) {
  6698. this._soundGain.disconnect();
  6699. this._soundGain = null;
  6700. }
  6701. if (this._soundPanner) {
  6702. this._soundPanner.disconnect();
  6703. this._soundPanner = null;
  6704. }
  6705. if (this._soundSource) {
  6706. this._soundSource.disconnect();
  6707. this._soundSource = null;
  6708. }
  6709. this._audioBuffer = null;
  6710. if (this._htmlAudioElement) {
  6711. this._htmlAudioElement.pause();
  6712. this._htmlAudioElement.src = "";
  6713. document.body.removeChild(this._htmlAudioElement);
  6714. }
  6715. if (this._streamingSource) {
  6716. this._streamingSource.disconnect();
  6717. }
  6718. if (this._connectedTransformNode && this._registerFunc) {
  6719. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6720. this._connectedTransformNode = null;
  6721. }
  6722. }
  6723. };
  6724. /**
  6725. * Gets if the sounds is ready to be played or not.
  6726. * @returns true if ready, otherwise false
  6727. */
  6728. Sound.prototype.isReady = function () {
  6729. return this._isReadyToPlay;
  6730. };
  6731. Sound.prototype._soundLoaded = function (audioData) {
  6732. var _this = this;
  6733. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6734. return;
  6735. }
  6736. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6737. _this._audioBuffer = buffer;
  6738. _this._isReadyToPlay = true;
  6739. if (_this.autoplay) {
  6740. _this.play();
  6741. }
  6742. if (_this._readyToPlayCallback) {
  6743. _this._readyToPlayCallback();
  6744. }
  6745. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6746. };
  6747. /**
  6748. * Sets the data of the sound from an audiobuffer
  6749. * @param audioBuffer The audioBuffer containing the data
  6750. */
  6751. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6752. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6753. this._audioBuffer = audioBuffer;
  6754. this._isReadyToPlay = true;
  6755. }
  6756. };
  6757. /**
  6758. * Updates the current sounds options such as maxdistance, loop...
  6759. * @param options A JSON object containing values named as the object properties
  6760. */
  6761. Sound.prototype.updateOptions = function (options) {
  6762. if (options) {
  6763. this.loop = options.loop || this.loop;
  6764. this.maxDistance = options.maxDistance || this.maxDistance;
  6765. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6766. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6767. this.refDistance = options.refDistance || this.refDistance;
  6768. this.distanceModel = options.distanceModel || this.distanceModel;
  6769. this._playbackRate = options.playbackRate || this._playbackRate;
  6770. this._updateSpatialParameters();
  6771. if (this.isPlaying) {
  6772. if (this._streaming && this._htmlAudioElement) {
  6773. this._htmlAudioElement.playbackRate = this._playbackRate;
  6774. }
  6775. else {
  6776. if (this._soundSource) {
  6777. this._soundSource.playbackRate.value = this._playbackRate;
  6778. }
  6779. }
  6780. }
  6781. }
  6782. };
  6783. Sound.prototype._createSpatialParameters = function () {
  6784. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6785. if (this._scene.headphone) {
  6786. this._panningModel = "HRTF";
  6787. }
  6788. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6789. this._updateSpatialParameters();
  6790. this._soundPanner.connect(this._outputAudioNode);
  6791. this._inputAudioNode = this._soundPanner;
  6792. }
  6793. };
  6794. Sound.prototype._updateSpatialParameters = function () {
  6795. if (this.spatialSound && this._soundPanner) {
  6796. if (this.useCustomAttenuation) {
  6797. // Tricks to disable in a way embedded Web Audio attenuation
  6798. this._soundPanner.distanceModel = "linear";
  6799. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6800. this._soundPanner.refDistance = 1;
  6801. this._soundPanner.rolloffFactor = 1;
  6802. this._soundPanner.panningModel = this._panningModel;
  6803. }
  6804. else {
  6805. this._soundPanner.distanceModel = this.distanceModel;
  6806. this._soundPanner.maxDistance = this.maxDistance;
  6807. this._soundPanner.refDistance = this.refDistance;
  6808. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6809. this._soundPanner.panningModel = this._panningModel;
  6810. }
  6811. }
  6812. };
  6813. /**
  6814. * Switch the panning model to HRTF:
  6815. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6817. */
  6818. Sound.prototype.switchPanningModelToHRTF = function () {
  6819. this._panningModel = "HRTF";
  6820. this._switchPanningModel();
  6821. };
  6822. /**
  6823. * Switch the panning model to Equal Power:
  6824. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6826. */
  6827. Sound.prototype.switchPanningModelToEqualPower = function () {
  6828. this._panningModel = "equalpower";
  6829. this._switchPanningModel();
  6830. };
  6831. Sound.prototype._switchPanningModel = function () {
  6832. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6833. this._soundPanner.panningModel = this._panningModel;
  6834. }
  6835. };
  6836. /**
  6837. * Connect this sound to a sound track audio node like gain...
  6838. * @param soundTrackAudioNode the sound track audio node to connect to
  6839. */
  6840. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6841. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6842. if (this._isOutputConnected) {
  6843. this._outputAudioNode.disconnect();
  6844. }
  6845. this._outputAudioNode.connect(soundTrackAudioNode);
  6846. this._isOutputConnected = true;
  6847. }
  6848. };
  6849. /**
  6850. * Transform this sound into a directional source
  6851. * @param coneInnerAngle Size of the inner cone in degree
  6852. * @param coneOuterAngle Size of the outer cone in degree
  6853. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6854. */
  6855. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6856. if (coneOuterAngle < coneInnerAngle) {
  6857. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6858. return;
  6859. }
  6860. this._coneInnerAngle = coneInnerAngle;
  6861. this._coneOuterAngle = coneOuterAngle;
  6862. this._coneOuterGain = coneOuterGain;
  6863. this._isDirectional = true;
  6864. if (this.isPlaying && this.loop) {
  6865. this.stop();
  6866. this.play();
  6867. }
  6868. };
  6869. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6870. /**
  6871. * Gets or sets the inner angle for the directional cone.
  6872. */
  6873. get: function () {
  6874. return this._coneInnerAngle;
  6875. },
  6876. /**
  6877. * Gets or sets the inner angle for the directional cone.
  6878. */
  6879. set: function (value) {
  6880. if (value != this._coneInnerAngle) {
  6881. if (this._coneOuterAngle < value) {
  6882. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6883. return;
  6884. }
  6885. this._coneInnerAngle = value;
  6886. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6887. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6888. }
  6889. }
  6890. },
  6891. enumerable: true,
  6892. configurable: true
  6893. });
  6894. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6895. /**
  6896. * Gets or sets the outer angle for the directional cone.
  6897. */
  6898. get: function () {
  6899. return this._coneOuterAngle;
  6900. },
  6901. /**
  6902. * Gets or sets the outer angle for the directional cone.
  6903. */
  6904. set: function (value) {
  6905. if (value != this._coneOuterAngle) {
  6906. if (value < this._coneInnerAngle) {
  6907. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6908. return;
  6909. }
  6910. this._coneOuterAngle = value;
  6911. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6912. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6913. }
  6914. }
  6915. },
  6916. enumerable: true,
  6917. configurable: true
  6918. });
  6919. /**
  6920. * Sets the position of the emitter if spatial sound is enabled
  6921. * @param newPosition Defines the new posisiton
  6922. */
  6923. Sound.prototype.setPosition = function (newPosition) {
  6924. this._position = newPosition;
  6925. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6926. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6927. }
  6928. };
  6929. /**
  6930. * Sets the local direction of the emitter if spatial sound is enabled
  6931. * @param newLocalDirection Defines the new local direction
  6932. */
  6933. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6934. this._localDirection = newLocalDirection;
  6935. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6936. this._updateDirection();
  6937. }
  6938. };
  6939. Sound.prototype._updateDirection = function () {
  6940. if (!this._connectedTransformNode || !this._soundPanner) {
  6941. return;
  6942. }
  6943. var mat = this._connectedTransformNode.getWorldMatrix();
  6944. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6945. direction.normalize();
  6946. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6947. };
  6948. /** @hidden */
  6949. Sound.prototype.updateDistanceFromListener = function () {
  6950. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6951. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6952. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6953. }
  6954. };
  6955. /**
  6956. * Sets a new custom attenuation function for the sound.
  6957. * @param callback Defines the function used for the attenuation
  6958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6959. */
  6960. Sound.prototype.setAttenuationFunction = function (callback) {
  6961. this._customAttenuationFunction = callback;
  6962. };
  6963. /**
  6964. * Play the sound
  6965. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6966. * @param offset (optional) Start the sound setting it at a specific time
  6967. */
  6968. Sound.prototype.play = function (time, offset) {
  6969. var _this = this;
  6970. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6971. try {
  6972. if (this._startOffset < 0) {
  6973. time = -this._startOffset;
  6974. this._startOffset = 0;
  6975. }
  6976. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6977. if (!this._soundSource || !this._streamingSource) {
  6978. if (this.spatialSound && this._soundPanner) {
  6979. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6980. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6981. }
  6982. if (this._isDirectional) {
  6983. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6984. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6985. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6986. if (this._connectedTransformNode) {
  6987. this._updateDirection();
  6988. }
  6989. else {
  6990. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6991. }
  6992. }
  6993. }
  6994. }
  6995. if (this._streaming) {
  6996. if (!this._streamingSource) {
  6997. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6998. this._htmlAudioElement.onended = function () { _this._onended(); };
  6999. this._htmlAudioElement.playbackRate = this._playbackRate;
  7000. }
  7001. this._streamingSource.disconnect();
  7002. this._streamingSource.connect(this._inputAudioNode);
  7003. if (this._htmlAudioElement) {
  7004. // required to manage properly the new suspended default state of Chrome
  7005. // When the option 'streaming: true' is used, we need first to wait for
  7006. // the audio engine to be unlocked by a user gesture before trying to play
  7007. // an HTML Audio elememt
  7008. var tryToPlay = function () {
  7009. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7010. var playPromise = _this._htmlAudioElement.play();
  7011. // In browsers that don’t yet support this functionality,
  7012. // playPromise won’t be defined.
  7013. if (playPromise !== undefined) {
  7014. playPromise.catch(function (error) {
  7015. // Automatic playback failed.
  7016. // Waiting for the audio engine to be unlocked by user click on unmute
  7017. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7018. if (_this.loop || _this.autoplay) {
  7019. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7020. }
  7021. });
  7022. }
  7023. }
  7024. else {
  7025. if (_this.loop || _this.autoplay) {
  7026. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7027. }
  7028. }
  7029. };
  7030. tryToPlay();
  7031. }
  7032. }
  7033. else {
  7034. var tryToPlay = function () {
  7035. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7036. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7037. _this._soundSource.buffer = _this._audioBuffer;
  7038. _this._soundSource.connect(_this._inputAudioNode);
  7039. _this._soundSource.loop = _this.loop;
  7040. _this._soundSource.playbackRate.value = _this._playbackRate;
  7041. _this._soundSource.onended = function () { _this._onended(); };
  7042. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7043. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7044. }
  7045. };
  7046. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7047. // Wait a bit for FF as context seems late to be ready.
  7048. setTimeout(function () {
  7049. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7050. // Automatic playback failed.
  7051. // Waiting for the audio engine to be unlocked by user click on unmute
  7052. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7053. if (_this.loop || _this.autoplay) {
  7054. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7055. }
  7056. }
  7057. else {
  7058. tryToPlay();
  7059. }
  7060. }, 500);
  7061. }
  7062. else {
  7063. tryToPlay();
  7064. }
  7065. }
  7066. this._startTime = startTime;
  7067. this.isPlaying = true;
  7068. this.isPaused = false;
  7069. }
  7070. catch (ex) {
  7071. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7072. }
  7073. }
  7074. };
  7075. Sound.prototype._onended = function () {
  7076. this.isPlaying = false;
  7077. if (this.onended) {
  7078. this.onended();
  7079. }
  7080. this.onEndedObservable.notifyObservers(this);
  7081. };
  7082. /**
  7083. * Stop the sound
  7084. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7085. */
  7086. Sound.prototype.stop = function (time) {
  7087. 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: PointerDragBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, 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, PointerDragBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, 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__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  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. /**
  9802. * Gets the current object class name.
  9803. * @return the class name
  9804. */
  9805. Bone.prototype.getClassName = function () {
  9806. return "Bone";
  9807. };
  9808. // Members
  9809. /**
  9810. * Gets the parent skeleton
  9811. * @returns a skeleton
  9812. */
  9813. Bone.prototype.getSkeleton = function () {
  9814. return this._skeleton;
  9815. };
  9816. /**
  9817. * Gets parent bone
  9818. * @returns a bone or null if the bone is the root of the bone hierarchy
  9819. */
  9820. Bone.prototype.getParent = function () {
  9821. return this._parent;
  9822. };
  9823. /**
  9824. * Returns an array containing the root bones
  9825. * @returns an array containing the root bones
  9826. */
  9827. Bone.prototype.getChildren = function () {
  9828. return this.children;
  9829. };
  9830. /**
  9831. * Sets the parent bone
  9832. * @param parent defines the parent (can be null if the bone is the root)
  9833. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9834. */
  9835. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9836. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9837. if (this._parent === parent) {
  9838. return;
  9839. }
  9840. if (this._parent) {
  9841. var index = this._parent.children.indexOf(this);
  9842. if (index !== -1) {
  9843. this._parent.children.splice(index, 1);
  9844. }
  9845. }
  9846. this._parent = parent;
  9847. if (this._parent) {
  9848. this._parent.children.push(this);
  9849. }
  9850. if (updateDifferenceMatrix) {
  9851. this._updateDifferenceMatrix();
  9852. }
  9853. this.markAsDirty();
  9854. };
  9855. /**
  9856. * Gets the local matrix
  9857. * @returns a matrix
  9858. */
  9859. Bone.prototype.getLocalMatrix = function () {
  9860. this._compose();
  9861. return this._localMatrix;
  9862. };
  9863. /**
  9864. * Gets the base matrix (initial matrix which remains unchanged)
  9865. * @returns a matrix
  9866. */
  9867. Bone.prototype.getBaseMatrix = function () {
  9868. return this._baseMatrix;
  9869. };
  9870. /**
  9871. * Gets the rest pose matrix
  9872. * @returns a matrix
  9873. */
  9874. Bone.prototype.getRestPose = function () {
  9875. return this._restPose;
  9876. };
  9877. /**
  9878. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9879. */
  9880. Bone.prototype.getWorldMatrix = function () {
  9881. return this._worldTransform;
  9882. };
  9883. /**
  9884. * Sets the local matrix to rest pose matrix
  9885. */
  9886. Bone.prototype.returnToRest = function () {
  9887. this.updateMatrix(this._restPose.clone());
  9888. };
  9889. /**
  9890. * Gets the inverse of the absolute transform matrix.
  9891. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9892. * @returns a matrix
  9893. */
  9894. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9895. return this._invertedAbsoluteTransform;
  9896. };
  9897. /**
  9898. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9899. * @returns a matrix
  9900. */
  9901. Bone.prototype.getAbsoluteTransform = function () {
  9902. return this._absoluteTransform;
  9903. };
  9904. /**
  9905. * Links with the given transform node.
  9906. * The local matrix of this bone is copied from the transform node every frame.
  9907. * @param transformNode defines the transform node to link to
  9908. */
  9909. Bone.prototype.linkTransformNode = function (transformNode) {
  9910. if (this._linkedTransformNode) {
  9911. this._skeleton._numBonesWithLinkedTransformNode--;
  9912. }
  9913. this._linkedTransformNode = transformNode;
  9914. if (this._linkedTransformNode) {
  9915. this._skeleton._numBonesWithLinkedTransformNode++;
  9916. }
  9917. };
  9918. Object.defineProperty(Bone.prototype, "position", {
  9919. // Properties (matches AbstractMesh properties)
  9920. /** Gets or sets current position (in local space) */
  9921. get: function () {
  9922. this._decompose();
  9923. return this._localPosition;
  9924. },
  9925. set: function (newPosition) {
  9926. this._decompose();
  9927. this._localPosition.copyFrom(newPosition);
  9928. this._markAsDirtyAndCompose();
  9929. },
  9930. enumerable: true,
  9931. configurable: true
  9932. });
  9933. Object.defineProperty(Bone.prototype, "rotation", {
  9934. /** Gets or sets current rotation (in local space) */
  9935. get: function () {
  9936. return this.getRotation();
  9937. },
  9938. set: function (newRotation) {
  9939. this.setRotation(newRotation);
  9940. },
  9941. enumerable: true,
  9942. configurable: true
  9943. });
  9944. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9945. /** Gets or sets current rotation quaternion (in local space) */
  9946. get: function () {
  9947. this._decompose();
  9948. return this._localRotation;
  9949. },
  9950. set: function (newRotation) {
  9951. this.setRotationQuaternion(newRotation);
  9952. },
  9953. enumerable: true,
  9954. configurable: true
  9955. });
  9956. Object.defineProperty(Bone.prototype, "scaling", {
  9957. /** Gets or sets current scaling (in local space) */
  9958. get: function () {
  9959. return this.getScale();
  9960. },
  9961. set: function (newScaling) {
  9962. this.setScale(newScaling);
  9963. },
  9964. enumerable: true,
  9965. configurable: true
  9966. });
  9967. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9968. /**
  9969. * Gets the animation properties override
  9970. */
  9971. get: function () {
  9972. return this._skeleton.animationPropertiesOverride;
  9973. },
  9974. enumerable: true,
  9975. configurable: true
  9976. });
  9977. // Methods
  9978. Bone.prototype._decompose = function () {
  9979. if (!this._needToDecompose) {
  9980. return;
  9981. }
  9982. this._needToDecompose = false;
  9983. if (!this._localScaling) {
  9984. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9985. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9986. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9987. }
  9988. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9989. };
  9990. Bone.prototype._compose = function () {
  9991. if (!this._needToCompose) {
  9992. return;
  9993. }
  9994. this._needToCompose = false;
  9995. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9996. };
  9997. /**
  9998. * Update the base and local matrices
  9999. * @param matrix defines the new base or local matrix
  10000. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10001. * @param updateLocalMatrix defines if the local matrix should be updated
  10002. */
  10003. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10004. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10005. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10006. this._baseMatrix.copyFrom(matrix);
  10007. if (updateDifferenceMatrix) {
  10008. this._updateDifferenceMatrix();
  10009. }
  10010. if (updateLocalMatrix) {
  10011. this._localMatrix.copyFrom(matrix);
  10012. this._markAsDirtyAndDecompose();
  10013. }
  10014. else {
  10015. this.markAsDirty();
  10016. }
  10017. };
  10018. /** @hidden */
  10019. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10020. if (updateChildren === void 0) { updateChildren = true; }
  10021. if (!rootMatrix) {
  10022. rootMatrix = this._baseMatrix;
  10023. }
  10024. if (this._parent) {
  10025. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10026. }
  10027. else {
  10028. this._absoluteTransform.copyFrom(rootMatrix);
  10029. }
  10030. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10031. if (updateChildren) {
  10032. for (var index = 0; index < this.children.length; index++) {
  10033. this.children[index]._updateDifferenceMatrix();
  10034. }
  10035. }
  10036. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10037. };
  10038. /**
  10039. * Flag the bone as dirty (Forcing it to update everything)
  10040. */
  10041. Bone.prototype.markAsDirty = function () {
  10042. this._currentRenderId++;
  10043. this._childRenderId++;
  10044. this._skeleton._markAsDirty();
  10045. };
  10046. Bone.prototype._markAsDirtyAndCompose = function () {
  10047. this.markAsDirty();
  10048. this._needToCompose = true;
  10049. };
  10050. Bone.prototype._markAsDirtyAndDecompose = function () {
  10051. this.markAsDirty();
  10052. this._needToDecompose = true;
  10053. };
  10054. /**
  10055. * Translate the bone in local or world space
  10056. * @param vec The amount to translate the bone
  10057. * @param space The space that the translation is in
  10058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10059. */
  10060. Bone.prototype.translate = function (vec, space, mesh) {
  10061. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10062. var lm = this.getLocalMatrix();
  10063. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10064. lm.addAtIndex(12, vec.x);
  10065. lm.addAtIndex(13, vec.y);
  10066. lm.addAtIndex(14, vec.z);
  10067. }
  10068. else {
  10069. var wm = null;
  10070. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10071. if (mesh) {
  10072. wm = mesh.getWorldMatrix();
  10073. }
  10074. this._skeleton.computeAbsoluteTransforms();
  10075. var tmat = Bone._tmpMats[0];
  10076. var tvec = Bone._tmpVecs[0];
  10077. if (this._parent) {
  10078. if (mesh && wm) {
  10079. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10080. tmat.multiplyToRef(wm, tmat);
  10081. }
  10082. else {
  10083. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10084. }
  10085. }
  10086. tmat.setTranslationFromFloats(0, 0, 0);
  10087. tmat.invert();
  10088. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10089. lm.addAtIndex(12, tvec.x);
  10090. lm.addAtIndex(13, tvec.y);
  10091. lm.addAtIndex(14, tvec.z);
  10092. }
  10093. this._markAsDirtyAndDecompose();
  10094. };
  10095. /**
  10096. * Set the postion of the bone in local or world space
  10097. * @param position The position to set the bone
  10098. * @param space The space that the position is in
  10099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10100. */
  10101. Bone.prototype.setPosition = function (position, space, mesh) {
  10102. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10103. var lm = this.getLocalMatrix();
  10104. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10105. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10106. }
  10107. else {
  10108. var wm = null;
  10109. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10110. if (mesh) {
  10111. wm = mesh.getWorldMatrix();
  10112. }
  10113. this._skeleton.computeAbsoluteTransforms();
  10114. var tmat = Bone._tmpMats[0];
  10115. var vec = Bone._tmpVecs[0];
  10116. if (this._parent) {
  10117. if (mesh && wm) {
  10118. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10119. tmat.multiplyToRef(wm, tmat);
  10120. }
  10121. else {
  10122. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10123. }
  10124. }
  10125. tmat.invert();
  10126. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10127. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10128. }
  10129. this._markAsDirtyAndDecompose();
  10130. };
  10131. /**
  10132. * Set the absolute position of the bone (world space)
  10133. * @param position The position to set the bone
  10134. * @param mesh The mesh that this bone is attached to
  10135. */
  10136. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10137. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10138. };
  10139. /**
  10140. * Scale the bone on the x, y and z axes (in local space)
  10141. * @param x The amount to scale the bone on the x axis
  10142. * @param y The amount to scale the bone on the y axis
  10143. * @param z The amount to scale the bone on the z axis
  10144. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10145. */
  10146. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10147. if (scaleChildren === void 0) { scaleChildren = false; }
  10148. var locMat = this.getLocalMatrix();
  10149. // Apply new scaling on top of current local matrix
  10150. var scaleMat = Bone._tmpMats[0];
  10151. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10152. scaleMat.multiplyToRef(locMat, locMat);
  10153. // Invert scaling matrix and apply the inverse to all children
  10154. scaleMat.invert();
  10155. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10156. var child = _a[_i];
  10157. var cm = child.getLocalMatrix();
  10158. cm.multiplyToRef(scaleMat, cm);
  10159. cm.multiplyAtIndex(12, x);
  10160. cm.multiplyAtIndex(13, y);
  10161. cm.multiplyAtIndex(14, z);
  10162. child._markAsDirtyAndDecompose();
  10163. }
  10164. this._markAsDirtyAndDecompose();
  10165. if (scaleChildren) {
  10166. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10167. var child = _c[_b];
  10168. child.scale(x, y, z, scaleChildren);
  10169. }
  10170. }
  10171. };
  10172. /**
  10173. * Set the bone scaling in local space
  10174. * @param scale defines the scaling vector
  10175. */
  10176. Bone.prototype.setScale = function (scale) {
  10177. this._decompose();
  10178. this._localScaling.copyFrom(scale);
  10179. this._markAsDirtyAndCompose();
  10180. };
  10181. /**
  10182. * Gets the current scaling in local space
  10183. * @returns the current scaling vector
  10184. */
  10185. Bone.prototype.getScale = function () {
  10186. this._decompose();
  10187. return this._localScaling;
  10188. };
  10189. /**
  10190. * Gets the current scaling in local space and stores it in a target vector
  10191. * @param result defines the target vector
  10192. */
  10193. Bone.prototype.getScaleToRef = function (result) {
  10194. this._decompose();
  10195. result.copyFrom(this._localScaling);
  10196. };
  10197. /**
  10198. * Set the yaw, pitch, and roll of the bone in local or world space
  10199. * @param yaw The rotation of the bone on the y axis
  10200. * @param pitch The rotation of the bone on the x axis
  10201. * @param roll The rotation of the bone on the z axis
  10202. * @param space The space that the axes of rotation are in
  10203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10204. */
  10205. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10206. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10207. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10208. var quat = Bone._tmpQuat;
  10209. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10210. this.setRotationQuaternion(quat, space, mesh);
  10211. return;
  10212. }
  10213. var rotMatInv = Bone._tmpMats[0];
  10214. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10215. return;
  10216. }
  10217. var rotMat = Bone._tmpMats[1];
  10218. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10219. rotMatInv.multiplyToRef(rotMat, rotMat);
  10220. this._rotateWithMatrix(rotMat, space, mesh);
  10221. };
  10222. /**
  10223. * Add a rotation to the bone on an axis in local or world space
  10224. * @param axis The axis to rotate the bone on
  10225. * @param amount The amount to rotate the bone
  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.rotate = function (axis, amount, space, mesh) {
  10230. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10231. var rmat = Bone._tmpMats[0];
  10232. rmat.setTranslationFromFloats(0, 0, 0);
  10233. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10234. this._rotateWithMatrix(rmat, space, mesh);
  10235. };
  10236. /**
  10237. * Set the rotation of the bone to a particular axis angle in local or world space
  10238. * @param axis The axis to rotate the bone on
  10239. * @param angle The angle that the bone should be rotated to
  10240. * @param space The space that the axis is in
  10241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10242. */
  10243. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10244. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10245. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10246. var quat = Bone._tmpQuat;
  10247. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10248. this.setRotationQuaternion(quat, space, mesh);
  10249. return;
  10250. }
  10251. var rotMatInv = Bone._tmpMats[0];
  10252. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10253. return;
  10254. }
  10255. var rotMat = Bone._tmpMats[1];
  10256. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10257. rotMatInv.multiplyToRef(rotMat, rotMat);
  10258. this._rotateWithMatrix(rotMat, space, mesh);
  10259. };
  10260. /**
  10261. * Set the euler rotation of the bone in local of world space
  10262. * @param rotation The euler rotation that the bone should be set to
  10263. * @param space The space that the rotation is in
  10264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10265. */
  10266. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10267. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10268. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10269. };
  10270. /**
  10271. * Set the quaternion rotation of the bone in local of world space
  10272. * @param quat The quaternion rotation that the bone should be set to
  10273. * @param space The space that the rotation is in
  10274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10275. */
  10276. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10277. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10278. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10279. this._decompose();
  10280. this._localRotation.copyFrom(quat);
  10281. this._markAsDirtyAndCompose();
  10282. return;
  10283. }
  10284. var rotMatInv = Bone._tmpMats[0];
  10285. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10286. return;
  10287. }
  10288. var rotMat = Bone._tmpMats[1];
  10289. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10290. rotMatInv.multiplyToRef(rotMat, rotMat);
  10291. this._rotateWithMatrix(rotMat, space, mesh);
  10292. };
  10293. /**
  10294. * Set the rotation matrix of the bone in local of world space
  10295. * @param rotMat The rotation matrix that the bone should be set to
  10296. * @param space The space that the rotation is in
  10297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10298. */
  10299. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10300. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10301. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10302. var quat = Bone._tmpQuat;
  10303. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10304. this.setRotationQuaternion(quat, space, mesh);
  10305. return;
  10306. }
  10307. var rotMatInv = Bone._tmpMats[0];
  10308. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10309. return;
  10310. }
  10311. var rotMat2 = Bone._tmpMats[1];
  10312. rotMat2.copyFrom(rotMat);
  10313. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10314. this._rotateWithMatrix(rotMat2, space, mesh);
  10315. };
  10316. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10317. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10318. var lmat = this.getLocalMatrix();
  10319. var lx = lmat.m[12];
  10320. var ly = lmat.m[13];
  10321. var lz = lmat.m[14];
  10322. var parent = this.getParent();
  10323. var parentScale = Bone._tmpMats[3];
  10324. var parentScaleInv = Bone._tmpMats[4];
  10325. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10326. if (mesh) {
  10327. parentScale.copyFrom(mesh.getWorldMatrix());
  10328. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10329. }
  10330. else {
  10331. parentScale.copyFrom(parent.getAbsoluteTransform());
  10332. }
  10333. parentScaleInv.copyFrom(parentScale);
  10334. parentScaleInv.invert();
  10335. lmat.multiplyToRef(parentScale, lmat);
  10336. lmat.multiplyToRef(rmat, lmat);
  10337. lmat.multiplyToRef(parentScaleInv, lmat);
  10338. }
  10339. else {
  10340. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10341. parentScale.copyFrom(mesh.getWorldMatrix());
  10342. parentScaleInv.copyFrom(parentScale);
  10343. parentScaleInv.invert();
  10344. lmat.multiplyToRef(parentScale, lmat);
  10345. lmat.multiplyToRef(rmat, lmat);
  10346. lmat.multiplyToRef(parentScaleInv, lmat);
  10347. }
  10348. else {
  10349. lmat.multiplyToRef(rmat, lmat);
  10350. }
  10351. }
  10352. lmat.setTranslationFromFloats(lx, ly, lz);
  10353. this.computeAbsoluteTransforms();
  10354. this._markAsDirtyAndDecompose();
  10355. };
  10356. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10357. var scaleMatrix = Bone._tmpMats[2];
  10358. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10359. if (mesh) {
  10360. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10362. }
  10363. rotMatInv.invert();
  10364. if (isNaN(rotMatInv.m[0])) {
  10365. // Matrix failed to invert.
  10366. // This can happen if scale is zero for example.
  10367. return false;
  10368. }
  10369. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10370. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10371. return true;
  10372. };
  10373. /**
  10374. * Get the position of the bone in local or world space
  10375. * @param space The space that the returned position is in
  10376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10377. * @returns The position of the bone
  10378. */
  10379. Bone.prototype.getPosition = function (space, mesh) {
  10380. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10381. if (mesh === void 0) { mesh = null; }
  10382. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10383. this.getPositionToRef(space, mesh, pos);
  10384. return pos;
  10385. };
  10386. /**
  10387. * Copy the position of the bone to a vector3 in local or world space
  10388. * @param space The space that the returned position is in
  10389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10390. * @param result The vector3 to copy the position to
  10391. */
  10392. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10393. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10394. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10395. var lm = this.getLocalMatrix();
  10396. result.x = lm.m[12];
  10397. result.y = lm.m[13];
  10398. result.z = lm.m[14];
  10399. }
  10400. else {
  10401. var wm = null;
  10402. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10403. if (mesh) {
  10404. wm = mesh.getWorldMatrix();
  10405. }
  10406. this._skeleton.computeAbsoluteTransforms();
  10407. var tmat = Bone._tmpMats[0];
  10408. if (mesh && wm) {
  10409. tmat.copyFrom(this.getAbsoluteTransform());
  10410. tmat.multiplyToRef(wm, tmat);
  10411. }
  10412. else {
  10413. tmat = this.getAbsoluteTransform();
  10414. }
  10415. result.x = tmat.m[12];
  10416. result.y = tmat.m[13];
  10417. result.z = tmat.m[14];
  10418. }
  10419. };
  10420. /**
  10421. * Get the absolute position of the bone (world space)
  10422. * @param mesh The mesh that this bone is attached to
  10423. * @returns The absolute position of the bone
  10424. */
  10425. Bone.prototype.getAbsolutePosition = function (mesh) {
  10426. if (mesh === void 0) { mesh = null; }
  10427. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10428. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10429. return pos;
  10430. };
  10431. /**
  10432. * Copy the absolute position of the bone (world space) to the result param
  10433. * @param mesh The mesh that this bone is attached to
  10434. * @param result The vector3 to copy the absolute position to
  10435. */
  10436. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10437. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10438. };
  10439. /**
  10440. * Compute the absolute transforms of this bone and its children
  10441. */
  10442. Bone.prototype.computeAbsoluteTransforms = function () {
  10443. this._compose();
  10444. if (this._parent) {
  10445. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10446. }
  10447. else {
  10448. this._absoluteTransform.copyFrom(this._localMatrix);
  10449. var poseMatrix = this._skeleton.getPoseMatrix();
  10450. if (poseMatrix) {
  10451. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10452. }
  10453. }
  10454. var children = this.children;
  10455. var len = children.length;
  10456. for (var i = 0; i < len; i++) {
  10457. children[i].computeAbsoluteTransforms();
  10458. }
  10459. };
  10460. /**
  10461. * Get the world direction from an axis that is in the local space of the bone
  10462. * @param localAxis The local direction that is used to compute the world direction
  10463. * @param mesh The mesh that this bone is attached to
  10464. * @returns The world direction
  10465. */
  10466. Bone.prototype.getDirection = function (localAxis, mesh) {
  10467. if (mesh === void 0) { mesh = null; }
  10468. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10469. this.getDirectionToRef(localAxis, mesh, result);
  10470. return result;
  10471. };
  10472. /**
  10473. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10474. * @param localAxis The local direction that is used to compute the world direction
  10475. * @param mesh The mesh that this bone is attached to
  10476. * @param result The vector3 that the world direction will be copied to
  10477. */
  10478. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10479. if (mesh === void 0) { mesh = null; }
  10480. var wm = null;
  10481. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10482. if (mesh) {
  10483. wm = mesh.getWorldMatrix();
  10484. }
  10485. this._skeleton.computeAbsoluteTransforms();
  10486. var mat = Bone._tmpMats[0];
  10487. mat.copyFrom(this.getAbsoluteTransform());
  10488. if (mesh && wm) {
  10489. mat.multiplyToRef(wm, mat);
  10490. }
  10491. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10492. result.normalize();
  10493. };
  10494. /**
  10495. * Get the euler rotation of the bone in local or world space
  10496. * @param space The space that the rotation should be in
  10497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10498. * @returns The euler rotation
  10499. */
  10500. Bone.prototype.getRotation = function (space, mesh) {
  10501. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10502. if (mesh === void 0) { mesh = null; }
  10503. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10504. this.getRotationToRef(space, mesh, result);
  10505. return result;
  10506. };
  10507. /**
  10508. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10509. * @param space The space that the rotation should be in
  10510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10511. * @param result The vector3 that the rotation should be copied to
  10512. */
  10513. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10514. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10515. if (mesh === void 0) { mesh = null; }
  10516. var quat = Bone._tmpQuat;
  10517. this.getRotationQuaternionToRef(space, mesh, quat);
  10518. quat.toEulerAnglesToRef(result);
  10519. };
  10520. /**
  10521. * Get the quaternion rotation of the bone in either local or world space
  10522. * @param space The space that the rotation should be in
  10523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10524. * @returns The quaternion rotation
  10525. */
  10526. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10527. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10528. if (mesh === void 0) { mesh = null; }
  10529. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10530. this.getRotationQuaternionToRef(space, mesh, result);
  10531. return result;
  10532. };
  10533. /**
  10534. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10535. * @param space The space that the rotation should be in
  10536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10537. * @param result The quaternion that the rotation should be copied to
  10538. */
  10539. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10540. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10541. if (mesh === void 0) { mesh = null; }
  10542. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10543. this._decompose();
  10544. result.copyFrom(this._localRotation);
  10545. }
  10546. else {
  10547. var mat = Bone._tmpMats[0];
  10548. var amat = this.getAbsoluteTransform();
  10549. if (mesh) {
  10550. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10551. }
  10552. else {
  10553. mat.copyFrom(amat);
  10554. }
  10555. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10556. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10557. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10558. mat.decompose(undefined, result, undefined);
  10559. }
  10560. };
  10561. /**
  10562. * Get the rotation matrix of the bone in local or world space
  10563. * @param space The space that the rotation should be in
  10564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10565. * @returns The rotation matrix
  10566. */
  10567. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10568. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10569. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10570. this.getRotationMatrixToRef(space, mesh, result);
  10571. return result;
  10572. };
  10573. /**
  10574. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10575. * @param space The space that the rotation should be in
  10576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10577. * @param result The quaternion that the rotation should be copied to
  10578. */
  10579. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10580. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10581. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10582. this.getLocalMatrix().getRotationMatrixToRef(result);
  10583. }
  10584. else {
  10585. var mat = Bone._tmpMats[0];
  10586. var amat = this.getAbsoluteTransform();
  10587. if (mesh) {
  10588. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10589. }
  10590. else {
  10591. mat.copyFrom(amat);
  10592. }
  10593. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10594. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10595. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10596. mat.getRotationMatrixToRef(result);
  10597. }
  10598. };
  10599. /**
  10600. * Get the world position of a point that is in the local space of the bone
  10601. * @param position The local position
  10602. * @param mesh The mesh that this bone is attached to
  10603. * @returns The world position
  10604. */
  10605. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10606. if (mesh === void 0) { mesh = null; }
  10607. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10608. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10609. return result;
  10610. };
  10611. /**
  10612. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10613. * @param position The local position
  10614. * @param mesh The mesh that this bone is attached to
  10615. * @param result The vector3 that the world position should be copied to
  10616. */
  10617. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10618. if (mesh === void 0) { mesh = null; }
  10619. var wm = null;
  10620. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10621. if (mesh) {
  10622. wm = mesh.getWorldMatrix();
  10623. }
  10624. this._skeleton.computeAbsoluteTransforms();
  10625. var tmat = Bone._tmpMats[0];
  10626. if (mesh && wm) {
  10627. tmat.copyFrom(this.getAbsoluteTransform());
  10628. tmat.multiplyToRef(wm, tmat);
  10629. }
  10630. else {
  10631. tmat = this.getAbsoluteTransform();
  10632. }
  10633. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10634. };
  10635. /**
  10636. * Get the local position of a point that is in world space
  10637. * @param position The world position
  10638. * @param mesh The mesh that this bone is attached to
  10639. * @returns The local position
  10640. */
  10641. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10642. if (mesh === void 0) { mesh = null; }
  10643. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10644. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10645. return result;
  10646. };
  10647. /**
  10648. * Get the local position of a point that is in world space and copy it to the result param
  10649. * @param position The world position
  10650. * @param mesh The mesh that this bone is attached to
  10651. * @param result The vector3 that the local position should be copied to
  10652. */
  10653. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10654. if (mesh === void 0) { mesh = null; }
  10655. var wm = null;
  10656. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10657. if (mesh) {
  10658. wm = mesh.getWorldMatrix();
  10659. }
  10660. this._skeleton.computeAbsoluteTransforms();
  10661. var tmat = Bone._tmpMats[0];
  10662. tmat.copyFrom(this.getAbsoluteTransform());
  10663. if (mesh && wm) {
  10664. tmat.multiplyToRef(wm, tmat);
  10665. }
  10666. tmat.invert();
  10667. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10668. };
  10669. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10670. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10671. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10672. return Bone;
  10673. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10674. /***/ }),
  10675. /***/ "./Bones/boneIKController.ts":
  10676. /*!***********************************!*\
  10677. !*** ./Bones/boneIKController.ts ***!
  10678. \***********************************/
  10679. /*! exports provided: BoneIKController */
  10680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10681. "use strict";
  10682. __webpack_require__.r(__webpack_exports__);
  10683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10685. /**
  10686. * Class used to apply inverse kinematics to bones
  10687. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10688. */
  10689. var BoneIKController = /** @class */ (function () {
  10690. /**
  10691. * Creates a new BoneIKController
  10692. * @param mesh defines the mesh to control
  10693. * @param bone defines the bone to control
  10694. * @param options defines options to set up the controller
  10695. */
  10696. function BoneIKController(mesh, bone, options) {
  10697. /**
  10698. * Gets or sets the target position
  10699. */
  10700. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10701. /**
  10702. * Gets or sets the pole target position
  10703. */
  10704. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10705. /**
  10706. * Gets or sets the pole target local offset
  10707. */
  10708. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10709. /**
  10710. * Gets or sets the pole angle
  10711. */
  10712. this.poleAngle = 0;
  10713. /**
  10714. * 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)
  10715. */
  10716. this.slerpAmount = 1;
  10717. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10718. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10719. this._bone2Ang = Math.PI;
  10720. this._maxAngle = Math.PI;
  10721. this._rightHandedSystem = false;
  10722. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10723. this._slerping = false;
  10724. this._adjustRoll = 0;
  10725. this._bone2 = bone;
  10726. this._bone1 = bone.getParent();
  10727. if (!this._bone1) {
  10728. return;
  10729. }
  10730. this.mesh = mesh;
  10731. var bonePos = bone.getPosition();
  10732. if (bone.getAbsoluteTransform().determinant() > 0) {
  10733. this._rightHandedSystem = true;
  10734. this._bendAxis.x = 0;
  10735. this._bendAxis.y = 0;
  10736. this._bendAxis.z = -1;
  10737. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10738. this._adjustRoll = Math.PI * .5;
  10739. this._bendAxis.z = 1;
  10740. }
  10741. }
  10742. if (this._bone1.length) {
  10743. var boneScale1 = this._bone1.getScale();
  10744. var boneScale2 = this._bone2.getScale();
  10745. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10746. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10747. }
  10748. else if (this._bone1.children[0]) {
  10749. mesh.computeWorldMatrix(true);
  10750. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10751. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10752. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10753. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10754. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10755. }
  10756. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10757. this.maxAngle = Math.PI;
  10758. if (options) {
  10759. if (options.targetMesh) {
  10760. this.targetMesh = options.targetMesh;
  10761. this.targetMesh.computeWorldMatrix(true);
  10762. }
  10763. if (options.poleTargetMesh) {
  10764. this.poleTargetMesh = options.poleTargetMesh;
  10765. this.poleTargetMesh.computeWorldMatrix(true);
  10766. }
  10767. else if (options.poleTargetBone) {
  10768. this.poleTargetBone = options.poleTargetBone;
  10769. }
  10770. else if (this._bone1.getParent()) {
  10771. this.poleTargetBone = this._bone1.getParent();
  10772. }
  10773. if (options.poleTargetLocalOffset) {
  10774. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10775. }
  10776. if (options.poleAngle) {
  10777. this.poleAngle = options.poleAngle;
  10778. }
  10779. if (options.bendAxis) {
  10780. this._bendAxis.copyFrom(options.bendAxis);
  10781. }
  10782. if (options.maxAngle) {
  10783. this.maxAngle = options.maxAngle;
  10784. }
  10785. if (options.slerpAmount) {
  10786. this.slerpAmount = options.slerpAmount;
  10787. }
  10788. }
  10789. }
  10790. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10791. /**
  10792. * Gets or sets maximum allowed angle
  10793. */
  10794. get: function () {
  10795. return this._maxAngle;
  10796. },
  10797. set: function (value) {
  10798. this._setMaxAngle(value);
  10799. },
  10800. enumerable: true,
  10801. configurable: true
  10802. });
  10803. BoneIKController.prototype._setMaxAngle = function (ang) {
  10804. if (ang < 0) {
  10805. ang = 0;
  10806. }
  10807. if (ang > Math.PI || ang == undefined) {
  10808. ang = Math.PI;
  10809. }
  10810. this._maxAngle = ang;
  10811. var a = this._bone1Length;
  10812. var b = this._bone2Length;
  10813. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10814. };
  10815. /**
  10816. * Force the controller to update the bones
  10817. */
  10818. BoneIKController.prototype.update = function () {
  10819. var bone1 = this._bone1;
  10820. if (!bone1) {
  10821. return;
  10822. }
  10823. var target = this.targetPosition;
  10824. var poleTarget = this.poleTargetPosition;
  10825. var mat1 = BoneIKController._tmpMats[0];
  10826. var mat2 = BoneIKController._tmpMats[1];
  10827. if (this.targetMesh) {
  10828. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10829. }
  10830. if (this.poleTargetBone) {
  10831. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10832. }
  10833. else if (this.poleTargetMesh) {
  10834. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10835. }
  10836. var bonePos = BoneIKController._tmpVecs[0];
  10837. var zaxis = BoneIKController._tmpVecs[1];
  10838. var xaxis = BoneIKController._tmpVecs[2];
  10839. var yaxis = BoneIKController._tmpVecs[3];
  10840. var upAxis = BoneIKController._tmpVecs[4];
  10841. var _tmpQuat = BoneIKController._tmpQuat;
  10842. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10843. poleTarget.subtractToRef(bonePos, upAxis);
  10844. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10845. upAxis.y = 1;
  10846. }
  10847. else {
  10848. upAxis.normalize();
  10849. }
  10850. target.subtractToRef(bonePos, yaxis);
  10851. yaxis.normalize();
  10852. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10853. zaxis.normalize();
  10854. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10855. xaxis.normalize();
  10856. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10857. var a = this._bone1Length;
  10858. var b = this._bone2Length;
  10859. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10860. if (this._maxReach > 0) {
  10861. c = Math.min(this._maxReach, c);
  10862. }
  10863. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10864. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10865. if (acosa > 1) {
  10866. acosa = 1;
  10867. }
  10868. if (acosb > 1) {
  10869. acosb = 1;
  10870. }
  10871. if (acosa < -1) {
  10872. acosa = -1;
  10873. }
  10874. if (acosb < -1) {
  10875. acosb = -1;
  10876. }
  10877. var angA = Math.acos(acosa);
  10878. var angB = Math.acos(acosb);
  10879. var angC = -angA - angB;
  10880. if (this._rightHandedSystem) {
  10881. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10882. mat2.multiplyToRef(mat1, mat1);
  10883. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10884. mat2.multiplyToRef(mat1, mat1);
  10885. }
  10886. else {
  10887. var _tmpVec = BoneIKController._tmpVecs[5];
  10888. _tmpVec.copyFrom(this._bendAxis);
  10889. _tmpVec.x *= -1;
  10890. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10891. mat2.multiplyToRef(mat1, mat1);
  10892. }
  10893. if (this.poleAngle) {
  10894. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10895. mat1.multiplyToRef(mat2, mat1);
  10896. }
  10897. if (this._bone1) {
  10898. if (this.slerpAmount < 1) {
  10899. if (!this._slerping) {
  10900. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10901. }
  10902. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10903. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10904. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10905. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10906. this._slerping = true;
  10907. }
  10908. else {
  10909. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10910. this._bone1Mat.copyFrom(mat1);
  10911. this._slerping = false;
  10912. }
  10913. }
  10914. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10915. this._bone2Ang = angC;
  10916. };
  10917. 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()];
  10918. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10919. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10920. return BoneIKController;
  10921. }());
  10922. /***/ }),
  10923. /***/ "./Bones/boneLookController.ts":
  10924. /*!*************************************!*\
  10925. !*** ./Bones/boneLookController.ts ***!
  10926. \*************************************/
  10927. /*! exports provided: BoneLookController */
  10928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10929. "use strict";
  10930. __webpack_require__.r(__webpack_exports__);
  10931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10932. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10933. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10934. /**
  10935. * Class used to make a bone look toward a point in space
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10937. */
  10938. var BoneLookController = /** @class */ (function () {
  10939. /**
  10940. * Create a BoneLookController
  10941. * @param mesh the mesh that the bone belongs to
  10942. * @param bone the bone that will be looking to the target
  10943. * @param target the target Vector3 to look at
  10944. * @param options optional settings:
  10945. * * maxYaw: the maximum angle the bone will yaw to
  10946. * * minYaw: the minimum angle the bone will yaw to
  10947. * * maxPitch: the maximum angle the bone will pitch to
  10948. * * minPitch: the minimum angle the bone will yaw to
  10949. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10950. * * upAxis: the up axis of the coordinate system
  10951. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10952. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10953. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10954. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10955. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10956. * * adjustRoll: used to make an adjustment to the roll of the bone
  10957. **/
  10958. function BoneLookController(mesh, bone, target, options) {
  10959. /**
  10960. * The up axis of the coordinate system that is used when the bone is rotated
  10961. */
  10962. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10963. /**
  10964. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10965. */
  10966. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10967. /**
  10968. * Used to make an adjustment to the yaw of the bone
  10969. */
  10970. this.adjustYaw = 0;
  10971. /**
  10972. * Used to make an adjustment to the pitch of the bone
  10973. */
  10974. this.adjustPitch = 0;
  10975. /**
  10976. * Used to make an adjustment to the roll of the bone
  10977. */
  10978. this.adjustRoll = 0;
  10979. /**
  10980. * 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)
  10981. */
  10982. this.slerpAmount = 1;
  10983. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10984. this._slerping = false;
  10985. this._firstFrameSkipped = false;
  10986. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10987. this.mesh = mesh;
  10988. this.bone = bone;
  10989. this.target = target;
  10990. if (options) {
  10991. if (options.adjustYaw) {
  10992. this.adjustYaw = options.adjustYaw;
  10993. }
  10994. if (options.adjustPitch) {
  10995. this.adjustPitch = options.adjustPitch;
  10996. }
  10997. if (options.adjustRoll) {
  10998. this.adjustRoll = options.adjustRoll;
  10999. }
  11000. if (options.maxYaw != null) {
  11001. this.maxYaw = options.maxYaw;
  11002. }
  11003. else {
  11004. this.maxYaw = Math.PI;
  11005. }
  11006. if (options.minYaw != null) {
  11007. this.minYaw = options.minYaw;
  11008. }
  11009. else {
  11010. this.minYaw = -Math.PI;
  11011. }
  11012. if (options.maxPitch != null) {
  11013. this.maxPitch = options.maxPitch;
  11014. }
  11015. else {
  11016. this.maxPitch = Math.PI;
  11017. }
  11018. if (options.minPitch != null) {
  11019. this.minPitch = options.minPitch;
  11020. }
  11021. else {
  11022. this.minPitch = -Math.PI;
  11023. }
  11024. if (options.slerpAmount != null) {
  11025. this.slerpAmount = options.slerpAmount;
  11026. }
  11027. if (options.upAxis != null) {
  11028. this.upAxis = options.upAxis;
  11029. }
  11030. if (options.upAxisSpace != null) {
  11031. this.upAxisSpace = options.upAxisSpace;
  11032. }
  11033. if (options.yawAxis != null || options.pitchAxis != null) {
  11034. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11035. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11036. if (options.yawAxis != null) {
  11037. newYawAxis = options.yawAxis.clone();
  11038. newYawAxis.normalize();
  11039. }
  11040. if (options.pitchAxis != null) {
  11041. newPitchAxis = options.pitchAxis.clone();
  11042. newPitchAxis.normalize();
  11043. }
  11044. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11045. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11046. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11047. this._transformYawPitchInv = this._transformYawPitch.clone();
  11048. this._transformYawPitch.invert();
  11049. }
  11050. }
  11051. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11052. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11053. }
  11054. }
  11055. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11056. /**
  11057. * Gets or sets the minimum yaw angle that the bone can look to
  11058. */
  11059. get: function () {
  11060. return this._minYaw;
  11061. },
  11062. set: function (value) {
  11063. this._minYaw = value;
  11064. this._minYawSin = Math.sin(value);
  11065. this._minYawCos = Math.cos(value);
  11066. if (this._maxYaw != null) {
  11067. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11068. this._yawRange = this._maxYaw - this._minYaw;
  11069. }
  11070. },
  11071. enumerable: true,
  11072. configurable: true
  11073. });
  11074. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11075. /**
  11076. * Gets or sets the maximum yaw angle that the bone can look to
  11077. */
  11078. get: function () {
  11079. return this._maxYaw;
  11080. },
  11081. set: function (value) {
  11082. this._maxYaw = value;
  11083. this._maxYawSin = Math.sin(value);
  11084. this._maxYawCos = Math.cos(value);
  11085. if (this._minYaw != null) {
  11086. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11087. this._yawRange = this._maxYaw - this._minYaw;
  11088. }
  11089. },
  11090. enumerable: true,
  11091. configurable: true
  11092. });
  11093. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11094. /**
  11095. * Gets or sets the minimum pitch angle that the bone can look to
  11096. */
  11097. get: function () {
  11098. return this._minPitch;
  11099. },
  11100. set: function (value) {
  11101. this._minPitch = value;
  11102. this._minPitchTan = Math.tan(value);
  11103. },
  11104. enumerable: true,
  11105. configurable: true
  11106. });
  11107. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11108. /**
  11109. * Gets or sets the maximum pitch angle that the bone can look to
  11110. */
  11111. get: function () {
  11112. return this._maxPitch;
  11113. },
  11114. set: function (value) {
  11115. this._maxPitch = value;
  11116. this._maxPitchTan = Math.tan(value);
  11117. },
  11118. enumerable: true,
  11119. configurable: true
  11120. });
  11121. /**
  11122. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11123. */
  11124. BoneLookController.prototype.update = function () {
  11125. //skip the first frame when slerping so that the mesh rotation is correct
  11126. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11127. this._firstFrameSkipped = true;
  11128. return;
  11129. }
  11130. var bone = this.bone;
  11131. var bonePos = BoneLookController._tmpVecs[0];
  11132. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11133. var target = this.target;
  11134. var _tmpMat1 = BoneLookController._tmpMats[0];
  11135. var _tmpMat2 = BoneLookController._tmpMats[1];
  11136. var mesh = this.mesh;
  11137. var parentBone = bone.getParent();
  11138. var upAxis = BoneLookController._tmpVecs[1];
  11139. upAxis.copyFrom(this.upAxis);
  11140. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11141. if (this._transformYawPitch) {
  11142. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11143. }
  11144. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11145. }
  11146. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11147. mesh.getDirectionToRef(upAxis, upAxis);
  11148. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11149. upAxis.normalize();
  11150. }
  11151. }
  11152. var checkYaw = false;
  11153. var checkPitch = false;
  11154. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11155. checkYaw = true;
  11156. }
  11157. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11158. checkPitch = true;
  11159. }
  11160. if (checkYaw || checkPitch) {
  11161. var spaceMat = BoneLookController._tmpMats[2];
  11162. var spaceMatInv = BoneLookController._tmpMats[3];
  11163. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11164. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11165. }
  11166. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11167. spaceMat.copyFrom(mesh.getWorldMatrix());
  11168. }
  11169. else {
  11170. var forwardAxis = BoneLookController._tmpVecs[2];
  11171. forwardAxis.copyFrom(this._fowardAxis);
  11172. if (this._transformYawPitch) {
  11173. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11174. }
  11175. if (parentBone) {
  11176. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11177. }
  11178. else {
  11179. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11180. }
  11181. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11182. rightAxis.normalize();
  11183. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11184. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11185. }
  11186. spaceMat.invertToRef(spaceMatInv);
  11187. var xzlen = null;
  11188. if (checkPitch) {
  11189. var localTarget = BoneLookController._tmpVecs[3];
  11190. target.subtractToRef(bonePos, localTarget);
  11191. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11192. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11193. var pitch = Math.atan2(localTarget.y, xzlen);
  11194. var newPitch = pitch;
  11195. if (pitch > this._maxPitch) {
  11196. localTarget.y = this._maxPitchTan * xzlen;
  11197. newPitch = this._maxPitch;
  11198. }
  11199. else if (pitch < this._minPitch) {
  11200. localTarget.y = this._minPitchTan * xzlen;
  11201. newPitch = this._minPitch;
  11202. }
  11203. if (pitch != newPitch) {
  11204. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11205. localTarget.addInPlace(bonePos);
  11206. target = localTarget;
  11207. }
  11208. }
  11209. if (checkYaw) {
  11210. var localTarget = BoneLookController._tmpVecs[4];
  11211. target.subtractToRef(bonePos, localTarget);
  11212. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11213. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11214. var newYaw = yaw;
  11215. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11216. if (xzlen == null) {
  11217. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11218. }
  11219. if (this._yawRange > Math.PI) {
  11220. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11221. localTarget.z = this._maxYawCos * xzlen;
  11222. localTarget.x = this._maxYawSin * xzlen;
  11223. newYaw = this._maxYaw;
  11224. }
  11225. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11226. localTarget.z = this._minYawCos * xzlen;
  11227. localTarget.x = this._minYawSin * xzlen;
  11228. newYaw = this._minYaw;
  11229. }
  11230. }
  11231. else {
  11232. if (yaw > this._maxYaw) {
  11233. localTarget.z = this._maxYawCos * xzlen;
  11234. localTarget.x = this._maxYawSin * xzlen;
  11235. newYaw = this._maxYaw;
  11236. }
  11237. else if (yaw < this._minYaw) {
  11238. localTarget.z = this._minYawCos * xzlen;
  11239. localTarget.x = this._minYawSin * xzlen;
  11240. newYaw = this._minYaw;
  11241. }
  11242. }
  11243. }
  11244. if (this._slerping && this._yawRange > Math.PI) {
  11245. //are we going to be crossing into the min/max region?
  11246. var boneFwd = BoneLookController._tmpVecs[8];
  11247. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11248. if (this._transformYawPitch) {
  11249. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11250. }
  11251. var boneRotMat = BoneLookController._tmpMats[4];
  11252. this._boneQuat.toRotationMatrix(boneRotMat);
  11253. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11254. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11255. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11256. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11257. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11258. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11259. if (angBtwTar > angBtwMidYaw) {
  11260. if (xzlen == null) {
  11261. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11262. }
  11263. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11264. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11265. if (angBtwMin < angBtwMax) {
  11266. newYaw = boneYaw + Math.PI * .75;
  11267. localTarget.z = Math.cos(newYaw) * xzlen;
  11268. localTarget.x = Math.sin(newYaw) * xzlen;
  11269. }
  11270. else {
  11271. newYaw = boneYaw - Math.PI * .75;
  11272. localTarget.z = Math.cos(newYaw) * xzlen;
  11273. localTarget.x = Math.sin(newYaw) * xzlen;
  11274. }
  11275. }
  11276. }
  11277. if (yaw != newYaw) {
  11278. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11279. localTarget.addInPlace(bonePos);
  11280. target = localTarget;
  11281. }
  11282. }
  11283. }
  11284. var zaxis = BoneLookController._tmpVecs[5];
  11285. var xaxis = BoneLookController._tmpVecs[6];
  11286. var yaxis = BoneLookController._tmpVecs[7];
  11287. var _tmpQuat = BoneLookController._tmpQuat;
  11288. target.subtractToRef(bonePos, zaxis);
  11289. zaxis.normalize();
  11290. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11291. xaxis.normalize();
  11292. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11293. yaxis.normalize();
  11294. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11295. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11296. return;
  11297. }
  11298. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11299. return;
  11300. }
  11301. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11302. return;
  11303. }
  11304. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11305. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11306. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11307. }
  11308. if (this.slerpAmount < 1) {
  11309. if (!this._slerping) {
  11310. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11311. }
  11312. if (this._transformYawPitch) {
  11313. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11314. }
  11315. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11316. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11317. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11318. this._slerping = true;
  11319. }
  11320. else {
  11321. if (this._transformYawPitch) {
  11322. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11323. }
  11324. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11325. this._slerping = false;
  11326. }
  11327. };
  11328. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11329. var angDiff = ang2 - ang1;
  11330. angDiff %= Math.PI * 2;
  11331. if (angDiff > Math.PI) {
  11332. angDiff -= Math.PI * 2;
  11333. }
  11334. else if (angDiff < -Math.PI) {
  11335. angDiff += Math.PI * 2;
  11336. }
  11337. return angDiff;
  11338. };
  11339. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11340. ang1 %= (2 * Math.PI);
  11341. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11342. ang2 %= (2 * Math.PI);
  11343. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11344. var ab = 0;
  11345. if (ang1 < ang2) {
  11346. ab = ang2 - ang1;
  11347. }
  11348. else {
  11349. ab = ang1 - ang2;
  11350. }
  11351. if (ab > Math.PI) {
  11352. ab = Math.PI * 2 - ab;
  11353. }
  11354. return ab;
  11355. };
  11356. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11357. ang %= (2 * Math.PI);
  11358. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11359. ang1 %= (2 * Math.PI);
  11360. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11361. ang2 %= (2 * Math.PI);
  11362. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11363. if (ang1 < ang2) {
  11364. if (ang > ang1 && ang < ang2) {
  11365. return true;
  11366. }
  11367. }
  11368. else {
  11369. if (ang > ang2 && ang < ang1) {
  11370. return true;
  11371. }
  11372. }
  11373. return false;
  11374. };
  11375. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11376. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11377. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11378. return BoneLookController;
  11379. }());
  11380. /***/ }),
  11381. /***/ "./Bones/index.ts":
  11382. /*!************************!*\
  11383. !*** ./Bones/index.ts ***!
  11384. \************************/
  11385. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11387. "use strict";
  11388. __webpack_require__.r(__webpack_exports__);
  11389. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11391. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11393. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11395. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11397. /***/ }),
  11398. /***/ "./Bones/skeleton.ts":
  11399. /*!***************************!*\
  11400. !*** ./Bones/skeleton.ts ***!
  11401. \***************************/
  11402. /*! exports provided: Skeleton */
  11403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11404. "use strict";
  11405. __webpack_require__.r(__webpack_exports__);
  11406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11407. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11408. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11409. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11410. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11411. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11412. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11413. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11414. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11415. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11416. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11417. /**
  11418. * Class used to handle skinning animations
  11419. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11420. */
  11421. var Skeleton = /** @class */ (function () {
  11422. /**
  11423. * Creates a new skeleton
  11424. * @param name defines the skeleton name
  11425. * @param id defines the skeleton Id
  11426. * @param scene defines the hosting scene
  11427. */
  11428. function Skeleton(
  11429. /** defines the skeleton name */
  11430. name,
  11431. /** defines the skeleton Id */
  11432. id, scene) {
  11433. this.name = name;
  11434. this.id = id;
  11435. /**
  11436. * Defines the list of child bones
  11437. */
  11438. this.bones = new Array();
  11439. /**
  11440. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11441. */
  11442. this.needInitialSkinMatrix = false;
  11443. /**
  11444. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11445. */
  11446. this.overrideMesh = null;
  11447. this._isDirty = true;
  11448. this._meshesWithPoseMatrix = new Array();
  11449. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11450. this._ranges = {};
  11451. this._lastAbsoluteTransformsUpdateId = -1;
  11452. this._canUseTextureForBones = false;
  11453. /** @hidden */
  11454. this._numBonesWithLinkedTransformNode = 0;
  11455. /**
  11456. * Specifies if the skeleton should be serialized
  11457. */
  11458. this.doNotSerialize = false;
  11459. /**
  11460. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11461. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11462. */
  11463. this.useTextureToStoreBoneMatrices = true;
  11464. this._animationPropertiesOverride = null;
  11465. // Events
  11466. /**
  11467. * An observable triggered before computing the skeleton's matrices
  11468. */
  11469. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11470. this.bones = [];
  11471. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11472. this._scene.skeletons.push(this);
  11473. //make sure it will recalculate the matrix next time prepare is called.
  11474. this._isDirty = true;
  11475. var engineCaps = this._scene.getEngine().getCaps();
  11476. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11477. }
  11478. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11479. /**
  11480. * Gets or sets the animation properties override
  11481. */
  11482. get: function () {
  11483. if (!this._animationPropertiesOverride) {
  11484. return this._scene.animationPropertiesOverride;
  11485. }
  11486. return this._animationPropertiesOverride;
  11487. },
  11488. set: function (value) {
  11489. this._animationPropertiesOverride = value;
  11490. },
  11491. enumerable: true,
  11492. configurable: true
  11493. });
  11494. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11495. /**
  11496. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11497. */
  11498. get: function () {
  11499. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11500. },
  11501. enumerable: true,
  11502. configurable: true
  11503. });
  11504. /**
  11505. * Gets the current object class name.
  11506. * @return the class name
  11507. */
  11508. Skeleton.prototype.getClassName = function () {
  11509. return "Skeleton";
  11510. };
  11511. /**
  11512. * Returns an array containing the root bones
  11513. * @returns an array containing the root bones
  11514. */
  11515. Skeleton.prototype.getChildren = function () {
  11516. return this.bones.filter(function (b) { return !b.getParent(); });
  11517. };
  11518. // Members
  11519. /**
  11520. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11521. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11522. * @returns a Float32Array containing matrices data
  11523. */
  11524. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11525. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11526. return mesh._bonesTransformMatrices;
  11527. }
  11528. if (!this._transformMatrices) {
  11529. this.prepare();
  11530. }
  11531. return this._transformMatrices;
  11532. };
  11533. /**
  11534. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11535. * @returns a raw texture containing the data
  11536. */
  11537. Skeleton.prototype.getTransformMatrixTexture = function () {
  11538. return this._transformMatrixTexture;
  11539. };
  11540. /**
  11541. * Gets the current hosting scene
  11542. * @returns a scene object
  11543. */
  11544. Skeleton.prototype.getScene = function () {
  11545. return this._scene;
  11546. };
  11547. // Methods
  11548. /**
  11549. * Gets a string representing the current skeleton data
  11550. * @param fullDetails defines a boolean indicating if we want a verbose version
  11551. * @returns a string representing the current skeleton data
  11552. */
  11553. Skeleton.prototype.toString = function (fullDetails) {
  11554. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11555. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11556. if (fullDetails) {
  11557. ret += ", Ranges: {";
  11558. var first = true;
  11559. for (var name_1 in this._ranges) {
  11560. if (first) {
  11561. ret += ", ";
  11562. first = false;
  11563. }
  11564. ret += name_1;
  11565. }
  11566. ret += "}";
  11567. }
  11568. return ret;
  11569. };
  11570. /**
  11571. * Get bone's index searching by name
  11572. * @param name defines bone's name to search for
  11573. * @return the indice of the bone. Returns -1 if not found
  11574. */
  11575. Skeleton.prototype.getBoneIndexByName = function (name) {
  11576. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11577. if (this.bones[boneIndex].name === name) {
  11578. return boneIndex;
  11579. }
  11580. }
  11581. return -1;
  11582. };
  11583. /**
  11584. * Creater a new animation range
  11585. * @param name defines the name of the range
  11586. * @param from defines the start key
  11587. * @param to defines the end key
  11588. */
  11589. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11590. // check name not already in use
  11591. if (!this._ranges[name]) {
  11592. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11593. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11594. if (this.bones[i].animations[0]) {
  11595. this.bones[i].animations[0].createRange(name, from, to);
  11596. }
  11597. }
  11598. }
  11599. };
  11600. /**
  11601. * Delete a specific animation range
  11602. * @param name defines the name of the range
  11603. * @param deleteFrames defines if frames must be removed as well
  11604. */
  11605. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11606. if (deleteFrames === void 0) { deleteFrames = true; }
  11607. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11608. if (this.bones[i].animations[0]) {
  11609. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11610. }
  11611. }
  11612. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11613. };
  11614. /**
  11615. * Gets a specific animation range
  11616. * @param name defines the name of the range to look for
  11617. * @returns the requested animation range or null if not found
  11618. */
  11619. Skeleton.prototype.getAnimationRange = function (name) {
  11620. return this._ranges[name];
  11621. };
  11622. /**
  11623. * Gets the list of all animation ranges defined on this skeleton
  11624. * @returns an array
  11625. */
  11626. Skeleton.prototype.getAnimationRanges = function () {
  11627. var animationRanges = [];
  11628. var name;
  11629. for (name in this._ranges) {
  11630. animationRanges.push(this._ranges[name]);
  11631. }
  11632. return animationRanges;
  11633. };
  11634. /**
  11635. * Copy animation range from a source skeleton.
  11636. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11637. * @param source defines the source skeleton
  11638. * @param name defines the name of the range to copy
  11639. * @param rescaleAsRequired defines if rescaling must be applied if required
  11640. * @returns true if operation was successful
  11641. */
  11642. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11643. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11644. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11645. return false;
  11646. }
  11647. var ret = true;
  11648. var frameOffset = this._getHighestAnimationFrame() + 1;
  11649. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11650. var boneDict = {};
  11651. var sourceBones = source.bones;
  11652. var nBones;
  11653. var i;
  11654. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11655. boneDict[sourceBones[i].name] = sourceBones[i];
  11656. }
  11657. if (this.bones.length !== sourceBones.length) {
  11658. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11659. ret = false;
  11660. }
  11661. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11662. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11663. var boneName = this.bones[i].name;
  11664. var sourceBone = boneDict[boneName];
  11665. if (sourceBone) {
  11666. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11667. }
  11668. else {
  11669. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11670. ret = false;
  11671. }
  11672. }
  11673. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11674. var range = source.getAnimationRange(name);
  11675. if (range) {
  11676. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11677. }
  11678. return ret;
  11679. };
  11680. /**
  11681. * Forces the skeleton to go to rest pose
  11682. */
  11683. Skeleton.prototype.returnToRest = function () {
  11684. for (var index = 0; index < this.bones.length; index++) {
  11685. this.bones[index].returnToRest();
  11686. }
  11687. };
  11688. Skeleton.prototype._getHighestAnimationFrame = function () {
  11689. var ret = 0;
  11690. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11691. if (this.bones[i].animations[0]) {
  11692. var highest = this.bones[i].animations[0].getHighestFrame();
  11693. if (ret < highest) {
  11694. ret = highest;
  11695. }
  11696. }
  11697. }
  11698. return ret;
  11699. };
  11700. /**
  11701. * Begin a specific animation range
  11702. * @param name defines the name of the range to start
  11703. * @param loop defines if looping must be turned on (false by default)
  11704. * @param speedRatio defines the speed ratio to apply (1 by default)
  11705. * @param onAnimationEnd defines a callback which will be called when animation will end
  11706. * @returns a new animatable
  11707. */
  11708. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11709. var range = this.getAnimationRange(name);
  11710. if (!range) {
  11711. return null;
  11712. }
  11713. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11714. };
  11715. /** @hidden */
  11716. Skeleton.prototype._markAsDirty = function () {
  11717. this._isDirty = true;
  11718. };
  11719. /** @hidden */
  11720. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11721. this._meshesWithPoseMatrix.push(mesh);
  11722. };
  11723. /** @hidden */
  11724. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11725. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11726. if (index > -1) {
  11727. this._meshesWithPoseMatrix.splice(index, 1);
  11728. }
  11729. };
  11730. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11731. this.onBeforeComputeObservable.notifyObservers(this);
  11732. for (var index = 0; index < this.bones.length; index++) {
  11733. var bone = this.bones[index];
  11734. var parentBone = bone.getParent();
  11735. if (parentBone) {
  11736. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11737. }
  11738. else {
  11739. if (initialSkinMatrix) {
  11740. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11741. }
  11742. else {
  11743. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11744. }
  11745. }
  11746. if (bone._index !== -1) {
  11747. var mappedIndex = bone._index === null ? index : bone._index;
  11748. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11749. }
  11750. }
  11751. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11752. };
  11753. /**
  11754. * Build all resources required to render a skeleton
  11755. */
  11756. Skeleton.prototype.prepare = function () {
  11757. // Update the local matrix of bones with linked transform nodes.
  11758. if (this._numBonesWithLinkedTransformNode > 0) {
  11759. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11760. var bone_1 = _a[_i];
  11761. if (bone_1._linkedTransformNode) {
  11762. // Computing the world matrix also computes the local matrix.
  11763. bone_1._linkedTransformNode.computeWorldMatrix();
  11764. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11765. bone_1.markAsDirty();
  11766. }
  11767. }
  11768. }
  11769. if (!this._isDirty) {
  11770. return;
  11771. }
  11772. if (this.needInitialSkinMatrix) {
  11773. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11774. var mesh = this._meshesWithPoseMatrix[index];
  11775. var poseMatrix = mesh.getPoseMatrix();
  11776. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11777. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11778. }
  11779. if (this._synchronizedWithMesh !== mesh) {
  11780. this._synchronizedWithMesh = mesh;
  11781. // Prepare bones
  11782. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11783. var bone = this.bones[boneIndex];
  11784. if (!bone.getParent()) {
  11785. var matrix = bone.getBaseMatrix();
  11786. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11787. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11788. }
  11789. }
  11790. }
  11791. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11792. }
  11793. }
  11794. else {
  11795. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11796. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11797. if (this.isUsingTextureForMatrices) {
  11798. if (this._transformMatrixTexture) {
  11799. this._transformMatrixTexture.dispose();
  11800. }
  11801. 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);
  11802. }
  11803. }
  11804. this._computeTransformMatrices(this._transformMatrices, null);
  11805. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11806. this._transformMatrixTexture.update(this._transformMatrices);
  11807. }
  11808. }
  11809. this._isDirty = false;
  11810. this._scene._activeBones.addCount(this.bones.length, false);
  11811. };
  11812. /**
  11813. * Gets the list of animatables currently running for this skeleton
  11814. * @returns an array of animatables
  11815. */
  11816. Skeleton.prototype.getAnimatables = function () {
  11817. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11818. this._animatables = [];
  11819. for (var index = 0; index < this.bones.length; index++) {
  11820. this._animatables.push(this.bones[index]);
  11821. }
  11822. }
  11823. return this._animatables;
  11824. };
  11825. /**
  11826. * Clone the current skeleton
  11827. * @param name defines the name of the new skeleton
  11828. * @param id defines the id of the enw skeleton
  11829. * @returns the new skeleton
  11830. */
  11831. Skeleton.prototype.clone = function (name, id) {
  11832. var result = new Skeleton(name, id || name, this._scene);
  11833. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11834. for (var index = 0; index < this.bones.length; index++) {
  11835. var source = this.bones[index];
  11836. var parentBone = null;
  11837. var parent_1 = source.getParent();
  11838. if (parent_1) {
  11839. var parentIndex = this.bones.indexOf(parent_1);
  11840. parentBone = result.bones[parentIndex];
  11841. }
  11842. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11843. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11844. }
  11845. if (this._ranges) {
  11846. result._ranges = {};
  11847. for (var rangeName in this._ranges) {
  11848. var range = this._ranges[rangeName];
  11849. if (range) {
  11850. result._ranges[rangeName] = range.clone();
  11851. }
  11852. }
  11853. }
  11854. this._isDirty = true;
  11855. return result;
  11856. };
  11857. /**
  11858. * Enable animation blending for this skeleton
  11859. * @param blendingSpeed defines the blending speed to apply
  11860. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11861. */
  11862. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11863. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11864. this.bones.forEach(function (bone) {
  11865. bone.animations.forEach(function (animation) {
  11866. animation.enableBlending = true;
  11867. animation.blendingSpeed = blendingSpeed;
  11868. });
  11869. });
  11870. };
  11871. /**
  11872. * Releases all resources associated with the current skeleton
  11873. */
  11874. Skeleton.prototype.dispose = function () {
  11875. this._meshesWithPoseMatrix = [];
  11876. // Animations
  11877. this.getScene().stopAnimation(this);
  11878. // Remove from scene
  11879. this.getScene().removeSkeleton(this);
  11880. if (this._transformMatrixTexture) {
  11881. this._transformMatrixTexture.dispose();
  11882. this._transformMatrixTexture = null;
  11883. }
  11884. };
  11885. /**
  11886. * Serialize the skeleton in a JSON object
  11887. * @returns a JSON object
  11888. */
  11889. Skeleton.prototype.serialize = function () {
  11890. var serializationObject = {};
  11891. serializationObject.name = this.name;
  11892. serializationObject.id = this.id;
  11893. if (this.dimensionsAtRest) {
  11894. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11895. }
  11896. serializationObject.bones = [];
  11897. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11898. for (var index = 0; index < this.bones.length; index++) {
  11899. var bone = this.bones[index];
  11900. var parent_2 = bone.getParent();
  11901. var serializedBone = {
  11902. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11903. name: bone.name,
  11904. matrix: bone.getBaseMatrix().toArray(),
  11905. rest: bone.getRestPose().toArray()
  11906. };
  11907. serializationObject.bones.push(serializedBone);
  11908. if (bone.length) {
  11909. serializedBone.length = bone.length;
  11910. }
  11911. if (bone.metadata) {
  11912. serializedBone.metadata = bone.metadata;
  11913. }
  11914. if (bone.animations && bone.animations.length > 0) {
  11915. serializedBone.animation = bone.animations[0].serialize();
  11916. }
  11917. serializationObject.ranges = [];
  11918. for (var name in this._ranges) {
  11919. var source = this._ranges[name];
  11920. if (!source) {
  11921. continue;
  11922. }
  11923. var range = {};
  11924. range.name = name;
  11925. range.from = source.from;
  11926. range.to = source.to;
  11927. serializationObject.ranges.push(range);
  11928. }
  11929. }
  11930. return serializationObject;
  11931. };
  11932. /**
  11933. * Creates a new skeleton from serialized data
  11934. * @param parsedSkeleton defines the serialized data
  11935. * @param scene defines the hosting scene
  11936. * @returns a new skeleton
  11937. */
  11938. Skeleton.Parse = function (parsedSkeleton, scene) {
  11939. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11940. if (parsedSkeleton.dimensionsAtRest) {
  11941. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11942. }
  11943. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11944. var index;
  11945. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11946. var parsedBone = parsedSkeleton.bones[index];
  11947. var parentBone = null;
  11948. if (parsedBone.parentBoneIndex > -1) {
  11949. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11950. }
  11951. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11952. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11953. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11954. bone.id = parsedBone.id;
  11955. }
  11956. if (parsedBone.length) {
  11957. bone.length = parsedBone.length;
  11958. }
  11959. if (parsedBone.metadata) {
  11960. bone.metadata = parsedBone.metadata;
  11961. }
  11962. if (parsedBone.animation) {
  11963. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11964. }
  11965. }
  11966. // placed after bones, so createAnimationRange can cascade down
  11967. if (parsedSkeleton.ranges) {
  11968. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11969. var data = parsedSkeleton.ranges[index];
  11970. skeleton.createAnimationRange(data.name, data.from, data.to);
  11971. }
  11972. }
  11973. return skeleton;
  11974. };
  11975. /**
  11976. * Compute all node absolute transforms
  11977. * @param forceUpdate defines if computation must be done even if cache is up to date
  11978. */
  11979. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11980. if (forceUpdate === void 0) { forceUpdate = false; }
  11981. var renderId = this._scene.getRenderId();
  11982. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11983. this.bones[0].computeAbsoluteTransforms();
  11984. this._lastAbsoluteTransformsUpdateId = renderId;
  11985. }
  11986. };
  11987. /**
  11988. * Gets the root pose matrix
  11989. * @returns a matrix
  11990. */
  11991. Skeleton.prototype.getPoseMatrix = function () {
  11992. var poseMatrix = null;
  11993. if (this._meshesWithPoseMatrix.length > 0) {
  11994. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11995. }
  11996. return poseMatrix;
  11997. };
  11998. /**
  11999. * Sorts bones per internal index
  12000. */
  12001. Skeleton.prototype.sortBones = function () {
  12002. var bones = new Array();
  12003. var visited = new Array(this.bones.length);
  12004. for (var index = 0; index < this.bones.length; index++) {
  12005. this._sortBones(index, bones, visited);
  12006. }
  12007. this.bones = bones;
  12008. };
  12009. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12010. if (visited[index]) {
  12011. return;
  12012. }
  12013. visited[index] = true;
  12014. var bone = this.bones[index];
  12015. if (bone._index === undefined) {
  12016. bone._index = index;
  12017. }
  12018. var parentBone = bone.getParent();
  12019. if (parentBone) {
  12020. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12021. }
  12022. bones.push(bone);
  12023. };
  12024. return Skeleton;
  12025. }());
  12026. /***/ }),
  12027. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12028. /*!***************************************************!*\
  12029. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12030. \***************************************************/
  12031. /*! exports provided: BaseCameraPointersInput */
  12032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12033. "use strict";
  12034. __webpack_require__.r(__webpack_exports__);
  12035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12036. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12037. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12038. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12039. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12040. /**
  12041. * Base class for Camera Pointer Inputs.
  12042. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12043. * for example usage.
  12044. */
  12045. var BaseCameraPointersInput = /** @class */ (function () {
  12046. function BaseCameraPointersInput() {
  12047. /**
  12048. * Defines the buttons associated with the input to handle camera move.
  12049. */
  12050. this.buttons = [0, 1, 2];
  12051. }
  12052. /**
  12053. * Attach the input controls to a specific dom element to get the input from.
  12054. * @param element Defines the element the controls should be listened from
  12055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12056. */
  12057. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12058. var _this = this;
  12059. var engine = this.camera.getEngine();
  12060. var pointA = null;
  12061. var pointB = null;
  12062. var previousPinchSquaredDistance = 0;
  12063. var previousMultiTouchPanPosition = null;
  12064. this._altKey = false;
  12065. this._ctrlKey = false;
  12066. this._metaKey = false;
  12067. this._shiftKey = false;
  12068. this._buttonsPressed = 0;
  12069. this._pointerInput = function (p, s) {
  12070. var evt = p.event;
  12071. var isTouch = evt.pointerType === "touch";
  12072. if (engine.isInVRExclusivePointerMode) {
  12073. return;
  12074. }
  12075. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12076. _this.buttons.indexOf(evt.button) === -1) {
  12077. return;
  12078. }
  12079. var srcElement = (evt.srcElement || evt.target);
  12080. _this._altKey = evt.altKey;
  12081. _this._ctrlKey = evt.ctrlKey;
  12082. _this._metaKey = evt.metaKey;
  12083. _this._shiftKey = evt.shiftKey;
  12084. _this._buttonsPressed = evt.buttons;
  12085. if (engine.isPointerLock) {
  12086. var offsetX = evt.movementX ||
  12087. evt.mozMovementX ||
  12088. evt.webkitMovementX ||
  12089. evt.msMovementX ||
  12090. 0;
  12091. var offsetY = evt.movementY ||
  12092. evt.mozMovementY ||
  12093. evt.webkitMovementY ||
  12094. evt.msMovementY ||
  12095. 0;
  12096. _this.onTouch(null, offsetX, offsetY);
  12097. pointA = null;
  12098. pointB = null;
  12099. }
  12100. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12101. try {
  12102. srcElement.setPointerCapture(evt.pointerId);
  12103. }
  12104. catch (e) {
  12105. //Nothing to do with the error. Execution will continue.
  12106. }
  12107. if (pointA === null) {
  12108. pointA = { x: evt.clientX,
  12109. y: evt.clientY,
  12110. pointerId: evt.pointerId,
  12111. type: evt.pointerType };
  12112. }
  12113. else if (pointB === null) {
  12114. pointB = { x: evt.clientX,
  12115. y: evt.clientY,
  12116. pointerId: evt.pointerId,
  12117. type: evt.pointerType };
  12118. }
  12119. _this.onButtonDown(evt, pointB ? 2 : 1);
  12120. if (!noPreventDefault) {
  12121. evt.preventDefault();
  12122. element.focus();
  12123. }
  12124. }
  12125. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12126. _this.onDoubleTap(evt.pointerType);
  12127. }
  12128. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12129. try {
  12130. srcElement.releasePointerCapture(evt.pointerId);
  12131. }
  12132. catch (e) {
  12133. //Nothing to do with the error.
  12134. }
  12135. if (!isTouch) {
  12136. pointB = null; // Mouse and pen are mono pointer
  12137. }
  12138. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12139. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12140. //when changing orientation while pinching camera,
  12141. //one pointer stay pressed forever if we don't release all pointers
  12142. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12143. if (engine._badOS) {
  12144. pointA = pointB = null;
  12145. }
  12146. else {
  12147. //only remove the impacted pointer in case of multitouch allowing on most
  12148. //platforms switching from rotate to zoom and pan seamlessly.
  12149. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12150. pointA = pointB;
  12151. pointB = null;
  12152. }
  12153. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12154. pointB = null;
  12155. }
  12156. else {
  12157. pointA = pointB = null;
  12158. }
  12159. }
  12160. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12161. // Previous pinch data is populated but a button has been lifted
  12162. // so pinch has ended.
  12163. _this.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12164. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12165. );
  12166. previousPinchSquaredDistance = 0;
  12167. previousMultiTouchPanPosition = null;
  12168. }
  12169. _this.onButtonUp(evt);
  12170. if (!noPreventDefault) {
  12171. evt.preventDefault();
  12172. }
  12173. }
  12174. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12175. if (!noPreventDefault) {
  12176. evt.preventDefault();
  12177. }
  12178. // One button down
  12179. if (pointA && pointB === null) {
  12180. var offsetX = evt.clientX - pointA.x;
  12181. var offsetY = evt.clientY - pointA.y;
  12182. _this.onTouch(pointA, offsetX, offsetY);
  12183. pointA.x = evt.clientX;
  12184. pointA.y = evt.clientY;
  12185. }
  12186. // Two buttons down: pinch
  12187. else if (pointA && pointB) {
  12188. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12189. ed.x = evt.clientX;
  12190. ed.y = evt.clientY;
  12191. var distX = pointA.x - pointB.x;
  12192. var distY = pointA.y - pointB.y;
  12193. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12194. var multiTouchPanPosition = { x: (pointA.x + pointB.x) / 2,
  12195. y: (pointA.y + pointB.y) / 2,
  12196. pointerId: evt.pointerId,
  12197. type: p.type };
  12198. _this.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12199. previousMultiTouchPanPosition = multiTouchPanPosition;
  12200. previousPinchSquaredDistance = pinchSquaredDistance;
  12201. }
  12202. }
  12203. };
  12204. 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 |
  12205. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12206. this._onLostFocus = function () {
  12207. pointA = pointB = null;
  12208. previousPinchSquaredDistance = 0;
  12209. previousMultiTouchPanPosition = null;
  12210. _this.onLostFocus();
  12211. };
  12212. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12213. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12214. { name: "blur", handler: this._onLostFocus }
  12215. ]);
  12216. };
  12217. /**
  12218. * Detach the current controls from the specified dom element.
  12219. * @param element Defines the element to stop listening the inputs from
  12220. */
  12221. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12222. if (this._onLostFocus) {
  12223. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12224. { name: "blur", handler: this._onLostFocus }
  12225. ]);
  12226. }
  12227. if (element && this._observer) {
  12228. this.camera.getScene().onPointerObservable.remove(this._observer);
  12229. this._observer = null;
  12230. if (this.onContextMenu) {
  12231. element.removeEventListener("contextmenu", this.onContextMenu);
  12232. }
  12233. this._onLostFocus = null;
  12234. }
  12235. this._altKey = false;
  12236. this._ctrlKey = false;
  12237. this._metaKey = false;
  12238. this._shiftKey = false;
  12239. this._buttonsPressed = 0;
  12240. };
  12241. /**
  12242. * Gets the class name of the current input.
  12243. * @returns the class name
  12244. */
  12245. BaseCameraPointersInput.prototype.getClassName = function () {
  12246. return "BaseCameraPointersInput";
  12247. };
  12248. /**
  12249. * Get the friendly name associated with the input class.
  12250. * @returns the input friendly name
  12251. */
  12252. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12253. return "pointers";
  12254. };
  12255. /**
  12256. * Called on pointer POINTERDOUBLETAP event.
  12257. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12258. */
  12259. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12260. };
  12261. /**
  12262. * Called on pointer POINTERMOVE event if only a single touch is active.
  12263. * Override this method to provide functionality.
  12264. */
  12265. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12266. };
  12267. /**
  12268. * Called on pointer POINTERMOVE event if multiple touches are active.
  12269. * Override this method to provide functionality.
  12270. */
  12271. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12272. };
  12273. /**
  12274. * Called on JS contextmenu event.
  12275. * Override this method to provide functionality.
  12276. */
  12277. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12278. evt.preventDefault();
  12279. };
  12280. /**
  12281. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12282. * press.
  12283. * Override this method to provide functionality.
  12284. */
  12285. BaseCameraPointersInput.prototype.onButtonDown = function (evt, buttonCount) {
  12286. };
  12287. /**
  12288. * Called each time a new POINTERUP event occurs. Ie, for each button
  12289. * release.
  12290. * Override this method to provide functionality.
  12291. */
  12292. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12293. };
  12294. /**
  12295. * Called when window becomes inactive.
  12296. * Override this method to provide functionality.
  12297. */
  12298. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12299. };
  12300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12302. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12303. return BaseCameraPointersInput;
  12304. }());
  12305. /***/ }),
  12306. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12307. /*!*******************************************************!*\
  12308. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12309. \*******************************************************/
  12310. /*! exports provided: ArcRotateCameraGamepadInput */
  12311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12312. "use strict";
  12313. __webpack_require__.r(__webpack_exports__);
  12314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12315. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12316. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12317. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12318. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12319. /**
  12320. * Manage the gamepad inputs to control an arc rotate camera.
  12321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12322. */
  12323. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12324. function ArcRotateCameraGamepadInput() {
  12325. /**
  12326. * Defines the gamepad rotation sensiblity.
  12327. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12328. */
  12329. this.gamepadRotationSensibility = 80;
  12330. /**
  12331. * Defines the gamepad move sensiblity.
  12332. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12333. */
  12334. this.gamepadMoveSensibility = 40;
  12335. }
  12336. /**
  12337. * Attach the input controls to a specific dom element to get the input from.
  12338. * @param element Defines the element the controls should be listened from
  12339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12340. */
  12341. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12342. var _this = this;
  12343. var manager = this.camera.getScene().gamepadManager;
  12344. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12345. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12346. // prioritize XBOX gamepads.
  12347. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12348. _this.gamepad = gamepad;
  12349. }
  12350. }
  12351. });
  12352. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12353. if (_this.gamepad === gamepad) {
  12354. _this.gamepad = null;
  12355. }
  12356. });
  12357. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12358. };
  12359. /**
  12360. * Detach the current controls from the specified dom element.
  12361. * @param element Defines the element to stop listening the inputs from
  12362. */
  12363. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12364. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12365. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12366. this.gamepad = null;
  12367. };
  12368. /**
  12369. * Update the current camera state depending on the inputs that have been used this frame.
  12370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12371. */
  12372. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12373. if (this.gamepad) {
  12374. var camera = this.camera;
  12375. var RSValues = this.gamepad.rightStick;
  12376. if (RSValues) {
  12377. if (RSValues.x != 0) {
  12378. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12379. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12380. camera.inertialAlphaOffset += normalizedRX;
  12381. }
  12382. }
  12383. if (RSValues.y != 0) {
  12384. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12385. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12386. camera.inertialBetaOffset += normalizedRY;
  12387. }
  12388. }
  12389. }
  12390. var LSValues = this.gamepad.leftStick;
  12391. if (LSValues && LSValues.y != 0) {
  12392. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12393. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12394. this.camera.inertialRadiusOffset -= normalizedLY;
  12395. }
  12396. }
  12397. }
  12398. };
  12399. /**
  12400. * Gets the class name of the current intput.
  12401. * @returns the class name
  12402. */
  12403. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12404. return "ArcRotateCameraGamepadInput";
  12405. };
  12406. /**
  12407. * Get the friendly name associated with the input class.
  12408. * @returns the input friendly name
  12409. */
  12410. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12411. return "gamepad";
  12412. };
  12413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12415. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12418. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12419. return ArcRotateCameraGamepadInput;
  12420. }());
  12421. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12422. /***/ }),
  12423. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12424. /*!************************************************************!*\
  12425. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12426. \************************************************************/
  12427. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12429. "use strict";
  12430. __webpack_require__.r(__webpack_exports__);
  12431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12432. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12433. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12434. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12435. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12436. /**
  12437. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12439. */
  12440. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12441. function ArcRotateCameraKeyboardMoveInput() {
  12442. /**
  12443. * Defines the list of key codes associated with the up action (increase alpha)
  12444. */
  12445. this.keysUp = [38];
  12446. /**
  12447. * Defines the list of key codes associated with the down action (decrease alpha)
  12448. */
  12449. this.keysDown = [40];
  12450. /**
  12451. * Defines the list of key codes associated with the left action (increase beta)
  12452. */
  12453. this.keysLeft = [37];
  12454. /**
  12455. * Defines the list of key codes associated with the right action (decrease beta)
  12456. */
  12457. this.keysRight = [39];
  12458. /**
  12459. * Defines the list of key codes associated with the reset action.
  12460. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12461. */
  12462. this.keysReset = [220];
  12463. /**
  12464. * Defines the panning sensibility of the inputs.
  12465. * (How fast is the camera paning)
  12466. */
  12467. this.panningSensibility = 50.0;
  12468. /**
  12469. * Defines the zooming sensibility of the inputs.
  12470. * (How fast is the camera zooming)
  12471. */
  12472. this.zoomingSensibility = 25.0;
  12473. /**
  12474. * Defines wether maintaining the alt key down switch the movement mode from
  12475. * orientation to zoom.
  12476. */
  12477. this.useAltToZoom = true;
  12478. /**
  12479. * Rotation speed of the camera
  12480. */
  12481. this.angularSpeed = 0.01;
  12482. this._keys = new Array();
  12483. }
  12484. /**
  12485. * Attach the input controls to a specific dom element to get the input from.
  12486. * @param element Defines the element the controls should be listened from
  12487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12488. */
  12489. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12490. var _this = this;
  12491. if (this._onCanvasBlurObserver) {
  12492. return;
  12493. }
  12494. this._scene = this.camera.getScene();
  12495. this._engine = this._scene.getEngine();
  12496. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12497. _this._keys = [];
  12498. });
  12499. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12500. var evt = info.event;
  12501. if (!evt.metaKey) {
  12502. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12503. _this._ctrlPressed = evt.ctrlKey;
  12504. _this._altPressed = evt.altKey;
  12505. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12506. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12507. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12508. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12509. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12510. var index = _this._keys.indexOf(evt.keyCode);
  12511. if (index === -1) {
  12512. _this._keys.push(evt.keyCode);
  12513. }
  12514. if (evt.preventDefault) {
  12515. if (!noPreventDefault) {
  12516. evt.preventDefault();
  12517. }
  12518. }
  12519. }
  12520. }
  12521. else {
  12522. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12523. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12524. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12525. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12526. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12527. var index = _this._keys.indexOf(evt.keyCode);
  12528. if (index >= 0) {
  12529. _this._keys.splice(index, 1);
  12530. }
  12531. if (evt.preventDefault) {
  12532. if (!noPreventDefault) {
  12533. evt.preventDefault();
  12534. }
  12535. }
  12536. }
  12537. }
  12538. }
  12539. });
  12540. };
  12541. /**
  12542. * Detach the current controls from the specified dom element.
  12543. * @param element Defines the element to stop listening the inputs from
  12544. */
  12545. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12546. if (this._scene) {
  12547. if (this._onKeyboardObserver) {
  12548. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12549. }
  12550. if (this._onCanvasBlurObserver) {
  12551. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12552. }
  12553. this._onKeyboardObserver = null;
  12554. this._onCanvasBlurObserver = null;
  12555. }
  12556. this._keys = [];
  12557. };
  12558. /**
  12559. * Update the current camera state depending on the inputs that have been used this frame.
  12560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12561. */
  12562. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12563. if (this._onKeyboardObserver) {
  12564. var camera = this.camera;
  12565. for (var index = 0; index < this._keys.length; index++) {
  12566. var keyCode = this._keys[index];
  12567. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12568. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12569. camera.inertialPanningX -= 1 / this.panningSensibility;
  12570. }
  12571. else {
  12572. camera.inertialAlphaOffset -= this.angularSpeed;
  12573. }
  12574. }
  12575. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12576. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12577. camera.inertialPanningY += 1 / this.panningSensibility;
  12578. }
  12579. else if (this._altPressed && this.useAltToZoom) {
  12580. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12581. }
  12582. else {
  12583. camera.inertialBetaOffset -= this.angularSpeed;
  12584. }
  12585. }
  12586. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12587. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12588. camera.inertialPanningX += 1 / this.panningSensibility;
  12589. }
  12590. else {
  12591. camera.inertialAlphaOffset += this.angularSpeed;
  12592. }
  12593. }
  12594. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12595. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12596. camera.inertialPanningY -= 1 / this.panningSensibility;
  12597. }
  12598. else if (this._altPressed && this.useAltToZoom) {
  12599. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12600. }
  12601. else {
  12602. camera.inertialBetaOffset += this.angularSpeed;
  12603. }
  12604. }
  12605. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12606. if (camera.useInputToRestoreState) {
  12607. camera.restoreState();
  12608. }
  12609. }
  12610. }
  12611. }
  12612. };
  12613. /**
  12614. * Gets the class name of the current intput.
  12615. * @returns the class name
  12616. */
  12617. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12618. return "ArcRotateCameraKeyboardMoveInput";
  12619. };
  12620. /**
  12621. * Get the friendly name associated with the input class.
  12622. * @returns the input friendly name
  12623. */
  12624. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12625. return "keyboard";
  12626. };
  12627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12629. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12632. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12635. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12638. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12641. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12644. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12647. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12650. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12653. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12654. return ArcRotateCameraKeyboardMoveInput;
  12655. }());
  12656. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12657. /***/ }),
  12658. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12659. /*!**********************************************************!*\
  12660. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12661. \**********************************************************/
  12662. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12664. "use strict";
  12665. __webpack_require__.r(__webpack_exports__);
  12666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12667. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12668. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12669. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12670. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12671. /**
  12672. * Manage the mouse wheel inputs to control an arc rotate camera.
  12673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12674. */
  12675. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12676. function ArcRotateCameraMouseWheelInput() {
  12677. /**
  12678. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12679. */
  12680. this.wheelPrecision = 3.0;
  12681. /**
  12682. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12683. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12684. */
  12685. this.wheelDeltaPercentage = 0;
  12686. }
  12687. /**
  12688. * Attach the input controls to a specific dom element to get the input from.
  12689. * @param element Defines the element the controls should be listened from
  12690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12691. */
  12692. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12693. var _this = this;
  12694. this._wheel = function (p, s) {
  12695. //sanity check - this should be a PointerWheel event.
  12696. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12697. return;
  12698. }
  12699. var event = p.event;
  12700. var delta = 0;
  12701. var mouseWheelLegacyEvent = event;
  12702. if (mouseWheelLegacyEvent.wheelDelta) {
  12703. if (_this.wheelDeltaPercentage) {
  12704. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12705. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12706. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12707. }
  12708. else {
  12709. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12710. }
  12711. }
  12712. else {
  12713. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12714. }
  12715. }
  12716. else {
  12717. var deltaValue = event.deltaY || event.detail;
  12718. delta = -deltaValue / _this.wheelPrecision;
  12719. }
  12720. if (delta) {
  12721. _this.camera.inertialRadiusOffset += delta;
  12722. }
  12723. if (event.preventDefault) {
  12724. if (!noPreventDefault) {
  12725. event.preventDefault();
  12726. }
  12727. }
  12728. };
  12729. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12730. };
  12731. /**
  12732. * Detach the current controls from the specified dom element.
  12733. * @param element Defines the element to stop listening the inputs from
  12734. */
  12735. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12736. if (this._observer && element) {
  12737. this.camera.getScene().onPointerObservable.remove(this._observer);
  12738. this._observer = null;
  12739. this._wheel = null;
  12740. }
  12741. };
  12742. /**
  12743. * Gets the class name of the current intput.
  12744. * @returns the class name
  12745. */
  12746. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12747. return "ArcRotateCameraMouseWheelInput";
  12748. };
  12749. /**
  12750. * Get the friendly name associated with the input class.
  12751. * @returns the input friendly name
  12752. */
  12753. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12754. return "mousewheel";
  12755. };
  12756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12758. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12761. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12762. return ArcRotateCameraMouseWheelInput;
  12763. }());
  12764. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12765. /***/ }),
  12766. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12767. /*!********************************************************!*\
  12768. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12769. \********************************************************/
  12770. /*! exports provided: ArcRotateCameraPointersInput */
  12771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12772. "use strict";
  12773. __webpack_require__.r(__webpack_exports__);
  12774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12775. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12776. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12777. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12778. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  12779. /**
  12780. * Manage the pointers inputs to control an arc rotate camera.
  12781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12782. */
  12783. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  12784. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  12785. function ArcRotateCameraPointersInput() {
  12786. var _this = _super !== null && _super.apply(this, arguments) || this;
  12787. /**
  12788. * Defines the buttons associated with the input to handle camera move.
  12789. */
  12790. _this.buttons = [0, 1, 2];
  12791. /**
  12792. * Defines the pointer angular sensibility along the X axis or how fast is
  12793. * the camera rotating.
  12794. */
  12795. _this.angularSensibilityX = 1000.0;
  12796. /**
  12797. * Defines the pointer angular sensibility along the Y axis or how fast is
  12798. * the camera rotating.
  12799. */
  12800. _this.angularSensibilityY = 1000.0;
  12801. /**
  12802. * Defines the pointer pinch precision or how fast is the camera zooming.
  12803. */
  12804. _this.pinchPrecision = 12.0;
  12805. /**
  12806. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  12807. * from 0.
  12808. * It defines the percentage of current camera.radius to use as delta when
  12809. * pinch zoom is used.
  12810. */
  12811. _this.pinchDeltaPercentage = 0;
  12812. /**
  12813. * Defines the pointer panning sensibility or how fast is the camera moving.
  12814. */
  12815. _this.panningSensibility = 1000.0;
  12816. /**
  12817. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12818. */
  12819. _this.multiTouchPanning = true;
  12820. /**
  12821. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  12822. * zoom (pinch) through multitouch.
  12823. */
  12824. _this.multiTouchPanAndZoom = true;
  12825. /**
  12826. * Revers pinch action direction.
  12827. */
  12828. _this.pinchInwards = true;
  12829. _this._isPanClick = false;
  12830. _this._twoFingerActivityCount = 0;
  12831. _this._isPinching = false;
  12832. return _this;
  12833. }
  12834. /**
  12835. * Gets the class name of the current input.
  12836. * @returns the class name
  12837. */
  12838. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12839. return "ArcRotateCameraPointersInput";
  12840. };
  12841. /**
  12842. * Called on pointer POINTERMOVE event if only a single touch is active.
  12843. */
  12844. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12845. if (this.panningSensibility !== 0 &&
  12846. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  12847. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  12848. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  12849. }
  12850. else {
  12851. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  12852. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  12853. }
  12854. };
  12855. /**
  12856. * Called on pointer POINTERDOUBLETAP event.
  12857. */
  12858. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  12859. if (this.camera.useInputToRestoreState) {
  12860. this.camera.restoreState();
  12861. }
  12862. };
  12863. /**
  12864. * Called on pointer POINTERMOVE event if multiple touches are active.
  12865. */
  12866. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12867. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  12868. // First time this method is called for new pinch.
  12869. // Next time this is called there will be a
  12870. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  12871. return;
  12872. }
  12873. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  12874. // Last time this method is called at the end of a pinch.
  12875. return;
  12876. }
  12877. var direction = this.pinchInwards ? 1 : -1;
  12878. if (this.multiTouchPanAndZoom) {
  12879. if (this.pinchDeltaPercentage) {
  12880. this.camera.inertialRadiusOffset +=
  12881. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12882. this.camera.radius * this.pinchDeltaPercentage;
  12883. }
  12884. else {
  12885. this.camera.inertialRadiusOffset +=
  12886. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12887. (this.pinchPrecision * direction *
  12888. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12889. }
  12890. if (this.panningSensibility !== 0 &&
  12891. previousMultiTouchPanPosition && multiTouchPanPosition) {
  12892. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12893. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12894. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12895. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12896. }
  12897. }
  12898. else {
  12899. this._twoFingerActivityCount++;
  12900. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  12901. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12902. if (this._isPinching ||
  12903. (this._twoFingerActivityCount < 20 &&
  12904. Math.abs(pinchDistance - previousPinchDistance) >
  12905. this.camera.pinchToPanMaxDistance)) {
  12906. // Since pinch has not been active long, assume we intend to zoom.
  12907. if (this.pinchDeltaPercentage) {
  12908. this.camera.inertialRadiusOffset +=
  12909. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12910. this.camera.radius * this.pinchDeltaPercentage;
  12911. }
  12912. else {
  12913. this.camera.inertialRadiusOffset +=
  12914. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12915. (this.pinchPrecision * direction *
  12916. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12917. }
  12918. // Since we are pinching, remain pinching on next iteration.
  12919. this._isPinching = true;
  12920. }
  12921. else {
  12922. // Pause between pinch starting and moving implies not a zoom event.
  12923. // Pan instead.
  12924. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  12925. multiTouchPanPosition && previousMultiTouchPanPosition) {
  12926. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12927. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12928. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12929. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12930. }
  12931. }
  12932. }
  12933. };
  12934. /**
  12935. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12936. * press.
  12937. */
  12938. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt, buttonCount) {
  12939. this._isPanClick = evt.button === this.camera._panningMouseButton;
  12940. };
  12941. /**
  12942. * Called each time a new POINTERUP event occurs. Ie, for each button
  12943. * release.
  12944. */
  12945. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  12946. this._twoFingerActivityCount = 0;
  12947. this._isPinching = false;
  12948. };
  12949. /**
  12950. * Called when window becomes inactive.
  12951. */
  12952. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  12953. this._isPanClick = false;
  12954. this._twoFingerActivityCount = 0;
  12955. this._isPinching = false;
  12956. };
  12957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12959. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12962. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12965. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12968. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12971. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12974. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12977. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12980. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12981. return ArcRotateCameraPointersInput;
  12982. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  12983. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  12984. ArcRotateCameraPointersInput;
  12985. /***/ }),
  12986. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12987. /*!*******************************************************************!*\
  12988. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12989. \*******************************************************************/
  12990. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12992. "use strict";
  12993. __webpack_require__.r(__webpack_exports__);
  12994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12995. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12996. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12997. /**
  12998. * Add orientation input support to the input manager.
  12999. * @returns the current input manager
  13000. */
  13001. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13002. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13003. return this;
  13004. };
  13005. /**
  13006. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13008. */
  13009. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13010. /**
  13011. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13012. */
  13013. function ArcRotateCameraVRDeviceOrientationInput() {
  13014. /**
  13015. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13016. */
  13017. this.alphaCorrection = 1;
  13018. /**
  13019. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13020. */
  13021. this.gammaCorrection = 1;
  13022. this._alpha = 0;
  13023. this._gamma = 0;
  13024. this._dirty = false;
  13025. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13026. }
  13027. /**
  13028. * Attach the input controls to a specific dom element to get the input from.
  13029. * @param element Defines the element the controls should be listened from
  13030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13031. */
  13032. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13033. this.camera.attachControl(element, noPreventDefault);
  13034. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13035. };
  13036. /** @hidden */
  13037. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13038. if (evt.alpha !== null) {
  13039. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13040. }
  13041. if (evt.gamma !== null) {
  13042. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13043. }
  13044. this._dirty = true;
  13045. };
  13046. /**
  13047. * Update the current camera state depending on the inputs that have been used this frame.
  13048. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13049. */
  13050. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13051. if (this._dirty) {
  13052. this._dirty = false;
  13053. if (this._gamma < 0) {
  13054. this._gamma = 180 + this._gamma;
  13055. }
  13056. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13057. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13058. }
  13059. };
  13060. /**
  13061. * Detach the current controls from the specified dom element.
  13062. * @param element Defines the element to stop listening the inputs from
  13063. */
  13064. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13065. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13066. };
  13067. /**
  13068. * Gets the class name of the current intput.
  13069. * @returns the class name
  13070. */
  13071. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13072. return "ArcRotateCameraVRDeviceOrientationInput";
  13073. };
  13074. /**
  13075. * Get the friendly name associated with the input class.
  13076. * @returns the input friendly name
  13077. */
  13078. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13079. return "VRDeviceOrientation";
  13080. };
  13081. return ArcRotateCameraVRDeviceOrientationInput;
  13082. }());
  13083. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13084. /***/ }),
  13085. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13086. /*!**************************************************!*\
  13087. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13088. \**************************************************/
  13089. /*! exports provided: FlyCameraKeyboardInput */
  13090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13091. "use strict";
  13092. __webpack_require__.r(__webpack_exports__);
  13093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13094. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13095. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13096. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13097. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13098. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13099. /**
  13100. * Listen to keyboard events to control the camera.
  13101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13102. */
  13103. var FlyCameraKeyboardInput = /** @class */ (function () {
  13104. function FlyCameraKeyboardInput() {
  13105. /**
  13106. * The list of keyboard keys used to control the forward move of the camera.
  13107. */
  13108. this.keysForward = [87];
  13109. /**
  13110. * The list of keyboard keys used to control the backward move of the camera.
  13111. */
  13112. this.keysBackward = [83];
  13113. /**
  13114. * The list of keyboard keys used to control the forward move of the camera.
  13115. */
  13116. this.keysUp = [69];
  13117. /**
  13118. * The list of keyboard keys used to control the backward move of the camera.
  13119. */
  13120. this.keysDown = [81];
  13121. /**
  13122. * The list of keyboard keys used to control the right strafe move of the camera.
  13123. */
  13124. this.keysRight = [68];
  13125. /**
  13126. * The list of keyboard keys used to control the left strafe move of the camera.
  13127. */
  13128. this.keysLeft = [65];
  13129. this._keys = new Array();
  13130. }
  13131. /**
  13132. * Attach the input controls to a specific dom element to get the input from.
  13133. * @param element Defines the element the controls should be listened from
  13134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13135. */
  13136. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13137. var _this = this;
  13138. if (this._onCanvasBlurObserver) {
  13139. return;
  13140. }
  13141. this._scene = this.camera.getScene();
  13142. this._engine = this._scene.getEngine();
  13143. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13144. _this._keys = [];
  13145. });
  13146. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13147. var evt = info.event;
  13148. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13149. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13150. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13151. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13152. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13153. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13154. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13155. var index = _this._keys.indexOf(evt.keyCode);
  13156. if (index === -1) {
  13157. _this._keys.push(evt.keyCode);
  13158. }
  13159. if (!noPreventDefault) {
  13160. evt.preventDefault();
  13161. }
  13162. }
  13163. }
  13164. else {
  13165. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13166. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13167. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13168. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13169. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13170. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13171. var index = _this._keys.indexOf(evt.keyCode);
  13172. if (index >= 0) {
  13173. _this._keys.splice(index, 1);
  13174. }
  13175. if (!noPreventDefault) {
  13176. evt.preventDefault();
  13177. }
  13178. }
  13179. }
  13180. });
  13181. };
  13182. /**
  13183. * Detach the current controls from the specified dom element.
  13184. * @param element Defines the element to stop listening the inputs from
  13185. */
  13186. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13187. if (this._scene) {
  13188. if (this._onKeyboardObserver) {
  13189. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13190. }
  13191. if (this._onCanvasBlurObserver) {
  13192. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13193. }
  13194. this._onKeyboardObserver = null;
  13195. this._onCanvasBlurObserver = null;
  13196. }
  13197. this._keys = [];
  13198. };
  13199. /**
  13200. * Gets the class name of the current intput.
  13201. * @returns the class name
  13202. */
  13203. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13204. return "FlyCameraKeyboardInput";
  13205. };
  13206. /** @hidden */
  13207. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13208. this._keys = [];
  13209. };
  13210. /**
  13211. * Get the friendly name associated with the input class.
  13212. * @returns the input friendly name
  13213. */
  13214. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13215. return "keyboard";
  13216. };
  13217. /**
  13218. * Update the current camera state depending on the inputs that have been used this frame.
  13219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13220. */
  13221. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13222. if (this._onKeyboardObserver) {
  13223. var camera = this.camera;
  13224. // Keyboard
  13225. for (var index = 0; index < this._keys.length; index++) {
  13226. var keyCode = this._keys[index];
  13227. var speed = camera._computeLocalCameraSpeed();
  13228. if (this.keysForward.indexOf(keyCode) !== -1) {
  13229. camera._localDirection.copyFromFloats(0, 0, speed);
  13230. }
  13231. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13232. camera._localDirection.copyFromFloats(0, 0, -speed);
  13233. }
  13234. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13235. camera._localDirection.copyFromFloats(0, speed, 0);
  13236. }
  13237. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13238. camera._localDirection.copyFromFloats(0, -speed, 0);
  13239. }
  13240. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13241. camera._localDirection.copyFromFloats(speed, 0, 0);
  13242. }
  13243. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13244. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13245. }
  13246. if (camera.getScene().useRightHandedSystem) {
  13247. camera._localDirection.z *= -1;
  13248. }
  13249. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13250. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13251. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13252. }
  13253. }
  13254. };
  13255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13257. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13260. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13263. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13266. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13269. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13272. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13273. return FlyCameraKeyboardInput;
  13274. }());
  13275. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13276. /***/ }),
  13277. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13278. /*!***********************************************!*\
  13279. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13280. \***********************************************/
  13281. /*! exports provided: FlyCameraMouseInput */
  13282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13283. "use strict";
  13284. __webpack_require__.r(__webpack_exports__);
  13285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13286. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13287. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13288. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13289. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13290. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13291. /**
  13292. * Listen to mouse events to control the camera.
  13293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13294. */
  13295. var FlyCameraMouseInput = /** @class */ (function () {
  13296. /**
  13297. * Listen to mouse events to control the camera.
  13298. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13300. */
  13301. function FlyCameraMouseInput(touchEnabled) {
  13302. if (touchEnabled === void 0) { touchEnabled = true; }
  13303. /**
  13304. * Defines the buttons associated with the input to handle camera rotation.
  13305. */
  13306. this.buttons = [0, 1, 2];
  13307. /**
  13308. * Assign buttons for Yaw control.
  13309. */
  13310. this.buttonsYaw = [-1, 0, 1];
  13311. /**
  13312. * Assign buttons for Pitch control.
  13313. */
  13314. this.buttonsPitch = [-1, 0, 1];
  13315. /**
  13316. * Assign buttons for Roll control.
  13317. */
  13318. this.buttonsRoll = [2];
  13319. /**
  13320. * Detect if any button is being pressed while mouse is moved.
  13321. * -1 = Mouse locked.
  13322. * 0 = Left button.
  13323. * 1 = Middle Button.
  13324. * 2 = Right Button.
  13325. */
  13326. this.activeButton = -1;
  13327. /**
  13328. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13329. * Higher values reduce its sensitivity.
  13330. */
  13331. this.angularSensibility = 1000.0;
  13332. this.previousPosition = null;
  13333. }
  13334. /**
  13335. * Attach the mouse control to the HTML DOM element.
  13336. * @param element Defines the element that listens to the input events.
  13337. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13338. */
  13339. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13340. var _this = this;
  13341. this.element = element;
  13342. this.noPreventDefault = noPreventDefault;
  13343. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13344. _this._pointerInput(p, s);
  13345. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13346. // Correct Roll by rate, if enabled.
  13347. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13348. if (_this.camera.rollCorrect) {
  13349. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13350. }
  13351. });
  13352. // Helper function to keep 'this'.
  13353. this._mousemoveCallback = function (e) {
  13354. _this._onMouseMove(e);
  13355. };
  13356. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13357. };
  13358. /**
  13359. * Detach the current controls from the specified dom element.
  13360. * @param element Defines the element to stop listening the inputs from
  13361. */
  13362. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13363. if (this._observer && element) {
  13364. this.camera.getScene().onPointerObservable.remove(this._observer);
  13365. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13366. if (this._mousemoveCallback) {
  13367. element.removeEventListener("mousemove", this._mousemoveCallback);
  13368. }
  13369. this._observer = null;
  13370. this._rollObserver = null;
  13371. this.previousPosition = null;
  13372. this.noPreventDefault = undefined;
  13373. }
  13374. };
  13375. /**
  13376. * Gets the class name of the current input.
  13377. * @returns the class name.
  13378. */
  13379. FlyCameraMouseInput.prototype.getClassName = function () {
  13380. return "FlyCameraMouseInput";
  13381. };
  13382. /**
  13383. * Get the friendly name associated with the input class.
  13384. * @returns the input's friendly name.
  13385. */
  13386. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13387. return "mouse";
  13388. };
  13389. // Track mouse movement, when the pointer is not locked.
  13390. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13391. var e = p.event;
  13392. var camera = this.camera;
  13393. var engine = camera.getEngine();
  13394. if (engine.isInVRExclusivePointerMode) {
  13395. return;
  13396. }
  13397. if (!this.touchEnabled && e.pointerType === "touch") {
  13398. return;
  13399. }
  13400. // Mouse is moved but an unknown mouse button is pressed.
  13401. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13402. return;
  13403. }
  13404. var srcElement = (e.srcElement || e.target);
  13405. // Mouse down.
  13406. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13407. try {
  13408. srcElement.setPointerCapture(e.pointerId);
  13409. }
  13410. catch (e) {
  13411. // Nothing to do with the error. Execution continues.
  13412. }
  13413. this.previousPosition = {
  13414. x: e.clientX,
  13415. y: e.clientY
  13416. };
  13417. this.activeButton = e.button;
  13418. if (!this.noPreventDefault) {
  13419. e.preventDefault();
  13420. this.element.focus();
  13421. }
  13422. }
  13423. else
  13424. // Mouse up.
  13425. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13426. try {
  13427. srcElement.releasePointerCapture(e.pointerId);
  13428. }
  13429. catch (e) {
  13430. // Nothing to do with the error. Execution continues.
  13431. }
  13432. this.activeButton = -1;
  13433. this.previousPosition = null;
  13434. if (!this.noPreventDefault) {
  13435. e.preventDefault();
  13436. }
  13437. }
  13438. else
  13439. // Mouse move.
  13440. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13441. if (!this.previousPosition || engine.isPointerLock) {
  13442. return;
  13443. }
  13444. var offsetX = e.clientX - this.previousPosition.x;
  13445. var offsetY = e.clientY - this.previousPosition.y;
  13446. this.rotateCamera(offsetX, offsetY);
  13447. this.previousPosition = {
  13448. x: e.clientX,
  13449. y: e.clientY
  13450. };
  13451. if (!this.noPreventDefault) {
  13452. e.preventDefault();
  13453. }
  13454. }
  13455. };
  13456. // Track mouse movement, when pointer is locked.
  13457. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13458. var camera = this.camera;
  13459. var engine = camera.getEngine();
  13460. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13461. return;
  13462. }
  13463. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13464. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13465. this.rotateCamera(offsetX, offsetY);
  13466. this.previousPosition = null;
  13467. if (!this.noPreventDefault) {
  13468. e.preventDefault();
  13469. }
  13470. };
  13471. /**
  13472. * Rotate camera by mouse offset.
  13473. */
  13474. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13475. var _this = this;
  13476. var camera = this.camera;
  13477. var scene = this.camera.getScene();
  13478. if (scene.useRightHandedSystem) {
  13479. offsetX *= -1;
  13480. }
  13481. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13482. offsetX *= -1;
  13483. }
  13484. var x = offsetX / this.angularSensibility;
  13485. var y = offsetY / this.angularSensibility;
  13486. // Initialize to current rotation.
  13487. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13488. var rotationChange;
  13489. // Pitch.
  13490. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13491. // Apply change in Radians to vector Angle.
  13492. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13493. // Apply Pitch to quaternion.
  13494. currentRotation.multiplyInPlace(rotationChange);
  13495. }
  13496. // Yaw.
  13497. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13498. // Apply change in Radians to vector Angle.
  13499. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13500. // Apply Yaw to quaternion.
  13501. currentRotation.multiplyInPlace(rotationChange);
  13502. // Add Roll, if banked turning is enabled, within Roll limit.
  13503. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13504. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13505. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13506. // Apply change in Radians to vector Angle.
  13507. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13508. // Apply Yaw to quaternion.
  13509. currentRotation.multiplyInPlace(rotationChange);
  13510. }
  13511. }
  13512. // Roll.
  13513. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13514. // Apply change in Radians to vector Angle.
  13515. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13516. // Track Rolling.
  13517. camera._trackRoll -= x;
  13518. // Apply Pitch to quaternion.
  13519. currentRotation.multiplyInPlace(rotationChange);
  13520. }
  13521. // Apply rotationQuaternion to Euler camera.rotation.
  13522. currentRotation.toEulerAnglesToRef(camera.rotation);
  13523. };
  13524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13526. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13529. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13530. return FlyCameraMouseInput;
  13531. }());
  13532. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13533. /***/ }),
  13534. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13535. /*!*********************************************************!*\
  13536. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13537. \*********************************************************/
  13538. /*! exports provided: FollowCameraKeyboardMoveInput */
  13539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13540. "use strict";
  13541. __webpack_require__.r(__webpack_exports__);
  13542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13543. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13544. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13545. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13546. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13547. /**
  13548. * Manage the keyboard inputs to control the movement of a follow camera.
  13549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13550. */
  13551. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13552. function FollowCameraKeyboardMoveInput() {
  13553. /**
  13554. * Defines the list of key codes associated with the up action (increase heightOffset)
  13555. */
  13556. this.keysHeightOffsetIncr = [38];
  13557. /**
  13558. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13559. */
  13560. this.keysHeightOffsetDecr = [40];
  13561. /**
  13562. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13563. */
  13564. this.keysHeightOffsetModifierAlt = false;
  13565. /**
  13566. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13567. */
  13568. this.keysHeightOffsetModifierCtrl = false;
  13569. /**
  13570. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13571. */
  13572. this.keysHeightOffsetModifierShift = false;
  13573. /**
  13574. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13575. */
  13576. this.keysRotationOffsetIncr = [37];
  13577. /**
  13578. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13579. */
  13580. this.keysRotationOffsetDecr = [39];
  13581. /**
  13582. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13583. */
  13584. this.keysRotationOffsetModifierAlt = false;
  13585. /**
  13586. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13587. */
  13588. this.keysRotationOffsetModifierCtrl = false;
  13589. /**
  13590. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13591. */
  13592. this.keysRotationOffsetModifierShift = false;
  13593. /**
  13594. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13595. */
  13596. this.keysRadiusIncr = [40];
  13597. /**
  13598. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13599. */
  13600. this.keysRadiusDecr = [38];
  13601. /**
  13602. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13603. */
  13604. this.keysRadiusModifierAlt = true;
  13605. /**
  13606. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13607. */
  13608. this.keysRadiusModifierCtrl = false;
  13609. /**
  13610. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13611. */
  13612. this.keysRadiusModifierShift = false;
  13613. /**
  13614. * Defines the rate of change of heightOffset.
  13615. */
  13616. this.heightSensibility = 1;
  13617. /**
  13618. * Defines the rate of change of rotationOffset.
  13619. */
  13620. this.rotationSensibility = 1;
  13621. /**
  13622. * Defines the rate of change of radius.
  13623. */
  13624. this.radiusSensibility = 1;
  13625. this._keys = new Array();
  13626. }
  13627. /**
  13628. * Attach the input controls to a specific dom element to get the input from.
  13629. * @param element Defines the element the controls should be listened from
  13630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13631. */
  13632. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13633. var _this = this;
  13634. if (this._onCanvasBlurObserver) {
  13635. return;
  13636. }
  13637. this._scene = this.camera.getScene();
  13638. this._engine = this._scene.getEngine();
  13639. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13640. _this._keys = [];
  13641. });
  13642. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13643. var evt = info.event;
  13644. if (!evt.metaKey) {
  13645. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13646. _this._ctrlPressed = evt.ctrlKey;
  13647. _this._altPressed = evt.altKey;
  13648. _this._shiftPressed = evt.shiftKey;
  13649. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13650. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13651. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13652. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13653. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13654. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13655. var index = _this._keys.indexOf(evt.keyCode);
  13656. if (index === -1) {
  13657. _this._keys.push(evt.keyCode);
  13658. }
  13659. if (evt.preventDefault) {
  13660. if (!noPreventDefault) {
  13661. evt.preventDefault();
  13662. }
  13663. }
  13664. }
  13665. }
  13666. else {
  13667. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13668. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13669. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13670. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13671. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13672. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13673. var index = _this._keys.indexOf(evt.keyCode);
  13674. if (index >= 0) {
  13675. _this._keys.splice(index, 1);
  13676. }
  13677. if (evt.preventDefault) {
  13678. if (!noPreventDefault) {
  13679. evt.preventDefault();
  13680. }
  13681. }
  13682. }
  13683. }
  13684. }
  13685. });
  13686. };
  13687. /**
  13688. * Detach the current controls from the specified dom element.
  13689. * @param element Defines the element to stop listening the inputs from
  13690. */
  13691. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13692. if (this._scene) {
  13693. if (this._onKeyboardObserver) {
  13694. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13695. }
  13696. if (this._onCanvasBlurObserver) {
  13697. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13698. }
  13699. this._onKeyboardObserver = null;
  13700. this._onCanvasBlurObserver = null;
  13701. }
  13702. this._keys = [];
  13703. };
  13704. /**
  13705. * Update the current camera state depending on the inputs that have been used this frame.
  13706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13707. */
  13708. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13709. var _this = this;
  13710. if (this._onKeyboardObserver) {
  13711. this._keys.forEach(function (keyCode) {
  13712. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13713. _this._modifierHeightOffset()) {
  13714. _this.camera.heightOffset += _this.heightSensibility;
  13715. }
  13716. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13717. _this._modifierHeightOffset()) {
  13718. _this.camera.heightOffset -= _this.heightSensibility;
  13719. }
  13720. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13721. _this._modifierRotationOffset()) {
  13722. _this.camera.rotationOffset += _this.rotationSensibility;
  13723. _this.camera.rotationOffset %= 360;
  13724. }
  13725. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13726. _this._modifierRotationOffset()) {
  13727. _this.camera.rotationOffset -= _this.rotationSensibility;
  13728. _this.camera.rotationOffset %= 360;
  13729. }
  13730. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13731. _this._modifierRadius()) {
  13732. _this.camera.radius += _this.radiusSensibility;
  13733. }
  13734. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13735. _this._modifierRadius()) {
  13736. _this.camera.radius -= _this.radiusSensibility;
  13737. }
  13738. });
  13739. }
  13740. };
  13741. /**
  13742. * Gets the class name of the current input.
  13743. * @returns the class name
  13744. */
  13745. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13746. return "FollowCameraKeyboardMoveInput";
  13747. };
  13748. /**
  13749. * Get the friendly name associated with the input class.
  13750. * @returns the input friendly name
  13751. */
  13752. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13753. return "keyboard";
  13754. };
  13755. /**
  13756. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13757. * allow modification of the heightOffset value.
  13758. */
  13759. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13760. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13761. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13762. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13763. };
  13764. /**
  13765. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13766. * allow modification of the rotationOffset value.
  13767. */
  13768. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13769. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13770. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13771. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13772. };
  13773. /**
  13774. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13775. * allow modification of the radius value.
  13776. */
  13777. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13778. return (this.keysRadiusModifierAlt === this._altPressed &&
  13779. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13780. this.keysRadiusModifierShift === this._shiftPressed);
  13781. };
  13782. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13783. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13784. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13785. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13786. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13787. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13788. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13790. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13791. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13792. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13793. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13794. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13795. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13796. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13797. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13798. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13799. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13802. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13805. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13806. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13807. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13808. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13811. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13814. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13817. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13820. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13823. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13826. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13829. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13832. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13835. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13836. return FollowCameraKeyboardMoveInput;
  13837. }());
  13838. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13839. /***/ }),
  13840. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13841. /*!*******************************************************!*\
  13842. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13843. \*******************************************************/
  13844. /*! exports provided: FollowCameraMouseWheelInput */
  13845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13846. "use strict";
  13847. __webpack_require__.r(__webpack_exports__);
  13848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13849. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13850. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13851. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13852. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13853. /**
  13854. * Manage the mouse wheel inputs to control a follow camera.
  13855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13856. */
  13857. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13858. function FollowCameraMouseWheelInput() {
  13859. /**
  13860. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  13861. */
  13862. this.axisControlRadius = true;
  13863. /**
  13864. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  13865. */
  13866. this.axisControlHeight = false;
  13867. /**
  13868. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  13869. */
  13870. this.axisControlRotation = false;
  13871. /**
  13872. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13873. * relation to mouseWheel events.
  13874. */
  13875. this.wheelPrecision = 3.0;
  13876. /**
  13877. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13878. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13879. */
  13880. this.wheelDeltaPercentage = 0;
  13881. }
  13882. /**
  13883. * Attach the input controls to a specific dom element to get the input from.
  13884. * @param element Defines the element the controls should be listened from
  13885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13886. */
  13887. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13888. var _this = this;
  13889. this._wheel = function (p, s) {
  13890. // sanity check - this should be a PointerWheel event.
  13891. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13892. return;
  13893. }
  13894. var event = p.event;
  13895. var delta = 0;
  13896. // Chrome, Safari: event.deltaY
  13897. // IE: event.wheelDelta
  13898. // Firefox: event.detail (inverted)
  13899. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13900. if (_this.wheelDeltaPercentage) {
  13901. console.assert((_this.axisControlRadius +
  13902. _this.axisControlHeight +
  13903. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13904. "controlls ONE axis. " +
  13905. "Currently enabled: " +
  13906. "axisControlRadius: " + _this.axisControlRadius +
  13907. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13908. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13909. if (_this.axisControlRadius) {
  13910. delta =
  13911. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13912. _this.camera.radius;
  13913. }
  13914. else if (_this.axisControlHeight) {
  13915. delta =
  13916. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13917. _this.camera.heightOffset;
  13918. }
  13919. else if (_this.axisControlRotation) {
  13920. delta =
  13921. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13922. _this.camera.rotationOffset;
  13923. }
  13924. }
  13925. else {
  13926. delta = wheelDelta * _this.wheelPrecision;
  13927. }
  13928. if (delta) {
  13929. if (_this.axisControlRadius) {
  13930. _this.camera.radius += delta;
  13931. }
  13932. else if (_this.axisControlHeight) {
  13933. _this.camera.heightOffset -= delta;
  13934. }
  13935. else if (_this.axisControlRotation) {
  13936. _this.camera.rotationOffset -= delta;
  13937. }
  13938. }
  13939. if (event.preventDefault) {
  13940. if (!noPreventDefault) {
  13941. event.preventDefault();
  13942. }
  13943. }
  13944. };
  13945. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13946. };
  13947. /**
  13948. * Detach the current controls from the specified dom element.
  13949. * @param element Defines the element to stop listening the inputs from
  13950. */
  13951. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13952. if (this._observer && element) {
  13953. this.camera.getScene().onPointerObservable.remove(this._observer);
  13954. this._observer = null;
  13955. this._wheel = null;
  13956. }
  13957. };
  13958. /**
  13959. * Gets the class name of the current intput.
  13960. * @returns the class name
  13961. */
  13962. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13963. return "ArcRotateCameraMouseWheelInput";
  13964. };
  13965. /**
  13966. * Get the friendly name associated with the input class.
  13967. * @returns the input friendly name
  13968. */
  13969. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13970. return "mousewheel";
  13971. };
  13972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13974. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  13975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13977. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  13978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13980. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  13981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13983. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13986. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13987. return FollowCameraMouseWheelInput;
  13988. }());
  13989. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  13990. /***/ }),
  13991. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  13992. /*!*****************************************************!*\
  13993. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  13994. \*****************************************************/
  13995. /*! exports provided: FollowCameraPointersInput */
  13996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13997. "use strict";
  13998. __webpack_require__.r(__webpack_exports__);
  13999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14000. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14001. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14002. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14003. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14004. /**
  14005. * Manage the pointers inputs to control an follow camera.
  14006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14007. */
  14008. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14010. function FollowCameraPointersInput() {
  14011. var _this = _super !== null && _super.apply(this, arguments) || this;
  14012. /**
  14013. * Defines the pointer angular sensibility along the X axis or how fast is
  14014. * the camera rotating.
  14015. * A negative number will reverse the axis direction.
  14016. */
  14017. _this.angularSensibilityX = 1;
  14018. /**
  14019. * Defines the pointer angular sensibility along the Y axis or how fast is
  14020. * the camera rotating.
  14021. * A negative number will reverse the axis direction.
  14022. */
  14023. _this.angularSensibilityY = 1;
  14024. /**
  14025. * Defines the pointer pinch precision or how fast is the camera zooming.
  14026. * A negative number will reverse the axis direction.
  14027. */
  14028. _this.pinchPrecision = 10000.0;
  14029. /**
  14030. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14031. * from 0.
  14032. * It defines the percentage of current camera.radius to use as delta when
  14033. * pinch zoom is used.
  14034. */
  14035. _this.pinchDeltaPercentage = 0;
  14036. /**
  14037. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14038. */
  14039. _this.axisXControlRadius = false;
  14040. /**
  14041. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14042. */
  14043. _this.axisXControlHeight = false;
  14044. /**
  14045. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14046. */
  14047. _this.axisXControlRotation = true;
  14048. /**
  14049. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14050. */
  14051. _this.axisYControlRadius = false;
  14052. /**
  14053. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14054. */
  14055. _this.axisYControlHeight = true;
  14056. /**
  14057. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14058. */
  14059. _this.axisYControlRotation = false;
  14060. /**
  14061. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14062. */
  14063. _this.axisPinchControlRadius = true;
  14064. /**
  14065. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14066. */
  14067. _this.axisPinchControlHeight = false;
  14068. /**
  14069. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14070. */
  14071. _this.axisPinchControlRotation = false;
  14072. /**
  14073. * Log error messages if basic misconfiguration has occurred.
  14074. */
  14075. _this.warningEnable = true;
  14076. /* Check for obvious misconfiguration. */
  14077. _this._warningCounter = 0;
  14078. return _this;
  14079. }
  14080. /**
  14081. * Gets the class name of the current input.
  14082. * @returns the class name
  14083. */
  14084. FollowCameraPointersInput.prototype.getClassName = function () {
  14085. return "FollowCameraPointersInput";
  14086. };
  14087. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14088. this._warning();
  14089. if (this.axisXControlRotation) {
  14090. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14091. }
  14092. else if (this.axisYControlRotation) {
  14093. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14094. }
  14095. if (this.axisXControlHeight) {
  14096. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14097. }
  14098. else if (this.axisYControlHeight) {
  14099. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14100. }
  14101. if (this.axisXControlRadius) {
  14102. this.camera.radius -= offsetX / this.angularSensibilityY;
  14103. }
  14104. else if (this.axisYControlRadius) {
  14105. this.camera.radius -= offsetY / this.angularSensibilityY;
  14106. }
  14107. };
  14108. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14109. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14110. // First time this method is called for new pinch.
  14111. // Next time this is called there will be a
  14112. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14113. return;
  14114. }
  14115. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14116. // Last time this method is called at the end of a pinch.
  14117. return;
  14118. }
  14119. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14120. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14121. if (this.pinchDeltaPercentage) {
  14122. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14123. if (this.axisPinchControlRotation) {
  14124. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14125. }
  14126. if (this.axisPinchControlHeight) {
  14127. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14128. }
  14129. if (this.axisPinchControlRadius) {
  14130. this.camera.radius -= pinchDelta * this.camera.radius;
  14131. }
  14132. }
  14133. else {
  14134. if (this.axisPinchControlRotation) {
  14135. this.camera.rotationOffset += pinchDelta;
  14136. }
  14137. if (this.axisPinchControlHeight) {
  14138. this.camera.heightOffset += pinchDelta;
  14139. }
  14140. if (this.axisPinchControlRadius) {
  14141. this.camera.radius -= pinchDelta;
  14142. }
  14143. }
  14144. };
  14145. FollowCameraPointersInput.prototype._warning = function () {
  14146. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14147. return;
  14148. }
  14149. var warn = "It probably only makes sense to control ONE camera " +
  14150. "property with each pointer axis. Set 'warningEnable = false' " +
  14151. "if you are sure. Currently enabled: ";
  14152. console.assert((this.axisXControlRotation +
  14153. this.axisXControlHeight +
  14154. this.axisXControlRadius) <= 1, warn +
  14155. "axisXControlRotation: " + this.axisXControlRotation +
  14156. ", axisXControlHeight: " + this.axisXControlHeight +
  14157. ", axisXControlRadius: " + this.axisXControlRadius);
  14158. console.assert((this.axisYControlRotation +
  14159. this.axisYControlHeight +
  14160. this.axisYControlRadius) <= 1, warn +
  14161. "axisYControlRotation: " + this.axisYControlRotation +
  14162. ", axisYControlHeight: " + this.axisYControlHeight +
  14163. ", axisYControlRadius: " + this.axisYControlRadius);
  14164. console.assert((this.axisPinchControlRotation +
  14165. this.axisPinchControlHeight +
  14166. this.axisPinchControlRadius) <= 1, warn +
  14167. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14168. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14169. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14170. };
  14171. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14172. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14173. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14174. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14175. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14176. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14177. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14178. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14179. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14180. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14181. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14182. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14183. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14184. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14185. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14186. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14187. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14188. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14189. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14190. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14191. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14192. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14193. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14194. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14195. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14197. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14198. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14199. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14200. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14201. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14202. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14203. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14204. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14206. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14209. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14210. return FollowCameraPointersInput;
  14211. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14212. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14213. /***/ }),
  14214. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14215. /*!************************************************************!*\
  14216. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14217. \************************************************************/
  14218. /*! exports provided: FreeCameraDeviceOrientationInput */
  14219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14220. "use strict";
  14221. __webpack_require__.r(__webpack_exports__);
  14222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14223. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14224. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14225. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14226. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14227. /**
  14228. * Add orientation input support to the input manager.
  14229. * @returns the current input manager
  14230. */
  14231. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14232. this.add(new FreeCameraDeviceOrientationInput());
  14233. return this;
  14234. };
  14235. /**
  14236. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14237. * Screen rotation is taken into account.
  14238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14239. */
  14240. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14241. /**
  14242. * Instantiates a new input
  14243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14244. */
  14245. function FreeCameraDeviceOrientationInput() {
  14246. var _this = this;
  14247. this._screenOrientationAngle = 0;
  14248. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14249. this._alpha = 0;
  14250. this._beta = 0;
  14251. this._gamma = 0;
  14252. this._orientationChanged = function () {
  14253. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14254. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14255. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14256. };
  14257. this._deviceOrientation = function (evt) {
  14258. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14259. _this._beta = evt.beta !== null ? evt.beta : 0;
  14260. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14261. };
  14262. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14263. this._orientationChanged();
  14264. }
  14265. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14266. /**
  14267. * Define the camera controlled by the input.
  14268. */
  14269. get: function () {
  14270. return this._camera;
  14271. },
  14272. set: function (camera) {
  14273. this._camera = camera;
  14274. if (this._camera != null && !this._camera.rotationQuaternion) {
  14275. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14276. }
  14277. },
  14278. enumerable: true,
  14279. configurable: true
  14280. });
  14281. /**
  14282. * Attach the input controls to a specific dom element to get the input from.
  14283. * @param element Defines the element the controls should be listened from
  14284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14285. */
  14286. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14287. window.addEventListener("orientationchange", this._orientationChanged);
  14288. window.addEventListener("deviceorientation", this._deviceOrientation);
  14289. //In certain cases, the attach control is called AFTER orientation was changed,
  14290. //So this is needed.
  14291. this._orientationChanged();
  14292. };
  14293. /**
  14294. * Detach the current controls from the specified dom element.
  14295. * @param element Defines the element to stop listening the inputs from
  14296. */
  14297. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14298. window.removeEventListener("orientationchange", this._orientationChanged);
  14299. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14300. this._alpha = 0;
  14301. };
  14302. /**
  14303. * Update the current camera state depending on the inputs that have been used this frame.
  14304. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14305. */
  14306. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14307. //if no device orientation provided, don't update the rotation.
  14308. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14309. if (!this._alpha) {
  14310. return;
  14311. }
  14312. _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);
  14313. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14314. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14315. //Mirror on XY Plane
  14316. this._camera.rotationQuaternion.z *= -1;
  14317. this._camera.rotationQuaternion.w *= -1;
  14318. };
  14319. /**
  14320. * Gets the class name of the current intput.
  14321. * @returns the class name
  14322. */
  14323. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14324. return "FreeCameraDeviceOrientationInput";
  14325. };
  14326. /**
  14327. * Get the friendly name associated with the input class.
  14328. * @returns the input friendly name
  14329. */
  14330. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14331. return "deviceOrientation";
  14332. };
  14333. return FreeCameraDeviceOrientationInput;
  14334. }());
  14335. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14336. /***/ }),
  14337. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14338. /*!**************************************************!*\
  14339. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14340. \**************************************************/
  14341. /*! exports provided: FreeCameraGamepadInput */
  14342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14343. "use strict";
  14344. __webpack_require__.r(__webpack_exports__);
  14345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14346. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14347. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14348. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14349. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14350. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14351. /**
  14352. * Manage the gamepad inputs to control a free camera.
  14353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14354. */
  14355. var FreeCameraGamepadInput = /** @class */ (function () {
  14356. function FreeCameraGamepadInput() {
  14357. /**
  14358. * Defines the gamepad rotation sensiblity.
  14359. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14360. */
  14361. this.gamepadAngularSensibility = 200;
  14362. /**
  14363. * Defines the gamepad move sensiblity.
  14364. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14365. */
  14366. this.gamepadMoveSensibility = 40;
  14367. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14368. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14369. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14370. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14371. }
  14372. /**
  14373. * Attach the input controls to a specific dom element to get the input from.
  14374. * @param element Defines the element the controls should be listened from
  14375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14376. */
  14377. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14378. var _this = this;
  14379. var manager = this.camera.getScene().gamepadManager;
  14380. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14381. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14382. // prioritize XBOX gamepads.
  14383. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14384. _this.gamepad = gamepad;
  14385. }
  14386. }
  14387. });
  14388. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14389. if (_this.gamepad === gamepad) {
  14390. _this.gamepad = null;
  14391. }
  14392. });
  14393. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14394. };
  14395. /**
  14396. * Detach the current controls from the specified dom element.
  14397. * @param element Defines the element to stop listening the inputs from
  14398. */
  14399. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14400. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14401. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14402. this.gamepad = null;
  14403. };
  14404. /**
  14405. * Update the current camera state depending on the inputs that have been used this frame.
  14406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14407. */
  14408. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14409. if (this.gamepad && this.gamepad.leftStick) {
  14410. var camera = this.camera;
  14411. var LSValues = this.gamepad.leftStick;
  14412. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14413. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14414. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14415. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14416. var RSValues = this.gamepad.rightStick;
  14417. if (RSValues) {
  14418. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14419. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14420. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14421. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14422. }
  14423. else {
  14424. RSValues = { x: 0, y: 0 };
  14425. }
  14426. if (!camera.rotationQuaternion) {
  14427. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14428. }
  14429. else {
  14430. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14431. }
  14432. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14433. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14434. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14435. camera.cameraDirection.addInPlace(this._deltaTransform);
  14436. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14437. camera.cameraRotation.addInPlace(this._vector2);
  14438. }
  14439. };
  14440. /**
  14441. * Gets the class name of the current intput.
  14442. * @returns the class name
  14443. */
  14444. FreeCameraGamepadInput.prototype.getClassName = function () {
  14445. return "FreeCameraGamepadInput";
  14446. };
  14447. /**
  14448. * Get the friendly name associated with the input class.
  14449. * @returns the input friendly name
  14450. */
  14451. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14452. return "gamepad";
  14453. };
  14454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14456. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14459. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14460. return FreeCameraGamepadInput;
  14461. }());
  14462. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14463. /***/ }),
  14464. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14465. /*!*******************************************************!*\
  14466. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14467. \*******************************************************/
  14468. /*! exports provided: FreeCameraKeyboardMoveInput */
  14469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14470. "use strict";
  14471. __webpack_require__.r(__webpack_exports__);
  14472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14473. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14474. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14475. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14476. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14477. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14478. /**
  14479. * Manage the keyboard inputs to control the movement of a free camera.
  14480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14481. */
  14482. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14483. function FreeCameraKeyboardMoveInput() {
  14484. /**
  14485. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14486. */
  14487. this.keysUp = [38];
  14488. /**
  14489. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14490. */
  14491. this.keysDown = [40];
  14492. /**
  14493. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14494. */
  14495. this.keysLeft = [37];
  14496. /**
  14497. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14498. */
  14499. this.keysRight = [39];
  14500. this._keys = new Array();
  14501. }
  14502. /**
  14503. * Attach the input controls to a specific dom element to get the input from.
  14504. * @param element Defines the element the controls should be listened from
  14505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14506. */
  14507. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14508. var _this = this;
  14509. if (this._onCanvasBlurObserver) {
  14510. return;
  14511. }
  14512. this._scene = this.camera.getScene();
  14513. this._engine = this._scene.getEngine();
  14514. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14515. _this._keys = [];
  14516. });
  14517. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14518. var evt = info.event;
  14519. if (!evt.metaKey) {
  14520. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14521. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14522. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14523. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14524. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14525. var index = _this._keys.indexOf(evt.keyCode);
  14526. if (index === -1) {
  14527. _this._keys.push(evt.keyCode);
  14528. }
  14529. if (!noPreventDefault) {
  14530. evt.preventDefault();
  14531. }
  14532. }
  14533. }
  14534. else {
  14535. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14536. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14537. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14538. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14539. var index = _this._keys.indexOf(evt.keyCode);
  14540. if (index >= 0) {
  14541. _this._keys.splice(index, 1);
  14542. }
  14543. if (!noPreventDefault) {
  14544. evt.preventDefault();
  14545. }
  14546. }
  14547. }
  14548. }
  14549. });
  14550. };
  14551. /**
  14552. * Detach the current controls from the specified dom element.
  14553. * @param element Defines the element to stop listening the inputs from
  14554. */
  14555. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14556. if (this._scene) {
  14557. if (this._onKeyboardObserver) {
  14558. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14559. }
  14560. if (this._onCanvasBlurObserver) {
  14561. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14562. }
  14563. this._onKeyboardObserver = null;
  14564. this._onCanvasBlurObserver = null;
  14565. }
  14566. this._keys = [];
  14567. };
  14568. /**
  14569. * Update the current camera state depending on the inputs that have been used this frame.
  14570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14571. */
  14572. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14573. if (this._onKeyboardObserver) {
  14574. var camera = this.camera;
  14575. // Keyboard
  14576. for (var index = 0; index < this._keys.length; index++) {
  14577. var keyCode = this._keys[index];
  14578. var speed = camera._computeLocalCameraSpeed();
  14579. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14580. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14581. }
  14582. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14583. camera._localDirection.copyFromFloats(0, 0, speed);
  14584. }
  14585. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14586. camera._localDirection.copyFromFloats(speed, 0, 0);
  14587. }
  14588. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14589. camera._localDirection.copyFromFloats(0, 0, -speed);
  14590. }
  14591. if (camera.getScene().useRightHandedSystem) {
  14592. camera._localDirection.z *= -1;
  14593. }
  14594. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14595. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14596. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14597. }
  14598. }
  14599. };
  14600. /**
  14601. * Gets the class name of the current intput.
  14602. * @returns the class name
  14603. */
  14604. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14605. return "FreeCameraKeyboardMoveInput";
  14606. };
  14607. /** @hidden */
  14608. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14609. this._keys = [];
  14610. };
  14611. /**
  14612. * Get the friendly name associated with the input class.
  14613. * @returns the input friendly name
  14614. */
  14615. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14616. return "keyboard";
  14617. };
  14618. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14620. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14623. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14624. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14625. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14626. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14629. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14630. return FreeCameraKeyboardMoveInput;
  14631. }());
  14632. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14633. /***/ }),
  14634. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14635. /*!************************************************!*\
  14636. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14637. \************************************************/
  14638. /*! exports provided: FreeCameraMouseInput */
  14639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14640. "use strict";
  14641. __webpack_require__.r(__webpack_exports__);
  14642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14643. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14644. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14645. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14646. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14647. /**
  14648. * Manage the mouse inputs to control the movement of a free camera.
  14649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14650. */
  14651. var FreeCameraMouseInput = /** @class */ (function () {
  14652. /**
  14653. * Manage the mouse inputs to control the movement of a free camera.
  14654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14655. * @param touchEnabled Defines if touch is enabled or not
  14656. */
  14657. function FreeCameraMouseInput(
  14658. /**
  14659. * Define if touch is enabled in the mouse input
  14660. */
  14661. touchEnabled) {
  14662. if (touchEnabled === void 0) { touchEnabled = true; }
  14663. this.touchEnabled = touchEnabled;
  14664. /**
  14665. * Defines the buttons associated with the input to handle camera move.
  14666. */
  14667. this.buttons = [0, 1, 2];
  14668. /**
  14669. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14670. */
  14671. this.angularSensibility = 2000.0;
  14672. this.previousPosition = null;
  14673. }
  14674. /**
  14675. * Attach the input controls to a specific dom element to get the input from.
  14676. * @param element Defines the element the controls should be listened from
  14677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14678. */
  14679. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14680. var _this = this;
  14681. var engine = this.camera.getEngine();
  14682. if (!this._pointerInput) {
  14683. this._pointerInput = function (p) {
  14684. var evt = p.event;
  14685. if (engine.isInVRExclusivePointerMode) {
  14686. return;
  14687. }
  14688. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14689. return;
  14690. }
  14691. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14692. return;
  14693. }
  14694. var srcElement = (evt.srcElement || evt.target);
  14695. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14696. try {
  14697. srcElement.setPointerCapture(evt.pointerId);
  14698. }
  14699. catch (e) {
  14700. //Nothing to do with the error. Execution will continue.
  14701. }
  14702. _this.previousPosition = {
  14703. x: evt.clientX,
  14704. y: evt.clientY
  14705. };
  14706. if (!noPreventDefault) {
  14707. evt.preventDefault();
  14708. element.focus();
  14709. }
  14710. }
  14711. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14712. try {
  14713. srcElement.releasePointerCapture(evt.pointerId);
  14714. }
  14715. catch (e) {
  14716. //Nothing to do with the error.
  14717. }
  14718. _this.previousPosition = null;
  14719. if (!noPreventDefault) {
  14720. evt.preventDefault();
  14721. }
  14722. }
  14723. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14724. if (!_this.previousPosition || engine.isPointerLock) {
  14725. return;
  14726. }
  14727. var offsetX = evt.clientX - _this.previousPosition.x;
  14728. if (_this.camera.getScene().useRightHandedSystem) {
  14729. offsetX *= -1;
  14730. }
  14731. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14732. offsetX *= -1;
  14733. }
  14734. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14735. var offsetY = evt.clientY - _this.previousPosition.y;
  14736. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14737. _this.previousPosition = {
  14738. x: evt.clientX,
  14739. y: evt.clientY
  14740. };
  14741. if (!noPreventDefault) {
  14742. evt.preventDefault();
  14743. }
  14744. }
  14745. };
  14746. }
  14747. this._onMouseMove = function (evt) {
  14748. if (!engine.isPointerLock) {
  14749. return;
  14750. }
  14751. if (engine.isInVRExclusivePointerMode) {
  14752. return;
  14753. }
  14754. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14755. if (_this.camera.getScene().useRightHandedSystem) {
  14756. offsetX *= -1;
  14757. }
  14758. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14759. offsetX *= -1;
  14760. }
  14761. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14762. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14763. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14764. _this.previousPosition = null;
  14765. if (!noPreventDefault) {
  14766. evt.preventDefault();
  14767. }
  14768. };
  14769. 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);
  14770. element.addEventListener("mousemove", this._onMouseMove, false);
  14771. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  14772. };
  14773. /**
  14774. * Called on JS contextmenu event.
  14775. * Override this method to provide functionality.
  14776. */
  14777. FreeCameraMouseInput.prototype.onContextMenu = function (evt) {
  14778. evt.preventDefault();
  14779. };
  14780. /**
  14781. * Detach the current controls from the specified dom element.
  14782. * @param element Defines the element to stop listening the inputs from
  14783. */
  14784. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14785. if (this._observer && element) {
  14786. this.camera.getScene().onPointerObservable.remove(this._observer);
  14787. if (this._onMouseMove) {
  14788. element.removeEventListener("mousemove", this._onMouseMove);
  14789. }
  14790. if (this.onContextMenu) {
  14791. element.removeEventListener("contextmenu", this.onContextMenu);
  14792. }
  14793. this._observer = null;
  14794. this._onMouseMove = null;
  14795. this.previousPosition = null;
  14796. }
  14797. };
  14798. /**
  14799. * Gets the class name of the current intput.
  14800. * @returns the class name
  14801. */
  14802. FreeCameraMouseInput.prototype.getClassName = function () {
  14803. return "FreeCameraMouseInput";
  14804. };
  14805. /**
  14806. * Get the friendly name associated with the input class.
  14807. * @returns the input friendly name
  14808. */
  14809. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14810. return "mouse";
  14811. };
  14812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14814. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14817. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14818. return FreeCameraMouseInput;
  14819. }());
  14820. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14821. /***/ }),
  14822. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14823. /*!************************************************!*\
  14824. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14825. \************************************************/
  14826. /*! exports provided: FreeCameraTouchInput */
  14827. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14828. "use strict";
  14829. __webpack_require__.r(__webpack_exports__);
  14830. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14831. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14832. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14833. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14834. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14835. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14836. /**
  14837. * Manage the touch inputs to control the movement of a free camera.
  14838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14839. */
  14840. var FreeCameraTouchInput = /** @class */ (function () {
  14841. function FreeCameraTouchInput() {
  14842. /**
  14843. * Defines the touch sensibility for rotation.
  14844. * The higher the faster.
  14845. */
  14846. this.touchAngularSensibility = 200000.0;
  14847. /**
  14848. * Defines the touch sensibility for move.
  14849. * The higher the faster.
  14850. */
  14851. this.touchMoveSensibility = 250.0;
  14852. this._offsetX = null;
  14853. this._offsetY = null;
  14854. this._pointerPressed = new Array();
  14855. }
  14856. /**
  14857. * Attach the input controls to a specific dom element to get the input from.
  14858. * @param element Defines the element the controls should be listened from
  14859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14860. */
  14861. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14862. var _this = this;
  14863. var previousPosition = null;
  14864. if (this._pointerInput === undefined) {
  14865. this._onLostFocus = function () {
  14866. _this._offsetX = null;
  14867. _this._offsetY = null;
  14868. };
  14869. this._pointerInput = function (p) {
  14870. var evt = p.event;
  14871. if (evt.pointerType === "mouse") {
  14872. return;
  14873. }
  14874. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14875. if (!noPreventDefault) {
  14876. evt.preventDefault();
  14877. }
  14878. _this._pointerPressed.push(evt.pointerId);
  14879. if (_this._pointerPressed.length !== 1) {
  14880. return;
  14881. }
  14882. previousPosition = {
  14883. x: evt.clientX,
  14884. y: evt.clientY
  14885. };
  14886. }
  14887. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14888. if (!noPreventDefault) {
  14889. evt.preventDefault();
  14890. }
  14891. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14892. if (index === -1) {
  14893. return;
  14894. }
  14895. _this._pointerPressed.splice(index, 1);
  14896. if (index != 0) {
  14897. return;
  14898. }
  14899. previousPosition = null;
  14900. _this._offsetX = null;
  14901. _this._offsetY = null;
  14902. }
  14903. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14904. if (!noPreventDefault) {
  14905. evt.preventDefault();
  14906. }
  14907. if (!previousPosition) {
  14908. return;
  14909. }
  14910. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14911. if (index != 0) {
  14912. return;
  14913. }
  14914. _this._offsetX = evt.clientX - previousPosition.x;
  14915. _this._offsetY = -(evt.clientY - previousPosition.y);
  14916. }
  14917. };
  14918. }
  14919. 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);
  14920. if (this._onLostFocus) {
  14921. element.addEventListener("blur", this._onLostFocus);
  14922. }
  14923. };
  14924. /**
  14925. * Detach the current controls from the specified dom element.
  14926. * @param element Defines the element to stop listening the inputs from
  14927. */
  14928. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14929. if (this._pointerInput && element) {
  14930. if (this._observer) {
  14931. this.camera.getScene().onPointerObservable.remove(this._observer);
  14932. this._observer = null;
  14933. }
  14934. if (this._onLostFocus) {
  14935. element.removeEventListener("blur", this._onLostFocus);
  14936. this._onLostFocus = null;
  14937. }
  14938. this._pointerPressed = [];
  14939. this._offsetX = null;
  14940. this._offsetY = null;
  14941. }
  14942. };
  14943. /**
  14944. * Update the current camera state depending on the inputs that have been used this frame.
  14945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14946. */
  14947. FreeCameraTouchInput.prototype.checkInputs = function () {
  14948. if (this._offsetX && this._offsetY) {
  14949. var camera = this.camera;
  14950. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14951. if (this._pointerPressed.length > 1) {
  14952. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14953. }
  14954. else {
  14955. var speed = camera._computeLocalCameraSpeed();
  14956. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14957. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14958. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14959. }
  14960. }
  14961. };
  14962. /**
  14963. * Gets the class name of the current intput.
  14964. * @returns the class name
  14965. */
  14966. FreeCameraTouchInput.prototype.getClassName = function () {
  14967. return "FreeCameraTouchInput";
  14968. };
  14969. /**
  14970. * Get the friendly name associated with the input class.
  14971. * @returns the input friendly name
  14972. */
  14973. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14974. return "touch";
  14975. };
  14976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14978. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14979. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14981. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14982. return FreeCameraTouchInput;
  14983. }());
  14984. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14985. /***/ }),
  14986. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14987. /*!**********************************************************!*\
  14988. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14989. \**********************************************************/
  14990. /*! exports provided: FreeCameraVirtualJoystickInput */
  14991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14992. "use strict";
  14993. __webpack_require__.r(__webpack_exports__);
  14994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14995. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14996. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14997. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14998. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14999. /**
  15000. * Add virtual joystick input support to the input manager.
  15001. * @returns the current input manager
  15002. */
  15003. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  15004. this.add(new FreeCameraVirtualJoystickInput());
  15005. return this;
  15006. };
  15007. /**
  15008. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  15009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15010. */
  15011. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15012. function FreeCameraVirtualJoystickInput() {
  15013. }
  15014. /**
  15015. * Gets the left stick of the virtual joystick.
  15016. * @returns The virtual Joystick
  15017. */
  15018. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15019. return this._leftjoystick;
  15020. };
  15021. /**
  15022. * Gets the right stick of the virtual joystick.
  15023. * @returns The virtual Joystick
  15024. */
  15025. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15026. return this._rightjoystick;
  15027. };
  15028. /**
  15029. * Update the current camera state depending on the inputs that have been used this frame.
  15030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15031. */
  15032. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15033. if (this._leftjoystick) {
  15034. var camera = this.camera;
  15035. var speed = camera._computeLocalCameraSpeed() * 50;
  15036. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15037. 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);
  15038. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15039. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15040. if (!this._leftjoystick.pressed) {
  15041. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15042. }
  15043. if (!this._rightjoystick.pressed) {
  15044. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15045. }
  15046. }
  15047. };
  15048. /**
  15049. * Attach the input controls to a specific dom element to get the input from.
  15050. * @param element Defines the element the controls should be listened from
  15051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15052. */
  15053. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15054. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15055. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15056. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15057. this._leftjoystick.setJoystickSensibility(0.15);
  15058. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15059. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15060. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15061. this._rightjoystick.reverseUpDown = true;
  15062. this._rightjoystick.setJoystickSensibility(0.05);
  15063. this._rightjoystick.setJoystickColor("yellow");
  15064. };
  15065. /**
  15066. * Detach the current controls from the specified dom element.
  15067. * @param element Defines the element to stop listening the inputs from
  15068. */
  15069. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15070. this._leftjoystick.releaseCanvas();
  15071. this._rightjoystick.releaseCanvas();
  15072. };
  15073. /**
  15074. * Gets the class name of the current intput.
  15075. * @returns the class name
  15076. */
  15077. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15078. return "FreeCameraVirtualJoystickInput";
  15079. };
  15080. /**
  15081. * Get the friendly name associated with the input class.
  15082. * @returns the input friendly name
  15083. */
  15084. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15085. return "virtualJoystick";
  15086. };
  15087. return FreeCameraVirtualJoystickInput;
  15088. }());
  15089. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15090. /***/ }),
  15091. /***/ "./Cameras/Inputs/index.ts":
  15092. /*!*********************************!*\
  15093. !*** ./Cameras/Inputs/index.ts ***!
  15094. \*********************************/
  15095. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15097. "use strict";
  15098. __webpack_require__.r(__webpack_exports__);
  15099. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15101. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15103. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15105. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15107. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15109. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15111. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15113. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15115. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15117. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15119. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15121. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15123. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15125. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15127. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15129. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15131. /***/ }),
  15132. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15133. /*!*********************************************************!*\
  15134. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15135. \*********************************************************/
  15136. /*! no exports provided */
  15137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15138. "use strict";
  15139. __webpack_require__.r(__webpack_exports__);
  15140. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15141. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15142. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15143. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15144. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15145. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15146. };
  15147. /***/ }),
  15148. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15149. /*!*************************************************!*\
  15150. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  15151. \*************************************************/
  15152. /*! no exports provided */
  15153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15154. "use strict";
  15155. __webpack_require__.r(__webpack_exports__);
  15156. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15157. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15158. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15159. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15160. 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;
  15161. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15162. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15163. };
  15164. /***/ }),
  15165. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15166. /*!***************************************!*\
  15167. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15168. \***************************************/
  15169. /*! no exports provided */
  15170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15171. "use strict";
  15172. __webpack_require__.r(__webpack_exports__);
  15173. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15174. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15175. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15176. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15177. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15178. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  15179. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15180. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15181. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15182. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15183. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15184. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15185. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15186. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15187. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15188. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15189. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15190. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15191. if (metrics.compensateDistortion) {
  15192. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15193. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15194. }
  15195. };
  15196. /***/ }),
  15197. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15198. /*!******************************************!*\
  15199. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15200. \******************************************/
  15201. /*! no exports provided */
  15202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15203. "use strict";
  15204. __webpack_require__.r(__webpack_exports__);
  15205. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15206. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15207. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15208. if (rigParams.vrDisplay) {
  15209. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15210. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15211. //Left eye
  15212. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15213. camera._rigCameras[0].setCameraRigParameter("left", true);
  15214. //leaving this for future reference
  15215. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15216. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15217. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15218. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15219. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15220. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15221. camera._rigCameras[0].parent = camera;
  15222. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15223. //Right eye
  15224. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15225. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15226. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15227. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15228. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15229. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15230. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15231. camera._rigCameras[1].parent = camera;
  15232. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15233. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  15234. camera._rigCameras[1]._skipRendering = true;
  15235. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  15236. }
  15237. }
  15238. };
  15239. /***/ }),
  15240. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15241. /*!*********************************************************!*\
  15242. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15243. \*********************************************************/
  15244. /*! exports provided: AnaglyphArcRotateCamera */
  15245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15246. "use strict";
  15247. __webpack_require__.r(__webpack_exports__);
  15248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15249. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15250. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15251. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15252. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15253. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15254. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15255. // Side effect import to define the stereoscopic mode.
  15256. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15257. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15258. });
  15259. /**
  15260. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15261. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15262. */
  15263. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15264. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15265. /**
  15266. * Creates a new AnaglyphArcRotateCamera
  15267. * @param name defines camera name
  15268. * @param alpha defines alpha angle (in radians)
  15269. * @param beta defines beta angle (in radians)
  15270. * @param radius defines radius
  15271. * @param target defines camera target
  15272. * @param interaxialDistance defines distance between each color axis
  15273. * @param scene defines the hosting scene
  15274. */
  15275. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15276. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15277. _this.interaxialDistance = interaxialDistance;
  15278. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15279. return _this;
  15280. }
  15281. /**
  15282. * Gets camera class name
  15283. * @returns AnaglyphArcRotateCamera
  15284. */
  15285. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15286. return "AnaglyphArcRotateCamera";
  15287. };
  15288. return AnaglyphArcRotateCamera;
  15289. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15290. /***/ }),
  15291. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15292. /*!****************************************************!*\
  15293. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15294. \****************************************************/
  15295. /*! exports provided: AnaglyphFreeCamera */
  15296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15297. "use strict";
  15298. __webpack_require__.r(__webpack_exports__);
  15299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  15300. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15301. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15302. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15303. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15304. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15305. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15306. // Side effect import to define the stereoscopic mode.
  15307. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  15308. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15309. });
  15310. /**
  15311. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15312. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15313. */
  15314. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15315. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15316. /**
  15317. * Creates a new AnaglyphFreeCamera
  15318. * @param name defines camera name
  15319. * @param position defines initial position
  15320. * @param interaxialDistance defines distance between each color axis
  15321. * @param scene defines the hosting scene
  15322. */
  15323. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  15324. var _this = _super.call(this, name, position, scene) || this;
  15325. _this.interaxialDistance = interaxialDistance;
  15326. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15327. return _this;
  15328. }
  15329. /**
  15330. * Gets camera class name
  15331. * @returns AnaglyphFreeCamera
  15332. */
  15333. AnaglyphFreeCamera.prototype.getClassName = function () {
  15334. return "AnaglyphFreeCamera";
  15335. };
  15336. return AnaglyphFreeCamera;
  15337. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15338. /***/ }),
  15339. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15340. /*!*******************************************************!*\
  15341. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15342. \*******************************************************/
  15343. /*! exports provided: AnaglyphGamepadCamera */
  15344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15345. "use strict";
  15346. __webpack_require__.r(__webpack_exports__);
  15347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  15348. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15349. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15350. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15351. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15352. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15353. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15354. // Side effect import to define the stereoscopic mode.
  15355. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  15356. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15357. });
  15358. /**
  15359. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15360. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15361. */
  15362. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15363. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15364. /**
  15365. * Creates a new AnaglyphGamepadCamera
  15366. * @param name defines camera name
  15367. * @param position defines initial position
  15368. * @param interaxialDistance defines distance between each color axis
  15369. * @param scene defines the hosting scene
  15370. */
  15371. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  15372. var _this = _super.call(this, name, position, scene) || this;
  15373. _this.interaxialDistance = interaxialDistance;
  15374. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15375. return _this;
  15376. }
  15377. /**
  15378. * Gets camera class name
  15379. * @returns AnaglyphGamepadCamera
  15380. */
  15381. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15382. return "AnaglyphGamepadCamera";
  15383. };
  15384. return AnaglyphGamepadCamera;
  15385. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15386. /***/ }),
  15387. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15388. /*!*********************************************************!*\
  15389. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15390. \*********************************************************/
  15391. /*! exports provided: AnaglyphUniversalCamera */
  15392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15393. "use strict";
  15394. __webpack_require__.r(__webpack_exports__);
  15395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15396. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15397. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15398. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15399. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15400. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15401. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15402. // Side effect import to define the stereoscopic mode.
  15403. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15404. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15405. });
  15406. /**
  15407. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15408. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15409. */
  15410. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15411. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15412. /**
  15413. * Creates a new AnaglyphUniversalCamera
  15414. * @param name defines camera name
  15415. * @param position defines initial position
  15416. * @param interaxialDistance defines distance between each color axis
  15417. * @param scene defines the hosting scene
  15418. */
  15419. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15420. var _this = _super.call(this, name, position, scene) || this;
  15421. _this.interaxialDistance = interaxialDistance;
  15422. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15423. return _this;
  15424. }
  15425. /**
  15426. * Gets camera class name
  15427. * @returns AnaglyphUniversalCamera
  15428. */
  15429. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15430. return "AnaglyphUniversalCamera";
  15431. };
  15432. return AnaglyphUniversalCamera;
  15433. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15434. /***/ }),
  15435. /***/ "./Cameras/Stereoscopic/index.ts":
  15436. /*!***************************************!*\
  15437. !*** ./Cameras/Stereoscopic/index.ts ***!
  15438. \***************************************/
  15439. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15441. "use strict";
  15442. __webpack_require__.r(__webpack_exports__);
  15443. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15445. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15447. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15449. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15451. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15453. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15455. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15457. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15459. /***/ }),
  15460. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15461. /*!*************************************************************!*\
  15462. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15463. \*************************************************************/
  15464. /*! exports provided: StereoscopicArcRotateCamera */
  15465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15466. "use strict";
  15467. __webpack_require__.r(__webpack_exports__);
  15468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15469. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15470. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15471. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15472. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15473. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15474. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15475. // Side effect import to define the stereoscopic mode.
  15476. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15477. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15478. });
  15479. /**
  15480. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15481. * @see http://doc.babylonjs.com/features/cameras
  15482. */
  15483. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15484. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15485. /**
  15486. * Creates a new StereoscopicArcRotateCamera
  15487. * @param name defines camera name
  15488. * @param alpha defines alpha angle (in radians)
  15489. * @param beta defines beta angle (in radians)
  15490. * @param radius defines radius
  15491. * @param target defines camera target
  15492. * @param interaxialDistance defines distance between each color axis
  15493. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15494. * @param scene defines the hosting scene
  15495. */
  15496. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15497. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15498. _this.interaxialDistance = interaxialDistance;
  15499. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15500. _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 });
  15501. return _this;
  15502. }
  15503. /**
  15504. * Gets camera class name
  15505. * @returns StereoscopicArcRotateCamera
  15506. */
  15507. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15508. return "StereoscopicArcRotateCamera";
  15509. };
  15510. return StereoscopicArcRotateCamera;
  15511. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15512. /***/ }),
  15513. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15514. /*!********************************************************!*\
  15515. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15516. \********************************************************/
  15517. /*! exports provided: StereoscopicFreeCamera */
  15518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15519. "use strict";
  15520. __webpack_require__.r(__webpack_exports__);
  15521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15522. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15523. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15524. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15525. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15526. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15527. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15528. // Side effect import to define the stereoscopic mode.
  15529. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15530. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15531. });
  15532. /**
  15533. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15534. * @see http://doc.babylonjs.com/features/cameras
  15535. */
  15536. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15537. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15538. /**
  15539. * Creates a new StereoscopicFreeCamera
  15540. * @param name defines camera name
  15541. * @param position defines initial position
  15542. * @param interaxialDistance defines distance between each color axis
  15543. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15544. * @param scene defines the hosting scene
  15545. */
  15546. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15547. var _this = _super.call(this, name, position, scene) || this;
  15548. _this.interaxialDistance = interaxialDistance;
  15549. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15550. _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 });
  15551. return _this;
  15552. }
  15553. /**
  15554. * Gets camera class name
  15555. * @returns StereoscopicFreeCamera
  15556. */
  15557. StereoscopicFreeCamera.prototype.getClassName = function () {
  15558. return "StereoscopicFreeCamera";
  15559. };
  15560. return StereoscopicFreeCamera;
  15561. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15562. /***/ }),
  15563. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15564. /*!***********************************************************!*\
  15565. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15566. \***********************************************************/
  15567. /*! exports provided: StereoscopicGamepadCamera */
  15568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15569. "use strict";
  15570. __webpack_require__.r(__webpack_exports__);
  15571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15572. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15573. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15574. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15575. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15576. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15577. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15578. // Side effect import to define the stereoscopic mode.
  15579. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15580. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15581. });
  15582. /**
  15583. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15584. * @see http://doc.babylonjs.com/features/cameras
  15585. */
  15586. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15587. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15588. /**
  15589. * Creates a new StereoscopicGamepadCamera
  15590. * @param name defines camera name
  15591. * @param position defines initial position
  15592. * @param interaxialDistance defines distance between each color axis
  15593. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15594. * @param scene defines the hosting scene
  15595. */
  15596. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15597. var _this = _super.call(this, name, position, scene) || this;
  15598. _this.interaxialDistance = interaxialDistance;
  15599. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15600. _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 });
  15601. return _this;
  15602. }
  15603. /**
  15604. * Gets camera class name
  15605. * @returns StereoscopicGamepadCamera
  15606. */
  15607. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15608. return "StereoscopicGamepadCamera";
  15609. };
  15610. return StereoscopicGamepadCamera;
  15611. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15612. /***/ }),
  15613. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15614. /*!*************************************************************!*\
  15615. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15616. \*************************************************************/
  15617. /*! exports provided: StereoscopicUniversalCamera */
  15618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15619. "use strict";
  15620. __webpack_require__.r(__webpack_exports__);
  15621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15622. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15623. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15624. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15625. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15626. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15627. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15628. // Side effect import to define the stereoscopic mode.
  15629. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15630. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15631. });
  15632. /**
  15633. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15634. * @see http://doc.babylonjs.com/features/cameras
  15635. */
  15636. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15637. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15638. /**
  15639. * Creates a new StereoscopicUniversalCamera
  15640. * @param name defines camera name
  15641. * @param position defines initial position
  15642. * @param interaxialDistance defines distance between each color axis
  15643. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15644. * @param scene defines the hosting scene
  15645. */
  15646. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15647. var _this = _super.call(this, name, position, scene) || this;
  15648. _this.interaxialDistance = interaxialDistance;
  15649. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15650. _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 });
  15651. return _this;
  15652. }
  15653. /**
  15654. * Gets camera class name
  15655. * @returns StereoscopicUniversalCamera
  15656. */
  15657. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15658. return "StereoscopicUniversalCamera";
  15659. };
  15660. return StereoscopicUniversalCamera;
  15661. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15662. /***/ }),
  15663. /***/ "./Cameras/VR/index.ts":
  15664. /*!*****************************!*\
  15665. !*** ./Cameras/VR/index.ts ***!
  15666. \*****************************/
  15667. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15669. "use strict";
  15670. __webpack_require__.r(__webpack_exports__);
  15671. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15673. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15675. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15677. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15679. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  15681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15682. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15684. /***/ }),
  15685. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15686. /*!***************************************!*\
  15687. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15688. \***************************************/
  15689. /*! exports provided: VRCameraMetrics */
  15690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15691. "use strict";
  15692. __webpack_require__.r(__webpack_exports__);
  15693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15694. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15695. /**
  15696. * This represents all the required metrics to create a VR camera.
  15697. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15698. */
  15699. var VRCameraMetrics = /** @class */ (function () {
  15700. function VRCameraMetrics() {
  15701. /**
  15702. * Define if the current vr camera should compensate the distortion of the lense or not.
  15703. */
  15704. this.compensateDistortion = true;
  15705. }
  15706. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15707. /**
  15708. * Gets the rendering aspect ratio based on the provided resolutions.
  15709. */
  15710. get: function () {
  15711. return this.hResolution / (2 * this.vResolution);
  15712. },
  15713. enumerable: true,
  15714. configurable: true
  15715. });
  15716. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15717. /**
  15718. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15719. */
  15720. get: function () {
  15721. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15722. },
  15723. enumerable: true,
  15724. configurable: true
  15725. });
  15726. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15727. /**
  15728. * @hidden
  15729. */
  15730. get: function () {
  15731. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15732. var h = (4 * meters) / this.hScreenSize;
  15733. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15734. },
  15735. enumerable: true,
  15736. configurable: true
  15737. });
  15738. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15739. /**
  15740. * @hidden
  15741. */
  15742. get: function () {
  15743. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15744. var h = (4 * meters) / this.hScreenSize;
  15745. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15746. },
  15747. enumerable: true,
  15748. configurable: true
  15749. });
  15750. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15751. /**
  15752. * @hidden
  15753. */
  15754. get: function () {
  15755. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15756. },
  15757. enumerable: true,
  15758. configurable: true
  15759. });
  15760. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15761. /**
  15762. * @hidden
  15763. */
  15764. get: function () {
  15765. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15766. },
  15767. enumerable: true,
  15768. configurable: true
  15769. });
  15770. /**
  15771. * Get the default VRMetrics based on the most generic setup.
  15772. * @returns the default vr metrics
  15773. */
  15774. VRCameraMetrics.GetDefault = function () {
  15775. var result = new VRCameraMetrics();
  15776. result.hResolution = 1280;
  15777. result.vResolution = 800;
  15778. result.hScreenSize = 0.149759993;
  15779. result.vScreenSize = 0.0935999975;
  15780. result.vScreenCenter = 0.0467999987;
  15781. result.eyeToScreenDistance = 0.0410000011;
  15782. result.lensSeparationDistance = 0.0635000020;
  15783. result.interpupillaryDistance = 0.0640000030;
  15784. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15785. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15786. result.postProcessScaleFactor = 1.714605507808412;
  15787. result.lensCenterOffset = 0.151976421;
  15788. return result;
  15789. };
  15790. return VRCameraMetrics;
  15791. }());
  15792. /***/ }),
  15793. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15794. /*!**********************************************************!*\
  15795. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15796. \**********************************************************/
  15797. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15799. "use strict";
  15800. __webpack_require__.r(__webpack_exports__);
  15801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15802. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15803. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15804. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15805. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15806. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15807. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15808. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15809. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15810. // Side effect import to define the stereoscopic mode.
  15811. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15812. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15813. });
  15814. /**
  15815. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15816. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15817. */
  15818. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15819. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15820. /**
  15821. * Creates a new VRDeviceOrientationArcRotateCamera
  15822. * @param name defines camera name
  15823. * @param alpha defines the camera rotation along the logitudinal axis
  15824. * @param beta defines the camera rotation along the latitudinal axis
  15825. * @param radius defines the camera distance from its target
  15826. * @param target defines the camera target
  15827. * @param scene defines the scene the camera belongs to
  15828. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15829. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15830. */
  15831. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15832. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15833. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15834. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15835. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15836. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15837. _this.inputs.addVRDeviceOrientation();
  15838. return _this;
  15839. }
  15840. /**
  15841. * Gets camera class name
  15842. * @returns VRDeviceOrientationArcRotateCamera
  15843. */
  15844. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15845. return "VRDeviceOrientationArcRotateCamera";
  15846. };
  15847. return VRDeviceOrientationArcRotateCamera;
  15848. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15849. /***/ }),
  15850. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15851. /*!*****************************************************!*\
  15852. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15853. \*****************************************************/
  15854. /*! exports provided: VRDeviceOrientationFreeCamera */
  15855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15856. "use strict";
  15857. __webpack_require__.r(__webpack_exports__);
  15858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15859. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15860. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15861. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15862. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15863. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15864. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15865. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15866. // Side effect import to define the stereoscopic mode.
  15867. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15868. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15869. });
  15870. /**
  15871. * Camera used to simulate VR rendering (based on FreeCamera)
  15872. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15873. */
  15874. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15875. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15876. /**
  15877. * Creates a new VRDeviceOrientationFreeCamera
  15878. * @param name defines camera name
  15879. * @param position defines the start position of the camera
  15880. * @param scene defines the scene the camera belongs to
  15881. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15882. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15883. */
  15884. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15885. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15886. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15887. var _this = _super.call(this, name, position, scene) || this;
  15888. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15889. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15890. return _this;
  15891. }
  15892. /**
  15893. * Gets camera class name
  15894. * @returns VRDeviceOrientationFreeCamera
  15895. */
  15896. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15897. return "VRDeviceOrientationFreeCamera";
  15898. };
  15899. return VRDeviceOrientationFreeCamera;
  15900. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15901. /***/ }),
  15902. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15903. /*!********************************************************!*\
  15904. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15905. \********************************************************/
  15906. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15908. "use strict";
  15909. __webpack_require__.r(__webpack_exports__);
  15910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15912. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15913. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15914. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15915. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15916. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15917. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15918. });
  15919. /**
  15920. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15921. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15922. */
  15923. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15925. /**
  15926. * Creates a new VRDeviceOrientationGamepadCamera
  15927. * @param name defines camera name
  15928. * @param position defines the start position of the camera
  15929. * @param scene defines the scene the camera belongs to
  15930. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15931. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15932. */
  15933. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15934. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15935. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15936. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15937. _this.inputs.addGamepad();
  15938. return _this;
  15939. }
  15940. /**
  15941. * Gets camera class name
  15942. * @returns VRDeviceOrientationGamepadCamera
  15943. */
  15944. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15945. return "VRDeviceOrientationGamepadCamera";
  15946. };
  15947. return VRDeviceOrientationGamepadCamera;
  15948. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15949. /***/ }),
  15950. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15951. /*!******************************************!*\
  15952. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15953. \******************************************/
  15954. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  15955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15956. "use strict";
  15957. __webpack_require__.r(__webpack_exports__);
  15958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  15959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15960. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15961. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15962. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15963. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15964. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15965. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15966. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15967. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15968. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15969. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15970. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15971. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15972. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15973. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15974. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15975. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15976. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15977. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15978. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15979. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15980. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15981. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15982. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  15983. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  15984. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  15985. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  15986. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  15987. var VRExperienceHelperGazer = /** @class */ (function () {
  15988. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15989. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15990. this.scene = scene;
  15991. /** @hidden */
  15992. this._pointerDownOnMeshAsked = false;
  15993. /** @hidden */
  15994. this._isActionableMesh = false;
  15995. /** @hidden */
  15996. this._teleportationRequestInitiated = false;
  15997. /** @hidden */
  15998. this._teleportationBackRequestInitiated = false;
  15999. /** @hidden */
  16000. this._rotationRightAsked = false;
  16001. /** @hidden */
  16002. this._rotationLeftAsked = false;
  16003. /** @hidden */
  16004. this._dpadPressed = true;
  16005. /** @hidden */
  16006. this._activePointer = false;
  16007. this._id = VRExperienceHelperGazer._idCounter++;
  16008. // Gaze tracker
  16009. if (!gazeTrackerToClone) {
  16010. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16011. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16012. this._gazeTracker.isPickable = false;
  16013. this._gazeTracker.isVisible = false;
  16014. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  16015. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  16016. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16017. targetMat.backFaceCulling = false;
  16018. this._gazeTracker.material = targetMat;
  16019. }
  16020. else {
  16021. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16022. }
  16023. }
  16024. /** @hidden */
  16025. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16026. 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));
  16027. };
  16028. /** @hidden */
  16029. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16030. this._pointerDownOnMeshAsked = true;
  16031. if (this._currentHit) {
  16032. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16033. }
  16034. };
  16035. /** @hidden */
  16036. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16037. if (this._currentHit) {
  16038. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16039. }
  16040. this._pointerDownOnMeshAsked = false;
  16041. };
  16042. /** @hidden */
  16043. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16044. this._activePointer = true;
  16045. };
  16046. /** @hidden */
  16047. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16048. this._activePointer = false;
  16049. };
  16050. /** @hidden */
  16051. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16052. if (distance === void 0) { distance = 100; }
  16053. };
  16054. VRExperienceHelperGazer.prototype.dispose = function () {
  16055. this._interactionsEnabled = false;
  16056. this._teleportationEnabled = false;
  16057. if (this._gazeTracker) {
  16058. this._gazeTracker.dispose();
  16059. }
  16060. };
  16061. VRExperienceHelperGazer._idCounter = 0;
  16062. return VRExperienceHelperGazer;
  16063. }());
  16064. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16065. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16066. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16067. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16068. _this.webVRController = webVRController;
  16069. // Laser pointer
  16070. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16071. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  16072. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16073. laserPointerMaterial.alpha = 0.6;
  16074. _this._laserPointer.material = laserPointerMaterial;
  16075. _this._laserPointer.rotation.x = Math.PI / 2;
  16076. _this._laserPointer.position.z = -0.5;
  16077. _this._laserPointer.isVisible = false;
  16078. _this._laserPointer.isPickable = false;
  16079. if (!webVRController.mesh) {
  16080. // Create an empty mesh that is used prior to loading the high quality model
  16081. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  16082. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  16083. preloadPointerPose.rotation.x = -0.7;
  16084. preloadMesh.addChild(preloadPointerPose);
  16085. webVRController.attachToMesh(preloadMesh);
  16086. }
  16087. _this._setLaserPointerParent(webVRController.mesh);
  16088. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16089. _this._setLaserPointerParent(mesh);
  16090. });
  16091. return _this;
  16092. }
  16093. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16094. return this.webVRController.getForwardRay(length);
  16095. };
  16096. /** @hidden */
  16097. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16098. _super.prototype._activatePointer.call(this);
  16099. this._laserPointer.isVisible = true;
  16100. };
  16101. /** @hidden */
  16102. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16103. _super.prototype._deactivatePointer.call(this);
  16104. this._laserPointer.isVisible = false;
  16105. };
  16106. /** @hidden */
  16107. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16108. this._laserPointer.material.emissiveColor = color;
  16109. };
  16110. /** @hidden */
  16111. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16112. var makeNotPick = function (root) {
  16113. root.isPickable = false;
  16114. root.getChildMeshes().forEach(function (c) {
  16115. makeNotPick(c);
  16116. });
  16117. };
  16118. makeNotPick(mesh);
  16119. var meshChildren = mesh.getChildren(undefined, false);
  16120. var laserParent = mesh;
  16121. this.webVRController._pointingPoseNode = null;
  16122. for (var i = 0; i < meshChildren.length; i++) {
  16123. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16124. laserParent = meshChildren[i];
  16125. this.webVRController._pointingPoseNode = laserParent;
  16126. break;
  16127. }
  16128. }
  16129. this._laserPointer.parent = laserParent;
  16130. };
  16131. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16132. if (distance === void 0) { distance = 100; }
  16133. this._laserPointer.scaling.y = distance;
  16134. this._laserPointer.position.z = -distance / 2;
  16135. };
  16136. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16137. _super.prototype.dispose.call(this);
  16138. this._laserPointer.dispose();
  16139. if (this._meshAttachedObserver) {
  16140. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16141. }
  16142. };
  16143. return VRExperienceHelperControllerGazer;
  16144. }(VRExperienceHelperGazer));
  16145. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16147. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16148. var _this = _super.call(this, scene) || this;
  16149. _this.getCamera = getCamera;
  16150. return _this;
  16151. }
  16152. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16153. var camera = this.getCamera();
  16154. if (camera) {
  16155. return camera.getForwardRay(length);
  16156. }
  16157. else {
  16158. 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());
  16159. }
  16160. };
  16161. return VRExperienceHelperCameraGazer;
  16162. }(VRExperienceHelperGazer));
  16163. /**
  16164. * Event containing information after VR has been entered
  16165. */
  16166. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16167. function OnAfterEnteringVRObservableEvent() {
  16168. }
  16169. return OnAfterEnteringVRObservableEvent;
  16170. }());
  16171. /**
  16172. * Helps to quickly add VR support to an existing scene.
  16173. * See http://doc.babylonjs.com/how_to/webvr_helper
  16174. */
  16175. var VRExperienceHelper = /** @class */ (function () {
  16176. /**
  16177. * Instantiates a VRExperienceHelper.
  16178. * Helps to quickly add VR support to an existing scene.
  16179. * @param scene The scene the VRExperienceHelper belongs to.
  16180. * @param webVROptions Options to modify the vr experience helper's behavior.
  16181. */
  16182. function VRExperienceHelper(scene,
  16183. /** Options to modify the vr experience helper's behavior. */
  16184. webVROptions) {
  16185. if (webVROptions === void 0) { webVROptions = {}; }
  16186. var _this = this;
  16187. this.webVROptions = webVROptions;
  16188. // Can the system support WebVR, even if a headset isn't plugged in?
  16189. this._webVRsupported = false;
  16190. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16191. this._webVRready = false;
  16192. // Are we waiting for the requestPresent callback to complete?
  16193. this._webVRrequesting = false;
  16194. // Are we presenting to the headset right now? (this is the vrDevice state)
  16195. this._webVRpresenting = false;
  16196. // Are we presenting in the fullscreen fallback?
  16197. this._fullscreenVRpresenting = false;
  16198. /**
  16199. * Observable raised right before entering VR.
  16200. */
  16201. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16202. /**
  16203. * Observable raised when entering VR has completed.
  16204. */
  16205. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16206. /**
  16207. * Observable raised when exiting VR.
  16208. */
  16209. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16210. /**
  16211. * Observable raised when controller mesh is loaded.
  16212. */
  16213. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16214. this._useCustomVRButton = false;
  16215. this._teleportationRequested = false;
  16216. this._teleportActive = false;
  16217. this._floorMeshesCollection = [];
  16218. this._rotationAllowed = true;
  16219. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16220. this._isDefaultTeleportationTarget = true;
  16221. this._teleportationFillColor = "#444444";
  16222. this._teleportationBorderColor = "#FFFFFF";
  16223. this._rotationAngle = 0;
  16224. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16225. this._padSensibilityUp = 0.65;
  16226. this._padSensibilityDown = 0.35;
  16227. this._leftController = null;
  16228. this._rightController = null;
  16229. /**
  16230. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16231. */
  16232. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16233. /**
  16234. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16235. */
  16236. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16237. /**
  16238. * Observable raised before camera teleportation
  16239. */
  16240. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16241. /**
  16242. * Observable raised after camera teleportation
  16243. */
  16244. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16245. /**
  16246. * Observable raised when current selected mesh gets unselected
  16247. */
  16248. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16249. /**
  16250. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16251. */
  16252. this.teleportationEnabled = true;
  16253. this._teleportationInitialized = false;
  16254. this._interactionsEnabled = false;
  16255. this._interactionsRequested = false;
  16256. this._displayGaze = true;
  16257. this._displayLaserPointer = true;
  16258. /**
  16259. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16260. */
  16261. this.updateGazeTrackerScale = true;
  16262. /**
  16263. * If the gaze trackers color should be updated when selecting meshes
  16264. */
  16265. this.updateGazeTrackerColor = true;
  16266. /**
  16267. * Defines wether or not Pointer lock should be requested when switching to
  16268. * full screen.
  16269. */
  16270. this.requestPointerLockOnFullScreen = true;
  16271. this._onResize = function () {
  16272. _this.moveButtonToBottomRight();
  16273. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16274. _this.exitVR();
  16275. }
  16276. };
  16277. this._onFullscreenChange = function () {
  16278. var anyDoc = document;
  16279. if (anyDoc.fullscreen !== undefined) {
  16280. _this._fullscreenVRpresenting = document.fullscreen;
  16281. }
  16282. else if (anyDoc.mozFullScreen !== undefined) {
  16283. _this._fullscreenVRpresenting = anyDoc.mozFullScreen;
  16284. }
  16285. else if (anyDoc.webkitIsFullScreen !== undefined) {
  16286. _this._fullscreenVRpresenting = anyDoc.webkitIsFullScreen;
  16287. }
  16288. else if (anyDoc.msIsFullScreen !== undefined) {
  16289. _this._fullscreenVRpresenting = anyDoc.msIsFullScreen;
  16290. }
  16291. else if (document.msFullscreenElement !== undefined) {
  16292. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16293. }
  16294. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16295. _this.exitVR();
  16296. if (!_this._useCustomVRButton) {
  16297. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16298. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16299. }
  16300. }
  16301. };
  16302. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16303. this.beforeRender = function () {
  16304. if (_this._leftController && _this._leftController._activePointer) {
  16305. _this._castRayAndSelectObject(_this._leftController);
  16306. }
  16307. if (_this._rightController && _this._rightController._activePointer) {
  16308. _this._castRayAndSelectObject(_this._rightController);
  16309. }
  16310. if (_this._noControllerIsActive) {
  16311. _this._castRayAndSelectObject(_this._cameraGazer);
  16312. }
  16313. else {
  16314. _this._cameraGazer._gazeTracker.isVisible = false;
  16315. }
  16316. };
  16317. this._onNewGamepadConnected = function (gamepad) {
  16318. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  16319. if (gamepad.leftStick) {
  16320. gamepad.onleftstickchanged(function (stickValues) {
  16321. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16322. // Listening to classic/xbox gamepad only if no VR controller is active
  16323. if ((!_this._leftController && !_this._rightController) ||
  16324. ((_this._leftController && !_this._leftController._activePointer) &&
  16325. (_this._rightController && !_this._rightController._activePointer))) {
  16326. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16327. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16328. }
  16329. }
  16330. });
  16331. }
  16332. if (gamepad.rightStick) {
  16333. gamepad.onrightstickchanged(function (stickValues) {
  16334. if (_this._teleportationInitialized) {
  16335. _this._checkRotate(stickValues, _this._cameraGazer);
  16336. }
  16337. });
  16338. }
  16339. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  16340. gamepad.onbuttondown(function (buttonPressed) {
  16341. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16342. _this._cameraGazer._selectionPointerDown();
  16343. }
  16344. });
  16345. gamepad.onbuttonup(function (buttonPressed) {
  16346. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16347. _this._cameraGazer._selectionPointerUp();
  16348. }
  16349. });
  16350. }
  16351. }
  16352. else {
  16353. var webVRController = gamepad;
  16354. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16355. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16356. _this._rightController = controller;
  16357. }
  16358. else {
  16359. _this._leftController = controller;
  16360. }
  16361. _this._tryEnableInteractionOnController(controller);
  16362. }
  16363. };
  16364. // 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
  16365. this._tryEnableInteractionOnController = function (controller) {
  16366. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16367. _this._enableInteractionOnController(controller);
  16368. }
  16369. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16370. _this._enableTeleportationOnController(controller);
  16371. }
  16372. };
  16373. this._onNewGamepadDisconnected = function (gamepad) {
  16374. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  16375. if (gamepad.hand === "left" && _this._leftController != null) {
  16376. _this._leftController.dispose();
  16377. _this._leftController = null;
  16378. }
  16379. if (gamepad.hand === "right" && _this._rightController != null) {
  16380. _this._rightController.dispose();
  16381. _this._rightController = null;
  16382. }
  16383. }
  16384. };
  16385. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16386. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16387. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16388. this._scene = scene;
  16389. this._canvas = scene.getEngine().getRenderingCanvas();
  16390. // Parse options
  16391. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16392. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16393. }
  16394. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16395. webVROptions.createDeviceOrientationCamera = true;
  16396. }
  16397. if (webVROptions.laserToggle === undefined) {
  16398. webVROptions.laserToggle = true;
  16399. }
  16400. if (webVROptions.defaultHeight === undefined) {
  16401. webVROptions.defaultHeight = 1.7;
  16402. }
  16403. if (webVROptions.useCustomVRButton) {
  16404. this._useCustomVRButton = true;
  16405. if (webVROptions.customVRButton) {
  16406. this._btnVR = webVROptions.customVRButton;
  16407. }
  16408. }
  16409. if (webVROptions.rayLength) {
  16410. this._rayLength = webVROptions.rayLength;
  16411. }
  16412. this._defaultHeight = webVROptions.defaultHeight;
  16413. if (webVROptions.positionScale) {
  16414. this._rayLength *= webVROptions.positionScale;
  16415. this._defaultHeight *= webVROptions.positionScale;
  16416. }
  16417. this._hasEnteredVR = false;
  16418. // Set position
  16419. if (this._scene.activeCamera) {
  16420. this._position = this._scene.activeCamera.position.clone();
  16421. }
  16422. else {
  16423. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16424. }
  16425. // Set non-vr camera
  16426. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16427. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16428. // Copy data from existing camera
  16429. if (this._scene.activeCamera) {
  16430. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16431. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16432. // Set rotation from previous camera
  16433. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16434. var targetCamera = this._scene.activeCamera;
  16435. if (targetCamera.rotationQuaternion) {
  16436. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16437. }
  16438. else {
  16439. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16440. }
  16441. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16442. }
  16443. }
  16444. this._scene.activeCamera = this._deviceOrientationCamera;
  16445. if (this._canvas) {
  16446. this._scene.activeCamera.attachControl(this._canvas);
  16447. }
  16448. }
  16449. else {
  16450. this._existingCamera = this._scene.activeCamera;
  16451. }
  16452. // Create VR cameras
  16453. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16454. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16455. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16456. }
  16457. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16458. this._webVRCamera.useStandingMatrix();
  16459. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16460. // Create default button
  16461. if (!this._useCustomVRButton) {
  16462. this._btnVR = document.createElement("BUTTON");
  16463. this._btnVR.className = "babylonVRicon";
  16464. this._btnVR.id = "babylonVRiconbtn";
  16465. this._btnVR.title = "Click to switch to VR";
  16466. 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) }";
  16467. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16468. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16469. // css += ".babylonVRicon.vrdisplaysupported { }";
  16470. // css += ".babylonVRicon.vrdisplayready { }";
  16471. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16472. var style = document.createElement('style');
  16473. style.appendChild(document.createTextNode(css));
  16474. document.getElementsByTagName('head')[0].appendChild(style);
  16475. this.moveButtonToBottomRight();
  16476. }
  16477. // VR button click event
  16478. if (this._btnVR) {
  16479. this._btnVR.addEventListener("click", function () {
  16480. if (!_this.isInVRMode) {
  16481. _this.enterVR();
  16482. }
  16483. else {
  16484. _this.exitVR();
  16485. }
  16486. });
  16487. }
  16488. // Window events
  16489. window.addEventListener("resize", this._onResize);
  16490. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16491. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16492. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16493. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16494. document.onmsfullscreenchange = this._onFullscreenChange;
  16495. // Display vr button when headset is connected
  16496. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16497. this.displayVRButton();
  16498. }
  16499. else {
  16500. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16501. if (e.vrDisplay) {
  16502. _this.displayVRButton();
  16503. }
  16504. });
  16505. }
  16506. // Exiting VR mode using 'ESC' key on desktop
  16507. this._onKeyDown = function (event) {
  16508. if (event.keyCode === 27 && _this.isInVRMode) {
  16509. _this.exitVR();
  16510. }
  16511. };
  16512. document.addEventListener("keydown", this._onKeyDown);
  16513. // Exiting VR mode double tapping the touch screen
  16514. this._scene.onPrePointerObservable.add(function () {
  16515. if (_this.isInVRMode) {
  16516. _this.exitVR();
  16517. if (_this._fullscreenVRpresenting) {
  16518. _this._scene.getEngine().exitFullscreen();
  16519. }
  16520. }
  16521. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16522. // Listen for WebVR display changes
  16523. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16524. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16525. this._onVRRequestPresentStart = function () {
  16526. _this._webVRrequesting = true;
  16527. _this.updateButtonVisibility();
  16528. };
  16529. this._onVRRequestPresentComplete = function () {
  16530. _this._webVRrequesting = false;
  16531. _this.updateButtonVisibility();
  16532. };
  16533. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16534. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16535. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16536. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16537. scene.onDisposeObservable.add(function () {
  16538. _this.dispose();
  16539. });
  16540. // Gamepad connection events
  16541. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16542. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16543. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16544. this.updateButtonVisibility();
  16545. //create easing functions
  16546. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16547. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16548. if (this.webVROptions.floorMeshes) {
  16549. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16550. }
  16551. }
  16552. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16553. /** Return this.onEnteringVRObservable
  16554. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16555. */
  16556. get: function () {
  16557. return this.onEnteringVRObservable;
  16558. },
  16559. enumerable: true,
  16560. configurable: true
  16561. });
  16562. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16563. /** Return this.onExitingVRObservable
  16564. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16565. */
  16566. get: function () {
  16567. return this.onExitingVRObservable;
  16568. },
  16569. enumerable: true,
  16570. configurable: true
  16571. });
  16572. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16573. /** Return this.onControllerMeshLoadedObservable
  16574. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16575. */
  16576. get: function () {
  16577. return this.onControllerMeshLoadedObservable;
  16578. },
  16579. enumerable: true,
  16580. configurable: true
  16581. });
  16582. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16583. /**
  16584. * The mesh used to display where the user is going to teleport.
  16585. */
  16586. get: function () {
  16587. return this._teleportationTarget;
  16588. },
  16589. /**
  16590. * Sets the mesh to be used to display where the user is going to teleport.
  16591. */
  16592. set: function (value) {
  16593. if (value) {
  16594. value.name = "teleportationTarget";
  16595. this._isDefaultTeleportationTarget = false;
  16596. this._teleportationTarget = value;
  16597. }
  16598. },
  16599. enumerable: true,
  16600. configurable: true
  16601. });
  16602. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16603. /**
  16604. * 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
  16605. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16606. * See http://doc.babylonjs.com/resources/baking_transformations
  16607. */
  16608. get: function () {
  16609. return this._cameraGazer._gazeTracker;
  16610. },
  16611. set: function (value) {
  16612. if (value) {
  16613. // Dispose of existing meshes
  16614. if (this._cameraGazer._gazeTracker) {
  16615. this._cameraGazer._gazeTracker.dispose();
  16616. }
  16617. if (this._leftController && this._leftController._gazeTracker) {
  16618. this._leftController._gazeTracker.dispose();
  16619. }
  16620. if (this._rightController && this._rightController._gazeTracker) {
  16621. this._rightController._gazeTracker.dispose();
  16622. }
  16623. // Set and create gaze trackers on head and controllers
  16624. this._cameraGazer._gazeTracker = value;
  16625. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16626. this._cameraGazer._gazeTracker.isPickable = false;
  16627. this._cameraGazer._gazeTracker.isVisible = false;
  16628. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16629. if (this._leftController) {
  16630. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16631. }
  16632. if (this._rightController) {
  16633. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16634. }
  16635. }
  16636. },
  16637. enumerable: true,
  16638. configurable: true
  16639. });
  16640. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16641. /**
  16642. * The gaze tracking mesh corresponding to the left controller
  16643. */
  16644. get: function () {
  16645. if (this._leftController) {
  16646. return this._leftController._gazeTracker;
  16647. }
  16648. return null;
  16649. },
  16650. enumerable: true,
  16651. configurable: true
  16652. });
  16653. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16654. /**
  16655. * The gaze tracking mesh corresponding to the right controller
  16656. */
  16657. get: function () {
  16658. if (this._rightController) {
  16659. return this._rightController._gazeTracker;
  16660. }
  16661. return null;
  16662. },
  16663. enumerable: true,
  16664. configurable: true
  16665. });
  16666. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16667. /**
  16668. * If the ray of the gaze should be displayed.
  16669. */
  16670. get: function () {
  16671. return this._displayGaze;
  16672. },
  16673. /**
  16674. * Sets if the ray of the gaze should be displayed.
  16675. */
  16676. set: function (value) {
  16677. this._displayGaze = value;
  16678. if (!value) {
  16679. this._cameraGazer._gazeTracker.isVisible = false;
  16680. if (this._leftController) {
  16681. this._leftController._gazeTracker.isVisible = false;
  16682. }
  16683. if (this._rightController) {
  16684. this._rightController._gazeTracker.isVisible = false;
  16685. }
  16686. }
  16687. },
  16688. enumerable: true,
  16689. configurable: true
  16690. });
  16691. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16692. /**
  16693. * If the ray of the LaserPointer should be displayed.
  16694. */
  16695. get: function () {
  16696. return this._displayLaserPointer;
  16697. },
  16698. /**
  16699. * Sets if the ray of the LaserPointer should be displayed.
  16700. */
  16701. set: function (value) {
  16702. this._displayLaserPointer = value;
  16703. if (!value) {
  16704. if (this._rightController) {
  16705. this._rightController._deactivatePointer();
  16706. this._rightController._gazeTracker.isVisible = false;
  16707. }
  16708. if (this._leftController) {
  16709. this._leftController._deactivatePointer();
  16710. this._leftController._gazeTracker.isVisible = false;
  16711. }
  16712. }
  16713. else {
  16714. if (this._rightController) {
  16715. this._rightController._activatePointer();
  16716. }
  16717. if (this._leftController) {
  16718. this._leftController._activatePointer();
  16719. }
  16720. }
  16721. },
  16722. enumerable: true,
  16723. configurable: true
  16724. });
  16725. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16726. /**
  16727. * The deviceOrientationCamera used as the camera when not in VR.
  16728. */
  16729. get: function () {
  16730. return this._deviceOrientationCamera;
  16731. },
  16732. enumerable: true,
  16733. configurable: true
  16734. });
  16735. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16736. /**
  16737. * Based on the current WebVR support, returns the current VR camera used.
  16738. */
  16739. get: function () {
  16740. if (this._webVRready) {
  16741. return this._webVRCamera;
  16742. }
  16743. else {
  16744. return this._scene.activeCamera;
  16745. }
  16746. },
  16747. enumerable: true,
  16748. configurable: true
  16749. });
  16750. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16751. /**
  16752. * The webVRCamera which is used when in VR.
  16753. */
  16754. get: function () {
  16755. return this._webVRCamera;
  16756. },
  16757. enumerable: true,
  16758. configurable: true
  16759. });
  16760. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16761. /**
  16762. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16763. */
  16764. get: function () {
  16765. return this._vrDeviceOrientationCamera;
  16766. },
  16767. enumerable: true,
  16768. configurable: true
  16769. });
  16770. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16771. get: function () {
  16772. var result = this._cameraGazer._teleportationRequestInitiated
  16773. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16774. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16775. return result;
  16776. },
  16777. enumerable: true,
  16778. configurable: true
  16779. });
  16780. // Raised when one of the controller has loaded successfully its associated default mesh
  16781. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16782. if (this._leftController && this._leftController.webVRController == webVRController) {
  16783. if (webVRController.mesh) {
  16784. this._leftController._setLaserPointerParent(webVRController.mesh);
  16785. }
  16786. }
  16787. if (this._rightController && this._rightController.webVRController == webVRController) {
  16788. if (webVRController.mesh) {
  16789. this._rightController._setLaserPointerParent(webVRController.mesh);
  16790. }
  16791. }
  16792. try {
  16793. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16794. }
  16795. catch (err) {
  16796. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16797. }
  16798. };
  16799. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16800. /**
  16801. * Gets a value indicating if we are currently in VR mode.
  16802. */
  16803. get: function () {
  16804. return this._webVRpresenting || this._fullscreenVRpresenting;
  16805. },
  16806. enumerable: true,
  16807. configurable: true
  16808. });
  16809. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16810. var vrDisplay = this._scene.getEngine().getVRDevice();
  16811. if (vrDisplay) {
  16812. var wasPresenting = this._webVRpresenting;
  16813. this._webVRpresenting = vrDisplay.isPresenting;
  16814. if (wasPresenting && !this._webVRpresenting) {
  16815. this.exitVR();
  16816. }
  16817. }
  16818. else {
  16819. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16820. }
  16821. this.updateButtonVisibility();
  16822. };
  16823. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16824. this._webVRsupported = eventArgs.vrSupported;
  16825. this._webVRready = !!eventArgs.vrDisplay;
  16826. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16827. this.updateButtonVisibility();
  16828. };
  16829. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16830. if (this._canvas && !this._useCustomVRButton) {
  16831. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16832. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16833. }
  16834. };
  16835. VRExperienceHelper.prototype.displayVRButton = function () {
  16836. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16837. document.body.appendChild(this._btnVR);
  16838. this._btnVRDisplayed = true;
  16839. }
  16840. };
  16841. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16842. if (!this._btnVR || this._useCustomVRButton) {
  16843. return;
  16844. }
  16845. this._btnVR.className = "babylonVRicon";
  16846. if (this.isInVRMode) {
  16847. this._btnVR.className += " vrdisplaypresenting";
  16848. }
  16849. else {
  16850. if (this._webVRready) {
  16851. this._btnVR.className += " vrdisplayready";
  16852. }
  16853. if (this._webVRsupported) {
  16854. this._btnVR.className += " vrdisplaysupported";
  16855. }
  16856. if (this._webVRrequesting) {
  16857. this._btnVR.className += " vrdisplayrequesting";
  16858. }
  16859. }
  16860. };
  16861. /**
  16862. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16863. * Otherwise, will use the fullscreen API.
  16864. */
  16865. VRExperienceHelper.prototype.enterVR = function () {
  16866. var _this = this;
  16867. if (this.onEnteringVRObservable) {
  16868. try {
  16869. this.onEnteringVRObservable.notifyObservers(this);
  16870. }
  16871. catch (err) {
  16872. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16873. }
  16874. }
  16875. if (this._scene.activeCamera) {
  16876. this._position = this._scene.activeCamera.position.clone();
  16877. if (this.vrDeviceOrientationCamera) {
  16878. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16879. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16880. }
  16881. if (this.webVRCamera) {
  16882. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16883. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16884. var delta = desiredYRotation - currentYRotation;
  16885. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16886. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16887. }
  16888. // make sure that we return to the last active camera
  16889. this._existingCamera = this._scene.activeCamera;
  16890. // Remove and cache angular sensability to avoid camera rotation when in VR
  16891. if (this._existingCamera.angularSensibilityX) {
  16892. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16893. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16894. }
  16895. if (this._existingCamera.angularSensibilityY) {
  16896. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16897. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16898. }
  16899. if (this._existingCamera.angularSensibility) {
  16900. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16901. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16902. }
  16903. }
  16904. if (this._webVRrequesting) {
  16905. return;
  16906. }
  16907. // If WebVR is supported and a headset is connected
  16908. if (this._webVRready) {
  16909. if (!this._webVRpresenting) {
  16910. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  16911. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  16912. });
  16913. this._webVRCamera.position = this._position;
  16914. this._scene.activeCamera = this._webVRCamera;
  16915. }
  16916. }
  16917. else if (this._vrDeviceOrientationCamera) {
  16918. this._vrDeviceOrientationCamera.position = this._position;
  16919. if (this._scene.activeCamera) {
  16920. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16921. }
  16922. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16923. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  16924. this.updateButtonVisibility();
  16925. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  16926. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  16927. });
  16928. }
  16929. if (this._scene.activeCamera && this._canvas) {
  16930. this._scene.activeCamera.attachControl(this._canvas);
  16931. }
  16932. if (this._interactionsEnabled) {
  16933. this._scene.registerBeforeRender(this.beforeRender);
  16934. }
  16935. if (this._displayLaserPointer) {
  16936. [this._leftController, this._rightController].forEach(function (controller) {
  16937. if (controller) {
  16938. controller._activatePointer();
  16939. }
  16940. });
  16941. }
  16942. this._hasEnteredVR = true;
  16943. };
  16944. /**
  16945. * Attempt to exit VR, or fullscreen.
  16946. */
  16947. VRExperienceHelper.prototype.exitVR = function () {
  16948. if (this._hasEnteredVR) {
  16949. if (this.onExitingVRObservable) {
  16950. try {
  16951. this.onExitingVRObservable.notifyObservers(this);
  16952. }
  16953. catch (err) {
  16954. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16955. }
  16956. }
  16957. if (this._webVRpresenting) {
  16958. this._scene.getEngine().disableVR();
  16959. }
  16960. if (this._scene.activeCamera) {
  16961. this._position = this._scene.activeCamera.position.clone();
  16962. }
  16963. if (this.vrDeviceOrientationCamera) {
  16964. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16965. }
  16966. if (this._deviceOrientationCamera) {
  16967. this._deviceOrientationCamera.position = this._position;
  16968. this._scene.activeCamera = this._deviceOrientationCamera;
  16969. if (this._canvas) {
  16970. this._scene.activeCamera.attachControl(this._canvas);
  16971. }
  16972. // Restore angular sensibility
  16973. if (this._cachedAngularSensibility.angularSensibilityX) {
  16974. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16975. this._cachedAngularSensibility.angularSensibilityX = null;
  16976. }
  16977. if (this._cachedAngularSensibility.angularSensibilityY) {
  16978. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16979. this._cachedAngularSensibility.angularSensibilityY = null;
  16980. }
  16981. if (this._cachedAngularSensibility.angularSensibility) {
  16982. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16983. this._cachedAngularSensibility.angularSensibility = null;
  16984. }
  16985. }
  16986. else if (this._existingCamera) {
  16987. this._existingCamera.position = this._position;
  16988. this._scene.activeCamera = this._existingCamera;
  16989. // Restore angular sensibility
  16990. if (this._cachedAngularSensibility.angularSensibilityX) {
  16991. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16992. this._cachedAngularSensibility.angularSensibilityX = null;
  16993. }
  16994. if (this._cachedAngularSensibility.angularSensibilityY) {
  16995. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16996. this._cachedAngularSensibility.angularSensibilityY = null;
  16997. }
  16998. if (this._cachedAngularSensibility.angularSensibility) {
  16999. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17000. this._cachedAngularSensibility.angularSensibility = null;
  17001. }
  17002. }
  17003. this.updateButtonVisibility();
  17004. if (this._interactionsEnabled) {
  17005. this._scene.unregisterBeforeRender(this.beforeRender);
  17006. this._cameraGazer._gazeTracker.isVisible = false;
  17007. if (this._leftController) {
  17008. this._leftController._gazeTracker.isVisible = false;
  17009. }
  17010. if (this._rightController) {
  17011. this._rightController._gazeTracker.isVisible = false;
  17012. }
  17013. }
  17014. // resize to update width and height when exiting vr exits fullscreen
  17015. this._scene.getEngine().resize();
  17016. [this._leftController, this._rightController].forEach(function (controller) {
  17017. if (controller) {
  17018. controller._deactivatePointer();
  17019. }
  17020. });
  17021. this._hasEnteredVR = false;
  17022. }
  17023. };
  17024. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17025. /**
  17026. * The position of the vr experience helper.
  17027. */
  17028. get: function () {
  17029. return this._position;
  17030. },
  17031. /**
  17032. * Sets the position of the vr experience helper.
  17033. */
  17034. set: function (value) {
  17035. this._position = value;
  17036. if (this._scene.activeCamera) {
  17037. this._scene.activeCamera.position = value;
  17038. }
  17039. },
  17040. enumerable: true,
  17041. configurable: true
  17042. });
  17043. /**
  17044. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17045. */
  17046. VRExperienceHelper.prototype.enableInteractions = function () {
  17047. var _this = this;
  17048. if (!this._interactionsEnabled) {
  17049. this._interactionsRequested = true;
  17050. if (this._leftController) {
  17051. this._enableInteractionOnController(this._leftController);
  17052. }
  17053. if (this._rightController) {
  17054. this._enableInteractionOnController(this._rightController);
  17055. }
  17056. this.raySelectionPredicate = function (mesh) {
  17057. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17058. };
  17059. this.meshSelectionPredicate = function () {
  17060. return true;
  17061. };
  17062. this._raySelectionPredicate = function (mesh) {
  17063. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17064. && mesh.name.indexOf("teleportationTarget") === -1
  17065. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17066. return _this.raySelectionPredicate(mesh);
  17067. }
  17068. return false;
  17069. };
  17070. this._interactionsEnabled = true;
  17071. }
  17072. };
  17073. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17074. get: function () {
  17075. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17076. },
  17077. enumerable: true,
  17078. configurable: true
  17079. });
  17080. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17081. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17082. if (this._floorMeshesCollection[i].id === mesh.id) {
  17083. return true;
  17084. }
  17085. }
  17086. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17087. return true;
  17088. }
  17089. return false;
  17090. };
  17091. /**
  17092. * Adds a floor mesh to be used for teleportation.
  17093. * @param floorMesh the mesh to be used for teleportation.
  17094. */
  17095. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17096. if (!this._floorMeshesCollection) {
  17097. return;
  17098. }
  17099. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17100. return;
  17101. }
  17102. this._floorMeshesCollection.push(floorMesh);
  17103. };
  17104. /**
  17105. * Removes a floor mesh from being used for teleportation.
  17106. * @param floorMesh the mesh to be removed.
  17107. */
  17108. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17109. if (!this._floorMeshesCollection) {
  17110. return;
  17111. }
  17112. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17113. if (meshIndex !== -1) {
  17114. this._floorMeshesCollection.splice(meshIndex, 1);
  17115. }
  17116. };
  17117. /**
  17118. * Enables interactions and teleportation using the VR controllers and gaze.
  17119. * @param vrTeleportationOptions options to modify teleportation behavior.
  17120. */
  17121. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17122. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17123. if (!this._teleportationInitialized) {
  17124. this._teleportationRequested = true;
  17125. this.enableInteractions();
  17126. if (vrTeleportationOptions.floorMeshName) {
  17127. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17128. }
  17129. if (vrTeleportationOptions.floorMeshes) {
  17130. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17131. }
  17132. if (this._leftController != null) {
  17133. this._enableTeleportationOnController(this._leftController);
  17134. }
  17135. if (this._rightController != null) {
  17136. this._enableTeleportationOnController(this._rightController);
  17137. }
  17138. // Creates an image processing post process for the vignette not relying
  17139. // on the main scene configuration for image processing to reduce setup and spaces
  17140. // (gamma/linear) conflicts.
  17141. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  17142. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  17143. imageProcessingConfiguration.vignetteEnabled = true;
  17144. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17145. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17146. this._teleportationInitialized = true;
  17147. if (this._isDefaultTeleportationTarget) {
  17148. this._createTeleportationCircles();
  17149. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17150. }
  17151. }
  17152. };
  17153. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17154. var _this = this;
  17155. var controllerMesh = controller.webVRController.mesh;
  17156. if (controllerMesh) {
  17157. controller._interactionsEnabled = true;
  17158. if (this.isInVRMode && this._displayLaserPointer) {
  17159. controller._activatePointer();
  17160. }
  17161. if (this.webVROptions.laserToggle) {
  17162. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17163. // Enabling / disabling laserPointer
  17164. if (_this._displayLaserPointer && stateObject.value === 1) {
  17165. if (controller._activePointer) {
  17166. controller._deactivatePointer();
  17167. }
  17168. else {
  17169. controller._activatePointer();
  17170. }
  17171. if (_this.displayGaze) {
  17172. controller._gazeTracker.isVisible = controller._activePointer;
  17173. }
  17174. }
  17175. });
  17176. }
  17177. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17178. var gazer = controller;
  17179. if (_this._noControllerIsActive) {
  17180. gazer = _this._cameraGazer;
  17181. }
  17182. if (!gazer._pointerDownOnMeshAsked) {
  17183. if (stateObject.value > _this._padSensibilityUp) {
  17184. gazer._selectionPointerDown();
  17185. }
  17186. }
  17187. else if (stateObject.value < _this._padSensibilityDown) {
  17188. gazer._selectionPointerUp();
  17189. }
  17190. });
  17191. }
  17192. };
  17193. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17194. // Dont teleport if another gaze already requested teleportation
  17195. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17196. return;
  17197. }
  17198. if (!gazer._teleportationRequestInitiated) {
  17199. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17200. gazer._activatePointer();
  17201. gazer._teleportationRequestInitiated = true;
  17202. }
  17203. }
  17204. else {
  17205. // Listening to the proper controller values changes to confirm teleportation
  17206. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17207. if (this._teleportActive) {
  17208. this.teleportCamera(this._haloCenter);
  17209. }
  17210. gazer._teleportationRequestInitiated = false;
  17211. }
  17212. }
  17213. };
  17214. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17215. // Only rotate when user is not currently selecting a teleportation location
  17216. if (gazer._teleportationRequestInitiated) {
  17217. return;
  17218. }
  17219. if (!gazer._rotationLeftAsked) {
  17220. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17221. gazer._rotationLeftAsked = true;
  17222. if (this._rotationAllowed) {
  17223. this._rotateCamera(false);
  17224. }
  17225. }
  17226. }
  17227. else {
  17228. if (stateObject.x > -this._padSensibilityDown) {
  17229. gazer._rotationLeftAsked = false;
  17230. }
  17231. }
  17232. if (!gazer._rotationRightAsked) {
  17233. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17234. gazer._rotationRightAsked = true;
  17235. if (this._rotationAllowed) {
  17236. this._rotateCamera(true);
  17237. }
  17238. }
  17239. }
  17240. else {
  17241. if (stateObject.x < this._padSensibilityDown) {
  17242. gazer._rotationRightAsked = false;
  17243. }
  17244. }
  17245. };
  17246. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17247. // Only teleport backwards when user is not currently selecting a teleportation location
  17248. if (gazer._teleportationRequestInitiated) {
  17249. return;
  17250. }
  17251. // Teleport backwards
  17252. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17253. if (!gazer._teleportationBackRequestInitiated) {
  17254. if (!this.currentVRCamera) {
  17255. return;
  17256. }
  17257. // Get rotation and position of the current camera
  17258. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17259. var position = this.currentVRCamera.position;
  17260. // If the camera has device position, use that instead
  17261. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17262. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17263. position = this.currentVRCamera.devicePosition;
  17264. }
  17265. // Get matrix with only the y rotation of the device rotation
  17266. rotation.toEulerAnglesToRef(this._workingVector);
  17267. this._workingVector.z = 0;
  17268. this._workingVector.x = 0;
  17269. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17270. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17271. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17272. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17273. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17274. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  17275. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17276. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17277. this.teleportCamera(hit.pickedPoint);
  17278. }
  17279. gazer._teleportationBackRequestInitiated = true;
  17280. }
  17281. }
  17282. else {
  17283. gazer._teleportationBackRequestInitiated = false;
  17284. }
  17285. };
  17286. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17287. var _this = this;
  17288. var controllerMesh = controller.webVRController.mesh;
  17289. if (controllerMesh) {
  17290. if (!controller._interactionsEnabled) {
  17291. this._enableInteractionOnController(controller);
  17292. }
  17293. controller._interactionsEnabled = true;
  17294. controller._teleportationEnabled = true;
  17295. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  17296. controller._dpadPressed = false;
  17297. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17298. controller._dpadPressed = stateObject.pressed;
  17299. if (!controller._dpadPressed) {
  17300. controller._rotationLeftAsked = false;
  17301. controller._rotationRightAsked = false;
  17302. controller._teleportationBackRequestInitiated = false;
  17303. }
  17304. });
  17305. }
  17306. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17307. if (_this.teleportationEnabled) {
  17308. _this._checkTeleportBackwards(stateObject, controller);
  17309. _this._checkTeleportWithRay(stateObject, controller);
  17310. }
  17311. _this._checkRotate(stateObject, controller);
  17312. });
  17313. }
  17314. };
  17315. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17316. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17317. this._teleportationTarget.isPickable = false;
  17318. var length = 512;
  17319. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17320. dynamicTexture.hasAlpha = true;
  17321. var context = dynamicTexture.getContext();
  17322. var centerX = length / 2;
  17323. var centerY = length / 2;
  17324. var radius = 200;
  17325. context.beginPath();
  17326. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17327. context.fillStyle = this._teleportationFillColor;
  17328. context.fill();
  17329. context.lineWidth = 10;
  17330. context.strokeStyle = this._teleportationBorderColor;
  17331. context.stroke();
  17332. context.closePath();
  17333. dynamicTexture.update();
  17334. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17335. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17336. this._teleportationTarget.material = teleportationCircleMaterial;
  17337. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17338. torus.isPickable = false;
  17339. torus.parent = this._teleportationTarget;
  17340. 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);
  17341. var keys = [];
  17342. keys.push({
  17343. frame: 0,
  17344. value: 0
  17345. });
  17346. keys.push({
  17347. frame: 30,
  17348. value: 0.4
  17349. });
  17350. keys.push({
  17351. frame: 60,
  17352. value: 0
  17353. });
  17354. animationInnerCircle.setKeys(keys);
  17355. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  17356. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  17357. animationInnerCircle.setEasingFunction(easingFunction);
  17358. torus.animations = [];
  17359. torus.animations.push(animationInnerCircle);
  17360. this._scene.beginAnimation(torus, 0, 60, true);
  17361. this._hideTeleportationTarget();
  17362. };
  17363. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17364. this._teleportActive = true;
  17365. if (this._teleportationInitialized) {
  17366. this._teleportationTarget.isVisible = true;
  17367. if (this._isDefaultTeleportationTarget) {
  17368. this._teleportationTarget.getChildren()[0].isVisible = true;
  17369. }
  17370. }
  17371. };
  17372. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17373. this._teleportActive = false;
  17374. if (this._teleportationInitialized) {
  17375. this._teleportationTarget.isVisible = false;
  17376. if (this._isDefaultTeleportationTarget) {
  17377. this._teleportationTarget.getChildren()[0].isVisible = false;
  17378. }
  17379. }
  17380. };
  17381. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17382. var _this = this;
  17383. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17384. return;
  17385. }
  17386. if (right) {
  17387. this._rotationAngle++;
  17388. }
  17389. else {
  17390. this._rotationAngle--;
  17391. }
  17392. this.currentVRCamera.animations = [];
  17393. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17394. 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);
  17395. var animationRotationKeys = [];
  17396. animationRotationKeys.push({
  17397. frame: 0,
  17398. value: this.currentVRCamera.rotationQuaternion
  17399. });
  17400. animationRotationKeys.push({
  17401. frame: 6,
  17402. value: target
  17403. });
  17404. animationRotation.setKeys(animationRotationKeys);
  17405. animationRotation.setEasingFunction(this._circleEase);
  17406. this.currentVRCamera.animations.push(animationRotation);
  17407. this._postProcessMove.animations = [];
  17408. 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);
  17409. var vignetteWeightKeys = [];
  17410. vignetteWeightKeys.push({
  17411. frame: 0,
  17412. value: 0
  17413. });
  17414. vignetteWeightKeys.push({
  17415. frame: 3,
  17416. value: 4
  17417. });
  17418. vignetteWeightKeys.push({
  17419. frame: 6,
  17420. value: 0
  17421. });
  17422. animationPP.setKeys(vignetteWeightKeys);
  17423. animationPP.setEasingFunction(this._circleEase);
  17424. this._postProcessMove.animations.push(animationPP);
  17425. 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);
  17426. var vignetteStretchKeys = [];
  17427. vignetteStretchKeys.push({
  17428. frame: 0,
  17429. value: 0
  17430. });
  17431. vignetteStretchKeys.push({
  17432. frame: 3,
  17433. value: 10
  17434. });
  17435. vignetteStretchKeys.push({
  17436. frame: 6,
  17437. value: 0
  17438. });
  17439. animationPP2.setKeys(vignetteStretchKeys);
  17440. animationPP2.setEasingFunction(this._circleEase);
  17441. this._postProcessMove.animations.push(animationPP2);
  17442. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17443. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17444. this._postProcessMove.samples = 4;
  17445. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17446. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17447. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17448. });
  17449. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17450. };
  17451. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17452. if (hit.pickedPoint) {
  17453. if (gazer._teleportationRequestInitiated) {
  17454. this._displayTeleportationTarget();
  17455. this._haloCenter.copyFrom(hit.pickedPoint);
  17456. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17457. }
  17458. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17459. if (pickNormal) {
  17460. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17461. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17462. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17463. }
  17464. this._teleportationTarget.position.y += 0.1;
  17465. }
  17466. };
  17467. /**
  17468. * Teleports the users feet to the desired location
  17469. * @param location The location where the user's feet should be placed
  17470. */
  17471. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17472. var _this = this;
  17473. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17474. return;
  17475. }
  17476. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17477. // offset of the headset from the anchor.
  17478. if (this.webVRCamera.leftCamera) {
  17479. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17480. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17481. location.subtractToRef(this._workingVector, this._workingVector);
  17482. }
  17483. else {
  17484. this._workingVector.copyFrom(location);
  17485. }
  17486. // Add height to account for user's height offset
  17487. if (this.isInVRMode) {
  17488. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17489. }
  17490. else {
  17491. this._workingVector.y += this._defaultHeight;
  17492. }
  17493. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17494. // Create animation from the camera's position to the new location
  17495. this.currentVRCamera.animations = [];
  17496. 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);
  17497. var animationCameraTeleportationKeys = [{
  17498. frame: 0,
  17499. value: this.currentVRCamera.position
  17500. },
  17501. {
  17502. frame: 11,
  17503. value: this._workingVector
  17504. }
  17505. ];
  17506. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17507. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17508. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17509. this._postProcessMove.animations = [];
  17510. 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);
  17511. var vignetteWeightKeys = [];
  17512. vignetteWeightKeys.push({
  17513. frame: 0,
  17514. value: 0
  17515. });
  17516. vignetteWeightKeys.push({
  17517. frame: 5,
  17518. value: 8
  17519. });
  17520. vignetteWeightKeys.push({
  17521. frame: 11,
  17522. value: 0
  17523. });
  17524. animationPP.setKeys(vignetteWeightKeys);
  17525. this._postProcessMove.animations.push(animationPP);
  17526. 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);
  17527. var vignetteStretchKeys = [];
  17528. vignetteStretchKeys.push({
  17529. frame: 0,
  17530. value: 0
  17531. });
  17532. vignetteStretchKeys.push({
  17533. frame: 5,
  17534. value: 10
  17535. });
  17536. vignetteStretchKeys.push({
  17537. frame: 11,
  17538. value: 0
  17539. });
  17540. animationPP2.setKeys(vignetteStretchKeys);
  17541. this._postProcessMove.animations.push(animationPP2);
  17542. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17543. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17544. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17545. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17546. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17547. });
  17548. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17549. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17550. });
  17551. this._hideTeleportationTarget();
  17552. };
  17553. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17554. if (normal) {
  17555. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17556. if (angle < Math.PI / 2) {
  17557. normal.scaleInPlace(-1);
  17558. }
  17559. }
  17560. return normal;
  17561. };
  17562. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17563. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17564. return;
  17565. }
  17566. var ray = gazer._getForwardRay(this._rayLength);
  17567. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17568. if (hit) {
  17569. // Populate the contrllers mesh that can be used for drag/drop
  17570. if (gazer._laserPointer) {
  17571. hit.originMesh = gazer._laserPointer.parent;
  17572. }
  17573. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17574. }
  17575. gazer._currentHit = hit;
  17576. // Moving the gazeTracker on the mesh face targetted
  17577. if (hit && hit.pickedPoint) {
  17578. if (this._displayGaze) {
  17579. var multiplier = 1;
  17580. gazer._gazeTracker.isVisible = true;
  17581. if (gazer._isActionableMesh) {
  17582. multiplier = 3;
  17583. }
  17584. if (this.updateGazeTrackerScale) {
  17585. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17586. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17587. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17588. }
  17589. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17590. // To avoid z-fighting
  17591. var deltaFighting = 0.002;
  17592. if (pickNormal) {
  17593. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17594. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17595. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17596. }
  17597. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17598. if (gazer._gazeTracker.position.x < 0) {
  17599. gazer._gazeTracker.position.x += deltaFighting;
  17600. }
  17601. else {
  17602. gazer._gazeTracker.position.x -= deltaFighting;
  17603. }
  17604. if (gazer._gazeTracker.position.y < 0) {
  17605. gazer._gazeTracker.position.y += deltaFighting;
  17606. }
  17607. else {
  17608. gazer._gazeTracker.position.y -= deltaFighting;
  17609. }
  17610. if (gazer._gazeTracker.position.z < 0) {
  17611. gazer._gazeTracker.position.z += deltaFighting;
  17612. }
  17613. else {
  17614. gazer._gazeTracker.position.z -= deltaFighting;
  17615. }
  17616. }
  17617. // Changing the size of the laser pointer based on the distance from the targetted point
  17618. gazer._updatePointerDistance(hit.distance);
  17619. }
  17620. else {
  17621. gazer._updatePointerDistance();
  17622. gazer._gazeTracker.isVisible = false;
  17623. }
  17624. if (hit && hit.pickedMesh) {
  17625. // The object selected is the floor, we're in a teleportation scenario
  17626. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17627. // Moving the teleportation area to this targetted point
  17628. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17629. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17630. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17631. }
  17632. gazer._currentMeshSelected = null;
  17633. if (gazer._teleportationRequestInitiated) {
  17634. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17635. }
  17636. return;
  17637. }
  17638. // If not, we're in a selection scenario
  17639. //this._teleportationAllowed = false;
  17640. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17641. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17642. this.onNewMeshPicked.notifyObservers(hit);
  17643. gazer._currentMeshSelected = hit.pickedMesh;
  17644. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17645. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17646. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17647. gazer._isActionableMesh = true;
  17648. }
  17649. else {
  17650. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17651. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17652. gazer._isActionableMesh = false;
  17653. }
  17654. try {
  17655. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17656. }
  17657. catch (err) {
  17658. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17659. }
  17660. }
  17661. else {
  17662. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17663. gazer._currentMeshSelected = null;
  17664. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17665. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17666. }
  17667. }
  17668. }
  17669. else {
  17670. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17671. gazer._currentMeshSelected = null;
  17672. //this._teleportationAllowed = false;
  17673. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17674. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17675. }
  17676. };
  17677. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17678. if (mesh) {
  17679. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17680. }
  17681. };
  17682. /**
  17683. * Sets the color of the laser ray from the vr controllers.
  17684. * @param color new color for the ray.
  17685. */
  17686. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17687. if (this._leftController) {
  17688. this._leftController._setLaserPointerColor(color);
  17689. }
  17690. if (this._rightController) {
  17691. this._rightController._setLaserPointerColor(color);
  17692. }
  17693. };
  17694. /**
  17695. * Sets the color of the ray from the vr headsets gaze.
  17696. * @param color new color for the ray.
  17697. */
  17698. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17699. if (!this.updateGazeTrackerColor) {
  17700. return;
  17701. }
  17702. if (!this._cameraGazer._gazeTracker.material) {
  17703. return;
  17704. }
  17705. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17706. if (this._leftController) {
  17707. this._leftController._gazeTracker.material.emissiveColor = color;
  17708. }
  17709. if (this._rightController) {
  17710. this._rightController._gazeTracker.material.emissiveColor = color;
  17711. }
  17712. };
  17713. /**
  17714. * Exits VR and disposes of the vr experience helper
  17715. */
  17716. VRExperienceHelper.prototype.dispose = function () {
  17717. if (this.isInVRMode) {
  17718. this.exitVR();
  17719. }
  17720. if (this._postProcessMove) {
  17721. this._postProcessMove.dispose();
  17722. }
  17723. if (this._webVRCamera) {
  17724. this._webVRCamera.dispose();
  17725. }
  17726. if (this._vrDeviceOrientationCamera) {
  17727. this._vrDeviceOrientationCamera.dispose();
  17728. }
  17729. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17730. document.body.removeChild(this._btnVR);
  17731. }
  17732. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17733. this._deviceOrientationCamera.dispose();
  17734. }
  17735. if (this._cameraGazer) {
  17736. this._cameraGazer.dispose();
  17737. }
  17738. if (this._leftController) {
  17739. this._leftController.dispose();
  17740. }
  17741. if (this._rightController) {
  17742. this._rightController.dispose();
  17743. }
  17744. if (this._teleportationTarget) {
  17745. this._teleportationTarget.dispose();
  17746. }
  17747. this._floorMeshesCollection = [];
  17748. document.removeEventListener("keydown", this._onKeyDown);
  17749. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17750. window.removeEventListener("resize", this._onResize);
  17751. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17752. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17753. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17754. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17755. document.onmsfullscreenchange = null;
  17756. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17757. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17758. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17759. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17760. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17761. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17762. this._scene.unregisterBeforeRender(this.beforeRender);
  17763. };
  17764. /**
  17765. * Gets the name of the VRExperienceHelper class
  17766. * @returns "VRExperienceHelper"
  17767. */
  17768. VRExperienceHelper.prototype.getClassName = function () {
  17769. return "VRExperienceHelper";
  17770. };
  17771. return VRExperienceHelper;
  17772. }());
  17773. /***/ }),
  17774. /***/ "./Cameras/VR/webVRCamera.ts":
  17775. /*!***********************************!*\
  17776. !*** ./Cameras/VR/webVRCamera.ts ***!
  17777. \***********************************/
  17778. /*! exports provided: WebVRFreeCamera */
  17779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17780. "use strict";
  17781. __webpack_require__.r(__webpack_exports__);
  17782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17783. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17784. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17785. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17786. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17787. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17788. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17789. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17790. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17791. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17792. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17793. // Side effect import to define the stereoscopic mode.
  17794. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17795. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17796. });
  17797. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17798. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17799. });
  17800. /**
  17801. * This represents a WebVR camera.
  17802. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17803. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17804. */
  17805. var WebVRFreeCamera = /** @class */ (function (_super) {
  17806. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17807. /**
  17808. * Instantiates a WebVRFreeCamera.
  17809. * @param name The name of the WebVRFreeCamera
  17810. * @param position The starting anchor position for the camera
  17811. * @param scene The scene the camera belongs to
  17812. * @param webVROptions a set of customizable options for the webVRCamera
  17813. */
  17814. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17815. if (webVROptions === void 0) { webVROptions = {}; }
  17816. var _this = _super.call(this, name, position, scene) || this;
  17817. _this.webVROptions = webVROptions;
  17818. /**
  17819. * @hidden
  17820. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17821. */
  17822. _this._vrDevice = null;
  17823. /**
  17824. * The rawPose of the vrDevice.
  17825. */
  17826. _this.rawPose = null;
  17827. _this._specsVersion = "1.1";
  17828. _this._attached = false;
  17829. _this._descendants = [];
  17830. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17831. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17832. /** @hidden */
  17833. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17834. _this._standingMatrix = null;
  17835. /**
  17836. * Represents device position in babylon space.
  17837. */
  17838. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17839. /**
  17840. * Represents device rotation in babylon space.
  17841. */
  17842. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17843. /**
  17844. * The scale of the device to be used when translating from device space to babylon space.
  17845. */
  17846. _this.deviceScaleFactor = 1;
  17847. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17848. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17849. /**
  17850. * References to the webVR controllers for the vrDevice.
  17851. */
  17852. _this.controllers = [];
  17853. /**
  17854. * Emits an event when a controller is attached.
  17855. */
  17856. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17857. /**
  17858. * Emits an event when a controller's mesh has been loaded;
  17859. */
  17860. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17861. /**
  17862. * Emits an event when the HMD's pose has been updated.
  17863. */
  17864. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17865. _this._poseSet = false;
  17866. /**
  17867. * If the rig cameras be used as parent instead of this camera.
  17868. */
  17869. _this.rigParenting = true;
  17870. _this._defaultHeight = undefined;
  17871. _this._htmlElementAttached = null;
  17872. _this._detachIfAttached = function () {
  17873. var vrDisplay = _this.getEngine().getVRDevice();
  17874. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17875. _this.detachControl(_this._htmlElementAttached);
  17876. }
  17877. };
  17878. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17879. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17880. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17881. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17882. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17883. if (webVROptions.defaultHeight) {
  17884. _this._defaultHeight = webVROptions.defaultHeight;
  17885. _this.position.y = _this._defaultHeight;
  17886. }
  17887. _this.minZ = 0.1;
  17888. //legacy support - the compensation boolean was removed.
  17889. if (arguments.length === 5) {
  17890. _this.webVROptions = arguments[4];
  17891. }
  17892. // default webVR options
  17893. if (_this.webVROptions.trackPosition == undefined) {
  17894. _this.webVROptions.trackPosition = true;
  17895. }
  17896. if (_this.webVROptions.controllerMeshes == undefined) {
  17897. _this.webVROptions.controllerMeshes = true;
  17898. }
  17899. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17900. _this.webVROptions.defaultLightingOnControllers = true;
  17901. }
  17902. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17903. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17904. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17905. }
  17906. //enable VR
  17907. var engine = _this.getEngine();
  17908. _this._onVREnabled = function (success) { if (success) {
  17909. _this.initControllers();
  17910. } };
  17911. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17912. engine.initWebVR().add(function (event) {
  17913. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17914. return;
  17915. }
  17916. _this._vrDevice = event.vrDisplay;
  17917. //reset the rig parameters.
  17918. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17919. if (_this._attached) {
  17920. _this.getEngine().enableVR();
  17921. }
  17922. });
  17923. if (typeof (VRFrameData) !== "undefined") {
  17924. _this._frameData = new VRFrameData();
  17925. }
  17926. /**
  17927. * The idea behind the following lines:
  17928. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17929. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17930. * the second will not show it correctly.
  17931. *
  17932. * To solve this - each object that has the camera as parent will be added to a protected array.
  17933. * When the rig camera renders, it will take this array and set all of those to be its children.
  17934. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17935. * Amazing!
  17936. */
  17937. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17938. if (camera.parent === _this && _this.rigParenting) {
  17939. _this._descendants = _this.getDescendants(true, function (n) {
  17940. // don't take the cameras or the controllers!
  17941. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17942. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17943. return !isController && !isRigCamera;
  17944. });
  17945. _this._descendants.forEach(function (node) {
  17946. node.parent = camera;
  17947. });
  17948. }
  17949. });
  17950. scene.onAfterCameraRenderObservable.add(function (camera) {
  17951. if (camera.parent === _this && _this.rigParenting) {
  17952. _this._descendants.forEach(function (node) {
  17953. node.parent = _this;
  17954. });
  17955. }
  17956. });
  17957. return _this;
  17958. }
  17959. /**
  17960. * Gets the device distance from the ground in meters.
  17961. * @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.
  17962. */
  17963. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17964. if (this._standingMatrix) {
  17965. // Add standing matrix offset to get real offset from ground in room
  17966. this._standingMatrix.getTranslationToRef(this._workingVector);
  17967. return this._deviceRoomPosition.y + this._workingVector.y;
  17968. }
  17969. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17970. return this._defaultHeight || 0;
  17971. };
  17972. /**
  17973. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17974. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17975. */
  17976. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17977. var _this = this;
  17978. if (callback === void 0) { callback = function (bool) { }; }
  17979. // Use standing matrix if available
  17980. this.getEngine().initWebVRAsync().then(function (result) {
  17981. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17982. callback(false);
  17983. }
  17984. else {
  17985. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17986. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17987. if (!_this.getScene().useRightHandedSystem) {
  17988. if (_this._standingMatrix) {
  17989. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17990. }
  17991. }
  17992. callback(true);
  17993. }
  17994. });
  17995. };
  17996. /**
  17997. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17998. * @returns A promise with a boolean set to if the standing matrix is supported.
  17999. */
  18000. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  18001. var _this = this;
  18002. return new Promise(function (res) {
  18003. _this.useStandingMatrix(function (supported) {
  18004. res(supported);
  18005. });
  18006. });
  18007. };
  18008. /**
  18009. * Disposes the camera
  18010. */
  18011. WebVRFreeCamera.prototype.dispose = function () {
  18012. this._detachIfAttached();
  18013. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18014. if (this._updateCacheWhenTrackingDisabledObserver) {
  18015. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18016. }
  18017. _super.prototype.dispose.call(this);
  18018. };
  18019. /**
  18020. * Gets a vrController by name.
  18021. * @param name The name of the controller to retreive
  18022. * @returns the controller matching the name specified or null if not found
  18023. */
  18024. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18025. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18026. var gp = _a[_i];
  18027. if (gp.hand === name) {
  18028. return gp;
  18029. }
  18030. }
  18031. return null;
  18032. };
  18033. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18034. /**
  18035. * The controller corrisponding to the users left hand.
  18036. */
  18037. get: function () {
  18038. if (!this._leftController) {
  18039. this._leftController = this.getControllerByName("left");
  18040. }
  18041. return this._leftController;
  18042. },
  18043. enumerable: true,
  18044. configurable: true
  18045. });
  18046. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18047. /**
  18048. * The controller corrisponding to the users right hand.
  18049. */
  18050. get: function () {
  18051. if (!this._rightController) {
  18052. this._rightController = this.getControllerByName("right");
  18053. }
  18054. return this._rightController;
  18055. },
  18056. enumerable: true,
  18057. configurable: true
  18058. });
  18059. /**
  18060. * Casts a ray forward from the vrCamera's gaze.
  18061. * @param length Length of the ray (default: 100)
  18062. * @returns the ray corrisponding to the gaze
  18063. */
  18064. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18065. if (length === void 0) { length = 100; }
  18066. if (this.leftCamera) {
  18067. // Use left eye to avoid computation to compute center on every call
  18068. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18069. }
  18070. else {
  18071. return _super.prototype.getForwardRay.call(this, length);
  18072. }
  18073. };
  18074. /**
  18075. * @hidden
  18076. * Updates the camera based on device's frame data
  18077. */
  18078. WebVRFreeCamera.prototype._checkInputs = function () {
  18079. if (this._vrDevice && this._vrDevice.isPresenting) {
  18080. this._vrDevice.getFrameData(this._frameData);
  18081. this.updateFromDevice(this._frameData.pose);
  18082. }
  18083. _super.prototype._checkInputs.call(this);
  18084. };
  18085. /**
  18086. * Updates the poseControlled values based on the input device pose.
  18087. * @param poseData Pose coming from the device
  18088. */
  18089. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18090. if (poseData && poseData.orientation) {
  18091. this.rawPose = poseData;
  18092. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18093. if (this.getScene().useRightHandedSystem) {
  18094. this._deviceRoomRotationQuaternion.z *= -1;
  18095. this._deviceRoomRotationQuaternion.w *= -1;
  18096. }
  18097. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18098. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18099. if (this.getScene().useRightHandedSystem) {
  18100. this._deviceRoomPosition.z *= -1;
  18101. }
  18102. }
  18103. this._poseSet = true;
  18104. }
  18105. };
  18106. /**
  18107. * WebVR's attach control will start broadcasting frames to the device.
  18108. * Note that in certain browsers (chrome for example) this function must be called
  18109. * within a user-interaction callback. Example:
  18110. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18111. *
  18112. * @param element html element to attach the vrDevice to
  18113. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18114. */
  18115. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18116. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18117. this._attached = true;
  18118. this._htmlElementAttached = element;
  18119. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18120. if (this._vrDevice) {
  18121. this.getEngine().enableVR();
  18122. }
  18123. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18124. };
  18125. /**
  18126. * Detaches the camera from the html element and disables VR
  18127. *
  18128. * @param element html element to detach from
  18129. */
  18130. WebVRFreeCamera.prototype.detachControl = function (element) {
  18131. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18132. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18133. _super.prototype.detachControl.call(this, element);
  18134. this._attached = false;
  18135. this.getEngine().disableVR();
  18136. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18137. };
  18138. /**
  18139. * @returns the name of this class
  18140. */
  18141. WebVRFreeCamera.prototype.getClassName = function () {
  18142. return "WebVRFreeCamera";
  18143. };
  18144. /**
  18145. * Calls resetPose on the vrDisplay
  18146. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18147. */
  18148. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18149. //uses the vrDisplay's "resetPose()".
  18150. //pitch and roll won't be affected.
  18151. this._vrDevice.resetPose();
  18152. };
  18153. /**
  18154. * @hidden
  18155. * Updates the rig cameras (left and right eye)
  18156. */
  18157. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18158. var camLeft = this._rigCameras[0];
  18159. var camRight = this._rigCameras[1];
  18160. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18161. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18162. camLeft.position.copyFrom(this._deviceRoomPosition);
  18163. camRight.position.copyFrom(this._deviceRoomPosition);
  18164. };
  18165. // Remove translation from 6dof headset if trackposition is set to false
  18166. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18167. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18168. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18169. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18170. if (!isViewMatrix) {
  18171. this._tmpMatrix.invert();
  18172. }
  18173. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18174. }
  18175. };
  18176. /**
  18177. * @hidden
  18178. * Updates the cached values of the camera
  18179. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18180. */
  18181. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18182. var _this = this;
  18183. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18184. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18185. if (!this.updateCacheCalled) {
  18186. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18187. this.updateCacheCalled = true;
  18188. this.update();
  18189. }
  18190. // Set working vector to the device position in room space rotated by the new rotation
  18191. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18192. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18193. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18194. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18195. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18196. // Add translation from anchor position
  18197. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18198. this._workingVector.addInPlace(this.position);
  18199. this._workingVector.subtractInPlace(this._cache.position);
  18200. this._deviceToWorld.setTranslation(this._workingVector);
  18201. // Set an inverted matrix to be used when updating the camera
  18202. this._deviceToWorld.invertToRef(this._worldToDevice);
  18203. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18204. this.controllers.forEach(function (controller) {
  18205. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18206. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18207. controller.update();
  18208. });
  18209. }
  18210. if (!ignoreParentClass) {
  18211. _super.prototype._updateCache.call(this);
  18212. }
  18213. this.updateCacheCalled = false;
  18214. };
  18215. /**
  18216. * @hidden
  18217. * Get current device position in babylon world
  18218. */
  18219. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18220. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18221. };
  18222. /**
  18223. * Updates the current device position and rotation in the babylon world
  18224. */
  18225. WebVRFreeCamera.prototype.update = function () {
  18226. this._computeDevicePosition();
  18227. // Get current device rotation in babylon world
  18228. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18229. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18230. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18231. if (this._poseSet) {
  18232. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18233. }
  18234. _super.prototype.update.call(this);
  18235. };
  18236. /**
  18237. * @hidden
  18238. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18239. * @returns an identity matrix
  18240. */
  18241. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18242. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18243. };
  18244. /**
  18245. * This function is called by the two RIG cameras.
  18246. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18247. * @hidden
  18248. */
  18249. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18250. // Update the parent camera prior to using a child camera to avoid desynchronization
  18251. var parentCamera = this._cameraRigParams["parentCamera"];
  18252. parentCamera._updateCache();
  18253. //WebVR 1.1
  18254. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18255. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18256. if (!this.getScene().useRightHandedSystem) {
  18257. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18258. }
  18259. // update the camera rotation matrix
  18260. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18261. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18262. // Computing target and final matrix
  18263. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18264. // should the view matrix be updated with scale and position offset?
  18265. if (parentCamera.deviceScaleFactor !== 1) {
  18266. this._webvrViewMatrix.invert();
  18267. // scale the position, if set
  18268. if (parentCamera.deviceScaleFactor) {
  18269. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18270. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18271. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18272. }
  18273. this._webvrViewMatrix.invert();
  18274. }
  18275. // Remove translation from 6dof headset if trackposition is set to false
  18276. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18277. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18278. // Compute global position
  18279. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18280. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18281. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18282. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18283. this._markSyncedWithParent();
  18284. return this._webvrViewMatrix;
  18285. };
  18286. /** @hidden */
  18287. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18288. var parentCamera = this.parent;
  18289. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18290. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18291. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18292. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18293. //babylon compatible matrix
  18294. if (!this.getScene().useRightHandedSystem) {
  18295. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18296. }
  18297. return this._projectionMatrix;
  18298. };
  18299. /**
  18300. * Initializes the controllers and their meshes
  18301. */
  18302. WebVRFreeCamera.prototype.initControllers = function () {
  18303. var _this = this;
  18304. this.controllers = [];
  18305. var manager = this.getScene().gamepadManager;
  18306. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18307. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18308. var webVrController = gamepad;
  18309. if (webVrController.defaultModel) {
  18310. webVrController.defaultModel.setEnabled(false);
  18311. }
  18312. if (webVrController.hand === "right") {
  18313. _this._rightController = null;
  18314. }
  18315. if (webVrController.hand === "left") {
  18316. _this._leftController = null;
  18317. }
  18318. var controllerIndex = _this.controllers.indexOf(webVrController);
  18319. if (controllerIndex !== -1) {
  18320. _this.controllers.splice(controllerIndex, 1);
  18321. }
  18322. }
  18323. });
  18324. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18325. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18326. var webVrController_1 = gamepad;
  18327. if (!_this.webVROptions.trackPosition) {
  18328. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18329. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18330. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18331. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18332. _this._updateCache();
  18333. });
  18334. }
  18335. }
  18336. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18337. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18338. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18339. if (_this.webVROptions.controllerMeshes) {
  18340. if (webVrController_1.defaultModel) {
  18341. webVrController_1.defaultModel.setEnabled(true);
  18342. }
  18343. else {
  18344. // Load the meshes
  18345. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18346. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18347. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18348. if (_this.webVROptions.defaultLightingOnControllers) {
  18349. if (!_this._lightOnControllers) {
  18350. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18351. }
  18352. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18353. var children = mesh.getChildren();
  18354. if (children && children.length !== 0) {
  18355. children.forEach(function (mesh) {
  18356. light.includedOnlyMeshes.push(mesh);
  18357. activateLightOnSubMeshes_1(mesh, light);
  18358. });
  18359. }
  18360. };
  18361. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18362. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18363. }
  18364. });
  18365. }
  18366. }
  18367. webVrController_1.attachToPoseControlledCamera(_this);
  18368. // since this is async - sanity check. Is the controller already stored?
  18369. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18370. //add to the controllers array
  18371. _this.controllers.push(webVrController_1);
  18372. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18373. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18374. // So we're overriding setting left & right manually to be sure
  18375. var firstViveWandDetected = false;
  18376. for (var i = 0; i < _this.controllers.length; i++) {
  18377. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18378. if (!firstViveWandDetected) {
  18379. firstViveWandDetected = true;
  18380. _this.controllers[i].hand = "left";
  18381. }
  18382. else {
  18383. _this.controllers[i].hand = "right";
  18384. }
  18385. }
  18386. }
  18387. //did we find enough controllers? Great! let the developer know.
  18388. if (_this.controllers.length >= 2) {
  18389. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18390. }
  18391. }
  18392. }
  18393. });
  18394. };
  18395. return WebVRFreeCamera;
  18396. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18397. /***/ }),
  18398. /***/ "./Cameras/XR/index.ts":
  18399. /*!*****************************!*\
  18400. !*** ./Cameras/XR/index.ts ***!
  18401. \*****************************/
  18402. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18404. "use strict";
  18405. __webpack_require__.r(__webpack_exports__);
  18406. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18408. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18412. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18415. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18418. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18420. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18422. /***/ }),
  18423. /***/ "./Cameras/XR/webXRCamera.ts":
  18424. /*!***********************************!*\
  18425. !*** ./Cameras/XR/webXRCamera.ts ***!
  18426. \***********************************/
  18427. /*! exports provided: WebXRCamera */
  18428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18429. "use strict";
  18430. __webpack_require__.r(__webpack_exports__);
  18431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18432. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18433. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18434. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18435. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18436. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18437. /**
  18438. * WebXR Camera which holds the views for the xrSession
  18439. * @see https://doc.babylonjs.com/how_to/webxr
  18440. */
  18441. var WebXRCamera = /** @class */ (function (_super) {
  18442. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18443. /**
  18444. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18445. * @param name the name of the camera
  18446. * @param scene the scene to add the camera to
  18447. */
  18448. function WebXRCamera(name, scene) {
  18449. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18450. // Initial camera configuration
  18451. _this.minZ = 0;
  18452. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18453. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18454. _this.updateUpVectorFromRotation = true;
  18455. _this._updateNumberOfRigCameras(1);
  18456. return _this;
  18457. }
  18458. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18459. if (viewCount === void 0) { viewCount = 1; }
  18460. while (this.rigCameras.length < viewCount) {
  18461. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18462. newCamera.minZ = 0;
  18463. newCamera.parent = this;
  18464. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18465. newCamera.updateUpVectorFromRotation = true;
  18466. this.rigCameras.push(newCamera);
  18467. }
  18468. while (this.rigCameras.length > viewCount) {
  18469. var removedCamera = this.rigCameras.pop();
  18470. if (removedCamera) {
  18471. removedCamera.dispose();
  18472. }
  18473. }
  18474. };
  18475. /** @hidden */
  18476. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18477. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18478. // Create initial camera rigs
  18479. this._updateNumberOfRigCameras(2);
  18480. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18481. this.rigCameras[0].position.x = -pupilDistance / 2;
  18482. this.rigCameras[0].outputRenderTarget = null;
  18483. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18484. this.rigCameras[1].position.x = pupilDistance / 2;
  18485. this.rigCameras[1].outputRenderTarget = null;
  18486. };
  18487. /**
  18488. * Updates the cameras position from the current pose information of the XR session
  18489. * @param xrSessionManager the session containing pose information
  18490. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18491. */
  18492. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18493. var _this = this;
  18494. // Ensure all frame data is available
  18495. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18496. return false;
  18497. }
  18498. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18499. if (!pose || !pose.poseModelMatrix) {
  18500. return false;
  18501. }
  18502. // Update the parent cameras matrix
  18503. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18504. if (!this._scene.useRightHandedSystem) {
  18505. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18506. }
  18507. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18508. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18509. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18510. this.computeWorldMatrix();
  18511. // Update camera rigs
  18512. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18513. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18514. // Update view/projection matrix
  18515. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18516. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18517. if (!_this._scene.useRightHandedSystem) {
  18518. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18519. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18520. }
  18521. // Update viewport
  18522. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18523. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18524. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18525. _this.rigCameras[i].viewport.width = viewport.width / width;
  18526. _this.rigCameras[i].viewport.height = viewport.height / height;
  18527. _this.rigCameras[i].viewport.x = viewport.x / width;
  18528. _this.rigCameras[i].viewport.y = viewport.y / height;
  18529. // Set cameras to render to the session's render target
  18530. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18531. });
  18532. return true;
  18533. };
  18534. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18535. return WebXRCamera;
  18536. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18537. /***/ }),
  18538. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18539. /*!****************************************!*\
  18540. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18541. \****************************************/
  18542. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18544. "use strict";
  18545. __webpack_require__.r(__webpack_exports__);
  18546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18550. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18551. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18552. /**
  18553. * Button which can be used to enter a different mode of XR
  18554. */
  18555. var WebXREnterExitUIButton = /** @class */ (function () {
  18556. /**
  18557. * Creates a WebXREnterExitUIButton
  18558. * @param element button element
  18559. * @param initializationOptions XR initialization options for the button
  18560. */
  18561. function WebXREnterExitUIButton(
  18562. /** button element */
  18563. element,
  18564. /** XR initialization options for the button */
  18565. initializationOptions) {
  18566. this.element = element;
  18567. this.initializationOptions = initializationOptions;
  18568. }
  18569. /**
  18570. * Overwritable function which can be used to update the button's visuals when the state changes
  18571. * @param activeButton the current active button in the UI
  18572. */
  18573. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18574. };
  18575. return WebXREnterExitUIButton;
  18576. }());
  18577. /**
  18578. * Options to create the webXR UI
  18579. */
  18580. var WebXREnterExitUIOptions = /** @class */ (function () {
  18581. function WebXREnterExitUIOptions() {
  18582. }
  18583. return WebXREnterExitUIOptions;
  18584. }());
  18585. /**
  18586. * UI to allow the user to enter/exit XR mode
  18587. */
  18588. var WebXREnterExitUI = /** @class */ (function () {
  18589. function WebXREnterExitUI(scene, options) {
  18590. var _this = this;
  18591. this.scene = scene;
  18592. this._buttons = [];
  18593. this._activeButton = null;
  18594. /**
  18595. * Fired every time the active button is changed.
  18596. *
  18597. * When xr is entered via a button that launches xr that button will be the callback parameter
  18598. *
  18599. * When exiting xr the callback parameter will be null)
  18600. */
  18601. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18602. this._overlay = document.createElement("div");
  18603. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18604. if (options.customButtons) {
  18605. this._buttons = options.customButtons;
  18606. }
  18607. else {
  18608. var hmdBtn = document.createElement("button");
  18609. 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;";
  18610. hmdBtn.innerText = "HMD";
  18611. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18612. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18613. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18614. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18615. };
  18616. var windowBtn = document.createElement("button");
  18617. windowBtn.style.cssText = hmdBtn.style.cssText;
  18618. windowBtn.innerText = "Window";
  18619. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18620. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18621. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18622. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18623. };
  18624. this._updateButtons(null);
  18625. }
  18626. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18627. if (renderCanvas && renderCanvas.parentNode) {
  18628. renderCanvas.parentNode.appendChild(this._overlay);
  18629. scene.onDisposeObservable.addOnce(function () {
  18630. _this.dispose();
  18631. });
  18632. }
  18633. }
  18634. /**
  18635. * Creates UI to allow the user to enter/exit XR mode
  18636. * @param scene the scene to add the ui to
  18637. * @param helper the xr experience helper to enter/exit xr with
  18638. * @param options options to configure the UI
  18639. * @returns the created ui
  18640. */
  18641. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18642. var _this = this;
  18643. var ui = new WebXREnterExitUI(scene, options);
  18644. var supportedPromises = ui._buttons.map(function (btn) {
  18645. return helper.supportsSessionAsync(btn.initializationOptions);
  18646. });
  18647. helper.onStateChangedObservable.add(function (state) {
  18648. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18649. ui._updateButtons(null);
  18650. }
  18651. });
  18652. return Promise.all(supportedPromises).then(function (results) {
  18653. results.forEach(function (supported, i) {
  18654. if (supported) {
  18655. ui._overlay.appendChild(ui._buttons[i].element);
  18656. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18657. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18658. switch (_a.label) {
  18659. case 0:
  18660. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18661. ui._updateButtons(null);
  18662. return [4 /*yield*/, helper.exitXRAsync()];
  18663. case 1:
  18664. _a.sent();
  18665. return [2 /*return*/];
  18666. case 2:
  18667. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18668. ui._updateButtons(ui._buttons[i]);
  18669. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18670. case 3:
  18671. _a.sent();
  18672. _a.label = 4;
  18673. case 4: return [2 /*return*/];
  18674. }
  18675. });
  18676. }); };
  18677. }
  18678. });
  18679. return ui;
  18680. });
  18681. };
  18682. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18683. var _this = this;
  18684. this._activeButton = activeButton;
  18685. this._buttons.forEach(function (b) {
  18686. b.update(_this._activeButton);
  18687. });
  18688. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18689. };
  18690. /**
  18691. * Disposes of the object
  18692. */
  18693. WebXREnterExitUI.prototype.dispose = function () {
  18694. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18695. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18696. renderCanvas.parentNode.removeChild(this._overlay);
  18697. }
  18698. this.activeButtonChangedObservable.clear();
  18699. };
  18700. return WebXREnterExitUI;
  18701. }());
  18702. /***/ }),
  18703. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18704. /*!*********************************************!*\
  18705. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18706. \*********************************************/
  18707. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18709. "use strict";
  18710. __webpack_require__.r(__webpack_exports__);
  18711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18713. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18714. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18715. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18716. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18717. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18718. /**
  18719. * States of the webXR experience
  18720. */
  18721. var WebXRState;
  18722. (function (WebXRState) {
  18723. /**
  18724. * Transitioning to being in XR mode
  18725. */
  18726. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18727. /**
  18728. * Transitioning to non XR mode
  18729. */
  18730. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18731. /**
  18732. * In XR mode and presenting
  18733. */
  18734. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18735. /**
  18736. * Not entered XR mode
  18737. */
  18738. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18739. })(WebXRState || (WebXRState = {}));
  18740. /**
  18741. * Helper class used to enable XR
  18742. * @see https://doc.babylonjs.com/how_to/webxr
  18743. */
  18744. var WebXRExperienceHelper = /** @class */ (function () {
  18745. /**
  18746. * Creates a WebXRExperienceHelper
  18747. * @param scene The scene the helper should be created in
  18748. */
  18749. function WebXRExperienceHelper(scene) {
  18750. this.scene = scene;
  18751. /**
  18752. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18753. */
  18754. this.state = WebXRState.NOT_IN_XR;
  18755. /**
  18756. * Fires when the state of the experience helper has changed
  18757. */
  18758. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18759. this._nonVRCamera = null;
  18760. this._originalSceneAutoClear = true;
  18761. this._supported = false;
  18762. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18763. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18764. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18765. this.camera.parent = this.container;
  18766. }
  18767. WebXRExperienceHelper.prototype._setState = function (val) {
  18768. this.state = val;
  18769. this.onStateChangedObservable.notifyObservers(this.state);
  18770. };
  18771. /**
  18772. * Creates the experience helper
  18773. * @param scene the scene to attach the experience helper to
  18774. * @returns a promise for the experience helper
  18775. */
  18776. WebXRExperienceHelper.CreateAsync = function (scene) {
  18777. var helper = new WebXRExperienceHelper(scene);
  18778. return helper._sessionManager.initializeAsync().then(function () {
  18779. helper._supported = true;
  18780. return helper;
  18781. }).catch(function () {
  18782. return helper;
  18783. });
  18784. };
  18785. /**
  18786. * Exits XR mode and returns the scene to its original state
  18787. * @returns promise that resolves after xr mode has exited
  18788. */
  18789. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18790. this._setState(WebXRState.EXITING_XR);
  18791. return this._sessionManager.exitXRAsync();
  18792. };
  18793. /**
  18794. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18795. * @param sessionCreationOptions options for the XR session
  18796. * @param frameOfReference frame of reference of the XR session
  18797. * @returns promise that resolves after xr mode has entered
  18798. */
  18799. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18800. var _this = this;
  18801. if (!this._supported) {
  18802. throw "XR session not supported by this browser";
  18803. }
  18804. this._setState(WebXRState.ENTERING_XR);
  18805. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18806. // Cache pre xr scene settings
  18807. _this._originalSceneAutoClear = _this.scene.autoClear;
  18808. _this._nonVRCamera = _this.scene.activeCamera;
  18809. // Overwrite current scene settings
  18810. _this.scene.autoClear = false;
  18811. _this.scene.activeCamera = _this.camera;
  18812. _this._sessionManager.onXRFrameObservable.add(function () {
  18813. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18814. });
  18815. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18816. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18817. _this.camera.rigCameras.forEach(function (c) {
  18818. c.outputRenderTarget = null;
  18819. });
  18820. // Restore scene settings
  18821. _this.scene.autoClear = _this._originalSceneAutoClear;
  18822. _this.scene.activeCamera = _this._nonVRCamera;
  18823. _this._sessionManager.onXRFrameObservable.clear();
  18824. _this._setState(WebXRState.NOT_IN_XR);
  18825. });
  18826. _this._setState(WebXRState.IN_XR);
  18827. });
  18828. };
  18829. /**
  18830. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18831. * @param ray ray to cast into the environment
  18832. * @returns Promise which resolves with a collision point in the environment if it exists
  18833. */
  18834. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18835. return this._sessionManager.environmentPointHitTestAsync(ray);
  18836. };
  18837. /**
  18838. * Updates the global position of the camera by moving the camera's container
  18839. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18840. * @param position The desired global position of the camera
  18841. */
  18842. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18843. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18844. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18845. };
  18846. /**
  18847. * Rotates the xr camera by rotating the camera's container around the camera's position
  18848. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18849. * @param rotation the desired quaternion rotation to apply to the camera
  18850. */
  18851. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18852. if (!this.container.rotationQuaternion) {
  18853. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18854. }
  18855. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18856. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18857. };
  18858. /**
  18859. * Checks if the creation options are supported by the xr session
  18860. * @param options creation options
  18861. * @returns true if supported
  18862. */
  18863. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18864. if (!this._supported) {
  18865. return Promise.resolve(false);
  18866. }
  18867. return this._sessionManager.supportsSessionAsync(options);
  18868. };
  18869. /**
  18870. * Disposes of the experience helper
  18871. */
  18872. WebXRExperienceHelper.prototype.dispose = function () {
  18873. this.camera.dispose();
  18874. this.container.dispose();
  18875. this.onStateChangedObservable.clear();
  18876. this._sessionManager.dispose();
  18877. };
  18878. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18879. return WebXRExperienceHelper;
  18880. }());
  18881. /***/ }),
  18882. /***/ "./Cameras/XR/webXRInput.ts":
  18883. /*!**********************************!*\
  18884. !*** ./Cameras/XR/webXRInput.ts ***!
  18885. \**********************************/
  18886. /*! exports provided: WebXRController, WebXRInput */
  18887. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18888. "use strict";
  18889. __webpack_require__.r(__webpack_exports__);
  18890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18892. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18893. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18894. /**
  18895. * Represents an XR input
  18896. */
  18897. var WebXRController = /** @class */ (function () {
  18898. /**
  18899. * Creates the controller
  18900. * @see https://doc.babylonjs.com/how_to/webxr
  18901. * @param scene the scene which the controller should be associated to
  18902. */
  18903. function WebXRController(scene) {
  18904. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18905. }
  18906. /**
  18907. * Disposes of the object
  18908. */
  18909. WebXRController.prototype.dispose = function () {
  18910. if (this.grip) {
  18911. this.grip.dispose();
  18912. }
  18913. this.pointer.dispose();
  18914. };
  18915. return WebXRController;
  18916. }());
  18917. /**
  18918. * XR input used to track XR inputs such as controllers/rays
  18919. */
  18920. var WebXRInput = /** @class */ (function () {
  18921. /**
  18922. * Initializes the WebXRInput
  18923. * @param helper experience helper which the input should be created for
  18924. */
  18925. function WebXRInput(helper) {
  18926. var _this = this;
  18927. this.helper = helper;
  18928. /**
  18929. * XR controllers being tracked
  18930. */
  18931. this.controllers = [];
  18932. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18933. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18934. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18935. return;
  18936. }
  18937. var xrFrame = helper._sessionManager._currentXRFrame;
  18938. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18939. inputSources.forEach(function (input, i) {
  18940. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18941. if (inputPose) {
  18942. if (_this.controllers.length <= i) {
  18943. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18944. }
  18945. var controller = _this.controllers[i];
  18946. // Manage the grip if it exists
  18947. if (inputPose.gripMatrix) {
  18948. if (!controller.grip) {
  18949. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18950. }
  18951. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18952. if (!controller.grip.getScene().useRightHandedSystem) {
  18953. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18954. }
  18955. if (!controller.grip.rotationQuaternion) {
  18956. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18957. }
  18958. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18959. }
  18960. // Manager pointer of controller
  18961. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18962. if (!controller.pointer.getScene().useRightHandedSystem) {
  18963. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18964. }
  18965. if (!controller.pointer.rotationQuaternion) {
  18966. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18967. }
  18968. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18969. }
  18970. });
  18971. });
  18972. }
  18973. /**
  18974. * Disposes of the object
  18975. */
  18976. WebXRInput.prototype.dispose = function () {
  18977. this.controllers.forEach(function (c) {
  18978. c.dispose();
  18979. });
  18980. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18981. };
  18982. return WebXRInput;
  18983. }());
  18984. /***/ }),
  18985. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18986. /*!************************************************!*\
  18987. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18988. \************************************************/
  18989. /*! exports provided: WebXRManagedOutputCanvas */
  18990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18991. "use strict";
  18992. __webpack_require__.r(__webpack_exports__);
  18993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18994. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18995. /**
  18996. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18997. */
  18998. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18999. /**
  19000. * Initializes the canvas to be added/removed upon entering/exiting xr
  19001. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  19002. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  19003. */
  19004. function WebXRManagedOutputCanvas(helper, canvas) {
  19005. var _this = this;
  19006. this._canvas = null;
  19007. /**
  19008. * xrpresent context of the canvas which can be used to display/mirror xr content
  19009. */
  19010. this.canvasContext = null;
  19011. if (!canvas) {
  19012. canvas = document.createElement('canvas');
  19013. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  19014. }
  19015. this._setManagedOutputCanvas(canvas);
  19016. helper.onStateChangedObservable.add(function (stateInfo) {
  19017. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19018. // 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
  19019. _this._addCanvas();
  19020. }
  19021. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19022. _this._removeCanvas();
  19023. }
  19024. });
  19025. }
  19026. /**
  19027. * Disposes of the object
  19028. */
  19029. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19030. this._removeCanvas();
  19031. this._setManagedOutputCanvas(null);
  19032. };
  19033. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19034. this._removeCanvas();
  19035. if (!canvas) {
  19036. this._canvas = null;
  19037. this.canvasContext = null;
  19038. }
  19039. else {
  19040. this._canvas = canvas;
  19041. this.canvasContext = this._canvas.getContext('xrpresent');
  19042. }
  19043. };
  19044. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  19045. if (this._canvas) {
  19046. document.body.appendChild(this._canvas);
  19047. }
  19048. };
  19049. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  19050. if (this._canvas && document.body.contains(this._canvas)) {
  19051. document.body.removeChild(this._canvas);
  19052. }
  19053. };
  19054. return WebXRManagedOutputCanvas;
  19055. }());
  19056. /***/ }),
  19057. /***/ "./Cameras/XR/webXRSessionManager.ts":
  19058. /*!*******************************************!*\
  19059. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  19060. \*******************************************/
  19061. /*! exports provided: WebXRSessionManager */
  19062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19063. "use strict";
  19064. __webpack_require__.r(__webpack_exports__);
  19065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  19066. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  19067. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19068. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19069. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  19070. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  19071. /**
  19072. * Manages an XRSession
  19073. * @see https://doc.babylonjs.com/how_to/webxr
  19074. */
  19075. var WebXRSessionManager = /** @class */ (function () {
  19076. /**
  19077. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  19078. * @param scene The scene which the session should be created for
  19079. */
  19080. function WebXRSessionManager(scene) {
  19081. this.scene = scene;
  19082. /**
  19083. * Fires every time a new xrFrame arrives which can be used to update the camera
  19084. */
  19085. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19086. /**
  19087. * Fires when the xr session is ended either by the device or manually done
  19088. */
  19089. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19090. /** @hidden */
  19091. this._sessionRenderTargetTexture = null;
  19092. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  19093. }
  19094. /**
  19095. * Initializes the manager
  19096. * After initialization enterXR can be called to start an XR session
  19097. * @returns Promise which resolves after it is initialized
  19098. */
  19099. WebXRSessionManager.prototype.initializeAsync = function () {
  19100. var _this = this;
  19101. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  19102. // Check if the browser supports webXR
  19103. this._xrNavigator = navigator;
  19104. if (!this._xrNavigator.xr) {
  19105. return Promise.reject("webXR not supported by this browser");
  19106. }
  19107. // Request the webXR device
  19108. return this._xrNavigator.xr.requestDevice().then(function (device) {
  19109. _this._xrDevice = device;
  19110. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  19111. });
  19112. };
  19113. /**
  19114. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  19115. * @param sessionCreationOptions xr options to create the session with
  19116. * @param frameOfReferenceType option to configure how the xr pose is expressed
  19117. * @returns Promise which resolves after it enters XR
  19118. */
  19119. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  19120. var _this = this;
  19121. // initialize session
  19122. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  19123. _this._xrSession = session;
  19124. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  19125. _this._xrSession.addEventListener("end", function () {
  19126. // Remove render target texture and notify frame obervers
  19127. _this._sessionRenderTargetTexture = null;
  19128. // Restore frame buffer to avoid clear on xr framebuffer after session end
  19129. _this.scene.getEngine().restoreDefaultFramebuffer();
  19130. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  19131. _this.scene.getEngine().customAnimationFrameRequester = null;
  19132. _this.onXRSessionEnded.notifyObservers(null);
  19133. _this.scene.getEngine()._renderLoop();
  19134. }, { once: true });
  19135. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  19136. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  19137. }).then(function (frameOfRef) {
  19138. _this._frameOfReference = frameOfRef;
  19139. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  19140. _this.scene.getEngine().customAnimationFrameRequester = {
  19141. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  19142. renderFunction: function (timestamp, xrFrame) {
  19143. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  19144. _this._currentXRFrame = xrFrame;
  19145. _this.onXRFrameObservable.notifyObservers(null);
  19146. _this.scene.getEngine()._renderLoop();
  19147. }
  19148. };
  19149. // Create render target texture from xr's webgl render target
  19150. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  19151. // Stop window's animation frame and trigger sessions animation frame
  19152. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  19153. _this.scene.getEngine()._renderLoop();
  19154. });
  19155. };
  19156. /**
  19157. * Stops the xrSession and restores the renderloop
  19158. * @returns Promise which resolves after it exits XR
  19159. */
  19160. WebXRSessionManager.prototype.exitXRAsync = function () {
  19161. return this._xrSession.end();
  19162. };
  19163. /**
  19164. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19165. * @param ray ray to cast into the environment
  19166. * @returns Promise which resolves with a collision point in the environment if it exists
  19167. */
  19168. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  19169. var _this = this;
  19170. return new Promise(function (res) {
  19171. // Compute left handed inputs to request hit test
  19172. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  19173. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  19174. if (!_this.scene.useRightHandedSystem) {
  19175. origin[2] *= -1;
  19176. direction[2] *= -1;
  19177. }
  19178. // Fire hittest
  19179. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  19180. .then(function (hits) {
  19181. if (hits.length > 0) {
  19182. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  19183. var hitPoint = _this._tmpMatrix.getTranslation();
  19184. if (!_this.scene.useRightHandedSystem) {
  19185. hitPoint.z *= -1;
  19186. }
  19187. res(hitPoint);
  19188. }
  19189. else {
  19190. res(null);
  19191. }
  19192. }).catch(function () {
  19193. res(null);
  19194. });
  19195. });
  19196. };
  19197. /**
  19198. * Checks if a session would be supported for the creation options specified
  19199. * @param options creation options to check if they are supported
  19200. * @returns true if supported
  19201. */
  19202. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  19203. return this._xrDevice.supportsSession(options).then(function () {
  19204. return true;
  19205. }).catch(function () {
  19206. return false;
  19207. });
  19208. };
  19209. /**
  19210. * @hidden
  19211. * Converts the render layer of xrSession to a render target
  19212. * @param session session to create render target for
  19213. * @param scene scene the new render target should be created for
  19214. */
  19215. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  19216. // Create internal texture
  19217. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  19218. internalTexture.width = session.baseLayer.framebufferWidth;
  19219. internalTexture.height = session.baseLayer.framebufferHeight;
  19220. internalTexture._framebuffer = session.baseLayer.framebuffer;
  19221. // Create render target texture from the internal texture
  19222. 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);
  19223. renderTargetTexture._texture = internalTexture;
  19224. return renderTargetTexture;
  19225. };
  19226. /**
  19227. * Disposes of the session manager
  19228. */
  19229. WebXRSessionManager.prototype.dispose = function () {
  19230. this.onXRFrameObservable.clear();
  19231. this.onXRSessionEnded.clear();
  19232. };
  19233. return WebXRSessionManager;
  19234. }());
  19235. /***/ }),
  19236. /***/ "./Cameras/arcRotateCamera.ts":
  19237. /*!************************************!*\
  19238. !*** ./Cameras/arcRotateCamera.ts ***!
  19239. \************************************/
  19240. /*! exports provided: ArcRotateCamera */
  19241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19242. "use strict";
  19243. __webpack_require__.r(__webpack_exports__);
  19244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  19245. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19246. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19247. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19248. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19249. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  19250. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  19251. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  19252. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  19253. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  19254. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  19255. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  19256. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  19257. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  19258. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  19259. });
  19260. /**
  19261. * This represents an orbital type of camera.
  19262. *
  19263. * 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.
  19264. * 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.
  19265. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  19266. */
  19267. var ArcRotateCamera = /** @class */ (function (_super) {
  19268. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  19269. /**
  19270. * Instantiates a new ArcRotateCamera in a given scene
  19271. * @param name Defines the name of the camera
  19272. * @param alpha Defines the camera rotation along the logitudinal axis
  19273. * @param beta Defines the camera rotation along the latitudinal axis
  19274. * @param radius Defines the camera distance from its target
  19275. * @param target Defines the camera target
  19276. * @param scene Defines the scene the camera belongs to
  19277. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19278. */
  19279. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  19280. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19281. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  19282. /**
  19283. * Current inertia value on the longitudinal axis.
  19284. * The bigger this number the longer it will take for the camera to stop.
  19285. */
  19286. _this.inertialAlphaOffset = 0;
  19287. /**
  19288. * Current inertia value on the latitudinal axis.
  19289. * The bigger this number the longer it will take for the camera to stop.
  19290. */
  19291. _this.inertialBetaOffset = 0;
  19292. /**
  19293. * Current inertia value on the radius axis.
  19294. * The bigger this number the longer it will take for the camera to stop.
  19295. */
  19296. _this.inertialRadiusOffset = 0;
  19297. /**
  19298. * Minimum allowed angle on the longitudinal axis.
  19299. * This can help limiting how the Camera is able to move in the scene.
  19300. */
  19301. _this.lowerAlphaLimit = null;
  19302. /**
  19303. * Maximum allowed angle on the longitudinal axis.
  19304. * This can help limiting how the Camera is able to move in the scene.
  19305. */
  19306. _this.upperAlphaLimit = null;
  19307. /**
  19308. * Minimum allowed angle on the latitudinal axis.
  19309. * This can help limiting how the Camera is able to move in the scene.
  19310. */
  19311. _this.lowerBetaLimit = 0.01;
  19312. /**
  19313. * Maximum allowed angle on the latitudinal axis.
  19314. * This can help limiting how the Camera is able to move in the scene.
  19315. */
  19316. _this.upperBetaLimit = Math.PI - 0.01;
  19317. /**
  19318. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  19319. * This can help limiting how the Camera is able to move in the scene.
  19320. */
  19321. _this.lowerRadiusLimit = null;
  19322. /**
  19323. * Maximum allowed distance of the camera to the target (The camera can not get further).
  19324. * This can help limiting how the Camera is able to move in the scene.
  19325. */
  19326. _this.upperRadiusLimit = null;
  19327. /**
  19328. * Defines the current inertia value used during panning of the camera along the X axis.
  19329. */
  19330. _this.inertialPanningX = 0;
  19331. /**
  19332. * Defines the current inertia value used during panning of the camera along the Y axis.
  19333. */
  19334. _this.inertialPanningY = 0;
  19335. /**
  19336. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  19337. * Basically if your fingers moves away from more than this distance you will be considered
  19338. * in pinch mode.
  19339. */
  19340. _this.pinchToPanMaxDistance = 20;
  19341. /**
  19342. * Defines the maximum distance the camera can pan.
  19343. * This could help keeping the cammera always in your scene.
  19344. */
  19345. _this.panningDistanceLimit = null;
  19346. /**
  19347. * Defines the target of the camera before paning.
  19348. */
  19349. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19350. /**
  19351. * Defines the value of the inertia used during panning.
  19352. * 0 would mean stop inertia and one would mean no decelleration at all.
  19353. */
  19354. _this.panningInertia = 0.9;
  19355. //-- end properties for backward compatibility for inputs
  19356. /**
  19357. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  19358. */
  19359. _this.zoomOnFactor = 1;
  19360. /**
  19361. * Defines a screen offset for the camera position.
  19362. */
  19363. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19364. /**
  19365. * Allows the camera to be completely reversed.
  19366. * If false the camera can not arrive upside down.
  19367. */
  19368. _this.allowUpsideDown = true;
  19369. /**
  19370. * Define if double tap/click is used to restore the previously saved state of the camera.
  19371. */
  19372. _this.useInputToRestoreState = true;
  19373. /** @hidden */
  19374. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19375. /**
  19376. * Defines the allowed panning axis.
  19377. */
  19378. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  19379. /**
  19380. * Observable triggered when the mesh target has been changed on the camera.
  19381. */
  19382. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  19383. /**
  19384. * Defines whether the camera should check collision with the objects oh the scene.
  19385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  19386. */
  19387. _this.checkCollisions = false;
  19388. /**
  19389. * Defines the collision radius of the camera.
  19390. * This simulates a sphere around the camera.
  19391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19392. */
  19393. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  19394. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19395. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19396. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19397. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19398. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  19399. if (collidedMesh === void 0) { collidedMesh = null; }
  19400. if (!collidedMesh) {
  19401. _this._previousPosition.copyFrom(_this._position);
  19402. }
  19403. else {
  19404. _this.setPosition(newPosition);
  19405. if (_this.onCollide) {
  19406. _this.onCollide(collidedMesh);
  19407. }
  19408. }
  19409. // Recompute because of constraints
  19410. var cosa = Math.cos(_this.alpha);
  19411. var sina = Math.sin(_this.alpha);
  19412. var cosb = Math.cos(_this.beta);
  19413. var sinb = Math.sin(_this.beta);
  19414. if (sinb === 0) {
  19415. sinb = 0.0001;
  19416. }
  19417. var target = _this._getTargetPosition();
  19418. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19419. target.addToRef(_this._computationVector, _this._newPosition);
  19420. _this._position.copyFrom(_this._newPosition);
  19421. var up = _this.upVector;
  19422. if (_this.allowUpsideDown && _this.beta < 0) {
  19423. up = up.clone();
  19424. up = up.negate();
  19425. }
  19426. _this._computeViewMatrix(_this._position, target, up);
  19427. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19428. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19429. _this._collisionTriggered = false;
  19430. };
  19431. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19432. if (target) {
  19433. _this.setTarget(target);
  19434. }
  19435. _this.alpha = alpha;
  19436. _this.beta = beta;
  19437. _this.radius = radius;
  19438. _this.getViewMatrix();
  19439. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19440. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19441. return _this;
  19442. }
  19443. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19444. /**
  19445. * Defines the target point of the camera.
  19446. * The camera looks towards it form the radius distance.
  19447. */
  19448. get: function () {
  19449. return this._target;
  19450. },
  19451. set: function (value) {
  19452. this.setTarget(value);
  19453. },
  19454. enumerable: true,
  19455. configurable: true
  19456. });
  19457. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  19458. /**
  19459. * Define the current local position of the camera in the scene
  19460. */
  19461. get: function () {
  19462. return this._position;
  19463. },
  19464. set: function (newPosition) {
  19465. this.setPosition(newPosition);
  19466. },
  19467. enumerable: true,
  19468. configurable: true
  19469. });
  19470. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19471. //-- begin properties for backward compatibility for inputs
  19472. /**
  19473. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19474. */
  19475. get: function () {
  19476. var pointers = this.inputs.attached["pointers"];
  19477. if (pointers) {
  19478. return pointers.angularSensibilityX;
  19479. }
  19480. return 0;
  19481. },
  19482. set: function (value) {
  19483. var pointers = this.inputs.attached["pointers"];
  19484. if (pointers) {
  19485. pointers.angularSensibilityX = value;
  19486. }
  19487. },
  19488. enumerable: true,
  19489. configurable: true
  19490. });
  19491. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19492. /**
  19493. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19494. */
  19495. get: function () {
  19496. var pointers = this.inputs.attached["pointers"];
  19497. if (pointers) {
  19498. return pointers.angularSensibilityY;
  19499. }
  19500. return 0;
  19501. },
  19502. set: function (value) {
  19503. var pointers = this.inputs.attached["pointers"];
  19504. if (pointers) {
  19505. pointers.angularSensibilityY = value;
  19506. }
  19507. },
  19508. enumerable: true,
  19509. configurable: true
  19510. });
  19511. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19512. /**
  19513. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19514. */
  19515. get: function () {
  19516. var pointers = this.inputs.attached["pointers"];
  19517. if (pointers) {
  19518. return pointers.pinchPrecision;
  19519. }
  19520. return 0;
  19521. },
  19522. set: function (value) {
  19523. var pointers = this.inputs.attached["pointers"];
  19524. if (pointers) {
  19525. pointers.pinchPrecision = value;
  19526. }
  19527. },
  19528. enumerable: true,
  19529. configurable: true
  19530. });
  19531. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19532. /**
  19533. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19534. * It will be used instead of pinchDeltaPrecision if different from 0.
  19535. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19536. */
  19537. get: function () {
  19538. var pointers = this.inputs.attached["pointers"];
  19539. if (pointers) {
  19540. return pointers.pinchDeltaPercentage;
  19541. }
  19542. return 0;
  19543. },
  19544. set: function (value) {
  19545. var pointers = this.inputs.attached["pointers"];
  19546. if (pointers) {
  19547. pointers.pinchDeltaPercentage = value;
  19548. }
  19549. },
  19550. enumerable: true,
  19551. configurable: true
  19552. });
  19553. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19554. /**
  19555. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19556. */
  19557. get: function () {
  19558. var pointers = this.inputs.attached["pointers"];
  19559. if (pointers) {
  19560. return pointers.panningSensibility;
  19561. }
  19562. return 0;
  19563. },
  19564. set: function (value) {
  19565. var pointers = this.inputs.attached["pointers"];
  19566. if (pointers) {
  19567. pointers.panningSensibility = value;
  19568. }
  19569. },
  19570. enumerable: true,
  19571. configurable: true
  19572. });
  19573. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19574. /**
  19575. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19576. */
  19577. get: function () {
  19578. var keyboard = this.inputs.attached["keyboard"];
  19579. if (keyboard) {
  19580. return keyboard.keysUp;
  19581. }
  19582. return [];
  19583. },
  19584. set: function (value) {
  19585. var keyboard = this.inputs.attached["keyboard"];
  19586. if (keyboard) {
  19587. keyboard.keysUp = value;
  19588. }
  19589. },
  19590. enumerable: true,
  19591. configurable: true
  19592. });
  19593. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19594. /**
  19595. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19596. */
  19597. get: function () {
  19598. var keyboard = this.inputs.attached["keyboard"];
  19599. if (keyboard) {
  19600. return keyboard.keysDown;
  19601. }
  19602. return [];
  19603. },
  19604. set: function (value) {
  19605. var keyboard = this.inputs.attached["keyboard"];
  19606. if (keyboard) {
  19607. keyboard.keysDown = value;
  19608. }
  19609. },
  19610. enumerable: true,
  19611. configurable: true
  19612. });
  19613. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19614. /**
  19615. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19616. */
  19617. get: function () {
  19618. var keyboard = this.inputs.attached["keyboard"];
  19619. if (keyboard) {
  19620. return keyboard.keysLeft;
  19621. }
  19622. return [];
  19623. },
  19624. set: function (value) {
  19625. var keyboard = this.inputs.attached["keyboard"];
  19626. if (keyboard) {
  19627. keyboard.keysLeft = value;
  19628. }
  19629. },
  19630. enumerable: true,
  19631. configurable: true
  19632. });
  19633. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19634. /**
  19635. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19636. */
  19637. get: function () {
  19638. var keyboard = this.inputs.attached["keyboard"];
  19639. if (keyboard) {
  19640. return keyboard.keysRight;
  19641. }
  19642. return [];
  19643. },
  19644. set: function (value) {
  19645. var keyboard = this.inputs.attached["keyboard"];
  19646. if (keyboard) {
  19647. keyboard.keysRight = value;
  19648. }
  19649. },
  19650. enumerable: true,
  19651. configurable: true
  19652. });
  19653. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19654. /**
  19655. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19656. */
  19657. get: function () {
  19658. var mousewheel = this.inputs.attached["mousewheel"];
  19659. if (mousewheel) {
  19660. return mousewheel.wheelPrecision;
  19661. }
  19662. return 0;
  19663. },
  19664. set: function (value) {
  19665. var mousewheel = this.inputs.attached["mousewheel"];
  19666. if (mousewheel) {
  19667. mousewheel.wheelPrecision = value;
  19668. }
  19669. },
  19670. enumerable: true,
  19671. configurable: true
  19672. });
  19673. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19674. /**
  19675. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19676. * It will be used instead of pinchDeltaPrecision if different from 0.
  19677. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19678. */
  19679. get: function () {
  19680. var mousewheel = this.inputs.attached["mousewheel"];
  19681. if (mousewheel) {
  19682. return mousewheel.wheelDeltaPercentage;
  19683. }
  19684. return 0;
  19685. },
  19686. set: function (value) {
  19687. var mousewheel = this.inputs.attached["mousewheel"];
  19688. if (mousewheel) {
  19689. mousewheel.wheelDeltaPercentage = value;
  19690. }
  19691. },
  19692. enumerable: true,
  19693. configurable: true
  19694. });
  19695. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19696. /**
  19697. * Gets the bouncing behavior of the camera if it has been enabled.
  19698. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19699. */
  19700. get: function () {
  19701. return this._bouncingBehavior;
  19702. },
  19703. enumerable: true,
  19704. configurable: true
  19705. });
  19706. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19707. /**
  19708. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19709. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19710. */
  19711. get: function () {
  19712. return this._bouncingBehavior != null;
  19713. },
  19714. set: function (value) {
  19715. if (value === this.useBouncingBehavior) {
  19716. return;
  19717. }
  19718. if (value) {
  19719. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19720. this.addBehavior(this._bouncingBehavior);
  19721. }
  19722. else if (this._bouncingBehavior) {
  19723. this.removeBehavior(this._bouncingBehavior);
  19724. this._bouncingBehavior = null;
  19725. }
  19726. },
  19727. enumerable: true,
  19728. configurable: true
  19729. });
  19730. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19731. /**
  19732. * Gets the framing behavior of the camera if it has been enabled.
  19733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19734. */
  19735. get: function () {
  19736. return this._framingBehavior;
  19737. },
  19738. enumerable: true,
  19739. configurable: true
  19740. });
  19741. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19742. /**
  19743. * Defines if the framing behavior of the camera is enabled on the camera.
  19744. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19745. */
  19746. get: function () {
  19747. return this._framingBehavior != null;
  19748. },
  19749. set: function (value) {
  19750. if (value === this.useFramingBehavior) {
  19751. return;
  19752. }
  19753. if (value) {
  19754. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19755. this.addBehavior(this._framingBehavior);
  19756. }
  19757. else if (this._framingBehavior) {
  19758. this.removeBehavior(this._framingBehavior);
  19759. this._framingBehavior = null;
  19760. }
  19761. },
  19762. enumerable: true,
  19763. configurable: true
  19764. });
  19765. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19766. /**
  19767. * Gets the auto rotation behavior of the camera if it has been enabled.
  19768. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19769. */
  19770. get: function () {
  19771. return this._autoRotationBehavior;
  19772. },
  19773. enumerable: true,
  19774. configurable: true
  19775. });
  19776. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19777. /**
  19778. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19779. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19780. */
  19781. get: function () {
  19782. return this._autoRotationBehavior != null;
  19783. },
  19784. set: function (value) {
  19785. if (value === this.useAutoRotationBehavior) {
  19786. return;
  19787. }
  19788. if (value) {
  19789. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19790. this.addBehavior(this._autoRotationBehavior);
  19791. }
  19792. else if (this._autoRotationBehavior) {
  19793. this.removeBehavior(this._autoRotationBehavior);
  19794. this._autoRotationBehavior = null;
  19795. }
  19796. },
  19797. enumerable: true,
  19798. configurable: true
  19799. });
  19800. // Cache
  19801. /** @hidden */
  19802. ArcRotateCamera.prototype._initCache = function () {
  19803. _super.prototype._initCache.call(this);
  19804. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19805. this._cache.alpha = undefined;
  19806. this._cache.beta = undefined;
  19807. this._cache.radius = undefined;
  19808. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19809. };
  19810. /** @hidden */
  19811. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19812. if (!ignoreParentClass) {
  19813. _super.prototype._updateCache.call(this);
  19814. }
  19815. this._cache._target.copyFrom(this._getTargetPosition());
  19816. this._cache.alpha = this.alpha;
  19817. this._cache.beta = this.beta;
  19818. this._cache.radius = this.radius;
  19819. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19820. };
  19821. ArcRotateCamera.prototype._getTargetPosition = function () {
  19822. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19823. var pos = this._targetHost.absolutePosition;
  19824. if (this._targetBoundingCenter) {
  19825. pos.addToRef(this._targetBoundingCenter, this._target);
  19826. }
  19827. else {
  19828. this._target.copyFrom(pos);
  19829. }
  19830. }
  19831. var lockedTargetPosition = this._getLockedTargetPosition();
  19832. if (lockedTargetPosition) {
  19833. return lockedTargetPosition;
  19834. }
  19835. return this._target;
  19836. };
  19837. /**
  19838. * Stores the current state of the camera (alpha, beta, radius and target)
  19839. * @returns the camera itself
  19840. */
  19841. ArcRotateCamera.prototype.storeState = function () {
  19842. this._storedAlpha = this.alpha;
  19843. this._storedBeta = this.beta;
  19844. this._storedRadius = this.radius;
  19845. this._storedTarget = this._getTargetPosition().clone();
  19846. return _super.prototype.storeState.call(this);
  19847. };
  19848. /**
  19849. * @hidden
  19850. * Restored camera state. You must call storeState() first
  19851. */
  19852. ArcRotateCamera.prototype._restoreStateValues = function () {
  19853. if (!_super.prototype._restoreStateValues.call(this)) {
  19854. return false;
  19855. }
  19856. this.alpha = this._storedAlpha;
  19857. this.beta = this._storedBeta;
  19858. this.radius = this._storedRadius;
  19859. this.setTarget(this._storedTarget.clone());
  19860. this.inertialAlphaOffset = 0;
  19861. this.inertialBetaOffset = 0;
  19862. this.inertialRadiusOffset = 0;
  19863. this.inertialPanningX = 0;
  19864. this.inertialPanningY = 0;
  19865. return true;
  19866. };
  19867. // Synchronized
  19868. /** @hidden */
  19869. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19870. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19871. return false;
  19872. }
  19873. return this._cache._target.equals(this._getTargetPosition())
  19874. && this._cache.alpha === this.alpha
  19875. && this._cache.beta === this.beta
  19876. && this._cache.radius === this.radius
  19877. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19878. };
  19879. /**
  19880. * Attached controls to the current camera.
  19881. * @param element Defines the element the controls should be listened from
  19882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19883. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19884. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19885. */
  19886. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19887. var _this = this;
  19888. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19889. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19890. this._useCtrlForPanning = useCtrlForPanning;
  19891. this._panningMouseButton = panningMouseButton;
  19892. this.inputs.attachElement(element, noPreventDefault);
  19893. this._reset = function () {
  19894. _this.inertialAlphaOffset = 0;
  19895. _this.inertialBetaOffset = 0;
  19896. _this.inertialRadiusOffset = 0;
  19897. _this.inertialPanningX = 0;
  19898. _this.inertialPanningY = 0;
  19899. };
  19900. };
  19901. /**
  19902. * Detach the current controls from the camera.
  19903. * The camera will stop reacting to inputs.
  19904. * @param element Defines the element to stop listening the inputs from
  19905. */
  19906. ArcRotateCamera.prototype.detachControl = function (element) {
  19907. this.inputs.detachElement(element);
  19908. if (this._reset) {
  19909. this._reset();
  19910. }
  19911. };
  19912. /** @hidden */
  19913. ArcRotateCamera.prototype._checkInputs = function () {
  19914. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19915. if (this._collisionTriggered) {
  19916. return;
  19917. }
  19918. this.inputs.checkInputs();
  19919. // Inertia
  19920. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19921. var inertialAlphaOffset = this.inertialAlphaOffset;
  19922. if (this.beta <= 0) {
  19923. inertialAlphaOffset *= -1;
  19924. }
  19925. if (this.getScene().useRightHandedSystem) {
  19926. inertialAlphaOffset *= -1;
  19927. }
  19928. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19929. inertialAlphaOffset *= -1;
  19930. }
  19931. this.alpha += inertialAlphaOffset;
  19932. this.beta += this.inertialBetaOffset;
  19933. this.radius -= this.inertialRadiusOffset;
  19934. this.inertialAlphaOffset *= this.inertia;
  19935. this.inertialBetaOffset *= this.inertia;
  19936. this.inertialRadiusOffset *= this.inertia;
  19937. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19938. this.inertialAlphaOffset = 0;
  19939. }
  19940. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19941. this.inertialBetaOffset = 0;
  19942. }
  19943. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19944. this.inertialRadiusOffset = 0;
  19945. }
  19946. }
  19947. // Panning inertia
  19948. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19949. if (!this._localDirection) {
  19950. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19951. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19952. }
  19953. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19954. this._localDirection.multiplyInPlace(this.panningAxis);
  19955. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19956. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19957. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19958. if (!this.panningAxis.y) {
  19959. this._transformedDirection.y = 0;
  19960. }
  19961. if (!this._targetHost) {
  19962. if (this.panningDistanceLimit) {
  19963. this._transformedDirection.addInPlace(this._target);
  19964. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19965. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19966. this._target.copyFrom(this._transformedDirection);
  19967. }
  19968. }
  19969. else {
  19970. this._target.addInPlace(this._transformedDirection);
  19971. }
  19972. }
  19973. this.inertialPanningX *= this.panningInertia;
  19974. this.inertialPanningY *= this.panningInertia;
  19975. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19976. this.inertialPanningX = 0;
  19977. }
  19978. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19979. this.inertialPanningY = 0;
  19980. }
  19981. }
  19982. // Limits
  19983. this._checkLimits();
  19984. _super.prototype._checkInputs.call(this);
  19985. };
  19986. ArcRotateCamera.prototype._checkLimits = function () {
  19987. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19988. if (this.allowUpsideDown && this.beta > Math.PI) {
  19989. this.beta = this.beta - (2 * Math.PI);
  19990. }
  19991. }
  19992. else {
  19993. if (this.beta < this.lowerBetaLimit) {
  19994. this.beta = this.lowerBetaLimit;
  19995. }
  19996. }
  19997. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19998. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19999. this.beta = this.beta + (2 * Math.PI);
  20000. }
  20001. }
  20002. else {
  20003. if (this.beta > this.upperBetaLimit) {
  20004. this.beta = this.upperBetaLimit;
  20005. }
  20006. }
  20007. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  20008. this.alpha = this.lowerAlphaLimit;
  20009. }
  20010. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  20011. this.alpha = this.upperAlphaLimit;
  20012. }
  20013. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  20014. this.radius = this.lowerRadiusLimit;
  20015. this.inertialRadiusOffset = 0;
  20016. }
  20017. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  20018. this.radius = this.upperRadiusLimit;
  20019. this.inertialRadiusOffset = 0;
  20020. }
  20021. };
  20022. /**
  20023. * Rebuilds angles (alpha, beta) and radius from the give position and target
  20024. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  20025. */
  20026. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function (updateView) {
  20027. if (updateView === void 0) { updateView = true; }
  20028. if (updateView) {
  20029. this.getViewMatrix(); // Force position update
  20030. }
  20031. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  20032. this.radius = this._computationVector.length();
  20033. if (this.radius === 0) {
  20034. this.radius = 0.0001; // Just to avoid division by zero
  20035. }
  20036. // Alpha
  20037. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  20038. if (this._computationVector.z < 0) {
  20039. this.alpha = 2 * Math.PI - this.alpha;
  20040. }
  20041. // Beta
  20042. this.beta = Math.acos(this._computationVector.y / this.radius);
  20043. this._checkLimits();
  20044. };
  20045. /**
  20046. * Use a position to define the current camera related information like aplha, beta and radius
  20047. * @param position Defines the position to set the camera at
  20048. */
  20049. ArcRotateCamera.prototype.setPosition = function (position) {
  20050. if (this._position.equals(position)) {
  20051. return;
  20052. }
  20053. this._position.copyFrom(position);
  20054. this.rebuildAnglesAndRadius(false);
  20055. };
  20056. /**
  20057. * Defines the target the camera should look at.
  20058. * This will automatically adapt alpha beta and radius to fit within the new target.
  20059. * @param target Defines the new target as a Vector or a mesh
  20060. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  20061. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  20062. */
  20063. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  20064. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  20065. if (allowSamePosition === void 0) { allowSamePosition = false; }
  20066. if (target.getBoundingInfo) {
  20067. if (toBoundingCenter) {
  20068. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  20069. }
  20070. else {
  20071. this._targetBoundingCenter = null;
  20072. }
  20073. target.computeWorldMatrix();
  20074. this._targetHost = target;
  20075. this._target = this._getTargetPosition();
  20076. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  20077. }
  20078. else {
  20079. var newTarget = target;
  20080. var currentTarget = this._getTargetPosition();
  20081. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  20082. return;
  20083. }
  20084. this._targetHost = null;
  20085. this._target = newTarget;
  20086. this._targetBoundingCenter = null;
  20087. this.onMeshTargetChangedObservable.notifyObservers(null);
  20088. }
  20089. this.rebuildAnglesAndRadius();
  20090. };
  20091. /** @hidden */
  20092. ArcRotateCamera.prototype._getViewMatrix = function () {
  20093. // Compute
  20094. var cosa = Math.cos(this.alpha);
  20095. var sina = Math.sin(this.alpha);
  20096. var cosb = Math.cos(this.beta);
  20097. var sinb = Math.sin(this.beta);
  20098. if (sinb === 0) {
  20099. sinb = 0.0001;
  20100. }
  20101. var target = this._getTargetPosition();
  20102. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  20103. // Rotate according to up vector
  20104. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  20105. if (!this._tempAxisVector) {
  20106. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  20107. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  20108. }
  20109. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  20110. this._tempAxisVector.normalize();
  20111. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  20112. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  20113. this._tempAxisVector.copyFrom(this._computationVector);
  20114. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  20115. }
  20116. target.addToRef(this._computationVector, this._newPosition);
  20117. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  20118. var coordinator = this.getScene().collisionCoordinator;
  20119. if (!this._collider) {
  20120. this._collider = coordinator.createCollider();
  20121. }
  20122. this._collider._radius = this.collisionRadius;
  20123. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  20124. this._collisionTriggered = true;
  20125. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20126. }
  20127. else {
  20128. this._position.copyFrom(this._newPosition);
  20129. var up = this.upVector;
  20130. if (this.allowUpsideDown && sinb < 0) {
  20131. up = up.clone();
  20132. up = up.negate();
  20133. }
  20134. this._computeViewMatrix(this._position, target, up);
  20135. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  20136. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  20137. }
  20138. this._currentTarget = target;
  20139. return this._viewMatrix;
  20140. };
  20141. /**
  20142. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  20143. * @param meshes Defines the mesh to zoom on
  20144. * @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)
  20145. */
  20146. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  20147. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20148. meshes = meshes || this.getScene().meshes;
  20149. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20150. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  20151. this.radius = distance * this.zoomOnFactor;
  20152. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  20153. };
  20154. /**
  20155. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  20156. * The target will be changed but the radius
  20157. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  20158. * @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)
  20159. */
  20160. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  20161. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20162. var meshesOrMinMaxVector;
  20163. var distance;
  20164. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  20165. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  20166. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20167. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  20168. }
  20169. else { //minMaxVector and distance
  20170. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  20171. meshesOrMinMaxVector = minMaxVectorAndDistance;
  20172. distance = minMaxVectorAndDistance.distance;
  20173. }
  20174. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  20175. if (!doNotUpdateMaxZ) {
  20176. this.maxZ = distance * 2;
  20177. }
  20178. };
  20179. /**
  20180. * @override
  20181. * Override Camera.createRigCamera
  20182. */
  20183. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  20184. var alphaShift = 0;
  20185. switch (this.cameraRigMode) {
  20186. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20187. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20188. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20189. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20190. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  20191. break;
  20192. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20193. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  20194. break;
  20195. }
  20196. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  20197. rigCam._cameraRigParams = {};
  20198. return rigCam;
  20199. };
  20200. /**
  20201. * @hidden
  20202. * @override
  20203. * Override Camera._updateRigCameras
  20204. */
  20205. ArcRotateCamera.prototype._updateRigCameras = function () {
  20206. var camLeft = this._rigCameras[0];
  20207. var camRight = this._rigCameras[1];
  20208. camLeft.beta = camRight.beta = this.beta;
  20209. switch (this.cameraRigMode) {
  20210. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20211. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20212. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20213. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20214. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20215. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20216. break;
  20217. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20218. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20219. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20220. break;
  20221. }
  20222. _super.prototype._updateRigCameras.call(this);
  20223. };
  20224. /**
  20225. * Destroy the camera and release the current resources hold by it.
  20226. */
  20227. ArcRotateCamera.prototype.dispose = function () {
  20228. this.inputs.clear();
  20229. _super.prototype.dispose.call(this);
  20230. };
  20231. /**
  20232. * Gets the current object class name.
  20233. * @return the class name
  20234. */
  20235. ArcRotateCamera.prototype.getClassName = function () {
  20236. return "ArcRotateCamera";
  20237. };
  20238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20240. ], ArcRotateCamera.prototype, "alpha", void 0);
  20241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20243. ], ArcRotateCamera.prototype, "beta", void 0);
  20244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20246. ], ArcRotateCamera.prototype, "radius", void 0);
  20247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  20249. ], ArcRotateCamera.prototype, "_target", void 0);
  20250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20252. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  20253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20255. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  20256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20258. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  20259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20261. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  20262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20264. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  20265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20267. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  20268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20270. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  20271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20273. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  20274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20276. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  20277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20279. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  20280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20282. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  20283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20285. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  20286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20288. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  20289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20291. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  20292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20294. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  20295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20297. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  20298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20300. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  20301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20303. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  20304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20306. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  20307. return ArcRotateCamera;
  20308. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  20309. /***/ }),
  20310. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  20311. /*!*************************************************!*\
  20312. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  20313. \*************************************************/
  20314. /*! exports provided: ArcRotateCameraInputsManager */
  20315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20316. "use strict";
  20317. __webpack_require__.r(__webpack_exports__);
  20318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  20319. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20320. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  20321. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  20322. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  20323. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  20324. /**
  20325. * Default Inputs manager for the ArcRotateCamera.
  20326. * It groups all the default supported inputs for ease of use.
  20327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20328. */
  20329. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  20330. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  20331. /**
  20332. * Instantiates a new ArcRotateCameraInputsManager.
  20333. * @param camera Defines the camera the inputs belong to
  20334. */
  20335. function ArcRotateCameraInputsManager(camera) {
  20336. return _super.call(this, camera) || this;
  20337. }
  20338. /**
  20339. * Add mouse wheel input support to the input manager.
  20340. * @returns the current input manager
  20341. */
  20342. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  20343. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  20344. return this;
  20345. };
  20346. /**
  20347. * Add pointers input support to the input manager.
  20348. * @returns the current input manager
  20349. */
  20350. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  20351. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  20352. return this;
  20353. };
  20354. /**
  20355. * Add keyboard input support to the input manager.
  20356. * @returns the current input manager
  20357. */
  20358. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  20359. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  20360. return this;
  20361. };
  20362. return ArcRotateCameraInputsManager;
  20363. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  20364. /***/ }),
  20365. /***/ "./Cameras/camera.ts":
  20366. /*!***************************!*\
  20367. !*** ./Cameras/camera.ts ***!
  20368. \***************************/
  20369. /*! exports provided: Camera */
  20370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20371. "use strict";
  20372. __webpack_require__.r(__webpack_exports__);
  20373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  20374. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20375. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20376. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  20377. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  20378. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20379. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20380. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  20381. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20382. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  20383. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  20384. /**
  20385. * This is the base class of all the camera used in the application.
  20386. * @see http://doc.babylonjs.com/features/cameras
  20387. */
  20388. var Camera = /** @class */ (function (_super) {
  20389. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  20390. /**
  20391. * Instantiates a new camera object.
  20392. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  20393. * @see http://doc.babylonjs.com/features/cameras
  20394. * @param name Defines the name of the camera in the scene
  20395. * @param position Defines the position of the camera
  20396. * @param scene Defines the scene the camera belongs too
  20397. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  20398. */
  20399. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20400. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20401. var _this = _super.call(this, name, scene) || this;
  20402. /** @hidden */
  20403. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20404. /**
  20405. * The vector the camera should consider as up.
  20406. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  20407. */
  20408. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  20409. /**
  20410. * Define the current limit on the left side for an orthographic camera
  20411. * In scene unit
  20412. */
  20413. _this.orthoLeft = null;
  20414. /**
  20415. * Define the current limit on the right side for an orthographic camera
  20416. * In scene unit
  20417. */
  20418. _this.orthoRight = null;
  20419. /**
  20420. * Define the current limit on the bottom side for an orthographic camera
  20421. * In scene unit
  20422. */
  20423. _this.orthoBottom = null;
  20424. /**
  20425. * Define the current limit on the top side for an orthographic camera
  20426. * In scene unit
  20427. */
  20428. _this.orthoTop = null;
  20429. /**
  20430. * Field Of View is set in Radians. (default is 0.8)
  20431. */
  20432. _this.fov = 0.8;
  20433. /**
  20434. * Define the minimum distance the camera can see from.
  20435. * This is important to note that the depth buffer are not infinite and the closer it starts
  20436. * the more your scene might encounter depth fighting issue.
  20437. */
  20438. _this.minZ = 1;
  20439. /**
  20440. * Define the maximum distance the camera can see to.
  20441. * This is important to note that the depth buffer are not infinite and the further it end
  20442. * the more your scene might encounter depth fighting issue.
  20443. */
  20444. _this.maxZ = 10000.0;
  20445. /**
  20446. * Define the default inertia of the camera.
  20447. * This helps giving a smooth feeling to the camera movement.
  20448. */
  20449. _this.inertia = 0.9;
  20450. /**
  20451. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20452. */
  20453. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20454. /**
  20455. * Define wether the camera is intermediate.
  20456. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20457. */
  20458. _this.isIntermediate = false;
  20459. /**
  20460. * Define the viewport of the camera.
  20461. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20462. */
  20463. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20464. /**
  20465. * Restricts the camera to viewing objects with the same layerMask.
  20466. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20467. */
  20468. _this.layerMask = 0x0FFFFFFF;
  20469. /**
  20470. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20471. */
  20472. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20473. /**
  20474. * Rig mode of the camera.
  20475. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20476. * This is normally controlled byt the camera themselves as internal use.
  20477. */
  20478. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20479. /**
  20480. * 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
  20481. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20482. * else in the scene.
  20483. */
  20484. _this.customRenderTargets = new Array();
  20485. /**
  20486. * When set, the camera will render to this render target instead of the default canvas
  20487. */
  20488. _this.outputRenderTarget = null;
  20489. /**
  20490. * Observable triggered when the camera view matrix has changed.
  20491. */
  20492. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20493. /**
  20494. * Observable triggered when the camera Projection matrix has changed.
  20495. */
  20496. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20497. /**
  20498. * Observable triggered when the inputs have been processed.
  20499. */
  20500. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20501. /**
  20502. * Observable triggered when reset has been called and applied to the camera.
  20503. */
  20504. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20505. /** @hidden */
  20506. _this._rigCameras = new Array();
  20507. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20508. /** @hidden */
  20509. _this._skipRendering = false;
  20510. /** @hidden */
  20511. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20512. /** @hidden */
  20513. _this._postProcesses = new Array();
  20514. /** @hidden */
  20515. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20516. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20517. /** hidden */
  20518. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20519. _this._doNotComputeProjectionMatrix = false;
  20520. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20521. _this._refreshFrustumPlanes = true;
  20522. /** @hidden */
  20523. _this._isCamera = true;
  20524. /** @hidden */
  20525. _this._isLeftCamera = false;
  20526. /** @hidden */
  20527. _this._isRightCamera = true;
  20528. _this.getScene().addCamera(_this);
  20529. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20530. _this.getScene().activeCamera = _this;
  20531. }
  20532. _this.position = position;
  20533. return _this;
  20534. }
  20535. Object.defineProperty(Camera.prototype, "position", {
  20536. /**
  20537. * Define the current local position of the camera in the scene
  20538. */
  20539. get: function () {
  20540. return this._position;
  20541. },
  20542. set: function (newPosition) {
  20543. this._position = newPosition;
  20544. },
  20545. enumerable: true,
  20546. configurable: true
  20547. });
  20548. /**
  20549. * Store current camera state (fov, position, etc..)
  20550. * @returns the camera
  20551. */
  20552. Camera.prototype.storeState = function () {
  20553. this._stateStored = true;
  20554. this._storedFov = this.fov;
  20555. return this;
  20556. };
  20557. /**
  20558. * Restores the camera state values if it has been stored. You must call storeState() first
  20559. */
  20560. Camera.prototype._restoreStateValues = function () {
  20561. if (!this._stateStored) {
  20562. return false;
  20563. }
  20564. this.fov = this._storedFov;
  20565. return true;
  20566. };
  20567. /**
  20568. * Restored camera state. You must call storeState() first.
  20569. * @returns true if restored and false otherwise
  20570. */
  20571. Camera.prototype.restoreState = function () {
  20572. if (this._restoreStateValues()) {
  20573. this.onRestoreStateObservable.notifyObservers(this);
  20574. return true;
  20575. }
  20576. return false;
  20577. };
  20578. /**
  20579. * Gets the class name of the camera.
  20580. * @returns the class name
  20581. */
  20582. Camera.prototype.getClassName = function () {
  20583. return "Camera";
  20584. };
  20585. /**
  20586. * Gets a string representation of the camera useful for debug purpose.
  20587. * @param fullDetails Defines that a more verboe level of logging is required
  20588. * @returns the string representation
  20589. */
  20590. Camera.prototype.toString = function (fullDetails) {
  20591. var ret = "Name: " + this.name;
  20592. ret += ", type: " + this.getClassName();
  20593. if (this.animations) {
  20594. for (var i = 0; i < this.animations.length; i++) {
  20595. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20596. }
  20597. }
  20598. if (fullDetails) {
  20599. }
  20600. return ret;
  20601. };
  20602. Object.defineProperty(Camera.prototype, "globalPosition", {
  20603. /**
  20604. * Gets the current world space position of the camera.
  20605. */
  20606. get: function () {
  20607. return this._globalPosition;
  20608. },
  20609. enumerable: true,
  20610. configurable: true
  20611. });
  20612. /**
  20613. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20614. * @returns the active meshe list
  20615. */
  20616. Camera.prototype.getActiveMeshes = function () {
  20617. return this._activeMeshes;
  20618. };
  20619. /**
  20620. * Check wether a mesh is part of the current active mesh list of the camera
  20621. * @param mesh Defines the mesh to check
  20622. * @returns true if active, false otherwise
  20623. */
  20624. Camera.prototype.isActiveMesh = function (mesh) {
  20625. return (this._activeMeshes.indexOf(mesh) !== -1);
  20626. };
  20627. /**
  20628. * Is this camera ready to be used/rendered
  20629. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20630. * @return true if the camera is ready
  20631. */
  20632. Camera.prototype.isReady = function (completeCheck) {
  20633. if (completeCheck === void 0) { completeCheck = false; }
  20634. if (completeCheck) {
  20635. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20636. var pp = _a[_i];
  20637. if (pp && !pp.isReady()) {
  20638. return false;
  20639. }
  20640. }
  20641. }
  20642. return _super.prototype.isReady.call(this, completeCheck);
  20643. };
  20644. /** @hidden */
  20645. Camera.prototype._initCache = function () {
  20646. _super.prototype._initCache.call(this);
  20647. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20648. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20649. this._cache.mode = undefined;
  20650. this._cache.minZ = undefined;
  20651. this._cache.maxZ = undefined;
  20652. this._cache.fov = undefined;
  20653. this._cache.fovMode = undefined;
  20654. this._cache.aspectRatio = undefined;
  20655. this._cache.orthoLeft = undefined;
  20656. this._cache.orthoRight = undefined;
  20657. this._cache.orthoBottom = undefined;
  20658. this._cache.orthoTop = undefined;
  20659. this._cache.renderWidth = undefined;
  20660. this._cache.renderHeight = undefined;
  20661. };
  20662. /** @hidden */
  20663. Camera.prototype._updateCache = function (ignoreParentClass) {
  20664. if (!ignoreParentClass) {
  20665. _super.prototype._updateCache.call(this);
  20666. }
  20667. this._cache.position.copyFrom(this.position);
  20668. this._cache.upVector.copyFrom(this.upVector);
  20669. };
  20670. /** @hidden */
  20671. Camera.prototype._isSynchronized = function () {
  20672. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20673. };
  20674. /** @hidden */
  20675. Camera.prototype._isSynchronizedViewMatrix = function () {
  20676. if (!_super.prototype._isSynchronized.call(this)) {
  20677. return false;
  20678. }
  20679. return this._cache.position.equals(this.position)
  20680. && this._cache.upVector.equals(this.upVector)
  20681. && this.isSynchronizedWithParent();
  20682. };
  20683. /** @hidden */
  20684. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20685. var check = this._cache.mode === this.mode
  20686. && this._cache.minZ === this.minZ
  20687. && this._cache.maxZ === this.maxZ;
  20688. if (!check) {
  20689. return false;
  20690. }
  20691. var engine = this.getEngine();
  20692. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20693. check = this._cache.fov === this.fov
  20694. && this._cache.fovMode === this.fovMode
  20695. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20696. }
  20697. else {
  20698. check = this._cache.orthoLeft === this.orthoLeft
  20699. && this._cache.orthoRight === this.orthoRight
  20700. && this._cache.orthoBottom === this.orthoBottom
  20701. && this._cache.orthoTop === this.orthoTop
  20702. && this._cache.renderWidth === engine.getRenderWidth()
  20703. && this._cache.renderHeight === engine.getRenderHeight();
  20704. }
  20705. return check;
  20706. };
  20707. /**
  20708. * Attach the input controls to a specific dom element to get the input from.
  20709. * @param element Defines the element the controls should be listened from
  20710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20711. */
  20712. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20713. };
  20714. /**
  20715. * Detach the current controls from the specified dom element.
  20716. * @param element Defines the element to stop listening the inputs from
  20717. */
  20718. Camera.prototype.detachControl = function (element) {
  20719. };
  20720. /**
  20721. * Update the camera state according to the different inputs gathered during the frame.
  20722. */
  20723. Camera.prototype.update = function () {
  20724. this._checkInputs();
  20725. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20726. this._updateRigCameras();
  20727. }
  20728. };
  20729. /** @hidden */
  20730. Camera.prototype._checkInputs = function () {
  20731. this.onAfterCheckInputsObservable.notifyObservers(this);
  20732. };
  20733. Object.defineProperty(Camera.prototype, "rigCameras", {
  20734. /** @hidden */
  20735. get: function () {
  20736. return this._rigCameras;
  20737. },
  20738. enumerable: true,
  20739. configurable: true
  20740. });
  20741. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20742. /**
  20743. * Gets the post process used by the rig cameras
  20744. */
  20745. get: function () {
  20746. return this._rigPostProcess;
  20747. },
  20748. enumerable: true,
  20749. configurable: true
  20750. });
  20751. /**
  20752. * Internal, gets the first post proces.
  20753. * @returns the first post process to be run on this camera.
  20754. */
  20755. Camera.prototype._getFirstPostProcess = function () {
  20756. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20757. if (this._postProcesses[ppIndex] !== null) {
  20758. return this._postProcesses[ppIndex];
  20759. }
  20760. }
  20761. return null;
  20762. };
  20763. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20764. // invalidate framebuffer
  20765. var firstPostProcess = this._getFirstPostProcess();
  20766. if (firstPostProcess) {
  20767. firstPostProcess.markTextureDirty();
  20768. }
  20769. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20770. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20771. var cam = this._rigCameras[i];
  20772. var rigPostProcess = cam._rigPostProcess;
  20773. // for VR rig, there does not have to be a post process
  20774. if (rigPostProcess) {
  20775. var isPass = rigPostProcess.getEffectName() === "pass";
  20776. if (isPass) {
  20777. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20778. cam.isIntermediate = this._postProcesses.length === 0;
  20779. }
  20780. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20781. rigPostProcess.markTextureDirty();
  20782. }
  20783. else {
  20784. cam._postProcesses = this._postProcesses.slice(0);
  20785. }
  20786. }
  20787. };
  20788. /**
  20789. * Attach a post process to the camera.
  20790. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20791. * @param postProcess The post process to attach to the camera
  20792. * @param insertAt The position of the post process in case several of them are in use in the scene
  20793. * @returns the position the post process has been inserted at
  20794. */
  20795. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20796. if (insertAt === void 0) { insertAt = null; }
  20797. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20798. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20799. return 0;
  20800. }
  20801. if (insertAt == null || insertAt < 0) {
  20802. this._postProcesses.push(postProcess);
  20803. }
  20804. else if (this._postProcesses[insertAt] === null) {
  20805. this._postProcesses[insertAt] = postProcess;
  20806. }
  20807. else {
  20808. this._postProcesses.splice(insertAt, 0, postProcess);
  20809. }
  20810. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20811. return this._postProcesses.indexOf(postProcess);
  20812. };
  20813. /**
  20814. * Detach a post process to the camera.
  20815. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20816. * @param postProcess The post process to detach from the camera
  20817. */
  20818. Camera.prototype.detachPostProcess = function (postProcess) {
  20819. var idx = this._postProcesses.indexOf(postProcess);
  20820. if (idx !== -1) {
  20821. this._postProcesses[idx] = null;
  20822. }
  20823. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20824. };
  20825. /**
  20826. * Gets the current world matrix of the camera
  20827. */
  20828. Camera.prototype.getWorldMatrix = function () {
  20829. if (this._isSynchronizedViewMatrix()) {
  20830. return this._worldMatrix;
  20831. }
  20832. // Getting the the view matrix will also compute the world matrix.
  20833. this.getViewMatrix();
  20834. return this._worldMatrix;
  20835. };
  20836. /** @hidden */
  20837. Camera.prototype._getViewMatrix = function () {
  20838. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20839. };
  20840. /**
  20841. * Gets the current view matrix of the camera.
  20842. * @param force forces the camera to recompute the matrix without looking at the cached state
  20843. * @returns the view matrix
  20844. */
  20845. Camera.prototype.getViewMatrix = function (force) {
  20846. if (!force && this._isSynchronizedViewMatrix()) {
  20847. return this._computedViewMatrix;
  20848. }
  20849. this.updateCache();
  20850. this._computedViewMatrix = this._getViewMatrix();
  20851. this._currentRenderId = this.getScene().getRenderId();
  20852. this._childRenderId = this._currentRenderId;
  20853. this._refreshFrustumPlanes = true;
  20854. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20855. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20856. }
  20857. this.onViewMatrixChangedObservable.notifyObservers(this);
  20858. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20859. return this._computedViewMatrix;
  20860. };
  20861. /**
  20862. * Freeze the projection matrix.
  20863. * It will prevent the cache check of the camera projection compute and can speed up perf
  20864. * if no parameter of the camera are meant to change
  20865. * @param projection Defines manually a projection if necessary
  20866. */
  20867. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20868. this._doNotComputeProjectionMatrix = true;
  20869. if (projection !== undefined) {
  20870. this._projectionMatrix = projection;
  20871. }
  20872. };
  20873. /**
  20874. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20875. */
  20876. Camera.prototype.unfreezeProjectionMatrix = function () {
  20877. this._doNotComputeProjectionMatrix = false;
  20878. };
  20879. /**
  20880. * Gets the current projection matrix of the camera.
  20881. * @param force forces the camera to recompute the matrix without looking at the cached state
  20882. * @returns the projection matrix
  20883. */
  20884. Camera.prototype.getProjectionMatrix = function (force) {
  20885. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20886. return this._projectionMatrix;
  20887. }
  20888. // Cache
  20889. this._cache.mode = this.mode;
  20890. this._cache.minZ = this.minZ;
  20891. this._cache.maxZ = this.maxZ;
  20892. // Matrix
  20893. this._refreshFrustumPlanes = true;
  20894. var engine = this.getEngine();
  20895. var scene = this.getScene();
  20896. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20897. this._cache.fov = this.fov;
  20898. this._cache.fovMode = this.fovMode;
  20899. this._cache.aspectRatio = engine.getAspectRatio(this);
  20900. if (this.minZ <= 0) {
  20901. this.minZ = 0.1;
  20902. }
  20903. if (scene.useRightHandedSystem) {
  20904. _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);
  20905. }
  20906. else {
  20907. _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);
  20908. }
  20909. }
  20910. else {
  20911. var halfWidth = engine.getRenderWidth() / 2.0;
  20912. var halfHeight = engine.getRenderHeight() / 2.0;
  20913. if (scene.useRightHandedSystem) {
  20914. _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);
  20915. }
  20916. else {
  20917. _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);
  20918. }
  20919. this._cache.orthoLeft = this.orthoLeft;
  20920. this._cache.orthoRight = this.orthoRight;
  20921. this._cache.orthoBottom = this.orthoBottom;
  20922. this._cache.orthoTop = this.orthoTop;
  20923. this._cache.renderWidth = engine.getRenderWidth();
  20924. this._cache.renderHeight = engine.getRenderHeight();
  20925. }
  20926. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20927. return this._projectionMatrix;
  20928. };
  20929. /**
  20930. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20931. * @returns a Matrix
  20932. */
  20933. Camera.prototype.getTransformationMatrix = function () {
  20934. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20935. return this._transformMatrix;
  20936. };
  20937. Camera.prototype._updateFrustumPlanes = function () {
  20938. if (!this._refreshFrustumPlanes) {
  20939. return;
  20940. }
  20941. this.getTransformationMatrix();
  20942. if (!this._frustumPlanes) {
  20943. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20944. }
  20945. else {
  20946. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20947. }
  20948. this._refreshFrustumPlanes = false;
  20949. };
  20950. /**
  20951. * Checks if a cullable object (mesh...) is in the camera frustum
  20952. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20953. * @param target The object to check
  20954. * @returns true if the object is in frustum otherwise false
  20955. */
  20956. Camera.prototype.isInFrustum = function (target) {
  20957. this._updateFrustumPlanes();
  20958. return target.isInFrustum(this._frustumPlanes);
  20959. };
  20960. /**
  20961. * Checks if a cullable object (mesh...) is in the camera frustum
  20962. * Unlike isInFrustum this cheks the full bounding box
  20963. * @param target The object to check
  20964. * @returns true if the object is in frustum otherwise false
  20965. */
  20966. Camera.prototype.isCompletelyInFrustum = function (target) {
  20967. this._updateFrustumPlanes();
  20968. return target.isCompletelyInFrustum(this._frustumPlanes);
  20969. };
  20970. /**
  20971. * Gets a ray in the forward direction from the camera.
  20972. * @param length Defines the length of the ray to create
  20973. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  20974. * @param origin Defines the start point of the ray which defaults to the camera position
  20975. * @returns the forward ray
  20976. */
  20977. Camera.prototype.getForwardRay = function (length, transform, origin) {
  20978. if (length === void 0) { length = 100; }
  20979. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  20980. };
  20981. /**
  20982. * Releases resources associated with this node.
  20983. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20984. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20985. */
  20986. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20987. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20988. // Observables
  20989. this.onViewMatrixChangedObservable.clear();
  20990. this.onProjectionMatrixChangedObservable.clear();
  20991. this.onAfterCheckInputsObservable.clear();
  20992. this.onRestoreStateObservable.clear();
  20993. // Inputs
  20994. if (this.inputs) {
  20995. this.inputs.clear();
  20996. }
  20997. // Animations
  20998. this.getScene().stopAnimation(this);
  20999. // Remove from scene
  21000. this.getScene().removeCamera(this);
  21001. while (this._rigCameras.length > 0) {
  21002. var camera = this._rigCameras.pop();
  21003. if (camera) {
  21004. camera.dispose();
  21005. }
  21006. }
  21007. // Postprocesses
  21008. if (this._rigPostProcess) {
  21009. this._rigPostProcess.dispose(this);
  21010. this._rigPostProcess = null;
  21011. this._postProcesses = [];
  21012. }
  21013. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21014. this._rigPostProcess = null;
  21015. this._postProcesses = [];
  21016. }
  21017. else {
  21018. var i = this._postProcesses.length;
  21019. while (--i >= 0) {
  21020. var postProcess = this._postProcesses[i];
  21021. if (postProcess) {
  21022. postProcess.dispose(this);
  21023. }
  21024. }
  21025. }
  21026. // Render targets
  21027. var i = this.customRenderTargets.length;
  21028. while (--i >= 0) {
  21029. this.customRenderTargets[i].dispose();
  21030. }
  21031. this.customRenderTargets = [];
  21032. // Active Meshes
  21033. this._activeMeshes.dispose();
  21034. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  21035. };
  21036. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  21037. /**
  21038. * Gets the left camera of a rig setup in case of Rigged Camera
  21039. */
  21040. get: function () {
  21041. return this._isLeftCamera;
  21042. },
  21043. enumerable: true,
  21044. configurable: true
  21045. });
  21046. Object.defineProperty(Camera.prototype, "isRightCamera", {
  21047. /**
  21048. * Gets the right camera of a rig setup in case of Rigged Camera
  21049. */
  21050. get: function () {
  21051. return this._isRightCamera;
  21052. },
  21053. enumerable: true,
  21054. configurable: true
  21055. });
  21056. Object.defineProperty(Camera.prototype, "leftCamera", {
  21057. /**
  21058. * Gets the left camera of a rig setup in case of Rigged Camera
  21059. */
  21060. get: function () {
  21061. if (this._rigCameras.length < 1) {
  21062. return null;
  21063. }
  21064. return this._rigCameras[0];
  21065. },
  21066. enumerable: true,
  21067. configurable: true
  21068. });
  21069. Object.defineProperty(Camera.prototype, "rightCamera", {
  21070. /**
  21071. * Gets the right camera of a rig setup in case of Rigged Camera
  21072. */
  21073. get: function () {
  21074. if (this._rigCameras.length < 2) {
  21075. return null;
  21076. }
  21077. return this._rigCameras[1];
  21078. },
  21079. enumerable: true,
  21080. configurable: true
  21081. });
  21082. /**
  21083. * Gets the left camera target of a rig setup in case of Rigged Camera
  21084. * @returns the target position
  21085. */
  21086. Camera.prototype.getLeftTarget = function () {
  21087. if (this._rigCameras.length < 1) {
  21088. return null;
  21089. }
  21090. return this._rigCameras[0].getTarget();
  21091. };
  21092. /**
  21093. * Gets the right camera target of a rig setup in case of Rigged Camera
  21094. * @returns the target position
  21095. */
  21096. Camera.prototype.getRightTarget = function () {
  21097. if (this._rigCameras.length < 2) {
  21098. return null;
  21099. }
  21100. return this._rigCameras[1].getTarget();
  21101. };
  21102. /**
  21103. * @hidden
  21104. */
  21105. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  21106. if (this.cameraRigMode === mode) {
  21107. return;
  21108. }
  21109. while (this._rigCameras.length > 0) {
  21110. var camera = this._rigCameras.pop();
  21111. if (camera) {
  21112. camera.dispose();
  21113. }
  21114. }
  21115. this.cameraRigMode = mode;
  21116. this._cameraRigParams = {};
  21117. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  21118. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  21119. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  21120. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  21121. // create the rig cameras, unless none
  21122. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21123. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  21124. if (leftCamera) {
  21125. leftCamera._isLeftCamera = true;
  21126. }
  21127. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  21128. if (rightCamera) {
  21129. rightCamera._isRightCamera = true;
  21130. }
  21131. if (leftCamera && rightCamera) {
  21132. this._rigCameras.push(leftCamera);
  21133. this._rigCameras.push(rightCamera);
  21134. }
  21135. }
  21136. switch (this.cameraRigMode) {
  21137. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21138. Camera._setStereoscopicAnaglyphRigMode(this);
  21139. break;
  21140. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21141. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21142. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21143. Camera._setStereoscopicRigMode(this);
  21144. break;
  21145. case Camera.RIG_MODE_VR:
  21146. Camera._setVRRigMode(this, rigParams);
  21147. break;
  21148. case Camera.RIG_MODE_WEBVR:
  21149. Camera._setWebVRRigMode(this, rigParams);
  21150. break;
  21151. }
  21152. this._cascadePostProcessesToRigCams();
  21153. this.update();
  21154. };
  21155. /** @hidden */
  21156. Camera._setStereoscopicRigMode = function (camera) {
  21157. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  21158. };
  21159. /** @hidden */
  21160. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  21161. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  21162. };
  21163. /** @hidden */
  21164. Camera._setVRRigMode = function (camera, rigParams) {
  21165. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  21166. };
  21167. /** @hidden */
  21168. Camera._setWebVRRigMode = function (camera, rigParams) {
  21169. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  21170. };
  21171. /** @hidden */
  21172. Camera.prototype._getVRProjectionMatrix = function () {
  21173. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  21174. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  21175. return this._projectionMatrix;
  21176. };
  21177. Camera.prototype._updateCameraRotationMatrix = function () {
  21178. //Here for WebVR
  21179. };
  21180. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  21181. //Here for WebVR
  21182. };
  21183. /**
  21184. * This function MUST be overwritten by the different WebVR cameras available.
  21185. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21186. * @hidden
  21187. */
  21188. Camera.prototype._getWebVRProjectionMatrix = function () {
  21189. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21190. };
  21191. /**
  21192. * This function MUST be overwritten by the different WebVR cameras available.
  21193. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21194. * @hidden
  21195. */
  21196. Camera.prototype._getWebVRViewMatrix = function () {
  21197. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21198. };
  21199. /** @hidden */
  21200. Camera.prototype.setCameraRigParameter = function (name, value) {
  21201. if (!this._cameraRigParams) {
  21202. this._cameraRigParams = {};
  21203. }
  21204. this._cameraRigParams[name] = value;
  21205. //provisionnally:
  21206. if (name === "interaxialDistance") {
  21207. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  21208. }
  21209. };
  21210. /**
  21211. * needs to be overridden by children so sub has required properties to be copied
  21212. * @hidden
  21213. */
  21214. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  21215. return null;
  21216. };
  21217. /**
  21218. * May need to be overridden by children
  21219. * @hidden
  21220. */
  21221. Camera.prototype._updateRigCameras = function () {
  21222. for (var i = 0; i < this._rigCameras.length; i++) {
  21223. this._rigCameras[i].minZ = this.minZ;
  21224. this._rigCameras[i].maxZ = this.maxZ;
  21225. this._rigCameras[i].fov = this.fov;
  21226. this._rigCameras[i].upVector.copyFrom(this.upVector);
  21227. }
  21228. // only update viewport when ANAGLYPH
  21229. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  21230. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  21231. }
  21232. };
  21233. /** @hidden */
  21234. Camera.prototype._setupInputs = function () {
  21235. };
  21236. /**
  21237. * Serialiaze the camera setup to a json represention
  21238. * @returns the JSON representation
  21239. */
  21240. Camera.prototype.serialize = function () {
  21241. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  21242. // Type
  21243. serializationObject.type = this.getClassName();
  21244. // Parent
  21245. if (this.parent) {
  21246. serializationObject.parentId = this.parent.id;
  21247. }
  21248. if (this.inputs) {
  21249. this.inputs.serialize(serializationObject);
  21250. }
  21251. // Animations
  21252. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  21253. serializationObject.ranges = this.serializeAnimationRanges();
  21254. return serializationObject;
  21255. };
  21256. /**
  21257. * Clones the current camera.
  21258. * @param name The cloned camera name
  21259. * @returns the cloned camera
  21260. */
  21261. Camera.prototype.clone = function (name) {
  21262. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  21263. };
  21264. /**
  21265. * Gets the direction of the camera relative to a given local axis.
  21266. * @param localAxis Defines the reference axis to provide a relative direction.
  21267. * @return the direction
  21268. */
  21269. Camera.prototype.getDirection = function (localAxis) {
  21270. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21271. this.getDirectionToRef(localAxis, result);
  21272. return result;
  21273. };
  21274. /**
  21275. * Gets the direction of the camera relative to a given local axis into a passed vector.
  21276. * @param localAxis Defines the reference axis to provide a relative direction.
  21277. * @param result Defines the vector to store the result in
  21278. */
  21279. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  21280. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  21281. };
  21282. /**
  21283. * Gets a camera constructor for a given camera type
  21284. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  21285. * @param name The name of the camera the result will be able to instantiate
  21286. * @param scene The scene the result will construct the camera in
  21287. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  21288. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  21289. * @returns a factory method to construc the camera
  21290. */
  21291. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  21292. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  21293. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  21294. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  21295. interaxial_distance: interaxial_distance,
  21296. isStereoscopicSideBySide: isStereoscopicSideBySide
  21297. });
  21298. if (constructorFunc) {
  21299. return constructorFunc;
  21300. }
  21301. // Default to universal camera
  21302. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  21303. };
  21304. /**
  21305. * Compute the world matrix of the camera.
  21306. * @returns the camera workd matrix
  21307. */
  21308. Camera.prototype.computeWorldMatrix = function () {
  21309. return this.getWorldMatrix();
  21310. };
  21311. /**
  21312. * Parse a JSON and creates the camera from the parsed information
  21313. * @param parsedCamera The JSON to parse
  21314. * @param scene The scene to instantiate the camera in
  21315. * @returns the newly constructed camera
  21316. */
  21317. Camera.Parse = function (parsedCamera, scene) {
  21318. var type = parsedCamera.type;
  21319. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  21320. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  21321. // Parent
  21322. if (parsedCamera.parentId) {
  21323. camera._waitingParentId = parsedCamera.parentId;
  21324. }
  21325. //If camera has an input manager, let it parse inputs settings
  21326. if (camera.inputs) {
  21327. camera.inputs.parse(parsedCamera);
  21328. camera._setupInputs();
  21329. }
  21330. if (camera.setPosition) { // need to force position
  21331. camera.position.copyFromFloats(0, 0, 0);
  21332. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  21333. }
  21334. // Target
  21335. if (parsedCamera.target) {
  21336. if (camera.setTarget) {
  21337. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  21338. }
  21339. }
  21340. // Apply 3d rig, when found
  21341. if (parsedCamera.cameraRigMode) {
  21342. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  21343. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  21344. }
  21345. // Animations
  21346. if (parsedCamera.animations) {
  21347. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  21348. var parsedAnimation = parsedCamera.animations[animationIndex];
  21349. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  21350. if (internalClass) {
  21351. camera.animations.push(internalClass.Parse(parsedAnimation));
  21352. }
  21353. }
  21354. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  21355. }
  21356. if (parsedCamera.autoAnimate) {
  21357. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  21358. }
  21359. return camera;
  21360. };
  21361. /** @hidden */
  21362. Camera._createDefaultParsedCamera = function (name, scene) {
  21363. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  21364. };
  21365. /**
  21366. * This is the default projection mode used by the cameras.
  21367. * It helps recreating a feeling of perspective and better appreciate depth.
  21368. * This is the best way to simulate real life cameras.
  21369. */
  21370. Camera.PERSPECTIVE_CAMERA = 0;
  21371. /**
  21372. * This helps creating camera with an orthographic mode.
  21373. * 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.
  21374. */
  21375. Camera.ORTHOGRAPHIC_CAMERA = 1;
  21376. /**
  21377. * This is the default FOV mode for perspective cameras.
  21378. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  21379. */
  21380. Camera.FOVMODE_VERTICAL_FIXED = 0;
  21381. /**
  21382. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  21383. */
  21384. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  21385. /**
  21386. * This specifies ther is no need for a camera rig.
  21387. * Basically only one eye is rendered corresponding to the camera.
  21388. */
  21389. Camera.RIG_MODE_NONE = 0;
  21390. /**
  21391. * Simulates a camera Rig with one blue eye and one red eye.
  21392. * This can be use with 3d blue and red glasses.
  21393. */
  21394. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  21395. /**
  21396. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  21397. */
  21398. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  21399. /**
  21400. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  21401. */
  21402. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  21403. /**
  21404. * Defines that both eyes of the camera will be rendered over under each other.
  21405. */
  21406. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  21407. /**
  21408. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  21409. */
  21410. Camera.RIG_MODE_VR = 20;
  21411. /**
  21412. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  21413. */
  21414. Camera.RIG_MODE_WEBVR = 21;
  21415. /**
  21416. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  21417. */
  21418. Camera.RIG_MODE_CUSTOM = 22;
  21419. /**
  21420. * Defines if by default attaching controls should prevent the default javascript event to continue.
  21421. */
  21422. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  21423. /**
  21424. * @hidden
  21425. * Might be removed once multiview will be a thing
  21426. */
  21427. Camera.UseAlternateWebVRRendering = false;
  21428. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  21430. ], Camera.prototype, "_position", void 0);
  21431. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21432. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21433. ], Camera.prototype, "upVector", void 0);
  21434. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21436. ], Camera.prototype, "orthoLeft", void 0);
  21437. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21438. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21439. ], Camera.prototype, "orthoRight", void 0);
  21440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21442. ], Camera.prototype, "orthoBottom", void 0);
  21443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21445. ], Camera.prototype, "orthoTop", void 0);
  21446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21448. ], Camera.prototype, "fov", void 0);
  21449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21451. ], Camera.prototype, "minZ", void 0);
  21452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21454. ], Camera.prototype, "maxZ", void 0);
  21455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21457. ], Camera.prototype, "inertia", void 0);
  21458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21460. ], Camera.prototype, "mode", void 0);
  21461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21463. ], Camera.prototype, "layerMask", void 0);
  21464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21466. ], Camera.prototype, "fovMode", void 0);
  21467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21469. ], Camera.prototype, "cameraRigMode", void 0);
  21470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21472. ], Camera.prototype, "interaxialDistance", void 0);
  21473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21475. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21476. return Camera;
  21477. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21478. /***/ }),
  21479. /***/ "./Cameras/cameraInputsManager.ts":
  21480. /*!****************************************!*\
  21481. !*** ./Cameras/cameraInputsManager.ts ***!
  21482. \****************************************/
  21483. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21485. "use strict";
  21486. __webpack_require__.r(__webpack_exports__);
  21487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21489. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21490. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21491. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21492. /**
  21493. * @ignore
  21494. * This is a list of all the different input types that are available in the application.
  21495. * Fo instance: ArcRotateCameraGamepadInput...
  21496. */
  21497. var CameraInputTypes = {};
  21498. /**
  21499. * This represents the input manager used within a camera.
  21500. * It helps dealing with all the different kind of input attached to a camera.
  21501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21502. */
  21503. var CameraInputsManager = /** @class */ (function () {
  21504. /**
  21505. * Instantiate a new Camera Input Manager.
  21506. * @param camera Defines the camera the input manager blongs to
  21507. */
  21508. function CameraInputsManager(camera) {
  21509. this.attached = {};
  21510. this.camera = camera;
  21511. this.checkInputs = function () { };
  21512. }
  21513. /**
  21514. * Add an input method to a camera
  21515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21516. * @param input camera input method
  21517. */
  21518. CameraInputsManager.prototype.add = function (input) {
  21519. var type = input.getSimpleName();
  21520. if (this.attached[type]) {
  21521. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21522. return;
  21523. }
  21524. this.attached[type] = input;
  21525. input.camera = this.camera;
  21526. //for checkInputs, we are dynamically creating a function
  21527. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21528. if (input.checkInputs) {
  21529. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21530. }
  21531. if (this.attachedElement) {
  21532. input.attachControl(this.attachedElement);
  21533. }
  21534. };
  21535. /**
  21536. * Remove a specific input method from a camera
  21537. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21538. * @param inputToRemove camera input method
  21539. */
  21540. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21541. for (var cam in this.attached) {
  21542. var input = this.attached[cam];
  21543. if (input === inputToRemove) {
  21544. input.detachControl(this.attachedElement);
  21545. input.camera = null;
  21546. delete this.attached[cam];
  21547. this.rebuildInputCheck();
  21548. }
  21549. }
  21550. };
  21551. /**
  21552. * Remove a specific input type from a camera
  21553. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21554. * @param inputType the type of the input to remove
  21555. */
  21556. CameraInputsManager.prototype.removeByType = function (inputType) {
  21557. for (var cam in this.attached) {
  21558. var input = this.attached[cam];
  21559. if (input.getClassName() === inputType) {
  21560. input.detachControl(this.attachedElement);
  21561. input.camera = null;
  21562. delete this.attached[cam];
  21563. this.rebuildInputCheck();
  21564. }
  21565. }
  21566. };
  21567. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21568. var current = this.checkInputs;
  21569. return function () {
  21570. current();
  21571. fn();
  21572. };
  21573. };
  21574. /**
  21575. * Attach the input controls to the currently attached dom element to listen the events from.
  21576. * @param input Defines the input to attach
  21577. */
  21578. CameraInputsManager.prototype.attachInput = function (input) {
  21579. if (this.attachedElement) {
  21580. input.attachControl(this.attachedElement, this.noPreventDefault);
  21581. }
  21582. };
  21583. /**
  21584. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21585. * @param element Defines the dom element to collect the events from
  21586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21587. */
  21588. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21589. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21590. if (this.attachedElement) {
  21591. return;
  21592. }
  21593. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21594. this.attachedElement = element;
  21595. this.noPreventDefault = noPreventDefault;
  21596. for (var cam in this.attached) {
  21597. this.attached[cam].attachControl(element, noPreventDefault);
  21598. }
  21599. };
  21600. /**
  21601. * Detach the current manager inputs controls from a specific dom element.
  21602. * @param element Defines the dom element to collect the events from
  21603. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21604. */
  21605. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21606. if (disconnect === void 0) { disconnect = false; }
  21607. if (this.attachedElement !== element) {
  21608. return;
  21609. }
  21610. for (var cam in this.attached) {
  21611. this.attached[cam].detachControl(element);
  21612. if (disconnect) {
  21613. this.attached[cam].camera = null;
  21614. }
  21615. }
  21616. this.attachedElement = null;
  21617. };
  21618. /**
  21619. * Rebuild the dynamic inputCheck function from the current list of
  21620. * defined inputs in the manager.
  21621. */
  21622. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21623. this.checkInputs = function () { };
  21624. for (var cam in this.attached) {
  21625. var input = this.attached[cam];
  21626. if (input.checkInputs) {
  21627. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21628. }
  21629. }
  21630. };
  21631. /**
  21632. * Remove all attached input methods from a camera
  21633. */
  21634. CameraInputsManager.prototype.clear = function () {
  21635. if (this.attachedElement) {
  21636. this.detachElement(this.attachedElement, true);
  21637. }
  21638. this.attached = {};
  21639. this.attachedElement = null;
  21640. this.checkInputs = function () { };
  21641. };
  21642. /**
  21643. * Serialize the current input manager attached to a camera.
  21644. * This ensures than once parsed,
  21645. * the input associated to the camera will be identical to the current ones
  21646. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21647. */
  21648. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21649. var inputs = {};
  21650. for (var cam in this.attached) {
  21651. var input = this.attached[cam];
  21652. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21653. inputs[input.getClassName()] = res;
  21654. }
  21655. serializedCamera.inputsmgr = inputs;
  21656. };
  21657. /**
  21658. * Parses an input manager serialized JSON to restore the previous list of inputs
  21659. * and states associated to a camera.
  21660. * @param parsedCamera Defines the JSON to parse
  21661. */
  21662. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21663. var parsedInputs = parsedCamera.inputsmgr;
  21664. if (parsedInputs) {
  21665. this.clear();
  21666. for (var n in parsedInputs) {
  21667. var construct = CameraInputTypes[n];
  21668. if (construct) {
  21669. var parsedinput = parsedInputs[n];
  21670. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21671. this.add(input);
  21672. }
  21673. }
  21674. }
  21675. else {
  21676. //2016-03-08 this part is for managing backward compatibility
  21677. for (var n in this.attached) {
  21678. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21679. if (construct) {
  21680. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21681. this.remove(this.attached[n]);
  21682. this.add(input);
  21683. }
  21684. }
  21685. }
  21686. };
  21687. return CameraInputsManager;
  21688. }());
  21689. /***/ }),
  21690. /***/ "./Cameras/deviceOrientationCamera.ts":
  21691. /*!********************************************!*\
  21692. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21693. \********************************************/
  21694. /*! exports provided: DeviceOrientationCamera */
  21695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21696. "use strict";
  21697. __webpack_require__.r(__webpack_exports__);
  21698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21699. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21700. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21701. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21702. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21703. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21704. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21705. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21706. });
  21707. // We're mainly based on the logic defined into the FreeCamera code
  21708. /**
  21709. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21710. * being tilted forward or back and left or right.
  21711. */
  21712. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21713. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21714. /**
  21715. * Creates a new device orientation camera
  21716. * @param name The name of the camera
  21717. * @param position The start position camera
  21718. * @param scene The scene the camera belongs to
  21719. */
  21720. function DeviceOrientationCamera(name, position, scene) {
  21721. var _this = _super.call(this, name, position, scene) || this;
  21722. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21723. _this.inputs.addDeviceOrientation();
  21724. return _this;
  21725. }
  21726. /**
  21727. * Gets the current instance class name ("DeviceOrientationCamera").
  21728. * This helps avoiding instanceof at run time.
  21729. * @returns the class name
  21730. */
  21731. DeviceOrientationCamera.prototype.getClassName = function () {
  21732. return "DeviceOrientationCamera";
  21733. };
  21734. /**
  21735. * @hidden
  21736. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21737. */
  21738. DeviceOrientationCamera.prototype._checkInputs = function () {
  21739. _super.prototype._checkInputs.call(this);
  21740. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21741. if (this._initialQuaternion) {
  21742. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21743. }
  21744. };
  21745. /**
  21746. * Reset the camera to its default orientation on the specified axis only.
  21747. * @param axis The axis to reset
  21748. */
  21749. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21750. var _this = this;
  21751. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21752. //can only work if this camera has a rotation quaternion already.
  21753. if (!this.rotationQuaternion) {
  21754. return;
  21755. }
  21756. if (!this._initialQuaternion) {
  21757. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21758. }
  21759. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21760. ['x', 'y', 'z'].forEach(function (axisName) {
  21761. if (!axis[axisName]) {
  21762. _this._initialQuaternion[axisName] = 0;
  21763. }
  21764. else {
  21765. _this._initialQuaternion[axisName] *= -1;
  21766. }
  21767. });
  21768. this._initialQuaternion.normalize();
  21769. //force rotation update
  21770. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21771. };
  21772. return DeviceOrientationCamera;
  21773. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21774. /***/ }),
  21775. /***/ "./Cameras/flyCamera.ts":
  21776. /*!******************************!*\
  21777. !*** ./Cameras/flyCamera.ts ***!
  21778. \******************************/
  21779. /*! exports provided: FlyCamera */
  21780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21781. "use strict";
  21782. __webpack_require__.r(__webpack_exports__);
  21783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21784. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21785. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21786. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21787. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21788. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21789. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21790. /**
  21791. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21792. * such as in a 3D Space Shooter or a Flight Simulator.
  21793. */
  21794. var FlyCamera = /** @class */ (function (_super) {
  21795. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21796. /**
  21797. * Instantiates a FlyCamera.
  21798. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21799. * such as in a 3D Space Shooter or a Flight Simulator.
  21800. * @param name Define the name of the camera in the scene.
  21801. * @param position Define the starting position of the camera in the scene.
  21802. * @param scene Define the scene the camera belongs to.
  21803. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21804. */
  21805. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21806. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21807. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21808. /**
  21809. * Define the collision ellipsoid of the camera.
  21810. * This is helpful for simulating a camera body, like a player's body.
  21811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21812. */
  21813. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21814. /**
  21815. * Define an offset for the position of the ellipsoid around the camera.
  21816. * This can be helpful if the camera is attached away from the player's body center,
  21817. * such as at its head.
  21818. */
  21819. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21820. /**
  21821. * Enable or disable collisions of the camera with the rest of the scene objects.
  21822. */
  21823. _this.checkCollisions = false;
  21824. /**
  21825. * Enable or disable gravity on the camera.
  21826. */
  21827. _this.applyGravity = false;
  21828. /**
  21829. * Define the current direction the camera is moving to.
  21830. */
  21831. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21832. /**
  21833. * Track Roll to maintain the wanted Rolling when looking around.
  21834. */
  21835. _this._trackRoll = 0;
  21836. /**
  21837. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21838. */
  21839. _this.rollCorrect = 100;
  21840. /**
  21841. * Mimic a banked turn, Rolling the camera when Yawing.
  21842. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21843. */
  21844. _this.bankedTurn = false;
  21845. /**
  21846. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21847. */
  21848. _this.bankedTurnLimit = Math.PI / 2;
  21849. /**
  21850. * Value of 0 disables the banked Roll.
  21851. * Value of 1 is equal to the Yaw angle in radians.
  21852. */
  21853. _this.bankedTurnMultiplier = 1;
  21854. _this._needMoveForGravity = false;
  21855. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21856. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21857. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21858. // Collisions.
  21859. _this._collisionMask = -1;
  21860. /** @hidden */
  21861. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21862. if (collidedMesh === void 0) { collidedMesh = null; }
  21863. var updatePosition = function (newPos) {
  21864. _this._newPosition.copyFrom(newPos);
  21865. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21866. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21867. _this.position.addInPlace(_this._diffPosition);
  21868. if (_this.onCollide && collidedMesh) {
  21869. _this.onCollide(collidedMesh);
  21870. }
  21871. }
  21872. };
  21873. updatePosition(newPosition);
  21874. };
  21875. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21876. _this.inputs.addKeyboard().addMouse();
  21877. return _this;
  21878. }
  21879. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21880. /**
  21881. * Gets the input sensibility for mouse input.
  21882. * Higher values reduce sensitivity.
  21883. */
  21884. get: function () {
  21885. var mouse = this.inputs.attached["mouse"];
  21886. if (mouse) {
  21887. return mouse.angularSensibility;
  21888. }
  21889. return 0;
  21890. },
  21891. /**
  21892. * Sets the input sensibility for a mouse input.
  21893. * Higher values reduce sensitivity.
  21894. */
  21895. set: function (value) {
  21896. var mouse = this.inputs.attached["mouse"];
  21897. if (mouse) {
  21898. mouse.angularSensibility = value;
  21899. }
  21900. },
  21901. enumerable: true,
  21902. configurable: true
  21903. });
  21904. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21905. /**
  21906. * Get the keys for camera movement forward.
  21907. */
  21908. get: function () {
  21909. var keyboard = this.inputs.attached["keyboard"];
  21910. if (keyboard) {
  21911. return keyboard.keysForward;
  21912. }
  21913. return [];
  21914. },
  21915. /**
  21916. * Set the keys for camera movement forward.
  21917. */
  21918. set: function (value) {
  21919. var keyboard = this.inputs.attached["keyboard"];
  21920. if (keyboard) {
  21921. keyboard.keysForward = value;
  21922. }
  21923. },
  21924. enumerable: true,
  21925. configurable: true
  21926. });
  21927. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21928. /**
  21929. * Get the keys for camera movement backward.
  21930. */
  21931. get: function () {
  21932. var keyboard = this.inputs.attached["keyboard"];
  21933. if (keyboard) {
  21934. return keyboard.keysBackward;
  21935. }
  21936. return [];
  21937. },
  21938. set: function (value) {
  21939. var keyboard = this.inputs.attached["keyboard"];
  21940. if (keyboard) {
  21941. keyboard.keysBackward = value;
  21942. }
  21943. },
  21944. enumerable: true,
  21945. configurable: true
  21946. });
  21947. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21948. /**
  21949. * Get the keys for camera movement up.
  21950. */
  21951. get: function () {
  21952. var keyboard = this.inputs.attached["keyboard"];
  21953. if (keyboard) {
  21954. return keyboard.keysUp;
  21955. }
  21956. return [];
  21957. },
  21958. /**
  21959. * Set the keys for camera movement up.
  21960. */
  21961. set: function (value) {
  21962. var keyboard = this.inputs.attached["keyboard"];
  21963. if (keyboard) {
  21964. keyboard.keysUp = value;
  21965. }
  21966. },
  21967. enumerable: true,
  21968. configurable: true
  21969. });
  21970. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21971. /**
  21972. * Get the keys for camera movement down.
  21973. */
  21974. get: function () {
  21975. var keyboard = this.inputs.attached["keyboard"];
  21976. if (keyboard) {
  21977. return keyboard.keysDown;
  21978. }
  21979. return [];
  21980. },
  21981. /**
  21982. * Set the keys for camera movement down.
  21983. */
  21984. set: function (value) {
  21985. var keyboard = this.inputs.attached["keyboard"];
  21986. if (keyboard) {
  21987. keyboard.keysDown = value;
  21988. }
  21989. },
  21990. enumerable: true,
  21991. configurable: true
  21992. });
  21993. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  21994. /**
  21995. * Get the keys for camera movement left.
  21996. */
  21997. get: function () {
  21998. var keyboard = this.inputs.attached["keyboard"];
  21999. if (keyboard) {
  22000. return keyboard.keysLeft;
  22001. }
  22002. return [];
  22003. },
  22004. /**
  22005. * Set the keys for camera movement left.
  22006. */
  22007. set: function (value) {
  22008. var keyboard = this.inputs.attached["keyboard"];
  22009. if (keyboard) {
  22010. keyboard.keysLeft = value;
  22011. }
  22012. },
  22013. enumerable: true,
  22014. configurable: true
  22015. });
  22016. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  22017. /**
  22018. * Set the keys for camera movement right.
  22019. */
  22020. get: function () {
  22021. var keyboard = this.inputs.attached["keyboard"];
  22022. if (keyboard) {
  22023. return keyboard.keysRight;
  22024. }
  22025. return [];
  22026. },
  22027. /**
  22028. * Set the keys for camera movement right.
  22029. */
  22030. set: function (value) {
  22031. var keyboard = this.inputs.attached["keyboard"];
  22032. if (keyboard) {
  22033. keyboard.keysRight = value;
  22034. }
  22035. },
  22036. enumerable: true,
  22037. configurable: true
  22038. });
  22039. /**
  22040. * Attach a control to the HTML DOM element.
  22041. * @param element Defines the element that listens to the input events.
  22042. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  22043. */
  22044. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  22045. this.inputs.attachElement(element, noPreventDefault);
  22046. };
  22047. /**
  22048. * Detach a control from the HTML DOM element.
  22049. * The camera will stop reacting to that input.
  22050. * @param element Defines the element that listens to the input events.
  22051. */
  22052. FlyCamera.prototype.detachControl = function (element) {
  22053. this.inputs.detachElement(element);
  22054. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22055. };
  22056. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  22057. /**
  22058. * Get the mask that the camera ignores in collision events.
  22059. */
  22060. get: function () {
  22061. return this._collisionMask;
  22062. },
  22063. /**
  22064. * Set the mask that the camera ignores in collision events.
  22065. */
  22066. set: function (mask) {
  22067. this._collisionMask = !isNaN(mask) ? mask : -1;
  22068. },
  22069. enumerable: true,
  22070. configurable: true
  22071. });
  22072. /** @hidden */
  22073. FlyCamera.prototype._collideWithWorld = function (displacement) {
  22074. var globalPosition;
  22075. if (this.parent) {
  22076. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22077. }
  22078. else {
  22079. globalPosition = this.position;
  22080. }
  22081. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22082. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22083. var coordinator = this.getScene().collisionCoordinator;
  22084. if (!this._collider) {
  22085. this._collider = coordinator.createCollider();
  22086. }
  22087. this._collider._radius = this.ellipsoid;
  22088. this._collider.collisionMask = this._collisionMask;
  22089. // No need for clone, as long as gravity is not on.
  22090. var actualDisplacement = displacement;
  22091. // Add gravity to direction to prevent dual-collision checking.
  22092. if (this.applyGravity) {
  22093. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  22094. actualDisplacement = displacement.add(this.getScene().gravity);
  22095. }
  22096. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22097. };
  22098. /** @hidden */
  22099. FlyCamera.prototype._checkInputs = function () {
  22100. if (!this._localDirection) {
  22101. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22102. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22103. }
  22104. this.inputs.checkInputs();
  22105. _super.prototype._checkInputs.call(this);
  22106. };
  22107. /** @hidden */
  22108. FlyCamera.prototype._decideIfNeedsToMove = function () {
  22109. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22110. };
  22111. /** @hidden */
  22112. FlyCamera.prototype._updatePosition = function () {
  22113. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22114. this._collideWithWorld(this.cameraDirection);
  22115. }
  22116. else {
  22117. _super.prototype._updatePosition.call(this);
  22118. }
  22119. };
  22120. /**
  22121. * Restore the Roll to its target value at the rate specified.
  22122. * @param rate - Higher means slower restoring.
  22123. * @hidden
  22124. */
  22125. FlyCamera.prototype.restoreRoll = function (rate) {
  22126. var limit = this._trackRoll; // Target Roll.
  22127. var z = this.rotation.z; // Current Roll.
  22128. var delta = limit - z; // Difference in Roll.
  22129. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  22130. // If the difference is noticable, restore the Roll.
  22131. if (Math.abs(delta) >= minRad) {
  22132. // Change Z rotation towards the target Roll.
  22133. this.rotation.z += delta / rate;
  22134. // Match when near enough.
  22135. if (Math.abs(limit - this.rotation.z) <= minRad) {
  22136. this.rotation.z = limit;
  22137. }
  22138. }
  22139. };
  22140. /**
  22141. * Destroy the camera and release the current resources held by it.
  22142. */
  22143. FlyCamera.prototype.dispose = function () {
  22144. this.inputs.clear();
  22145. _super.prototype.dispose.call(this);
  22146. };
  22147. /**
  22148. * Get the current object class name.
  22149. * @returns the class name.
  22150. */
  22151. FlyCamera.prototype.getClassName = function () {
  22152. return "FlyCamera";
  22153. };
  22154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22156. ], FlyCamera.prototype, "ellipsoid", void 0);
  22157. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22158. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22159. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  22160. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22161. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22162. ], FlyCamera.prototype, "checkCollisions", void 0);
  22163. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22165. ], FlyCamera.prototype, "applyGravity", void 0);
  22166. return FlyCamera;
  22167. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22168. /***/ }),
  22169. /***/ "./Cameras/flyCameraInputsManager.ts":
  22170. /*!*******************************************!*\
  22171. !*** ./Cameras/flyCameraInputsManager.ts ***!
  22172. \*******************************************/
  22173. /*! exports provided: FlyCameraInputsManager */
  22174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22175. "use strict";
  22176. __webpack_require__.r(__webpack_exports__);
  22177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  22178. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22179. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22180. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  22181. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  22182. /**
  22183. * Default Inputs manager for the FlyCamera.
  22184. * It groups all the default supported inputs for ease of use.
  22185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22186. */
  22187. var FlyCameraInputsManager = /** @class */ (function (_super) {
  22188. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  22189. /**
  22190. * Instantiates a new FlyCameraInputsManager.
  22191. * @param camera Defines the camera the inputs belong to.
  22192. */
  22193. function FlyCameraInputsManager(camera) {
  22194. return _super.call(this, camera) || this;
  22195. }
  22196. /**
  22197. * Add keyboard input support to the input manager.
  22198. * @returns the new FlyCameraKeyboardMoveInput().
  22199. */
  22200. FlyCameraInputsManager.prototype.addKeyboard = function () {
  22201. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  22202. return this;
  22203. };
  22204. /**
  22205. * Add mouse input support to the input manager.
  22206. * @param touchEnabled Enable touch screen support.
  22207. * @returns the new FlyCameraMouseInput().
  22208. */
  22209. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22210. if (touchEnabled === void 0) { touchEnabled = true; }
  22211. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  22212. return this;
  22213. };
  22214. return FlyCameraInputsManager;
  22215. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22216. /***/ }),
  22217. /***/ "./Cameras/followCamera.ts":
  22218. /*!*********************************!*\
  22219. !*** ./Cameras/followCamera.ts ***!
  22220. \*********************************/
  22221. /*! exports provided: FollowCamera, ArcFollowCamera */
  22222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22223. "use strict";
  22224. __webpack_require__.r(__webpack_exports__);
  22225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  22226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  22227. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22228. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22229. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  22230. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22231. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22232. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  22233. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  22234. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  22235. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  22236. });
  22237. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  22238. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  22239. });
  22240. /**
  22241. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  22242. * an arc rotate version arcFollowCamera are available.
  22243. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22244. */
  22245. var FollowCamera = /** @class */ (function (_super) {
  22246. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  22247. /**
  22248. * Instantiates the follow camera.
  22249. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22250. * @param name Define the name of the camera in the scene
  22251. * @param position Define the position of the camera
  22252. * @param scene Define the scene the camera belong to
  22253. * @param lockedTarget Define the target of the camera
  22254. */
  22255. function FollowCamera(name, position, scene, lockedTarget) {
  22256. if (lockedTarget === void 0) { lockedTarget = null; }
  22257. var _this = _super.call(this, name, position, scene) || this;
  22258. /**
  22259. * Distance the follow camera should follow an object at
  22260. */
  22261. _this.radius = 12;
  22262. /**
  22263. * Minimum allowed distance of the camera to the axis of rotation
  22264. * (The camera can not get closer).
  22265. * This can help limiting how the Camera is able to move in the scene.
  22266. */
  22267. _this.lowerRadiusLimit = null;
  22268. /**
  22269. * Maximum allowed distance of the camera to the axis of rotation
  22270. * (The camera can not get further).
  22271. * This can help limiting how the Camera is able to move in the scene.
  22272. */
  22273. _this.upperRadiusLimit = null;
  22274. /**
  22275. * Define a rotation offset between the camera and the object it follows
  22276. */
  22277. _this.rotationOffset = 0;
  22278. /**
  22279. * Minimum allowed angle to camera position relative to target object.
  22280. * This can help limiting how the Camera is able to move in the scene.
  22281. */
  22282. _this.lowerRotationOffsetLimit = null;
  22283. /**
  22284. * Maximum allowed angle to camera position relative to target object.
  22285. * This can help limiting how the Camera is able to move in the scene.
  22286. */
  22287. _this.upperRotationOffsetLimit = null;
  22288. /**
  22289. * Define a height offset between the camera and the object it follows.
  22290. * It can help following an object from the top (like a car chaing a plane)
  22291. */
  22292. _this.heightOffset = 4;
  22293. /**
  22294. * Minimum allowed height of camera position relative to target object.
  22295. * This can help limiting how the Camera is able to move in the scene.
  22296. */
  22297. _this.lowerHeightOffsetLimit = null;
  22298. /**
  22299. * Maximum allowed height of camera position relative to target object.
  22300. * This can help limiting how the Camera is able to move in the scene.
  22301. */
  22302. _this.upperHeightOffsetLimit = null;
  22303. /**
  22304. * Define how fast the camera can accelerate to follow it s target.
  22305. */
  22306. _this.cameraAcceleration = 0.05;
  22307. /**
  22308. * Define the speed limit of the camera following an object.
  22309. */
  22310. _this.maxCameraSpeed = 20;
  22311. _this.lockedTarget = lockedTarget;
  22312. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  22313. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  22314. return _this;
  22315. // Uncomment the following line when the relevant handlers have been implemented.
  22316. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  22317. }
  22318. FollowCamera.prototype._follow = function (cameraTarget) {
  22319. if (!cameraTarget) {
  22320. return;
  22321. }
  22322. var yRotation;
  22323. if (cameraTarget.rotationQuaternion) {
  22324. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  22325. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  22326. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  22327. }
  22328. else {
  22329. yRotation = cameraTarget.rotation.y;
  22330. }
  22331. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  22332. var targetPosition = cameraTarget.getAbsolutePosition();
  22333. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  22334. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  22335. var dx = targetX - this.position.x;
  22336. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  22337. var dz = (targetZ) - this.position.z;
  22338. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  22339. var vy = dy * this.cameraAcceleration;
  22340. var vz = dz * this.cameraAcceleration * 2;
  22341. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  22342. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22343. }
  22344. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  22345. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22346. }
  22347. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  22348. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22349. }
  22350. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  22351. this.setTarget(targetPosition);
  22352. };
  22353. /**
  22354. * Attached controls to the current camera.
  22355. * @param element Defines the element the controls should be listened from
  22356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22357. */
  22358. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  22359. this.inputs.attachElement(element, noPreventDefault);
  22360. this._reset = function () {
  22361. };
  22362. };
  22363. /**
  22364. * Detach the current controls from the camera.
  22365. * The camera will stop reacting to inputs.
  22366. * @param element Defines the element to stop listening the inputs from
  22367. */
  22368. FollowCamera.prototype.detachControl = function (element) {
  22369. this.inputs.detachElement(element);
  22370. if (this._reset) {
  22371. this._reset();
  22372. }
  22373. };
  22374. /** @hidden */
  22375. FollowCamera.prototype._checkInputs = function () {
  22376. this.inputs.checkInputs();
  22377. this._checkLimits();
  22378. _super.prototype._checkInputs.call(this);
  22379. if (this.lockedTarget) {
  22380. this._follow(this.lockedTarget);
  22381. }
  22382. };
  22383. FollowCamera.prototype._checkLimits = function () {
  22384. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  22385. this.radius = this.lowerRadiusLimit;
  22386. }
  22387. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  22388. this.radius = this.upperRadiusLimit;
  22389. }
  22390. if (this.lowerHeightOffsetLimit !== null &&
  22391. this.heightOffset < this.lowerHeightOffsetLimit) {
  22392. this.heightOffset = this.lowerHeightOffsetLimit;
  22393. }
  22394. if (this.upperHeightOffsetLimit !== null &&
  22395. this.heightOffset > this.upperHeightOffsetLimit) {
  22396. this.heightOffset = this.upperHeightOffsetLimit;
  22397. }
  22398. if (this.lowerRotationOffsetLimit !== null &&
  22399. this.rotationOffset < this.lowerRotationOffsetLimit) {
  22400. this.rotationOffset = this.lowerRotationOffsetLimit;
  22401. }
  22402. if (this.upperRotationOffsetLimit !== null &&
  22403. this.rotationOffset > this.upperRotationOffsetLimit) {
  22404. this.rotationOffset = this.upperRotationOffsetLimit;
  22405. }
  22406. };
  22407. /**
  22408. * Gets the camera class name.
  22409. * @returns the class name
  22410. */
  22411. FollowCamera.prototype.getClassName = function () {
  22412. return "FollowCamera";
  22413. };
  22414. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22416. ], FollowCamera.prototype, "radius", void 0);
  22417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22419. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  22420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22422. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  22423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22425. ], FollowCamera.prototype, "rotationOffset", void 0);
  22426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22428. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  22429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22431. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  22432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22434. ], FollowCamera.prototype, "heightOffset", void 0);
  22435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22437. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  22438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22440. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  22441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22443. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  22444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22446. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  22447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22449. ], FollowCamera.prototype, "lockedTarget", void 0);
  22450. return FollowCamera;
  22451. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22452. /**
  22453. * Arc Rotate version of the follow camera.
  22454. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  22455. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22456. */
  22457. var ArcFollowCamera = /** @class */ (function (_super) {
  22458. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  22459. /**
  22460. * Instantiates a new ArcFollowCamera
  22461. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22462. * @param name Define the name of the camera
  22463. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  22464. * @param beta Define the rotation angle of the camera around the elevation axis
  22465. * @param radius Define the radius of the camera from its target point
  22466. * @param target Define the target of the camera
  22467. * @param scene Define the scene the camera belongs to
  22468. */
  22469. function ArcFollowCamera(name,
  22470. /** The longitudinal angle of the camera */
  22471. alpha,
  22472. /** The latitudinal angle of the camera */
  22473. beta,
  22474. /** The radius of the camera from its target */
  22475. radius,
  22476. /** Define the camera target (the messh it should follow) */
  22477. target, scene) {
  22478. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22479. _this.alpha = alpha;
  22480. _this.beta = beta;
  22481. _this.radius = radius;
  22482. _this.target = target;
  22483. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22484. _this._follow();
  22485. return _this;
  22486. }
  22487. ArcFollowCamera.prototype._follow = function () {
  22488. if (!this.target) {
  22489. return;
  22490. }
  22491. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22492. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22493. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22494. var targetPosition = this.target.getAbsolutePosition();
  22495. this.position = targetPosition.add(this._cartesianCoordinates);
  22496. this.setTarget(targetPosition);
  22497. };
  22498. /** @hidden */
  22499. ArcFollowCamera.prototype._checkInputs = function () {
  22500. _super.prototype._checkInputs.call(this);
  22501. this._follow();
  22502. };
  22503. /**
  22504. * Returns the class name of the object.
  22505. * It is mostly used internally for serialization purposes.
  22506. */
  22507. ArcFollowCamera.prototype.getClassName = function () {
  22508. return "ArcFollowCamera";
  22509. };
  22510. return ArcFollowCamera;
  22511. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22512. /***/ }),
  22513. /***/ "./Cameras/followCameraInputsManager.ts":
  22514. /*!**********************************************!*\
  22515. !*** ./Cameras/followCameraInputsManager.ts ***!
  22516. \**********************************************/
  22517. /*! exports provided: FollowCameraInputsManager */
  22518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22519. "use strict";
  22520. __webpack_require__.r(__webpack_exports__);
  22521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22522. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22523. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22524. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22525. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22526. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  22527. /**
  22528. * Default Inputs manager for the FollowCamera.
  22529. * It groups all the default supported inputs for ease of use.
  22530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22531. */
  22532. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22533. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22534. /**
  22535. * Instantiates a new FollowCameraInputsManager.
  22536. * @param camera Defines the camera the inputs belong to
  22537. */
  22538. function FollowCameraInputsManager(camera) {
  22539. return _super.call(this, camera) || this;
  22540. }
  22541. /**
  22542. * Add keyboard input support to the input manager.
  22543. * @returns the current input manager
  22544. */
  22545. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22546. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22547. return this;
  22548. };
  22549. /**
  22550. * Add mouse wheel input support to the input manager.
  22551. * @returns the current input manager
  22552. */
  22553. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22554. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22555. return this;
  22556. };
  22557. /**
  22558. * Add pointers input support to the input manager.
  22559. * @returns the current input manager
  22560. */
  22561. FollowCameraInputsManager.prototype.addPointers = function () {
  22562. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  22563. return this;
  22564. };
  22565. /**
  22566. * Add orientation input support to the input manager.
  22567. * @returns the current input manager
  22568. */
  22569. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22570. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22571. return this;
  22572. };
  22573. return FollowCameraInputsManager;
  22574. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22575. /***/ }),
  22576. /***/ "./Cameras/freeCamera.ts":
  22577. /*!*******************************!*\
  22578. !*** ./Cameras/freeCamera.ts ***!
  22579. \*******************************/
  22580. /*! exports provided: FreeCamera */
  22581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22582. "use strict";
  22583. __webpack_require__.r(__webpack_exports__);
  22584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22585. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22586. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22587. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22588. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22589. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22590. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22591. /**
  22592. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22593. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22594. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22595. */
  22596. var FreeCamera = /** @class */ (function (_super) {
  22597. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22598. /**
  22599. * Instantiates a Free Camera.
  22600. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22601. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22602. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22603. * @param name Define the name of the camera in the scene
  22604. * @param position Define the start position of the camera in the scene
  22605. * @param scene Define the scene the camera belongs to
  22606. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22607. */
  22608. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22609. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22610. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22611. /**
  22612. * Define the collision ellipsoid of the camera.
  22613. * This is helpful to simulate a camera body like the player body around the camera
  22614. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22615. */
  22616. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22617. /**
  22618. * Define an offset for the position of the ellipsoid around the camera.
  22619. * This can be helpful to determine the center of the body near the gravity center of the body
  22620. * instead of its head.
  22621. */
  22622. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22623. /**
  22624. * Enable or disable collisions of the camera with the rest of the scene objects.
  22625. */
  22626. _this.checkCollisions = false;
  22627. /**
  22628. * Enable or disable gravity on the camera.
  22629. */
  22630. _this.applyGravity = false;
  22631. _this._needMoveForGravity = false;
  22632. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22633. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22634. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22635. // Collisions
  22636. _this._collisionMask = -1;
  22637. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22638. if (collidedMesh === void 0) { collidedMesh = null; }
  22639. var updatePosition = function (newPos) {
  22640. _this._newPosition.copyFrom(newPos);
  22641. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22642. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22643. _this.position.addInPlace(_this._diffPosition);
  22644. if (_this.onCollide && collidedMesh) {
  22645. _this.onCollide(collidedMesh);
  22646. }
  22647. }
  22648. };
  22649. updatePosition(newPosition);
  22650. };
  22651. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22652. _this.inputs.addKeyboard().addMouse();
  22653. return _this;
  22654. }
  22655. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22656. /**
  22657. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22658. * Higher values reduce sensitivity.
  22659. */
  22660. get: function () {
  22661. var mouse = this.inputs.attached["mouse"];
  22662. if (mouse) {
  22663. return mouse.angularSensibility;
  22664. }
  22665. return 0;
  22666. },
  22667. /**
  22668. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22669. * Higher values reduce sensitivity.
  22670. */
  22671. set: function (value) {
  22672. var mouse = this.inputs.attached["mouse"];
  22673. if (mouse) {
  22674. mouse.angularSensibility = value;
  22675. }
  22676. },
  22677. enumerable: true,
  22678. configurable: true
  22679. });
  22680. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22681. /**
  22682. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22683. */
  22684. get: function () {
  22685. var keyboard = this.inputs.attached["keyboard"];
  22686. if (keyboard) {
  22687. return keyboard.keysUp;
  22688. }
  22689. return [];
  22690. },
  22691. set: function (value) {
  22692. var keyboard = this.inputs.attached["keyboard"];
  22693. if (keyboard) {
  22694. keyboard.keysUp = value;
  22695. }
  22696. },
  22697. enumerable: true,
  22698. configurable: true
  22699. });
  22700. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22701. /**
  22702. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22703. */
  22704. get: function () {
  22705. var keyboard = this.inputs.attached["keyboard"];
  22706. if (keyboard) {
  22707. return keyboard.keysDown;
  22708. }
  22709. return [];
  22710. },
  22711. set: function (value) {
  22712. var keyboard = this.inputs.attached["keyboard"];
  22713. if (keyboard) {
  22714. keyboard.keysDown = value;
  22715. }
  22716. },
  22717. enumerable: true,
  22718. configurable: true
  22719. });
  22720. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22721. /**
  22722. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22723. */
  22724. get: function () {
  22725. var keyboard = this.inputs.attached["keyboard"];
  22726. if (keyboard) {
  22727. return keyboard.keysLeft;
  22728. }
  22729. return [];
  22730. },
  22731. set: function (value) {
  22732. var keyboard = this.inputs.attached["keyboard"];
  22733. if (keyboard) {
  22734. keyboard.keysLeft = value;
  22735. }
  22736. },
  22737. enumerable: true,
  22738. configurable: true
  22739. });
  22740. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22741. /**
  22742. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22743. */
  22744. get: function () {
  22745. var keyboard = this.inputs.attached["keyboard"];
  22746. if (keyboard) {
  22747. return keyboard.keysRight;
  22748. }
  22749. return [];
  22750. },
  22751. set: function (value) {
  22752. var keyboard = this.inputs.attached["keyboard"];
  22753. if (keyboard) {
  22754. keyboard.keysRight = value;
  22755. }
  22756. },
  22757. enumerable: true,
  22758. configurable: true
  22759. });
  22760. /**
  22761. * Attached controls to the current camera.
  22762. * @param element Defines the element the controls should be listened from
  22763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22764. */
  22765. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22766. this.inputs.attachElement(element, noPreventDefault);
  22767. };
  22768. /**
  22769. * Detach the current controls from the camera.
  22770. * The camera will stop reacting to inputs.
  22771. * @param element Defines the element to stop listening the inputs from
  22772. */
  22773. FreeCamera.prototype.detachControl = function (element) {
  22774. this.inputs.detachElement(element);
  22775. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22776. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22777. };
  22778. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22779. /**
  22780. * Define a collision mask to limit the list of object the camera can collide with
  22781. */
  22782. get: function () {
  22783. return this._collisionMask;
  22784. },
  22785. set: function (mask) {
  22786. this._collisionMask = !isNaN(mask) ? mask : -1;
  22787. },
  22788. enumerable: true,
  22789. configurable: true
  22790. });
  22791. /** @hidden */
  22792. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22793. var globalPosition;
  22794. if (this.parent) {
  22795. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22796. }
  22797. else {
  22798. globalPosition = this.position;
  22799. }
  22800. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22801. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22802. var coordinator = this.getScene().collisionCoordinator;
  22803. if (!this._collider) {
  22804. this._collider = coordinator.createCollider();
  22805. }
  22806. this._collider._radius = this.ellipsoid;
  22807. this._collider.collisionMask = this._collisionMask;
  22808. //no need for clone, as long as gravity is not on.
  22809. var actualDisplacement = displacement;
  22810. //add gravity to the direction to prevent the dual-collision checking
  22811. if (this.applyGravity) {
  22812. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22813. actualDisplacement = displacement.add(this.getScene().gravity);
  22814. }
  22815. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22816. };
  22817. /** @hidden */
  22818. FreeCamera.prototype._checkInputs = function () {
  22819. if (!this._localDirection) {
  22820. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22821. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22822. }
  22823. this.inputs.checkInputs();
  22824. _super.prototype._checkInputs.call(this);
  22825. };
  22826. /** @hidden */
  22827. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22828. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22829. };
  22830. /** @hidden */
  22831. FreeCamera.prototype._updatePosition = function () {
  22832. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22833. this._collideWithWorld(this.cameraDirection);
  22834. }
  22835. else {
  22836. _super.prototype._updatePosition.call(this);
  22837. }
  22838. };
  22839. /**
  22840. * Destroy the camera and release the current resources hold by it.
  22841. */
  22842. FreeCamera.prototype.dispose = function () {
  22843. this.inputs.clear();
  22844. _super.prototype.dispose.call(this);
  22845. };
  22846. /**
  22847. * Gets the current object class name.
  22848. * @return the class name
  22849. */
  22850. FreeCamera.prototype.getClassName = function () {
  22851. return "FreeCamera";
  22852. };
  22853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22855. ], FreeCamera.prototype, "ellipsoid", void 0);
  22856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22858. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22861. ], FreeCamera.prototype, "checkCollisions", void 0);
  22862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22864. ], FreeCamera.prototype, "applyGravity", void 0);
  22865. return FreeCamera;
  22866. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22867. /***/ }),
  22868. /***/ "./Cameras/freeCameraInputsManager.ts":
  22869. /*!********************************************!*\
  22870. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22871. \********************************************/
  22872. /*! exports provided: FreeCameraInputsManager */
  22873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22874. "use strict";
  22875. __webpack_require__.r(__webpack_exports__);
  22876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22877. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22878. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22879. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22880. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22881. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22882. /**
  22883. * Default Inputs manager for the FreeCamera.
  22884. * It groups all the default supported inputs for ease of use.
  22885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22886. */
  22887. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22888. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22889. /**
  22890. * Instantiates a new FreeCameraInputsManager.
  22891. * @param camera Defines the camera the inputs belong to
  22892. */
  22893. function FreeCameraInputsManager(camera) {
  22894. return _super.call(this, camera) || this;
  22895. }
  22896. /**
  22897. * Add keyboard input support to the input manager.
  22898. * @returns the current input manager
  22899. */
  22900. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22901. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22902. return this;
  22903. };
  22904. /**
  22905. * Add mouse input support to the input manager.
  22906. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22907. * @returns the current input manager
  22908. */
  22909. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22910. if (touchEnabled === void 0) { touchEnabled = true; }
  22911. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22912. return this;
  22913. };
  22914. /**
  22915. * Add touch input support to the input manager.
  22916. * @returns the current input manager
  22917. */
  22918. FreeCameraInputsManager.prototype.addTouch = function () {
  22919. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  22920. return this;
  22921. };
  22922. return FreeCameraInputsManager;
  22923. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22924. /***/ }),
  22925. /***/ "./Cameras/gamepadCamera.ts":
  22926. /*!**********************************!*\
  22927. !*** ./Cameras/gamepadCamera.ts ***!
  22928. \**********************************/
  22929. /*! exports provided: GamepadCamera */
  22930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22931. "use strict";
  22932. __webpack_require__.r(__webpack_exports__);
  22933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  22934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22935. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22936. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22937. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22938. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22939. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22940. });
  22941. /**
  22942. * This represents a FPS type of camera. This is only here for back compat purpose.
  22943. * Please use the UniversalCamera instead as both are identical.
  22944. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22945. */
  22946. var GamepadCamera = /** @class */ (function (_super) {
  22947. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22948. /**
  22949. * Instantiates a new Gamepad Camera
  22950. * This represents a FPS type of camera. This is only here for back compat purpose.
  22951. * Please use the UniversalCamera instead as both are identical.
  22952. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22953. * @param name Define the name of the camera in the scene
  22954. * @param position Define the start position of the camera in the scene
  22955. * @param scene Define the scene the camera belongs to
  22956. */
  22957. function GamepadCamera(name, position, scene) {
  22958. return _super.call(this, name, position, scene) || this;
  22959. }
  22960. /**
  22961. * Gets the current object class name.
  22962. * @return the class name
  22963. */
  22964. GamepadCamera.prototype.getClassName = function () {
  22965. return "GamepadCamera";
  22966. };
  22967. return GamepadCamera;
  22968. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22969. /***/ }),
  22970. /***/ "./Cameras/index.ts":
  22971. /*!**************************!*\
  22972. !*** ./Cameras/index.ts ***!
  22973. \**************************/
  22974. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  22975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22976. "use strict";
  22977. __webpack_require__.r(__webpack_exports__);
  22978. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  22979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  22980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  22981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  22982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  22983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  22984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  22985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  22986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  22987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  22988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  22989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  22990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  22991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  22992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  22993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  22994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  22995. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  22997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  22998. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  23000. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  23002. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  23004. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  23005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  23006. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  23008. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  23009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  23010. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  23011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  23012. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  23013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  23014. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  23015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  23016. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  23017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  23018. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  23019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  23020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  23021. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  23022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  23023. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  23024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  23025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  23026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  23027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  23028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  23029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  23030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  23031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  23032. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  23034. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  23035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  23036. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  23037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  23038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  23039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  23040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  23041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  23042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  23043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  23044. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  23045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  23046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  23047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  23048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  23049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  23050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  23051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  23052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  23053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  23054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  23055. /***/ }),
  23056. /***/ "./Cameras/targetCamera.ts":
  23057. /*!*********************************!*\
  23058. !*** ./Cameras/targetCamera.ts ***!
  23059. \*********************************/
  23060. /*! exports provided: TargetCamera */
  23061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23062. "use strict";
  23063. __webpack_require__.r(__webpack_exports__);
  23064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  23065. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23066. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23067. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23068. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23069. /**
  23070. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  23071. * This is the base of the follow, arc rotate cameras and Free camera
  23072. * @see http://doc.babylonjs.com/features/cameras
  23073. */
  23074. var TargetCamera = /** @class */ (function (_super) {
  23075. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  23076. /**
  23077. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  23078. * This is the base of the follow, arc rotate cameras and Free camera
  23079. * @see http://doc.babylonjs.com/features/cameras
  23080. * @param name Defines the name of the camera in the scene
  23081. * @param position Defines the start position of the camera in the scene
  23082. * @param scene Defines the scene the camera belongs to
  23083. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23084. */
  23085. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23086. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23087. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23088. /**
  23089. * Define the current direction the camera is moving to
  23090. */
  23091. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23092. /**
  23093. * Define the current rotation the camera is rotating to
  23094. */
  23095. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  23096. /**
  23097. * When set, the up vector of the camera will be updated by the rotation of the camera
  23098. */
  23099. _this.updateUpVectorFromRotation = false;
  23100. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23101. /**
  23102. * Define the current rotation of the camera
  23103. */
  23104. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23105. /**
  23106. * Define the current speed of the camera
  23107. */
  23108. _this.speed = 2.0;
  23109. /**
  23110. * Add cconstraint to the camera to prevent it to move freely in all directions and
  23111. * around all axis.
  23112. */
  23113. _this.noRotationConstraint = false;
  23114. /**
  23115. * Define the current target of the camera as an object or a position.
  23116. */
  23117. _this.lockedTarget = null;
  23118. /** @hidden */
  23119. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23120. /** @hidden */
  23121. _this._initialFocalDistance = 1;
  23122. /** @hidden */
  23123. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23124. /** @hidden */
  23125. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23126. /** @hidden */
  23127. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23128. /** @hidden */
  23129. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23130. /** @hidden */
  23131. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  23132. /** @hidden */
  23133. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23134. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23135. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23136. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  23137. _this._cachedRotationZ = 0;
  23138. _this._cachedQuaternionRotationZ = 0;
  23139. return _this;
  23140. }
  23141. /**
  23142. * Gets the position in front of the camera at a given distance.
  23143. * @param distance The distance from the camera we want the position to be
  23144. * @returns the position
  23145. */
  23146. TargetCamera.prototype.getFrontPosition = function (distance) {
  23147. this.getWorldMatrix();
  23148. var direction = this.getTarget().subtract(this.position);
  23149. direction.normalize();
  23150. direction.scaleInPlace(distance);
  23151. return this.globalPosition.add(direction);
  23152. };
  23153. /** @hidden */
  23154. TargetCamera.prototype._getLockedTargetPosition = function () {
  23155. if (!this.lockedTarget) {
  23156. return null;
  23157. }
  23158. if (this.lockedTarget.absolutePosition) {
  23159. this.lockedTarget.computeWorldMatrix();
  23160. }
  23161. return this.lockedTarget.absolutePosition || this.lockedTarget;
  23162. };
  23163. /**
  23164. * Store current camera state of the camera (fov, position, rotation, etc..)
  23165. * @returns the camera
  23166. */
  23167. TargetCamera.prototype.storeState = function () {
  23168. this._storedPosition = this.position.clone();
  23169. this._storedRotation = this.rotation.clone();
  23170. if (this.rotationQuaternion) {
  23171. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  23172. }
  23173. return _super.prototype.storeState.call(this);
  23174. };
  23175. /**
  23176. * Restored camera state. You must call storeState() first
  23177. * @returns whether it was successful or not
  23178. * @hidden
  23179. */
  23180. TargetCamera.prototype._restoreStateValues = function () {
  23181. if (!_super.prototype._restoreStateValues.call(this)) {
  23182. return false;
  23183. }
  23184. this.position = this._storedPosition.clone();
  23185. this.rotation = this._storedRotation.clone();
  23186. if (this.rotationQuaternion) {
  23187. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  23188. }
  23189. this.cameraDirection.copyFromFloats(0, 0, 0);
  23190. this.cameraRotation.copyFromFloats(0, 0);
  23191. return true;
  23192. };
  23193. /** @hidden */
  23194. TargetCamera.prototype._initCache = function () {
  23195. _super.prototype._initCache.call(this);
  23196. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23197. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23198. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23199. };
  23200. /** @hidden */
  23201. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  23202. if (!ignoreParentClass) {
  23203. _super.prototype._updateCache.call(this);
  23204. }
  23205. var lockedTargetPosition = this._getLockedTargetPosition();
  23206. if (!lockedTargetPosition) {
  23207. this._cache.lockedTarget = null;
  23208. }
  23209. else {
  23210. if (!this._cache.lockedTarget) {
  23211. this._cache.lockedTarget = lockedTargetPosition.clone();
  23212. }
  23213. else {
  23214. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  23215. }
  23216. }
  23217. this._cache.rotation.copyFrom(this.rotation);
  23218. if (this.rotationQuaternion) {
  23219. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23220. }
  23221. };
  23222. // Synchronized
  23223. /** @hidden */
  23224. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  23225. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  23226. return false;
  23227. }
  23228. var lockedTargetPosition = this._getLockedTargetPosition();
  23229. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  23230. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  23231. };
  23232. // Methods
  23233. /** @hidden */
  23234. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  23235. var engine = this.getEngine();
  23236. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  23237. };
  23238. // Target
  23239. /**
  23240. * Defines the target the camera should look at.
  23241. * This will automatically adapt alpha beta and radius to fit within the new target.
  23242. * @param target Defines the new target as a Vector or a mesh
  23243. */
  23244. TargetCamera.prototype.setTarget = function (target) {
  23245. this.upVector.normalize();
  23246. this._initialFocalDistance = target.subtract(this.position).length();
  23247. if (this.position.z === target.z) {
  23248. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  23249. }
  23250. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  23251. this._camMatrix.invert();
  23252. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  23253. var vDir = target.subtract(this.position);
  23254. if (vDir.x >= 0.0) {
  23255. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  23256. }
  23257. else {
  23258. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  23259. }
  23260. this.rotation.z = 0;
  23261. if (isNaN(this.rotation.x)) {
  23262. this.rotation.x = 0;
  23263. }
  23264. if (isNaN(this.rotation.y)) {
  23265. this.rotation.y = 0;
  23266. }
  23267. if (isNaN(this.rotation.z)) {
  23268. this.rotation.z = 0;
  23269. }
  23270. if (this.rotationQuaternion) {
  23271. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23272. }
  23273. };
  23274. /**
  23275. * Return the current target position of the camera. This value is expressed in local space.
  23276. * @returns the target position
  23277. */
  23278. TargetCamera.prototype.getTarget = function () {
  23279. return this._currentTarget;
  23280. };
  23281. /** @hidden */
  23282. TargetCamera.prototype._decideIfNeedsToMove = function () {
  23283. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23284. };
  23285. /** @hidden */
  23286. TargetCamera.prototype._updatePosition = function () {
  23287. if (this.parent) {
  23288. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  23289. _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]);
  23290. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23291. return;
  23292. }
  23293. this.position.addInPlace(this.cameraDirection);
  23294. };
  23295. /** @hidden */
  23296. TargetCamera.prototype._checkInputs = function () {
  23297. var needToMove = this._decideIfNeedsToMove();
  23298. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  23299. // Move
  23300. if (needToMove) {
  23301. this._updatePosition();
  23302. }
  23303. // Rotate
  23304. if (needToRotate) {
  23305. this.rotation.x += this.cameraRotation.x;
  23306. this.rotation.y += this.cameraRotation.y;
  23307. //rotate, if quaternion is set and rotation was used
  23308. if (this.rotationQuaternion) {
  23309. var len = this.rotation.lengthSquared();
  23310. if (len) {
  23311. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23312. }
  23313. }
  23314. if (!this.noRotationConstraint) {
  23315. var limit = (Math.PI / 2) * 0.95;
  23316. if (this.rotation.x > limit) {
  23317. this.rotation.x = limit;
  23318. }
  23319. if (this.rotation.x < -limit) {
  23320. this.rotation.x = -limit;
  23321. }
  23322. }
  23323. }
  23324. // Inertia
  23325. if (needToMove) {
  23326. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23327. this.cameraDirection.x = 0;
  23328. }
  23329. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23330. this.cameraDirection.y = 0;
  23331. }
  23332. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23333. this.cameraDirection.z = 0;
  23334. }
  23335. this.cameraDirection.scaleInPlace(this.inertia);
  23336. }
  23337. if (needToRotate) {
  23338. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23339. this.cameraRotation.x = 0;
  23340. }
  23341. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23342. this.cameraRotation.y = 0;
  23343. }
  23344. this.cameraRotation.scaleInPlace(this.inertia);
  23345. }
  23346. _super.prototype._checkInputs.call(this);
  23347. };
  23348. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  23349. if (this.rotationQuaternion) {
  23350. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  23351. }
  23352. else {
  23353. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  23354. }
  23355. };
  23356. /**
  23357. * 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)
  23358. * @returns the current camera
  23359. */
  23360. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  23361. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  23362. return this;
  23363. };
  23364. /** @hidden */
  23365. TargetCamera.prototype._getViewMatrix = function () {
  23366. if (this.lockedTarget) {
  23367. this.setTarget(this._getLockedTargetPosition());
  23368. }
  23369. // Compute
  23370. this._updateCameraRotationMatrix();
  23371. // Apply the changed rotation to the upVector
  23372. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  23373. this._rotateUpVectorWithCameraRotationMatrix();
  23374. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  23375. }
  23376. else if (this._cachedRotationZ != this.rotation.z) {
  23377. this._rotateUpVectorWithCameraRotationMatrix();
  23378. this._cachedRotationZ = this.rotation.z;
  23379. }
  23380. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  23381. // Computing target and final matrix
  23382. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  23383. if (this.updateUpVectorFromRotation) {
  23384. if (this.rotationQuaternion) {
  23385. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  23386. }
  23387. else {
  23388. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  23389. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  23390. }
  23391. }
  23392. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  23393. return this._viewMatrix;
  23394. };
  23395. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  23396. if (this.parent) {
  23397. var parentWorldMatrix = this.parent.getWorldMatrix();
  23398. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  23399. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  23400. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  23401. this._markSyncedWithParent();
  23402. }
  23403. else {
  23404. this._globalPosition.copyFrom(position);
  23405. this._globalCurrentTarget.copyFrom(target);
  23406. this._globalCurrentUpVector.copyFrom(up);
  23407. }
  23408. if (this.getScene().useRightHandedSystem) {
  23409. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23410. }
  23411. else {
  23412. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23413. }
  23414. };
  23415. /**
  23416. * @hidden
  23417. */
  23418. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  23419. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  23420. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  23421. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  23422. if (!this.rotationQuaternion) {
  23423. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23424. }
  23425. rigCamera._cameraRigParams = {};
  23426. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23427. }
  23428. return rigCamera;
  23429. }
  23430. return null;
  23431. };
  23432. /**
  23433. * @hidden
  23434. */
  23435. TargetCamera.prototype._updateRigCameras = function () {
  23436. var camLeft = this._rigCameras[0];
  23437. var camRight = this._rigCameras[1];
  23438. this.computeWorldMatrix();
  23439. switch (this.cameraRigMode) {
  23440. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  23441. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  23442. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  23443. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  23444. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  23445. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  23446. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  23447. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  23448. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  23449. break;
  23450. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  23451. if (camLeft.rotationQuaternion) {
  23452. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23453. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23454. }
  23455. else {
  23456. camLeft.rotation.copyFrom(this.rotation);
  23457. camRight.rotation.copyFrom(this.rotation);
  23458. }
  23459. camLeft.position.copyFrom(this.position);
  23460. camRight.position.copyFrom(this.position);
  23461. break;
  23462. }
  23463. _super.prototype._updateRigCameras.call(this);
  23464. };
  23465. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  23466. var target = this.getTarget();
  23467. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  23468. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  23469. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  23470. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23471. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  23472. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23473. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23474. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23475. rigCamera.setTarget(newFocalTarget);
  23476. };
  23477. /**
  23478. * Gets the current object class name.
  23479. * @return the class name
  23480. */
  23481. TargetCamera.prototype.getClassName = function () {
  23482. return "TargetCamera";
  23483. };
  23484. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23485. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23486. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23487. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23488. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23489. ], TargetCamera.prototype, "rotation", void 0);
  23490. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23491. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23492. ], TargetCamera.prototype, "speed", void 0);
  23493. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23494. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23495. ], TargetCamera.prototype, "lockedTarget", void 0);
  23496. return TargetCamera;
  23497. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23498. /***/ }),
  23499. /***/ "./Cameras/touchCamera.ts":
  23500. /*!********************************!*\
  23501. !*** ./Cameras/touchCamera.ts ***!
  23502. \********************************/
  23503. /*! exports provided: TouchCamera */
  23504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23505. "use strict";
  23506. __webpack_require__.r(__webpack_exports__);
  23507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23508. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23509. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23510. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23511. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23512. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23513. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23514. });
  23515. /**
  23516. * This represents a FPS type of camera controlled by touch.
  23517. * This is like a universal camera minus the Gamepad controls.
  23518. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23519. */
  23520. var TouchCamera = /** @class */ (function (_super) {
  23521. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23522. /**
  23523. * Instantiates a new touch camera.
  23524. * This represents a FPS type of camera controlled by touch.
  23525. * This is like a universal camera minus the Gamepad controls.
  23526. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23527. * @param name Define the name of the camera in the scene
  23528. * @param position Define the start position of the camera in the scene
  23529. * @param scene Define the scene the camera belongs to
  23530. */
  23531. function TouchCamera(name, position, scene) {
  23532. var _this = _super.call(this, name, position, scene) || this;
  23533. _this.inputs.addTouch();
  23534. _this._setupInputs();
  23535. return _this;
  23536. }
  23537. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23538. /**
  23539. * Defines the touch sensibility for rotation.
  23540. * The higher the faster.
  23541. */
  23542. get: function () {
  23543. var touch = this.inputs.attached["touch"];
  23544. if (touch) {
  23545. return touch.touchAngularSensibility;
  23546. }
  23547. return 0;
  23548. },
  23549. set: function (value) {
  23550. var touch = this.inputs.attached["touch"];
  23551. if (touch) {
  23552. touch.touchAngularSensibility = value;
  23553. }
  23554. },
  23555. enumerable: true,
  23556. configurable: true
  23557. });
  23558. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23559. /**
  23560. * Defines the touch sensibility for move.
  23561. * The higher the faster.
  23562. */
  23563. get: function () {
  23564. var touch = this.inputs.attached["touch"];
  23565. if (touch) {
  23566. return touch.touchMoveSensibility;
  23567. }
  23568. return 0;
  23569. },
  23570. set: function (value) {
  23571. var touch = this.inputs.attached["touch"];
  23572. if (touch) {
  23573. touch.touchMoveSensibility = value;
  23574. }
  23575. },
  23576. enumerable: true,
  23577. configurable: true
  23578. });
  23579. /**
  23580. * Gets the current object class name.
  23581. * @return the class name
  23582. */
  23583. TouchCamera.prototype.getClassName = function () {
  23584. return "TouchCamera";
  23585. };
  23586. /** @hidden */
  23587. TouchCamera.prototype._setupInputs = function () {
  23588. var mouse = this.inputs.attached["mouse"];
  23589. if (mouse) {
  23590. mouse.touchEnabled = false;
  23591. }
  23592. };
  23593. return TouchCamera;
  23594. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23595. /***/ }),
  23596. /***/ "./Cameras/universalCamera.ts":
  23597. /*!************************************!*\
  23598. !*** ./Cameras/universalCamera.ts ***!
  23599. \************************************/
  23600. /*! exports provided: UniversalCamera */
  23601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23602. "use strict";
  23603. __webpack_require__.r(__webpack_exports__);
  23604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23605. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23606. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23607. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23608. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23609. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23610. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23611. // Forcing to use the Universal camera
  23612. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23613. });
  23614. /**
  23615. * 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,
  23616. * which still works and will still be found in many Playgrounds.
  23617. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23618. */
  23619. var UniversalCamera = /** @class */ (function (_super) {
  23620. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23621. /**
  23622. * 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,
  23623. * which still works and will still be found in many Playgrounds.
  23624. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23625. * @param name Define the name of the camera in the scene
  23626. * @param position Define the start position of the camera in the scene
  23627. * @param scene Define the scene the camera belongs to
  23628. */
  23629. function UniversalCamera(name, position, scene) {
  23630. var _this = _super.call(this, name, position, scene) || this;
  23631. _this.inputs.addGamepad();
  23632. return _this;
  23633. }
  23634. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23635. /**
  23636. * Defines the gamepad rotation sensiblity.
  23637. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23638. */
  23639. get: function () {
  23640. var gamepad = this.inputs.attached["gamepad"];
  23641. if (gamepad) {
  23642. return gamepad.gamepadAngularSensibility;
  23643. }
  23644. return 0;
  23645. },
  23646. set: function (value) {
  23647. var gamepad = this.inputs.attached["gamepad"];
  23648. if (gamepad) {
  23649. gamepad.gamepadAngularSensibility = value;
  23650. }
  23651. },
  23652. enumerable: true,
  23653. configurable: true
  23654. });
  23655. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23656. /**
  23657. * Defines the gamepad move sensiblity.
  23658. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23659. */
  23660. get: function () {
  23661. var gamepad = this.inputs.attached["gamepad"];
  23662. if (gamepad) {
  23663. return gamepad.gamepadMoveSensibility;
  23664. }
  23665. return 0;
  23666. },
  23667. set: function (value) {
  23668. var gamepad = this.inputs.attached["gamepad"];
  23669. if (gamepad) {
  23670. gamepad.gamepadMoveSensibility = value;
  23671. }
  23672. },
  23673. enumerable: true,
  23674. configurable: true
  23675. });
  23676. /**
  23677. * Gets the current object class name.
  23678. * @return the class name
  23679. */
  23680. UniversalCamera.prototype.getClassName = function () {
  23681. return "UniversalCamera";
  23682. };
  23683. return UniversalCamera;
  23684. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23685. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23686. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23687. };
  23688. /***/ }),
  23689. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23690. /*!*******************************************!*\
  23691. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23692. \*******************************************/
  23693. /*! exports provided: VirtualJoysticksCamera */
  23694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23695. "use strict";
  23696. __webpack_require__.r(__webpack_exports__);
  23697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23698. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23699. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23700. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23701. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23702. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23703. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23704. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23705. });
  23706. /**
  23707. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23708. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23709. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23710. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23711. */
  23712. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23713. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23714. /**
  23715. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23716. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23717. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23718. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23719. * @param name Define the name of the camera in the scene
  23720. * @param position Define the start position of the camera in the scene
  23721. * @param scene Define the scene the camera belongs to
  23722. */
  23723. function VirtualJoysticksCamera(name, position, scene) {
  23724. var _this = _super.call(this, name, position, scene) || this;
  23725. _this.inputs.addVirtualJoystick();
  23726. return _this;
  23727. }
  23728. /**
  23729. * Gets the current object class name.
  23730. * @return the class name
  23731. */
  23732. VirtualJoysticksCamera.prototype.getClassName = function () {
  23733. return "VirtualJoysticksCamera";
  23734. };
  23735. return VirtualJoysticksCamera;
  23736. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23737. /***/ }),
  23738. /***/ "./Collisions/collider.ts":
  23739. /*!********************************!*\
  23740. !*** ./Collisions/collider.ts ***!
  23741. \********************************/
  23742. /*! exports provided: Collider */
  23743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23744. "use strict";
  23745. __webpack_require__.r(__webpack_exports__);
  23746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23747. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23748. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23749. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23750. return false;
  23751. }
  23752. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23753. return false;
  23754. }
  23755. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23756. return false;
  23757. }
  23758. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23759. return false;
  23760. }
  23761. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23762. return false;
  23763. }
  23764. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23765. return false;
  23766. }
  23767. return true;
  23768. };
  23769. var getLowestRoot = (function () {
  23770. var result = { root: 0, found: false };
  23771. return function (a, b, c, maxR) {
  23772. result.root = 0;
  23773. result.found = false;
  23774. var determinant = b * b - 4.0 * a * c;
  23775. if (determinant < 0) {
  23776. return result;
  23777. }
  23778. var sqrtD = Math.sqrt(determinant);
  23779. var r1 = (-b - sqrtD) / (2.0 * a);
  23780. var r2 = (-b + sqrtD) / (2.0 * a);
  23781. if (r1 > r2) {
  23782. var temp = r2;
  23783. r2 = r1;
  23784. r1 = temp;
  23785. }
  23786. if (r1 > 0 && r1 < maxR) {
  23787. result.root = r1;
  23788. result.found = true;
  23789. return result;
  23790. }
  23791. if (r2 > 0 && r2 < maxR) {
  23792. result.root = r2;
  23793. result.found = true;
  23794. return result;
  23795. }
  23796. return result;
  23797. };
  23798. })();
  23799. /** @hidden */
  23800. var Collider = /** @class */ (function () {
  23801. function Collider() {
  23802. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23803. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23804. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23805. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23806. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23807. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23808. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23809. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23810. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23811. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23812. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23813. /** @hidden */
  23814. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23815. /** @hidden */
  23816. this._retry = 0;
  23817. /** @hidden */
  23818. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23819. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23820. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23821. this._collisionMask = -1;
  23822. }
  23823. Object.defineProperty(Collider.prototype, "collisionMask", {
  23824. get: function () {
  23825. return this._collisionMask;
  23826. },
  23827. set: function (mask) {
  23828. this._collisionMask = !isNaN(mask) ? mask : -1;
  23829. },
  23830. enumerable: true,
  23831. configurable: true
  23832. });
  23833. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23834. /**
  23835. * Gets the plane normal used to compute the sliding response (in local space)
  23836. */
  23837. get: function () {
  23838. return this._slidePlaneNormal;
  23839. },
  23840. enumerable: true,
  23841. configurable: true
  23842. });
  23843. // Methods
  23844. /** @hidden */
  23845. Collider.prototype._initialize = function (source, dir, e) {
  23846. this._velocity = dir;
  23847. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23848. this._basePoint = source;
  23849. source.multiplyToRef(this._radius, this._basePointWorld);
  23850. dir.multiplyToRef(this._radius, this._velocityWorld);
  23851. this._velocityWorldLength = this._velocityWorld.length();
  23852. this._epsilon = e;
  23853. this.collisionFound = false;
  23854. };
  23855. /** @hidden */
  23856. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23857. pa.subtractToRef(point, this._tempVector);
  23858. pb.subtractToRef(point, this._tempVector2);
  23859. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23860. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23861. if (d < 0) {
  23862. return false;
  23863. }
  23864. pc.subtractToRef(point, this._tempVector3);
  23865. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23866. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23867. if (d < 0) {
  23868. return false;
  23869. }
  23870. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23871. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23872. return d >= 0;
  23873. };
  23874. /** @hidden */
  23875. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23876. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23877. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23878. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23879. return false;
  23880. }
  23881. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23882. return false;
  23883. }
  23884. return true;
  23885. };
  23886. /** @hidden */
  23887. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23888. var t0;
  23889. var embeddedInPlane = false;
  23890. //defensive programming, actually not needed.
  23891. if (!trianglePlaneArray) {
  23892. trianglePlaneArray = [];
  23893. }
  23894. if (!trianglePlaneArray[faceIndex]) {
  23895. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23896. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23897. }
  23898. var trianglePlane = trianglePlaneArray[faceIndex];
  23899. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23900. return;
  23901. }
  23902. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23903. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23904. if (normalDotVelocity == 0) {
  23905. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23906. return;
  23907. }
  23908. embeddedInPlane = true;
  23909. t0 = 0;
  23910. }
  23911. else {
  23912. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23913. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23914. if (t0 > t1) {
  23915. var temp = t1;
  23916. t1 = t0;
  23917. t0 = temp;
  23918. }
  23919. if (t0 > 1.0 || t1 < 0.0) {
  23920. return;
  23921. }
  23922. if (t0 < 0) {
  23923. t0 = 0;
  23924. }
  23925. if (t0 > 1.0) {
  23926. t0 = 1.0;
  23927. }
  23928. }
  23929. this._collisionPoint.copyFromFloats(0, 0, 0);
  23930. var found = false;
  23931. var t = 1.0;
  23932. if (!embeddedInPlane) {
  23933. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  23934. this._velocity.scaleToRef(t0, this._tempVector);
  23935. this._planeIntersectionPoint.addInPlace(this._tempVector);
  23936. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  23937. found = true;
  23938. t = t0;
  23939. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  23940. }
  23941. }
  23942. if (!found) {
  23943. var velocitySquaredLength = this._velocity.lengthSquared();
  23944. var a = velocitySquaredLength;
  23945. this._basePoint.subtractToRef(p1, this._tempVector);
  23946. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23947. var c = this._tempVector.lengthSquared() - 1.0;
  23948. var lowestRoot = getLowestRoot(a, b, c, t);
  23949. if (lowestRoot.found) {
  23950. t = lowestRoot.root;
  23951. found = true;
  23952. this._collisionPoint.copyFrom(p1);
  23953. }
  23954. this._basePoint.subtractToRef(p2, this._tempVector);
  23955. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23956. c = this._tempVector.lengthSquared() - 1.0;
  23957. lowestRoot = getLowestRoot(a, b, c, t);
  23958. if (lowestRoot.found) {
  23959. t = lowestRoot.root;
  23960. found = true;
  23961. this._collisionPoint.copyFrom(p2);
  23962. }
  23963. this._basePoint.subtractToRef(p3, this._tempVector);
  23964. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23965. c = this._tempVector.lengthSquared() - 1.0;
  23966. lowestRoot = getLowestRoot(a, b, c, t);
  23967. if (lowestRoot.found) {
  23968. t = lowestRoot.root;
  23969. found = true;
  23970. this._collisionPoint.copyFrom(p3);
  23971. }
  23972. p2.subtractToRef(p1, this._edge);
  23973. p1.subtractToRef(this._basePoint, this._baseToVertex);
  23974. var edgeSquaredLength = this._edge.lengthSquared();
  23975. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23976. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23977. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23978. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23979. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23980. lowestRoot = getLowestRoot(a, b, c, t);
  23981. if (lowestRoot.found) {
  23982. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23983. if (f >= 0.0 && f <= 1.0) {
  23984. t = lowestRoot.root;
  23985. found = true;
  23986. this._edge.scaleInPlace(f);
  23987. p1.addToRef(this._edge, this._collisionPoint);
  23988. }
  23989. }
  23990. p3.subtractToRef(p2, this._edge);
  23991. p2.subtractToRef(this._basePoint, this._baseToVertex);
  23992. edgeSquaredLength = this._edge.lengthSquared();
  23993. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23994. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23995. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23996. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23997. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23998. lowestRoot = getLowestRoot(a, b, c, t);
  23999. if (lowestRoot.found) {
  24000. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24001. if (f >= 0.0 && f <= 1.0) {
  24002. t = lowestRoot.root;
  24003. found = true;
  24004. this._edge.scaleInPlace(f);
  24005. p2.addToRef(this._edge, this._collisionPoint);
  24006. }
  24007. }
  24008. p1.subtractToRef(p3, this._edge);
  24009. p3.subtractToRef(this._basePoint, this._baseToVertex);
  24010. edgeSquaredLength = this._edge.lengthSquared();
  24011. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24012. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24013. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24014. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24015. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24016. lowestRoot = getLowestRoot(a, b, c, t);
  24017. if (lowestRoot.found) {
  24018. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24019. if (f >= 0.0 && f <= 1.0) {
  24020. t = lowestRoot.root;
  24021. found = true;
  24022. this._edge.scaleInPlace(f);
  24023. p3.addToRef(this._edge, this._collisionPoint);
  24024. }
  24025. }
  24026. }
  24027. if (found) {
  24028. var distToCollision = t * this._velocity.length();
  24029. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  24030. if (!this.intersectionPoint) {
  24031. this.intersectionPoint = this._collisionPoint.clone();
  24032. }
  24033. else {
  24034. this.intersectionPoint.copyFrom(this._collisionPoint);
  24035. }
  24036. this._nearestDistance = distToCollision;
  24037. this.collisionFound = true;
  24038. }
  24039. }
  24040. };
  24041. /** @hidden */
  24042. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  24043. for (var i = indexStart; i < indexEnd; i += 3) {
  24044. var p1 = pts[indices[i] - decal];
  24045. var p2 = pts[indices[i + 1] - decal];
  24046. var p3 = pts[indices[i + 2] - decal];
  24047. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  24048. }
  24049. };
  24050. /** @hidden */
  24051. Collider.prototype._getResponse = function (pos, vel) {
  24052. pos.addToRef(vel, this._destinationPoint);
  24053. vel.scaleInPlace((this._nearestDistance / vel.length()));
  24054. this._basePoint.addToRef(vel, pos);
  24055. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  24056. this._slidePlaneNormal.normalize();
  24057. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  24058. pos.addInPlace(this._displacementVector);
  24059. this.intersectionPoint.addInPlace(this._displacementVector);
  24060. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  24061. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  24062. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  24063. };
  24064. return Collider;
  24065. }());
  24066. /***/ }),
  24067. /***/ "./Collisions/collisionCoordinator.ts":
  24068. /*!********************************************!*\
  24069. !*** ./Collisions/collisionCoordinator.ts ***!
  24070. \********************************************/
  24071. /*! exports provided: DefaultCollisionCoordinator */
  24072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24073. "use strict";
  24074. __webpack_require__.r(__webpack_exports__);
  24075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  24076. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  24077. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24078. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  24079. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24080. /** @hidden */
  24081. var DefaultCollisionCoordinator = /** @class */ (function () {
  24082. function DefaultCollisionCoordinator() {
  24083. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24084. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24085. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24086. }
  24087. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  24088. position.divideToRef(collider._radius, this._scaledPosition);
  24089. displacement.divideToRef(collider._radius, this._scaledVelocity);
  24090. collider.collidedMesh = null;
  24091. collider._retry = 0;
  24092. collider._initialVelocity = this._scaledVelocity;
  24093. collider._initialPosition = this._scaledPosition;
  24094. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  24095. this._finalPosition.multiplyInPlace(collider._radius);
  24096. //run the callback
  24097. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  24098. };
  24099. DefaultCollisionCoordinator.prototype.createCollider = function () {
  24100. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  24101. };
  24102. DefaultCollisionCoordinator.prototype.init = function (scene) {
  24103. this._scene = scene;
  24104. };
  24105. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  24106. if (excludedMesh === void 0) { excludedMesh = null; }
  24107. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  24108. if (collider._retry >= maximumRetry) {
  24109. finalPosition.copyFrom(position);
  24110. return;
  24111. }
  24112. // Check if this is a mesh else camera or -1
  24113. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  24114. collider._initialize(position, velocity, closeDistance);
  24115. // Check all meshes
  24116. for (var index = 0; index < this._scene.meshes.length; index++) {
  24117. var mesh = this._scene.meshes[index];
  24118. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  24119. mesh._checkCollision(collider);
  24120. }
  24121. }
  24122. if (!collider.collisionFound) {
  24123. position.addToRef(velocity, finalPosition);
  24124. return;
  24125. }
  24126. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  24127. collider._getResponse(position, velocity);
  24128. }
  24129. if (velocity.length() <= closeDistance) {
  24130. finalPosition.copyFrom(position);
  24131. return;
  24132. }
  24133. collider._retry++;
  24134. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  24135. };
  24136. return DefaultCollisionCoordinator;
  24137. }());
  24138. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  24139. return new DefaultCollisionCoordinator();
  24140. };
  24141. /***/ }),
  24142. /***/ "./Collisions/index.ts":
  24143. /*!*****************************!*\
  24144. !*** ./Collisions/index.ts ***!
  24145. \*****************************/
  24146. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  24147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24148. "use strict";
  24149. __webpack_require__.r(__webpack_exports__);
  24150. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  24152. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  24153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  24154. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  24155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  24156. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  24158. /***/ }),
  24159. /***/ "./Collisions/intersectionInfo.ts":
  24160. /*!****************************************!*\
  24161. !*** ./Collisions/intersectionInfo.ts ***!
  24162. \****************************************/
  24163. /*! exports provided: IntersectionInfo */
  24164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24165. "use strict";
  24166. __webpack_require__.r(__webpack_exports__);
  24167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  24168. /**
  24169. * @hidden
  24170. */
  24171. var IntersectionInfo = /** @class */ (function () {
  24172. function IntersectionInfo(bu, bv, distance) {
  24173. this.bu = bu;
  24174. this.bv = bv;
  24175. this.distance = distance;
  24176. this.faceId = 0;
  24177. this.subMeshId = 0;
  24178. }
  24179. return IntersectionInfo;
  24180. }());
  24181. /***/ }),
  24182. /***/ "./Collisions/pickingInfo.ts":
  24183. /*!***********************************!*\
  24184. !*** ./Collisions/pickingInfo.ts ***!
  24185. \***********************************/
  24186. /*! exports provided: PickingInfo */
  24187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24188. "use strict";
  24189. __webpack_require__.r(__webpack_exports__);
  24190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  24191. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24192. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  24193. /**
  24194. * Information about the result of picking within a scene
  24195. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24196. */
  24197. var PickingInfo = /** @class */ (function () {
  24198. function PickingInfo() {
  24199. /** @hidden */
  24200. this._pickingUnavailable = false;
  24201. /**
  24202. * If the pick collided with an object
  24203. */
  24204. this.hit = false;
  24205. /**
  24206. * Distance away where the pick collided
  24207. */
  24208. this.distance = 0;
  24209. /**
  24210. * The location of pick collision
  24211. */
  24212. this.pickedPoint = null;
  24213. /**
  24214. * The mesh corresponding the the pick collision
  24215. */
  24216. this.pickedMesh = null;
  24217. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  24218. this.bu = 0;
  24219. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  24220. this.bv = 0;
  24221. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24222. this.faceId = -1;
  24223. /** Id of the the submesh that was picked */
  24224. this.subMeshId = 0;
  24225. /** If a sprite was picked, this will be the sprite the pick collided with */
  24226. this.pickedSprite = null;
  24227. /**
  24228. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24229. */
  24230. this.originMesh = null;
  24231. /**
  24232. * The ray that was used to perform the picking.
  24233. */
  24234. this.ray = null;
  24235. }
  24236. /**
  24237. * Gets the normal correspodning to the face the pick collided with
  24238. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24239. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24240. * @returns The normal correspodning to the face the pick collided with
  24241. */
  24242. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  24243. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  24244. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  24245. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  24246. return null;
  24247. }
  24248. var indices = this.pickedMesh.getIndices();
  24249. if (!indices) {
  24250. return null;
  24251. }
  24252. var result;
  24253. if (useVerticesNormals) {
  24254. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  24255. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  24256. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  24257. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  24258. normal0 = normal0.scale(this.bu);
  24259. normal1 = normal1.scale(this.bv);
  24260. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  24261. 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);
  24262. }
  24263. else {
  24264. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  24265. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  24266. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  24267. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  24268. var p1p2 = vertex1.subtract(vertex2);
  24269. var p3p2 = vertex3.subtract(vertex2);
  24270. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  24271. }
  24272. if (useWorldCoordinates) {
  24273. var wm = this.pickedMesh.getWorldMatrix();
  24274. if (this.pickedMesh.nonUniformScaling) {
  24275. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  24276. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  24277. wm.setTranslationFromFloats(0, 0, 0);
  24278. wm.invert();
  24279. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  24280. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  24281. }
  24282. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  24283. }
  24284. result.normalize();
  24285. return result;
  24286. };
  24287. /**
  24288. * Gets the texture coordinates of where the pick occured
  24289. * @returns the vector containing the coordnates of the texture
  24290. */
  24291. PickingInfo.prototype.getTextureCoordinates = function () {
  24292. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  24293. return null;
  24294. }
  24295. var indices = this.pickedMesh.getIndices();
  24296. if (!indices) {
  24297. return null;
  24298. }
  24299. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  24300. if (!uvs) {
  24301. return null;
  24302. }
  24303. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  24304. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  24305. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  24306. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  24307. uv1 = uv1.scale(this.bu);
  24308. uv2 = uv2.scale(this.bv);
  24309. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  24310. };
  24311. return PickingInfo;
  24312. }());
  24313. /***/ }),
  24314. /***/ "./Culling/Octrees/index.ts":
  24315. /*!**********************************!*\
  24316. !*** ./Culling/Octrees/index.ts ***!
  24317. \**********************************/
  24318. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  24319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24320. "use strict";
  24321. __webpack_require__.r(__webpack_exports__);
  24322. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  24324. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  24326. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  24327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  24328. /***/ }),
  24329. /***/ "./Culling/Octrees/octree.ts":
  24330. /*!***********************************!*\
  24331. !*** ./Culling/Octrees/octree.ts ***!
  24332. \***********************************/
  24333. /*! exports provided: Octree */
  24334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24335. "use strict";
  24336. __webpack_require__.r(__webpack_exports__);
  24337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  24338. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  24339. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24340. /**
  24341. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  24342. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24343. */
  24344. var Octree = /** @class */ (function () {
  24345. /**
  24346. * Creates a octree
  24347. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24348. * @param creationFunc function to be used to instatiate the octree
  24349. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  24350. * @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.)
  24351. */
  24352. function Octree(creationFunc, maxBlockCapacity,
  24353. /** 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.) */
  24354. maxDepth) {
  24355. if (maxDepth === void 0) { maxDepth = 2; }
  24356. this.maxDepth = maxDepth;
  24357. /**
  24358. * Content stored in the octree
  24359. */
  24360. this.dynamicContent = new Array();
  24361. this._maxBlockCapacity = maxBlockCapacity || 64;
  24362. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  24363. this._creationFunc = creationFunc;
  24364. }
  24365. // Methods
  24366. /**
  24367. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  24368. * @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);
  24369. * @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);
  24370. * @param entries meshes to be added to the octree blocks
  24371. */
  24372. Octree.prototype.update = function (worldMin, worldMax, entries) {
  24373. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  24374. };
  24375. /**
  24376. * Adds a mesh to the octree
  24377. * @param entry Mesh to add to the octree
  24378. */
  24379. Octree.prototype.addMesh = function (entry) {
  24380. for (var index = 0; index < this.blocks.length; index++) {
  24381. var block = this.blocks[index];
  24382. block.addEntry(entry);
  24383. }
  24384. };
  24385. /**
  24386. * Remove an element from the octree
  24387. * @param entry defines the element to remove
  24388. */
  24389. Octree.prototype.removeMesh = function (entry) {
  24390. for (var index = 0; index < this.blocks.length; index++) {
  24391. var block = this.blocks[index];
  24392. block.removeEntry(entry);
  24393. }
  24394. };
  24395. /**
  24396. * Selects an array of meshes within the frustum
  24397. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  24398. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  24399. * @returns array of meshes within the frustum
  24400. */
  24401. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  24402. this._selectionContent.reset();
  24403. for (var index = 0; index < this.blocks.length; index++) {
  24404. var block = this.blocks[index];
  24405. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  24406. }
  24407. if (allowDuplicate) {
  24408. this._selectionContent.concat(this.dynamicContent);
  24409. }
  24410. else {
  24411. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24412. }
  24413. return this._selectionContent;
  24414. };
  24415. /**
  24416. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  24417. * @param sphereCenter defines the bounding sphere center
  24418. * @param sphereRadius defines the bounding sphere radius
  24419. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24420. * @returns an array of objects that intersect the sphere
  24421. */
  24422. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  24423. this._selectionContent.reset();
  24424. for (var index = 0; index < this.blocks.length; index++) {
  24425. var block = this.blocks[index];
  24426. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  24427. }
  24428. if (allowDuplicate) {
  24429. this._selectionContent.concat(this.dynamicContent);
  24430. }
  24431. else {
  24432. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24433. }
  24434. return this._selectionContent;
  24435. };
  24436. /**
  24437. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  24438. * @param ray defines the ray to test with
  24439. * @returns array of intersected objects
  24440. */
  24441. Octree.prototype.intersectsRay = function (ray) {
  24442. this._selectionContent.reset();
  24443. for (var index = 0; index < this.blocks.length; index++) {
  24444. var block = this.blocks[index];
  24445. block.intersectsRay(ray, this._selectionContent);
  24446. }
  24447. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24448. return this._selectionContent;
  24449. };
  24450. /**
  24451. * Adds a mesh into the octree block if it intersects the block
  24452. */
  24453. Octree.CreationFuncForMeshes = function (entry, block) {
  24454. var boundingInfo = entry.getBoundingInfo();
  24455. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24456. block.entries.push(entry);
  24457. }
  24458. };
  24459. /**
  24460. * Adds a submesh into the octree block if it intersects the block
  24461. */
  24462. Octree.CreationFuncForSubMeshes = function (entry, block) {
  24463. var boundingInfo = entry.getBoundingInfo();
  24464. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24465. block.entries.push(entry);
  24466. }
  24467. };
  24468. return Octree;
  24469. }());
  24470. /***/ }),
  24471. /***/ "./Culling/Octrees/octreeBlock.ts":
  24472. /*!****************************************!*\
  24473. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24474. \****************************************/
  24475. /*! exports provided: OctreeBlock */
  24476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24477. "use strict";
  24478. __webpack_require__.r(__webpack_exports__);
  24479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24480. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24481. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24482. /**
  24483. * Class used to store a cell in an octree
  24484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24485. */
  24486. var OctreeBlock = /** @class */ (function () {
  24487. /**
  24488. * Creates a new block
  24489. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24490. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24491. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24492. * @param depth defines the current depth of this block in the octree
  24493. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24494. * @param creationFunc defines a callback to call when an element is added to the block
  24495. */
  24496. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24497. /**
  24498. * Gets the content of the current block
  24499. */
  24500. this.entries = new Array();
  24501. this._boundingVectors = new Array();
  24502. this._capacity = capacity;
  24503. this._depth = depth;
  24504. this._maxDepth = maxDepth;
  24505. this._creationFunc = creationFunc;
  24506. this._minPoint = minPoint;
  24507. this._maxPoint = maxPoint;
  24508. this._boundingVectors.push(minPoint.clone());
  24509. this._boundingVectors.push(maxPoint.clone());
  24510. this._boundingVectors.push(minPoint.clone());
  24511. this._boundingVectors[2].x = maxPoint.x;
  24512. this._boundingVectors.push(minPoint.clone());
  24513. this._boundingVectors[3].y = maxPoint.y;
  24514. this._boundingVectors.push(minPoint.clone());
  24515. this._boundingVectors[4].z = maxPoint.z;
  24516. this._boundingVectors.push(maxPoint.clone());
  24517. this._boundingVectors[5].z = minPoint.z;
  24518. this._boundingVectors.push(maxPoint.clone());
  24519. this._boundingVectors[6].x = minPoint.x;
  24520. this._boundingVectors.push(maxPoint.clone());
  24521. this._boundingVectors[7].y = minPoint.y;
  24522. }
  24523. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24524. // Property
  24525. /**
  24526. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24527. */
  24528. get: function () {
  24529. return this._capacity;
  24530. },
  24531. enumerable: true,
  24532. configurable: true
  24533. });
  24534. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24535. /**
  24536. * Gets the minimum vector (in world space) of the block's bounding box
  24537. */
  24538. get: function () {
  24539. return this._minPoint;
  24540. },
  24541. enumerable: true,
  24542. configurable: true
  24543. });
  24544. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24545. /**
  24546. * Gets the maximum vector (in world space) of the block's bounding box
  24547. */
  24548. get: function () {
  24549. return this._maxPoint;
  24550. },
  24551. enumerable: true,
  24552. configurable: true
  24553. });
  24554. // Methods
  24555. /**
  24556. * Add a new element to this block
  24557. * @param entry defines the element to add
  24558. */
  24559. OctreeBlock.prototype.addEntry = function (entry) {
  24560. if (this.blocks) {
  24561. for (var index = 0; index < this.blocks.length; index++) {
  24562. var block = this.blocks[index];
  24563. block.addEntry(entry);
  24564. }
  24565. return;
  24566. }
  24567. this._creationFunc(entry, this);
  24568. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24569. this.createInnerBlocks();
  24570. }
  24571. };
  24572. /**
  24573. * Remove an element from this block
  24574. * @param entry defines the element to remove
  24575. */
  24576. OctreeBlock.prototype.removeEntry = function (entry) {
  24577. if (this.blocks) {
  24578. for (var index = 0; index < this.blocks.length; index++) {
  24579. var block = this.blocks[index];
  24580. block.removeEntry(entry);
  24581. }
  24582. return;
  24583. }
  24584. var entryIndex = this.entries.indexOf(entry);
  24585. if (entryIndex > -1) {
  24586. this.entries.splice(entryIndex, 1);
  24587. }
  24588. };
  24589. /**
  24590. * Add an array of elements to this block
  24591. * @param entries defines the array of elements to add
  24592. */
  24593. OctreeBlock.prototype.addEntries = function (entries) {
  24594. for (var index = 0; index < entries.length; index++) {
  24595. var mesh = entries[index];
  24596. this.addEntry(mesh);
  24597. }
  24598. };
  24599. /**
  24600. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24601. * @param frustumPlanes defines the frustum planes to test
  24602. * @param selection defines the array to store current content if selection is positive
  24603. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24604. */
  24605. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24606. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24607. if (this.blocks) {
  24608. for (var index = 0; index < this.blocks.length; index++) {
  24609. var block = this.blocks[index];
  24610. block.select(frustumPlanes, selection, allowDuplicate);
  24611. }
  24612. return;
  24613. }
  24614. if (allowDuplicate) {
  24615. selection.concat(this.entries);
  24616. }
  24617. else {
  24618. selection.concatWithNoDuplicate(this.entries);
  24619. }
  24620. }
  24621. };
  24622. /**
  24623. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24624. * @param sphereCenter defines the bounding sphere center
  24625. * @param sphereRadius defines the bounding sphere radius
  24626. * @param selection defines the array to store current content if selection is positive
  24627. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24628. */
  24629. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24630. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24631. if (this.blocks) {
  24632. for (var index = 0; index < this.blocks.length; index++) {
  24633. var block = this.blocks[index];
  24634. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24635. }
  24636. return;
  24637. }
  24638. if (allowDuplicate) {
  24639. selection.concat(this.entries);
  24640. }
  24641. else {
  24642. selection.concatWithNoDuplicate(this.entries);
  24643. }
  24644. }
  24645. };
  24646. /**
  24647. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24648. * @param ray defines the ray to test with
  24649. * @param selection defines the array to store current content if selection is positive
  24650. */
  24651. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24652. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24653. if (this.blocks) {
  24654. for (var index = 0; index < this.blocks.length; index++) {
  24655. var block = this.blocks[index];
  24656. block.intersectsRay(ray, selection);
  24657. }
  24658. return;
  24659. }
  24660. selection.concatWithNoDuplicate(this.entries);
  24661. }
  24662. };
  24663. /**
  24664. * Subdivide the content into child blocks (this block will then be empty)
  24665. */
  24666. OctreeBlock.prototype.createInnerBlocks = function () {
  24667. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24668. };
  24669. /**
  24670. * @hidden
  24671. */
  24672. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24673. target.blocks = new Array();
  24674. 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);
  24675. // Segmenting space
  24676. for (var x = 0; x < 2; x++) {
  24677. for (var y = 0; y < 2; y++) {
  24678. for (var z = 0; z < 2; z++) {
  24679. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24680. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24681. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24682. block.addEntries(entries);
  24683. target.blocks.push(block);
  24684. }
  24685. }
  24686. }
  24687. };
  24688. return OctreeBlock;
  24689. }());
  24690. /***/ }),
  24691. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24692. /*!*************************************************!*\
  24693. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24694. \*************************************************/
  24695. /*! exports provided: OctreeSceneComponent */
  24696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24697. "use strict";
  24698. __webpack_require__.r(__webpack_exports__);
  24699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24700. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24701. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24702. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24703. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24704. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24705. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24706. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24707. if (maxCapacity === void 0) { maxCapacity = 64; }
  24708. if (maxDepth === void 0) { maxDepth = 2; }
  24709. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24710. if (!component) {
  24711. component = new OctreeSceneComponent(this);
  24712. this._addComponent(component);
  24713. }
  24714. if (!this._selectionOctree) {
  24715. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24716. }
  24717. var worldExtends = this.getWorldExtends();
  24718. // Update octree
  24719. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24720. return this._selectionOctree;
  24721. };
  24722. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24723. get: function () {
  24724. return this._selectionOctree;
  24725. },
  24726. enumerable: true,
  24727. configurable: true
  24728. });
  24729. /**
  24730. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24731. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24732. * @param maxCapacity defines the maximum size of each block (64 by default)
  24733. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24734. * @returns the new octree
  24735. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24736. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24737. */
  24738. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24739. if (maxCapacity === void 0) { maxCapacity = 64; }
  24740. if (maxDepth === void 0) { maxDepth = 2; }
  24741. var scene = this.getScene();
  24742. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24743. if (!component) {
  24744. component = new OctreeSceneComponent(scene);
  24745. scene._addComponent(component);
  24746. }
  24747. if (!this._submeshesOctree) {
  24748. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24749. }
  24750. this.computeWorldMatrix(true);
  24751. var boundingInfo = this.getBoundingInfo();
  24752. // Update octree
  24753. var bbox = boundingInfo.boundingBox;
  24754. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24755. return this._submeshesOctree;
  24756. };
  24757. /**
  24758. * Defines the octree scene component responsible to manage any octrees
  24759. * in a given scene.
  24760. */
  24761. var OctreeSceneComponent = /** @class */ (function () {
  24762. /**
  24763. * Creates a new instance of the component for the given scene
  24764. * @param scene Defines the scene to register the component in
  24765. */
  24766. function OctreeSceneComponent(scene) {
  24767. /**
  24768. * The component name helpfull to identify the component in the list of scene components.
  24769. */
  24770. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24771. /**
  24772. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24773. */
  24774. this.checksIsEnabled = true;
  24775. 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));
  24776. this.scene = scene;
  24777. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24778. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24779. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24780. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24781. }
  24782. /**
  24783. * Registers the component in a given scene
  24784. */
  24785. OctreeSceneComponent.prototype.register = function () {
  24786. var _this = this;
  24787. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24788. var sceneOctree = _this.scene.selectionOctree;
  24789. if (sceneOctree !== undefined && sceneOctree !== null) {
  24790. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24791. if (index !== -1) {
  24792. sceneOctree.dynamicContent.splice(index, 1);
  24793. }
  24794. }
  24795. });
  24796. this.scene.onMeshImportedObservable.add(function (mesh) {
  24797. var sceneOctree = _this.scene.selectionOctree;
  24798. if (sceneOctree !== undefined && sceneOctree !== null) {
  24799. sceneOctree.addMesh(mesh);
  24800. }
  24801. });
  24802. };
  24803. /**
  24804. * Return the list of active meshes
  24805. * @returns the list of active meshes
  24806. */
  24807. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24808. if (this.scene._selectionOctree) {
  24809. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24810. return selection;
  24811. }
  24812. return this.scene._getDefaultMeshCandidates();
  24813. };
  24814. /**
  24815. * Return the list of active sub meshes
  24816. * @param mesh The mesh to get the candidates sub meshes from
  24817. * @returns the list of active sub meshes
  24818. */
  24819. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24820. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24821. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24822. return intersections;
  24823. }
  24824. return this.scene._getDefaultSubMeshCandidates(mesh);
  24825. };
  24826. /**
  24827. * Return the list of sub meshes intersecting with a given local ray
  24828. * @param mesh defines the mesh to find the submesh for
  24829. * @param localRay defines the ray in local space
  24830. * @returns the list of intersecting sub meshes
  24831. */
  24832. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24833. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24834. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24835. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24836. return intersections;
  24837. }
  24838. return this.scene._getDefaultSubMeshCandidates(mesh);
  24839. };
  24840. /**
  24841. * Return the list of sub meshes colliding with a collider
  24842. * @param mesh defines the mesh to find the submesh for
  24843. * @param collider defines the collider to evaluate the collision against
  24844. * @returns the list of colliding sub meshes
  24845. */
  24846. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24847. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24848. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24849. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24850. return intersections;
  24851. }
  24852. return this.scene._getDefaultSubMeshCandidates(mesh);
  24853. };
  24854. /**
  24855. * Rebuilds the elements related to this component in case of
  24856. * context lost for instance.
  24857. */
  24858. OctreeSceneComponent.prototype.rebuild = function () {
  24859. // Nothing to do here.
  24860. };
  24861. /**
  24862. * Disposes the component and the associated ressources.
  24863. */
  24864. OctreeSceneComponent.prototype.dispose = function () {
  24865. // Nothing to do here.
  24866. };
  24867. return OctreeSceneComponent;
  24868. }());
  24869. /***/ }),
  24870. /***/ "./Culling/boundingBox.ts":
  24871. /*!********************************!*\
  24872. !*** ./Culling/boundingBox.ts ***!
  24873. \********************************/
  24874. /*! exports provided: BoundingBox */
  24875. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24876. "use strict";
  24877. __webpack_require__.r(__webpack_exports__);
  24878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24879. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24880. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24881. /**
  24882. * Class used to store bounding box information
  24883. */
  24884. var BoundingBox = /** @class */ (function () {
  24885. /**
  24886. * Creates a new bounding box
  24887. * @param min defines the minimum vector (in local space)
  24888. * @param max defines the maximum vector (in local space)
  24889. * @param worldMatrix defines the new world matrix
  24890. */
  24891. function BoundingBox(min, max, worldMatrix) {
  24892. /**
  24893. * Gets the 8 vectors representing the bounding box in local space
  24894. */
  24895. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24896. /**
  24897. * Gets the center of the bounding box in local space
  24898. */
  24899. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24900. /**
  24901. * Gets the center of the bounding box in world space
  24902. */
  24903. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24904. /**
  24905. * Gets the extend size in local space
  24906. */
  24907. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24908. /**
  24909. * Gets the extend size in world space
  24910. */
  24911. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24912. /**
  24913. * Gets the OBB (object bounding box) directions
  24914. */
  24915. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24916. /**
  24917. * Gets the 8 vectors representing the bounding box in world space
  24918. */
  24919. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24920. /**
  24921. * Gets the minimum vector in world space
  24922. */
  24923. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24924. /**
  24925. * Gets the maximum vector in world space
  24926. */
  24927. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24928. /**
  24929. * Gets the minimum vector in local space
  24930. */
  24931. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24932. /**
  24933. * Gets the maximum vector in local space
  24934. */
  24935. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24936. this.reConstruct(min, max, worldMatrix);
  24937. }
  24938. // Methods
  24939. /**
  24940. * Recreates the entire bounding box from scratch as if we call the constructor in place
  24941. * @param min defines the new minimum vector (in local space)
  24942. * @param max defines the new maximum vector (in local space)
  24943. * @param worldMatrix defines the new world matrix
  24944. */
  24945. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24946. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24947. var vectors = this.vectors;
  24948. this.minimum.copyFromFloats(minX, minY, minZ);
  24949. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24950. vectors[0].copyFromFloats(minX, minY, minZ);
  24951. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24952. vectors[2].copyFromFloats(maxX, minY, minZ);
  24953. vectors[3].copyFromFloats(minX, maxY, minZ);
  24954. vectors[4].copyFromFloats(minX, minY, maxZ);
  24955. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24956. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24957. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24958. // OBB
  24959. max.addToRef(min, this.center).scaleInPlace(0.5);
  24960. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24961. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24962. };
  24963. /**
  24964. * Scale the current bounding box by applying a scale factor
  24965. * @param factor defines the scale factor to apply
  24966. * @returns the current bounding box
  24967. */
  24968. BoundingBox.prototype.scale = function (factor) {
  24969. var tmpVectors = BoundingBox.TmpVector3;
  24970. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24971. var len = diff.length();
  24972. diff.normalizeFromLength(len);
  24973. var distance = len * factor;
  24974. var newRadius = diff.scaleInPlace(distance * 0.5);
  24975. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  24976. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  24977. this.reConstruct(min, max, this._worldMatrix);
  24978. return this;
  24979. };
  24980. /**
  24981. * Gets the world matrix of the bounding box
  24982. * @returns a matrix
  24983. */
  24984. BoundingBox.prototype.getWorldMatrix = function () {
  24985. return this._worldMatrix;
  24986. };
  24987. /** @hidden */
  24988. BoundingBox.prototype._update = function (world) {
  24989. var minWorld = this.minimumWorld;
  24990. var maxWorld = this.maximumWorld;
  24991. var directions = this.directions;
  24992. var vectorsWorld = this.vectorsWorld;
  24993. var vectors = this.vectors;
  24994. if (!world.isIdentity()) {
  24995. minWorld.setAll(Number.MAX_VALUE);
  24996. maxWorld.setAll(-Number.MAX_VALUE);
  24997. for (var index = 0; index < 8; ++index) {
  24998. var v = vectorsWorld[index];
  24999. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  25000. minWorld.minimizeInPlace(v);
  25001. maxWorld.maximizeInPlace(v);
  25002. }
  25003. // Extend
  25004. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  25005. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  25006. }
  25007. else {
  25008. minWorld.copyFrom(this.minimum);
  25009. maxWorld.copyFrom(this.maximum);
  25010. for (var index = 0; index < 8; ++index) {
  25011. vectorsWorld[index].copyFrom(vectors[index]);
  25012. }
  25013. // Extend
  25014. this.extendSizeWorld.copyFrom(this.extendSize);
  25015. this.centerWorld.copyFrom(this.center);
  25016. }
  25017. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  25018. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  25019. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  25020. this._worldMatrix = world;
  25021. };
  25022. /**
  25023. * Tests if the bounding box is intersecting the frustum planes
  25024. * @param frustumPlanes defines the frustum planes to test
  25025. * @returns true if there is an intersection
  25026. */
  25027. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  25028. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  25029. };
  25030. /**
  25031. * Tests if the bounding box is entirely inside the frustum planes
  25032. * @param frustumPlanes defines the frustum planes to test
  25033. * @returns true if there is an inclusion
  25034. */
  25035. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25036. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  25037. };
  25038. /**
  25039. * Tests if a point is inside the bounding box
  25040. * @param point defines the point to test
  25041. * @returns true if the point is inside the bounding box
  25042. */
  25043. BoundingBox.prototype.intersectsPoint = function (point) {
  25044. var min = this.minimumWorld;
  25045. var max = this.maximumWorld;
  25046. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25047. var pointX = point.x, pointY = point.y, pointZ = point.z;
  25048. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  25049. if (maxX - pointX < delta || delta > pointX - minX) {
  25050. return false;
  25051. }
  25052. if (maxY - pointY < delta || delta > pointY - minY) {
  25053. return false;
  25054. }
  25055. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  25056. return false;
  25057. }
  25058. return true;
  25059. };
  25060. /**
  25061. * Tests if the bounding box intersects with a bounding sphere
  25062. * @param sphere defines the sphere to test
  25063. * @returns true if there is an intersection
  25064. */
  25065. BoundingBox.prototype.intersectsSphere = function (sphere) {
  25066. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  25067. };
  25068. /**
  25069. * Tests if the bounding box intersects with a box defined by a min and max vectors
  25070. * @param min defines the min vector to use
  25071. * @param max defines the max vector to use
  25072. * @returns true if there is an intersection
  25073. */
  25074. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  25075. var myMin = this.minimumWorld;
  25076. var myMax = this.maximumWorld;
  25077. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  25078. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25079. if (myMaxX < minX || myMinX > maxX) {
  25080. return false;
  25081. }
  25082. if (myMaxY < minY || myMinY > maxY) {
  25083. return false;
  25084. }
  25085. if (myMaxZ < minZ || myMinZ > maxZ) {
  25086. return false;
  25087. }
  25088. return true;
  25089. };
  25090. // Statics
  25091. /**
  25092. * Tests if two bounding boxes are intersections
  25093. * @param box0 defines the first box to test
  25094. * @param box1 defines the second box to test
  25095. * @returns true if there is an intersection
  25096. */
  25097. BoundingBox.Intersects = function (box0, box1) {
  25098. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  25099. };
  25100. /**
  25101. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  25102. * @param minPoint defines the minimum vector of the bounding box
  25103. * @param maxPoint defines the maximum vector of the bounding box
  25104. * @param sphereCenter defines the sphere center
  25105. * @param sphereRadius defines the sphere radius
  25106. * @returns true if there is an intersection
  25107. */
  25108. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  25109. var vector = BoundingBox.TmpVector3[0];
  25110. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  25111. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  25112. return (num <= (sphereRadius * sphereRadius));
  25113. };
  25114. /**
  25115. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  25116. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25117. * @param frustumPlanes defines the frustum planes to test
  25118. * @return true if there is an inclusion
  25119. */
  25120. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  25121. for (var p = 0; p < 6; ++p) {
  25122. var frustumPlane = frustumPlanes[p];
  25123. for (var i = 0; i < 8; ++i) {
  25124. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  25125. return false;
  25126. }
  25127. }
  25128. }
  25129. return true;
  25130. };
  25131. /**
  25132. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  25133. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25134. * @param frustumPlanes defines the frustum planes to test
  25135. * @return true if there is an intersection
  25136. */
  25137. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  25138. for (var p = 0; p < 6; ++p) {
  25139. var canReturnFalse = true;
  25140. var frustumPlane = frustumPlanes[p];
  25141. for (var i = 0; i < 8; ++i) {
  25142. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  25143. canReturnFalse = false;
  25144. break;
  25145. }
  25146. }
  25147. if (canReturnFalse) {
  25148. return false;
  25149. }
  25150. }
  25151. return true;
  25152. };
  25153. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25154. return BoundingBox;
  25155. }());
  25156. /***/ }),
  25157. /***/ "./Culling/boundingInfo.ts":
  25158. /*!*********************************!*\
  25159. !*** ./Culling/boundingInfo.ts ***!
  25160. \*********************************/
  25161. /*! exports provided: BoundingInfo */
  25162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25163. "use strict";
  25164. __webpack_require__.r(__webpack_exports__);
  25165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  25166. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25167. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25168. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  25169. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25170. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25171. var _result0 = { min: 0, max: 0 };
  25172. var _result1 = { min: 0, max: 0 };
  25173. var computeBoxExtents = function (axis, box, result) {
  25174. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  25175. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  25176. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  25177. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  25178. var r = r0 + r1 + r2;
  25179. result.min = p - r;
  25180. result.max = p + r;
  25181. };
  25182. var axisOverlap = function (axis, box0, box1) {
  25183. computeBoxExtents(axis, box0, _result0);
  25184. computeBoxExtents(axis, box1, _result1);
  25185. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  25186. };
  25187. /**
  25188. * Info for a bounding data of a mesh
  25189. */
  25190. var BoundingInfo = /** @class */ (function () {
  25191. /**
  25192. * Constructs bounding info
  25193. * @param minimum min vector of the bounding box/sphere
  25194. * @param maximum max vector of the bounding box/sphere
  25195. * @param worldMatrix defines the new world matrix
  25196. */
  25197. function BoundingInfo(minimum, maximum, worldMatrix) {
  25198. this._isLocked = false;
  25199. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  25200. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  25201. }
  25202. /**
  25203. * Recreates the entire bounding info from scratch as if we call the constructor in place
  25204. * @param min defines the new minimum vector (in local space)
  25205. * @param max defines the new maximum vector (in local space)
  25206. * @param worldMatrix defines the new world matrix
  25207. */
  25208. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  25209. this.boundingBox.reConstruct(min, max, worldMatrix);
  25210. this.boundingSphere.reConstruct(min, max, worldMatrix);
  25211. };
  25212. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  25213. /**
  25214. * min vector of the bounding box/sphere
  25215. */
  25216. get: function () {
  25217. return this.boundingBox.minimum;
  25218. },
  25219. enumerable: true,
  25220. configurable: true
  25221. });
  25222. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  25223. /**
  25224. * max vector of the bounding box/sphere
  25225. */
  25226. get: function () {
  25227. return this.boundingBox.maximum;
  25228. },
  25229. enumerable: true,
  25230. configurable: true
  25231. });
  25232. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  25233. /**
  25234. * If the info is locked and won't be updated to avoid perf overhead
  25235. */
  25236. get: function () {
  25237. return this._isLocked;
  25238. },
  25239. set: function (value) {
  25240. this._isLocked = value;
  25241. },
  25242. enumerable: true,
  25243. configurable: true
  25244. });
  25245. // Methods
  25246. /**
  25247. * Updates the bounding sphere and box
  25248. * @param world world matrix to be used to update
  25249. */
  25250. BoundingInfo.prototype.update = function (world) {
  25251. if (this._isLocked) {
  25252. return;
  25253. }
  25254. this.boundingBox._update(world);
  25255. this.boundingSphere._update(world);
  25256. };
  25257. /**
  25258. * Recreate the bounding info to be centered around a specific point given a specific extend.
  25259. * @param center New center of the bounding info
  25260. * @param extend New extend of the bounding info
  25261. * @returns the current bounding info
  25262. */
  25263. BoundingInfo.prototype.centerOn = function (center, extend) {
  25264. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  25265. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  25266. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25267. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25268. return this;
  25269. };
  25270. /**
  25271. * Scale the current bounding info by applying a scale factor
  25272. * @param factor defines the scale factor to apply
  25273. * @returns the current bounding info
  25274. */
  25275. BoundingInfo.prototype.scale = function (factor) {
  25276. this.boundingBox.scale(factor);
  25277. this.boundingSphere.scale(factor);
  25278. return this;
  25279. };
  25280. /**
  25281. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  25282. * @param frustumPlanes defines the frustum to test
  25283. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  25284. * @returns true if the bounding info is in the frustum planes
  25285. */
  25286. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  25287. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  25288. 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);
  25289. if (inclusionTest) {
  25290. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  25291. return true;
  25292. }
  25293. }
  25294. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  25295. return false;
  25296. }
  25297. 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);
  25298. if (bSphereOnlyTest) {
  25299. return true;
  25300. }
  25301. return this.boundingBox.isInFrustum(frustumPlanes);
  25302. };
  25303. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  25304. /**
  25305. * Gets the world distance between the min and max points of the bounding box
  25306. */
  25307. get: function () {
  25308. var boundingBox = this.boundingBox;
  25309. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  25310. return diag.length();
  25311. },
  25312. enumerable: true,
  25313. configurable: true
  25314. });
  25315. /**
  25316. * Checks if a cullable object (mesh...) is in the camera frustum
  25317. * Unlike isInFrustum this cheks the full bounding box
  25318. * @param frustumPlanes Camera near/planes
  25319. * @returns true if the object is in frustum otherwise false
  25320. */
  25321. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25322. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  25323. };
  25324. /** @hidden */
  25325. BoundingInfo.prototype._checkCollision = function (collider) {
  25326. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  25327. };
  25328. /**
  25329. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  25330. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25331. * @param point the point to check intersection with
  25332. * @returns if the point intersects
  25333. */
  25334. BoundingInfo.prototype.intersectsPoint = function (point) {
  25335. if (!this.boundingSphere.centerWorld) {
  25336. return false;
  25337. }
  25338. if (!this.boundingSphere.intersectsPoint(point)) {
  25339. return false;
  25340. }
  25341. if (!this.boundingBox.intersectsPoint(point)) {
  25342. return false;
  25343. }
  25344. return true;
  25345. };
  25346. /**
  25347. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  25348. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25349. * @param boundingInfo the bounding info to check intersection with
  25350. * @param precise if the intersection should be done using OBB
  25351. * @returns if the bounding info intersects
  25352. */
  25353. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  25354. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  25355. return false;
  25356. }
  25357. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  25358. return false;
  25359. }
  25360. if (!precise) {
  25361. return true;
  25362. }
  25363. var box0 = this.boundingBox;
  25364. var box1 = boundingInfo.boundingBox;
  25365. if (!axisOverlap(box0.directions[0], box0, box1)) {
  25366. return false;
  25367. }
  25368. if (!axisOverlap(box0.directions[1], box0, box1)) {
  25369. return false;
  25370. }
  25371. if (!axisOverlap(box0.directions[2], box0, box1)) {
  25372. return false;
  25373. }
  25374. if (!axisOverlap(box1.directions[0], box0, box1)) {
  25375. return false;
  25376. }
  25377. if (!axisOverlap(box1.directions[1], box0, box1)) {
  25378. return false;
  25379. }
  25380. if (!axisOverlap(box1.directions[2], box0, box1)) {
  25381. return false;
  25382. }
  25383. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  25384. return false;
  25385. }
  25386. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  25387. return false;
  25388. }
  25389. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  25390. return false;
  25391. }
  25392. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  25393. return false;
  25394. }
  25395. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  25396. return false;
  25397. }
  25398. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  25399. return false;
  25400. }
  25401. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  25402. return false;
  25403. }
  25404. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  25405. return false;
  25406. }
  25407. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  25408. return false;
  25409. }
  25410. return true;
  25411. };
  25412. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25413. return BoundingInfo;
  25414. }());
  25415. /***/ }),
  25416. /***/ "./Culling/boundingSphere.ts":
  25417. /*!***********************************!*\
  25418. !*** ./Culling/boundingSphere.ts ***!
  25419. \***********************************/
  25420. /*! exports provided: BoundingSphere */
  25421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25422. "use strict";
  25423. __webpack_require__.r(__webpack_exports__);
  25424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  25425. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25426. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25427. /**
  25428. * Class used to store bounding sphere information
  25429. */
  25430. var BoundingSphere = /** @class */ (function () {
  25431. /**
  25432. * Creates a new bounding sphere
  25433. * @param min defines the minimum vector (in local space)
  25434. * @param max defines the maximum vector (in local space)
  25435. * @param worldMatrix defines the new world matrix
  25436. */
  25437. function BoundingSphere(min, max, worldMatrix) {
  25438. /**
  25439. * Gets the center of the bounding sphere in local space
  25440. */
  25441. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25442. /**
  25443. * Gets the center of the bounding sphere in world space
  25444. */
  25445. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25446. /**
  25447. * Gets the minimum vector in local space
  25448. */
  25449. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25450. /**
  25451. * Gets the maximum vector in local space
  25452. */
  25453. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25454. this.reConstruct(min, max, worldMatrix);
  25455. }
  25456. /**
  25457. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  25458. * @param min defines the new minimum vector (in local space)
  25459. * @param max defines the new maximum vector (in local space)
  25460. * @param worldMatrix defines the new world matrix
  25461. */
  25462. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  25463. this.minimum.copyFrom(min);
  25464. this.maximum.copyFrom(max);
  25465. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  25466. max.addToRef(min, this.center).scaleInPlace(0.5);
  25467. this.radius = distance * 0.5;
  25468. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25469. };
  25470. /**
  25471. * Scale the current bounding sphere by applying a scale factor
  25472. * @param factor defines the scale factor to apply
  25473. * @returns the current bounding box
  25474. */
  25475. BoundingSphere.prototype.scale = function (factor) {
  25476. var newRadius = this.radius * factor;
  25477. var tmpVectors = BoundingSphere.TmpVector3;
  25478. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25479. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25480. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25481. this.reConstruct(min, max, this._worldMatrix);
  25482. return this;
  25483. };
  25484. /**
  25485. * Gets the world matrix of the bounding box
  25486. * @returns a matrix
  25487. */
  25488. BoundingSphere.prototype.getWorldMatrix = function () {
  25489. return this._worldMatrix;
  25490. };
  25491. // Methods
  25492. /** @hidden */
  25493. BoundingSphere.prototype._update = function (worldMatrix) {
  25494. if (!worldMatrix.isIdentity()) {
  25495. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25496. var tempVector = BoundingSphere.TmpVector3[0];
  25497. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25498. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25499. }
  25500. else {
  25501. this.centerWorld.copyFrom(this.center);
  25502. this.radiusWorld = this.radius;
  25503. }
  25504. };
  25505. /**
  25506. * Tests if the bounding sphere is intersecting the frustum planes
  25507. * @param frustumPlanes defines the frustum planes to test
  25508. * @returns true if there is an intersection
  25509. */
  25510. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25511. var center = this.centerWorld;
  25512. var radius = this.radiusWorld;
  25513. for (var i = 0; i < 6; i++) {
  25514. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25515. return false;
  25516. }
  25517. }
  25518. return true;
  25519. };
  25520. /**
  25521. * Tests if the bounding sphere center is in between the frustum planes.
  25522. * Used for optimistic fast inclusion.
  25523. * @param frustumPlanes defines the frustum planes to test
  25524. * @returns true if the sphere center is in between the frustum planes
  25525. */
  25526. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25527. var center = this.centerWorld;
  25528. for (var i = 0; i < 6; i++) {
  25529. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25530. return false;
  25531. }
  25532. }
  25533. return true;
  25534. };
  25535. /**
  25536. * Tests if a point is inside the bounding sphere
  25537. * @param point defines the point to test
  25538. * @returns true if the point is inside the bounding sphere
  25539. */
  25540. BoundingSphere.prototype.intersectsPoint = function (point) {
  25541. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25542. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25543. return false;
  25544. }
  25545. return true;
  25546. };
  25547. // Statics
  25548. /**
  25549. * Checks if two sphere intersct
  25550. * @param sphere0 sphere 0
  25551. * @param sphere1 sphere 1
  25552. * @returns true if the speres intersect
  25553. */
  25554. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25555. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25556. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25557. if (radiusSum * radiusSum < squareDistance) {
  25558. return false;
  25559. }
  25560. return true;
  25561. };
  25562. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25563. return BoundingSphere;
  25564. }());
  25565. /***/ }),
  25566. /***/ "./Culling/index.ts":
  25567. /*!**************************!*\
  25568. !*** ./Culling/index.ts ***!
  25569. \**************************/
  25570. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25572. "use strict";
  25573. __webpack_require__.r(__webpack_exports__);
  25574. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25576. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25578. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25580. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25584. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25586. /***/ }),
  25587. /***/ "./Culling/ray.ts":
  25588. /*!************************!*\
  25589. !*** ./Culling/ray.ts ***!
  25590. \************************/
  25591. /*! exports provided: Ray */
  25592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25593. "use strict";
  25594. __webpack_require__.r(__webpack_exports__);
  25595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25596. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25597. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25598. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25599. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25600. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25601. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25602. /**
  25603. * Class representing a ray with position and direction
  25604. */
  25605. var Ray = /** @class */ (function () {
  25606. /**
  25607. * Creates a new ray
  25608. * @param origin origin point
  25609. * @param direction direction
  25610. * @param length length of the ray
  25611. */
  25612. function Ray(
  25613. /** origin point */
  25614. origin,
  25615. /** direction */
  25616. direction,
  25617. /** length of the ray */
  25618. length) {
  25619. if (length === void 0) { length = Number.MAX_VALUE; }
  25620. this.origin = origin;
  25621. this.direction = direction;
  25622. this.length = length;
  25623. }
  25624. // Methods
  25625. /**
  25626. * Checks if the ray intersects a box
  25627. * @param minimum bound of the box
  25628. * @param maximum bound of the box
  25629. * @param intersectionTreshold extra extend to be added to the box in all direction
  25630. * @returns if the box was hit
  25631. */
  25632. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25633. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25634. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25635. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25636. var d = 0.0;
  25637. var maxValue = Number.MAX_VALUE;
  25638. var inv;
  25639. var min;
  25640. var max;
  25641. var temp;
  25642. if (Math.abs(this.direction.x) < 0.0000001) {
  25643. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25644. return false;
  25645. }
  25646. }
  25647. else {
  25648. inv = 1.0 / this.direction.x;
  25649. min = (newMinimum.x - this.origin.x) * inv;
  25650. max = (newMaximum.x - this.origin.x) * inv;
  25651. if (max === -Infinity) {
  25652. max = Infinity;
  25653. }
  25654. if (min > max) {
  25655. temp = min;
  25656. min = max;
  25657. max = temp;
  25658. }
  25659. d = Math.max(min, d);
  25660. maxValue = Math.min(max, maxValue);
  25661. if (d > maxValue) {
  25662. return false;
  25663. }
  25664. }
  25665. if (Math.abs(this.direction.y) < 0.0000001) {
  25666. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25667. return false;
  25668. }
  25669. }
  25670. else {
  25671. inv = 1.0 / this.direction.y;
  25672. min = (newMinimum.y - this.origin.y) * inv;
  25673. max = (newMaximum.y - this.origin.y) * inv;
  25674. if (max === -Infinity) {
  25675. max = Infinity;
  25676. }
  25677. if (min > max) {
  25678. temp = min;
  25679. min = max;
  25680. max = temp;
  25681. }
  25682. d = Math.max(min, d);
  25683. maxValue = Math.min(max, maxValue);
  25684. if (d > maxValue) {
  25685. return false;
  25686. }
  25687. }
  25688. if (Math.abs(this.direction.z) < 0.0000001) {
  25689. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25690. return false;
  25691. }
  25692. }
  25693. else {
  25694. inv = 1.0 / this.direction.z;
  25695. min = (newMinimum.z - this.origin.z) * inv;
  25696. max = (newMaximum.z - this.origin.z) * inv;
  25697. if (max === -Infinity) {
  25698. max = Infinity;
  25699. }
  25700. if (min > max) {
  25701. temp = min;
  25702. min = max;
  25703. max = temp;
  25704. }
  25705. d = Math.max(min, d);
  25706. maxValue = Math.min(max, maxValue);
  25707. if (d > maxValue) {
  25708. return false;
  25709. }
  25710. }
  25711. return true;
  25712. };
  25713. /**
  25714. * Checks if the ray intersects a box
  25715. * @param box the bounding box to check
  25716. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25717. * @returns if the box was hit
  25718. */
  25719. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25720. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25721. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25722. };
  25723. /**
  25724. * If the ray hits a sphere
  25725. * @param sphere the bounding sphere to check
  25726. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25727. * @returns true if it hits the sphere
  25728. */
  25729. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25730. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25731. var x = sphere.center.x - this.origin.x;
  25732. var y = sphere.center.y - this.origin.y;
  25733. var z = sphere.center.z - this.origin.z;
  25734. var pyth = (x * x) + (y * y) + (z * z);
  25735. var radius = sphere.radius + intersectionTreshold;
  25736. var rr = radius * radius;
  25737. if (pyth <= rr) {
  25738. return true;
  25739. }
  25740. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25741. if (dot < 0.0) {
  25742. return false;
  25743. }
  25744. var temp = pyth - (dot * dot);
  25745. return temp <= rr;
  25746. };
  25747. /**
  25748. * If the ray hits a triange
  25749. * @param vertex0 triangle vertex
  25750. * @param vertex1 triangle vertex
  25751. * @param vertex2 triangle vertex
  25752. * @returns intersection information if hit
  25753. */
  25754. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25755. var edge1 = Ray.TmpVector3[0];
  25756. var edge2 = Ray.TmpVector3[1];
  25757. var pvec = Ray.TmpVector3[2];
  25758. var tvec = Ray.TmpVector3[3];
  25759. var qvec = Ray.TmpVector3[4];
  25760. vertex1.subtractToRef(vertex0, edge1);
  25761. vertex2.subtractToRef(vertex0, edge2);
  25762. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25763. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25764. if (det === 0) {
  25765. return null;
  25766. }
  25767. var invdet = 1 / det;
  25768. this.origin.subtractToRef(vertex0, tvec);
  25769. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25770. if (bu < 0 || bu > 1.0) {
  25771. return null;
  25772. }
  25773. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25774. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25775. if (bv < 0 || bu + bv > 1.0) {
  25776. return null;
  25777. }
  25778. //check if the distance is longer than the predefined length.
  25779. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25780. if (distance > this.length) {
  25781. return null;
  25782. }
  25783. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25784. };
  25785. /**
  25786. * Checks if ray intersects a plane
  25787. * @param plane the plane to check
  25788. * @returns the distance away it was hit
  25789. */
  25790. Ray.prototype.intersectsPlane = function (plane) {
  25791. var distance;
  25792. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25793. if (Math.abs(result1) < 9.99999997475243E-07) {
  25794. return null;
  25795. }
  25796. else {
  25797. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25798. distance = (-plane.d - result2) / result1;
  25799. if (distance < 0.0) {
  25800. if (distance < -9.99999997475243E-07) {
  25801. return null;
  25802. }
  25803. else {
  25804. return 0;
  25805. }
  25806. }
  25807. return distance;
  25808. }
  25809. };
  25810. /**
  25811. * Checks if ray intersects a mesh
  25812. * @param mesh the mesh to check
  25813. * @param fastCheck if only the bounding box should checked
  25814. * @returns picking info of the intersecton
  25815. */
  25816. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25817. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25818. mesh.getWorldMatrix().invertToRef(tm);
  25819. if (this._tmpRay) {
  25820. Ray.TransformToRef(this, tm, this._tmpRay);
  25821. }
  25822. else {
  25823. this._tmpRay = Ray.Transform(this, tm);
  25824. }
  25825. return mesh.intersects(this._tmpRay, fastCheck);
  25826. };
  25827. /**
  25828. * Checks if ray intersects a mesh
  25829. * @param meshes the meshes to check
  25830. * @param fastCheck if only the bounding box should checked
  25831. * @param results array to store result in
  25832. * @returns Array of picking infos
  25833. */
  25834. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25835. if (results) {
  25836. results.length = 0;
  25837. }
  25838. else {
  25839. results = [];
  25840. }
  25841. for (var i = 0; i < meshes.length; i++) {
  25842. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25843. if (pickInfo.hit) {
  25844. results.push(pickInfo);
  25845. }
  25846. }
  25847. results.sort(this._comparePickingInfo);
  25848. return results;
  25849. };
  25850. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25851. if (pickingInfoA.distance < pickingInfoB.distance) {
  25852. return -1;
  25853. }
  25854. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25855. return 1;
  25856. }
  25857. else {
  25858. return 0;
  25859. }
  25860. };
  25861. /**
  25862. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25863. * @param sega the first point of the segment to test the intersection against
  25864. * @param segb the second point of the segment to test the intersection against
  25865. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25866. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25867. */
  25868. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25869. var o = this.origin;
  25870. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25871. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25872. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25873. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25874. segb.subtractToRef(sega, u);
  25875. this.direction.scaleToRef(Ray.rayl, v);
  25876. o.addToRef(v, rsegb);
  25877. sega.subtractToRef(o, w);
  25878. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25879. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25880. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25881. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25882. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25883. var D = a * c - b * b; // always >= 0
  25884. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25885. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25886. // compute the line parameters of the two closest points
  25887. if (D < Ray.smallnum) { // the lines are almost parallel
  25888. sN = 0.0; // force using point P0 on segment S1
  25889. sD = 1.0; // to prevent possible division by 0.0 later
  25890. tN = e;
  25891. tD = c;
  25892. }
  25893. else { // get the closest points on the infinite lines
  25894. sN = (b * e - c * d);
  25895. tN = (a * e - b * d);
  25896. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25897. sN = 0.0;
  25898. tN = e;
  25899. tD = c;
  25900. }
  25901. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25902. sN = sD;
  25903. tN = e + b;
  25904. tD = c;
  25905. }
  25906. }
  25907. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25908. tN = 0.0;
  25909. // recompute sc for this edge
  25910. if (-d < 0.0) {
  25911. sN = 0.0;
  25912. }
  25913. else if (-d > a) {
  25914. sN = sD;
  25915. }
  25916. else {
  25917. sN = -d;
  25918. sD = a;
  25919. }
  25920. }
  25921. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  25922. tN = tD;
  25923. // recompute sc for this edge
  25924. if ((-d + b) < 0.0) {
  25925. sN = 0;
  25926. }
  25927. else if ((-d + b) > a) {
  25928. sN = sD;
  25929. }
  25930. else {
  25931. sN = (-d + b);
  25932. sD = a;
  25933. }
  25934. }
  25935. // finally do the division to get sc and tc
  25936. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  25937. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  25938. // get the difference of the two closest points
  25939. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  25940. v.scaleToRef(tc, qtc);
  25941. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  25942. u.scaleToRef(sc, qsc);
  25943. qsc.addInPlace(w);
  25944. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  25945. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  25946. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25947. if (isIntersected) {
  25948. return qsc.length();
  25949. }
  25950. return -1;
  25951. };
  25952. /**
  25953. * Update the ray from viewport position
  25954. * @param x position
  25955. * @param y y position
  25956. * @param viewportWidth viewport width
  25957. * @param viewportHeight viewport height
  25958. * @param world world matrix
  25959. * @param view view matrix
  25960. * @param projection projection matrix
  25961. * @returns this ray updated
  25962. */
  25963. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25964. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25965. return this;
  25966. };
  25967. // Statics
  25968. /**
  25969. * Creates a ray with origin and direction of 0,0,0
  25970. * @returns the new ray
  25971. */
  25972. Ray.Zero = function () {
  25973. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  25974. };
  25975. /**
  25976. * Creates a new ray from screen space and viewport
  25977. * @param x position
  25978. * @param y y position
  25979. * @param viewportWidth viewport width
  25980. * @param viewportHeight viewport height
  25981. * @param world world matrix
  25982. * @param view view matrix
  25983. * @param projection projection matrix
  25984. * @returns new ray
  25985. */
  25986. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25987. var result = Ray.Zero();
  25988. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  25989. };
  25990. /**
  25991. * 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
  25992. * transformed to the given world matrix.
  25993. * @param origin The origin point
  25994. * @param end The end point
  25995. * @param world a matrix to transform the ray to. Default is the identity matrix.
  25996. * @returns the new ray
  25997. */
  25998. Ray.CreateNewFromTo = function (origin, end, world) {
  25999. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  26000. var direction = end.subtract(origin);
  26001. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  26002. direction.normalize();
  26003. return Ray.Transform(new Ray(origin, direction, length), world);
  26004. };
  26005. /**
  26006. * Transforms a ray by a matrix
  26007. * @param ray ray to transform
  26008. * @param matrix matrix to apply
  26009. * @returns the resulting new ray
  26010. */
  26011. Ray.Transform = function (ray, matrix) {
  26012. 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));
  26013. Ray.TransformToRef(ray, matrix, result);
  26014. return result;
  26015. };
  26016. /**
  26017. * Transforms a ray by a matrix
  26018. * @param ray ray to transform
  26019. * @param matrix matrix to apply
  26020. * @param result ray to store result in
  26021. */
  26022. Ray.TransformToRef = function (ray, matrix, result) {
  26023. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  26024. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  26025. result.length = ray.length;
  26026. var dir = result.direction;
  26027. var len = dir.length();
  26028. if (!(len === 0 || len === 1)) {
  26029. var num = 1.0 / len;
  26030. dir.x *= num;
  26031. dir.y *= num;
  26032. dir.z *= num;
  26033. result.length *= len;
  26034. }
  26035. };
  26036. /**
  26037. * Unproject a ray from screen space to object space
  26038. * @param sourceX defines the screen space x coordinate to use
  26039. * @param sourceY defines the screen space y coordinate to use
  26040. * @param viewportWidth defines the current width of the viewport
  26041. * @param viewportHeight defines the current height of the viewport
  26042. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  26043. * @param view defines the view matrix to use
  26044. * @param projection defines the projection matrix to use
  26045. */
  26046. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  26047. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26048. world.multiplyToRef(view, matrix);
  26049. matrix.multiplyToRef(projection, matrix);
  26050. matrix.invert();
  26051. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26052. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  26053. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  26054. nearScreenSource.z = -1.0;
  26055. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  26056. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26057. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26058. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  26059. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  26060. this.origin.copyFrom(nearVec3);
  26061. farVec3.subtractToRef(nearVec3, this.direction);
  26062. this.direction.normalize();
  26063. };
  26064. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26065. Ray.smallnum = 0.00000001;
  26066. Ray.rayl = 10e8;
  26067. return Ray;
  26068. }());
  26069. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  26070. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26071. var result = Ray.Zero();
  26072. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  26073. return result;
  26074. };
  26075. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  26076. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26077. var engine = this.getEngine();
  26078. if (!camera) {
  26079. if (!this.activeCamera) {
  26080. throw new Error("Active camera not set");
  26081. }
  26082. camera = this.activeCamera;
  26083. }
  26084. var cameraViewport = camera.viewport;
  26085. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26086. // Moving coordinates to local viewport world
  26087. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26088. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26089. 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());
  26090. return this;
  26091. };
  26092. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  26093. var result = Ray.Zero();
  26094. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  26095. return result;
  26096. };
  26097. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  26098. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26099. return this;
  26100. }
  26101. var engine = this.getEngine();
  26102. if (!camera) {
  26103. if (!this.activeCamera) {
  26104. throw new Error("Active camera not set");
  26105. }
  26106. camera = this.activeCamera;
  26107. }
  26108. var cameraViewport = camera.viewport;
  26109. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26110. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26111. // Moving coordinates to local viewport world
  26112. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26113. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26114. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  26115. return this;
  26116. };
  26117. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  26118. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26119. return null;
  26120. }
  26121. var pickingInfo = null;
  26122. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26123. var mesh = this.meshes[meshIndex];
  26124. if (predicate) {
  26125. if (!predicate(mesh)) {
  26126. continue;
  26127. }
  26128. }
  26129. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26130. continue;
  26131. }
  26132. var world = mesh.getWorldMatrix();
  26133. var ray = rayFunction(world);
  26134. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  26135. if (!result || !result.hit) {
  26136. continue;
  26137. }
  26138. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  26139. continue;
  26140. }
  26141. pickingInfo = result;
  26142. if (fastCheck) {
  26143. break;
  26144. }
  26145. }
  26146. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  26147. };
  26148. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  26149. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26150. return null;
  26151. }
  26152. var pickingInfos = new Array();
  26153. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26154. var mesh = this.meshes[meshIndex];
  26155. if (predicate) {
  26156. if (!predicate(mesh)) {
  26157. continue;
  26158. }
  26159. }
  26160. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26161. continue;
  26162. }
  26163. var world = mesh.getWorldMatrix();
  26164. var ray = rayFunction(world);
  26165. var result = mesh.intersects(ray, false, trianglePredicate);
  26166. if (!result || !result.hit) {
  26167. continue;
  26168. }
  26169. pickingInfos.push(result);
  26170. }
  26171. return pickingInfos;
  26172. };
  26173. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  26174. var _this = this;
  26175. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26176. return null;
  26177. }
  26178. var result = this._internalPick(function (world) {
  26179. if (!_this._tempPickingRay) {
  26180. _this._tempPickingRay = Ray.Zero();
  26181. }
  26182. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  26183. return _this._tempPickingRay;
  26184. }, predicate, fastCheck, trianglePredicate);
  26185. if (result) {
  26186. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  26187. }
  26188. return result;
  26189. };
  26190. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  26191. var _this = this;
  26192. var result = this._internalPick(function (world) {
  26193. if (!_this._pickWithRayInverseMatrix) {
  26194. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26195. }
  26196. world.invertToRef(_this._pickWithRayInverseMatrix);
  26197. if (!_this._cachedRayForTransform) {
  26198. _this._cachedRayForTransform = Ray.Zero();
  26199. }
  26200. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26201. return _this._cachedRayForTransform;
  26202. }, predicate, fastCheck, trianglePredicate);
  26203. if (result) {
  26204. result.ray = ray;
  26205. }
  26206. return result;
  26207. };
  26208. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  26209. var _this = this;
  26210. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  26211. };
  26212. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  26213. var _this = this;
  26214. return this._internalMultiPick(function (world) {
  26215. if (!_this._pickWithRayInverseMatrix) {
  26216. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26217. }
  26218. world.invertToRef(_this._pickWithRayInverseMatrix);
  26219. if (!_this._cachedRayForTransform) {
  26220. _this._cachedRayForTransform = Ray.Zero();
  26221. }
  26222. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26223. return _this._cachedRayForTransform;
  26224. }, predicate, trianglePredicate);
  26225. };
  26226. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  26227. if (length === void 0) { length = 100; }
  26228. if (!transform) {
  26229. transform = this.getWorldMatrix();
  26230. }
  26231. if (!origin) {
  26232. origin = this.position;
  26233. }
  26234. 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);
  26235. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  26236. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  26237. return new Ray(origin, direction, length);
  26238. };
  26239. /***/ }),
  26240. /***/ "./Debug/axesViewer.ts":
  26241. /*!*****************************!*\
  26242. !*** ./Debug/axesViewer.ts ***!
  26243. \*****************************/
  26244. /*! exports provided: AxesViewer */
  26245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26246. "use strict";
  26247. __webpack_require__.r(__webpack_exports__);
  26248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  26249. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26250. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26251. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  26252. /**
  26253. * The Axes viewer will show 3 axes in a specific point in space
  26254. */
  26255. var AxesViewer = /** @class */ (function () {
  26256. /**
  26257. * Creates a new AxesViewer
  26258. * @param scene defines the hosting scene
  26259. * @param scaleLines defines a number used to scale line length (1 by default)
  26260. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  26261. * @param xAxis defines the node hierarchy used to render the x-axis
  26262. * @param yAxis defines the node hierarchy used to render the y-axis
  26263. * @param zAxis defines the node hierarchy used to render the z-axis
  26264. */
  26265. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  26266. if (scaleLines === void 0) { scaleLines = 1; }
  26267. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  26268. this._scaleLinesFactor = 4;
  26269. this._instanced = false;
  26270. /**
  26271. * Gets or sets a number used to scale line length
  26272. */
  26273. this.scaleLines = 1;
  26274. this.scaleLines = scaleLines;
  26275. if (!xAxis) {
  26276. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26277. redColoredMaterial.disableLighting = true;
  26278. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  26279. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  26280. }
  26281. if (!yAxis) {
  26282. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26283. greenColoredMaterial.disableLighting = true;
  26284. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  26285. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  26286. }
  26287. if (!zAxis) {
  26288. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26289. blueColoredMaterial.disableLighting = true;
  26290. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  26291. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  26292. }
  26293. this._xAxis = xAxis;
  26294. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26295. this._yAxis = yAxis;
  26296. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26297. this._zAxis = zAxis;
  26298. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26299. if (renderingGroupId != null) {
  26300. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  26301. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  26302. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  26303. }
  26304. this.scene = scene;
  26305. 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());
  26306. }
  26307. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  26308. /** Gets the node hierarchy used to render x-axis */
  26309. get: function () {
  26310. return this._xAxis;
  26311. },
  26312. enumerable: true,
  26313. configurable: true
  26314. });
  26315. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  26316. /** Gets the node hierarchy used to render y-axis */
  26317. get: function () {
  26318. return this._yAxis;
  26319. },
  26320. enumerable: true,
  26321. configurable: true
  26322. });
  26323. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  26324. /** Gets the node hierarchy used to render z-axis */
  26325. get: function () {
  26326. return this._zAxis;
  26327. },
  26328. enumerable: true,
  26329. configurable: true
  26330. });
  26331. /**
  26332. * Force the viewer to update
  26333. * @param position defines the position of the viewer
  26334. * @param xaxis defines the x axis of the viewer
  26335. * @param yaxis defines the y axis of the viewer
  26336. * @param zaxis defines the z axis of the viewer
  26337. */
  26338. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  26339. this._xAxis.position.copyFrom(position);
  26340. this._xAxis.setDirection(xaxis);
  26341. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26342. this._yAxis.position.copyFrom(position);
  26343. this._yAxis.setDirection(yaxis);
  26344. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26345. this._zAxis.position.copyFrom(position);
  26346. this._zAxis.setDirection(zaxis);
  26347. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26348. };
  26349. /**
  26350. * Creates an instance of this axes viewer.
  26351. * @returns a new axes viewer with instanced meshes
  26352. */
  26353. AxesViewer.prototype.createInstance = function () {
  26354. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  26355. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  26356. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  26357. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  26358. axesViewer._instanced = true;
  26359. return axesViewer;
  26360. };
  26361. /** Releases resources */
  26362. AxesViewer.prototype.dispose = function () {
  26363. if (this._xAxis) {
  26364. this._xAxis.dispose(false, !this._instanced);
  26365. delete this._xAxis;
  26366. }
  26367. if (this._yAxis) {
  26368. this._yAxis.dispose(false, !this._instanced);
  26369. delete this._yAxis;
  26370. }
  26371. if (this._zAxis) {
  26372. this._zAxis.dispose(false, !this._instanced);
  26373. delete this._zAxis;
  26374. }
  26375. delete this.scene;
  26376. };
  26377. AxesViewer._SetRenderingGroupId = function (node, id) {
  26378. node.getChildMeshes().forEach(function (mesh) {
  26379. mesh.renderingGroupId = id;
  26380. });
  26381. };
  26382. return AxesViewer;
  26383. }());
  26384. /***/ }),
  26385. /***/ "./Debug/boneAxesViewer.ts":
  26386. /*!*********************************!*\
  26387. !*** ./Debug/boneAxesViewer.ts ***!
  26388. \*********************************/
  26389. /*! exports provided: BoneAxesViewer */
  26390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26391. "use strict";
  26392. __webpack_require__.r(__webpack_exports__);
  26393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  26394. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26395. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  26396. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26397. /**
  26398. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  26399. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  26400. */
  26401. var BoneAxesViewer = /** @class */ (function (_super) {
  26402. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  26403. /**
  26404. * Creates a new BoneAxesViewer
  26405. * @param scene defines the hosting scene
  26406. * @param bone defines the target bone
  26407. * @param mesh defines the target mesh
  26408. * @param scaleLines defines a scaling factor for line length (1 by default)
  26409. */
  26410. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  26411. if (scaleLines === void 0) { scaleLines = 1; }
  26412. var _this = _super.call(this, scene, scaleLines) || this;
  26413. /** Gets current position */
  26414. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26415. /** Gets direction of X axis */
  26416. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26417. /** Gets direction of Y axis */
  26418. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26419. /** Gets direction of Z axis */
  26420. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26421. _this.mesh = mesh;
  26422. _this.bone = bone;
  26423. return _this;
  26424. }
  26425. /**
  26426. * Force the viewer to update
  26427. */
  26428. BoneAxesViewer.prototype.update = function () {
  26429. if (!this.mesh || !this.bone) {
  26430. return;
  26431. }
  26432. var bone = this.bone;
  26433. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  26434. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  26435. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  26436. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  26437. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  26438. };
  26439. /** Releases resources */
  26440. BoneAxesViewer.prototype.dispose = function () {
  26441. if (this.mesh) {
  26442. this.mesh = null;
  26443. this.bone = null;
  26444. _super.prototype.dispose.call(this);
  26445. }
  26446. };
  26447. return BoneAxesViewer;
  26448. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  26449. /***/ }),
  26450. /***/ "./Debug/debugLayer.ts":
  26451. /*!*****************************!*\
  26452. !*** ./Debug/debugLayer.ts ***!
  26453. \*****************************/
  26454. /*! exports provided: DebugLayer */
  26455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26456. "use strict";
  26457. __webpack_require__.r(__webpack_exports__);
  26458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  26459. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26460. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26461. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26462. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26463. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  26464. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  26465. get: function () {
  26466. if (!this._debugLayer) {
  26467. this._debugLayer = new DebugLayer(this);
  26468. }
  26469. return this._debugLayer;
  26470. },
  26471. enumerable: true,
  26472. configurable: true
  26473. });
  26474. /**
  26475. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26476. * what is happening in your scene
  26477. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26478. */
  26479. var DebugLayer = /** @class */ (function () {
  26480. /**
  26481. * Instantiates a new debug layer.
  26482. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26483. * what is happening in your scene
  26484. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26485. * @param scene Defines the scene to inspect
  26486. */
  26487. function DebugLayer(scene) {
  26488. var _this = this;
  26489. this.BJSINSPECTOR = this._getGlobalInspector();
  26490. /**
  26491. * Observable triggered when a property is changed through the inspector.
  26492. */
  26493. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26494. this._scene = scene;
  26495. this._scene.onDisposeObservable.add(function () {
  26496. // Debug layer
  26497. if (_this._scene._debugLayer) {
  26498. _this._scene._debugLayer.hide();
  26499. }
  26500. });
  26501. }
  26502. /** Creates the inspector window. */
  26503. DebugLayer.prototype._createInspector = function (config) {
  26504. if (this.isVisible()) {
  26505. return;
  26506. }
  26507. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26508. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26509. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26510. };
  26511. /**
  26512. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  26513. * @param entity defines the entity to select
  26514. * @param lineContainerTitle defines the specific block to highlight
  26515. */
  26516. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26517. if (this.BJSINSPECTOR) {
  26518. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26519. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26520. }
  26521. };
  26522. /** Get the inspector from bundle or global */
  26523. DebugLayer.prototype._getGlobalInspector = function () {
  26524. // UMD Global name detection from Webpack Bundle UMD Name.
  26525. if (typeof INSPECTOR !== 'undefined') {
  26526. return INSPECTOR;
  26527. }
  26528. // In case of module let s check the global emitted from the Inspector entry point.
  26529. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26530. return BABYLON;
  26531. }
  26532. return undefined;
  26533. };
  26534. /**
  26535. * Get if the inspector is visible or not.
  26536. * @returns true if visible otherwise, false
  26537. */
  26538. DebugLayer.prototype.isVisible = function () {
  26539. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26540. };
  26541. /**
  26542. * Hide the inspector and close its window.
  26543. */
  26544. DebugLayer.prototype.hide = function () {
  26545. if (this.BJSINSPECTOR) {
  26546. this.BJSINSPECTOR.Inspector.Hide();
  26547. }
  26548. };
  26549. /**
  26550. * Launch the debugLayer.
  26551. * @param config Define the configuration of the inspector
  26552. * @return a promise fulfilled when the debug layer is visible
  26553. */
  26554. DebugLayer.prototype.show = function (config) {
  26555. var _this = this;
  26556. return new Promise(function (resolve, reject) {
  26557. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26558. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26559. // Load inspector and add it to the DOM
  26560. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26561. _this._createInspector(config);
  26562. resolve(_this);
  26563. });
  26564. }
  26565. else {
  26566. // Otherwise creates the inspector
  26567. _this._createInspector(config);
  26568. resolve(_this);
  26569. }
  26570. });
  26571. };
  26572. /**
  26573. * Define the url to get the inspector script from.
  26574. * By default it uses the babylonjs CDN.
  26575. * @ignoreNaming
  26576. */
  26577. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26578. return DebugLayer;
  26579. }());
  26580. /***/ }),
  26581. /***/ "./Debug/index.ts":
  26582. /*!************************!*\
  26583. !*** ./Debug/index.ts ***!
  26584. \************************/
  26585. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26587. "use strict";
  26588. __webpack_require__.r(__webpack_exports__);
  26589. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26591. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26593. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26595. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26597. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26599. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26601. /***/ }),
  26602. /***/ "./Debug/physicsViewer.ts":
  26603. /*!********************************!*\
  26604. !*** ./Debug/physicsViewer.ts ***!
  26605. \********************************/
  26606. /*! exports provided: PhysicsViewer */
  26607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26608. "use strict";
  26609. __webpack_require__.r(__webpack_exports__);
  26610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26611. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26612. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26613. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26614. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26615. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26616. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26617. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26618. /**
  26619. * Used to show the physics impostor around the specific mesh
  26620. */
  26621. var PhysicsViewer = /** @class */ (function () {
  26622. /**
  26623. * Creates a new PhysicsViewer
  26624. * @param scene defines the hosting scene
  26625. */
  26626. function PhysicsViewer(scene) {
  26627. /** @hidden */
  26628. this._impostors = [];
  26629. /** @hidden */
  26630. this._meshes = [];
  26631. /** @hidden */
  26632. this._numMeshes = 0;
  26633. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  26634. var physicEngine = this._scene.getPhysicsEngine();
  26635. if (physicEngine) {
  26636. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26637. }
  26638. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"](this._scene, false);
  26639. this._utilityLayer.pickUtilitySceneFirst = false;
  26640. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26641. }
  26642. /** @hidden */
  26643. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26644. var plugin = this._physicsEnginePlugin;
  26645. for (var i = 0; i < this._numMeshes; i++) {
  26646. var impostor = this._impostors[i];
  26647. if (!impostor) {
  26648. continue;
  26649. }
  26650. if (impostor.isDisposed) {
  26651. this.hideImpostor(this._impostors[i--]);
  26652. }
  26653. else {
  26654. var mesh = this._meshes[i];
  26655. if (mesh && plugin) {
  26656. plugin.syncMeshWithImpostor(mesh, impostor);
  26657. }
  26658. }
  26659. }
  26660. };
  26661. /**
  26662. * Renders a specified physic impostor
  26663. * @param impostor defines the impostor to render
  26664. * @returns the new debug mesh used to render the impostor
  26665. */
  26666. PhysicsViewer.prototype.showImpostor = function (impostor) {
  26667. if (!this._scene) {
  26668. return null;
  26669. }
  26670. for (var i = 0; i < this._numMeshes; i++) {
  26671. if (this._impostors[i] == impostor) {
  26672. return null;
  26673. }
  26674. }
  26675. var debugMesh = this._getDebugMesh(impostor);
  26676. if (debugMesh) {
  26677. this._impostors[this._numMeshes] = impostor;
  26678. this._meshes[this._numMeshes] = debugMesh;
  26679. if (this._numMeshes === 0) {
  26680. this._renderFunction = this._updateDebugMeshes.bind(this);
  26681. this._scene.registerBeforeRender(this._renderFunction);
  26682. }
  26683. this._numMeshes++;
  26684. }
  26685. return debugMesh;
  26686. };
  26687. /**
  26688. * Hides a specified physic impostor
  26689. * @param impostor defines the impostor to hide
  26690. */
  26691. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26692. if (!impostor || !this._scene || !this._utilityLayer) {
  26693. return;
  26694. }
  26695. var removed = false;
  26696. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26697. for (var i = 0; i < this._numMeshes; i++) {
  26698. if (this._impostors[i] == impostor) {
  26699. var mesh = this._meshes[i];
  26700. if (!mesh) {
  26701. continue;
  26702. }
  26703. utilityLayerScene.removeMesh(mesh);
  26704. mesh.dispose();
  26705. this._numMeshes--;
  26706. if (this._numMeshes > 0) {
  26707. this._meshes[i] = this._meshes[this._numMeshes];
  26708. this._impostors[i] = this._impostors[this._numMeshes];
  26709. this._meshes[this._numMeshes] = null;
  26710. this._impostors[this._numMeshes] = null;
  26711. }
  26712. else {
  26713. this._meshes[0] = null;
  26714. this._impostors[0] = null;
  26715. }
  26716. removed = true;
  26717. break;
  26718. }
  26719. }
  26720. if (removed && this._numMeshes === 0) {
  26721. this._scene.unregisterBeforeRender(this._renderFunction);
  26722. }
  26723. };
  26724. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26725. if (!this._debugMaterial) {
  26726. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__["StandardMaterial"]('', scene);
  26727. this._debugMaterial.wireframe = true;
  26728. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  26729. this._debugMaterial.disableLighting = true;
  26730. }
  26731. return this._debugMaterial;
  26732. };
  26733. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26734. if (!this._debugBoxMesh) {
  26735. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26736. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26737. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26738. }
  26739. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26740. };
  26741. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26742. if (!this._debugSphereMesh) {
  26743. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26744. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26745. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26746. }
  26747. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26748. };
  26749. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  26750. if (!this._utilityLayer) {
  26751. return null;
  26752. }
  26753. var mesh = null;
  26754. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26755. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].BoxImpostor) {
  26756. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26757. impostor.getBoxSizeToRef(mesh.scaling);
  26758. }
  26759. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].SphereImpostor) {
  26760. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26761. var radius = impostor.getRadius();
  26762. mesh.scaling.x = radius * 2;
  26763. mesh.scaling.y = radius * 2;
  26764. mesh.scaling.z = radius * 2;
  26765. }
  26766. return mesh;
  26767. };
  26768. /** Releases all resources */
  26769. PhysicsViewer.prototype.dispose = function () {
  26770. for (var i = 0; i < this._numMeshes; i++) {
  26771. this.hideImpostor(this._impostors[i]);
  26772. }
  26773. if (this._debugBoxMesh) {
  26774. this._debugBoxMesh.dispose();
  26775. }
  26776. if (this._debugSphereMesh) {
  26777. this._debugSphereMesh.dispose();
  26778. }
  26779. if (this._debugMaterial) {
  26780. this._debugMaterial.dispose();
  26781. }
  26782. this._impostors.length = 0;
  26783. this._scene = null;
  26784. this._physicsEnginePlugin = null;
  26785. if (this._utilityLayer) {
  26786. this._utilityLayer.dispose();
  26787. this._utilityLayer = null;
  26788. }
  26789. };
  26790. return PhysicsViewer;
  26791. }());
  26792. /***/ }),
  26793. /***/ "./Debug/rayHelper.ts":
  26794. /*!****************************!*\
  26795. !*** ./Debug/rayHelper.ts ***!
  26796. \****************************/
  26797. /*! exports provided: RayHelper */
  26798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26799. "use strict";
  26800. __webpack_require__.r(__webpack_exports__);
  26801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26802. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26803. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26804. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26805. /**
  26806. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26807. * in order to better appreciate the issue one might have.
  26808. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26809. */
  26810. var RayHelper = /** @class */ (function () {
  26811. /**
  26812. * Instantiate a new ray helper.
  26813. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26814. * in order to better appreciate the issue one might have.
  26815. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26816. * @param ray Defines the ray we are currently tryin to visualize
  26817. */
  26818. function RayHelper(ray) {
  26819. this.ray = ray;
  26820. }
  26821. /**
  26822. * Helper function to create a colored helper in a scene in one line.
  26823. * @param ray Defines the ray we are currently tryin to visualize
  26824. * @param scene Defines the scene the ray is used in
  26825. * @param color Defines the color we want to see the ray in
  26826. * @returns The newly created ray helper.
  26827. */
  26828. RayHelper.CreateAndShow = function (ray, scene, color) {
  26829. var helper = new RayHelper(ray);
  26830. helper.show(scene, color);
  26831. return helper;
  26832. };
  26833. /**
  26834. * Shows the ray we are willing to debug.
  26835. * @param scene Defines the scene the ray needs to be rendered in
  26836. * @param color Defines the color the ray needs to be rendered in
  26837. */
  26838. RayHelper.prototype.show = function (scene, color) {
  26839. if (!this._renderFunction && this.ray) {
  26840. var ray = this.ray;
  26841. this._renderFunction = this._render.bind(this);
  26842. this._scene = scene;
  26843. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26844. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26845. if (this._renderFunction) {
  26846. this._scene.registerBeforeRender(this._renderFunction);
  26847. }
  26848. }
  26849. if (color && this._renderLine) {
  26850. this._renderLine.color.copyFrom(color);
  26851. }
  26852. };
  26853. /**
  26854. * Hides the ray we are debugging.
  26855. */
  26856. RayHelper.prototype.hide = function () {
  26857. if (this._renderFunction && this._scene) {
  26858. this._scene.unregisterBeforeRender(this._renderFunction);
  26859. this._scene = null;
  26860. this._renderFunction = null;
  26861. if (this._renderLine) {
  26862. this._renderLine.dispose();
  26863. this._renderLine = null;
  26864. }
  26865. this._renderPoints = [];
  26866. }
  26867. };
  26868. RayHelper.prototype._render = function () {
  26869. var ray = this.ray;
  26870. if (!ray) {
  26871. return;
  26872. }
  26873. var point = this._renderPoints[1];
  26874. var len = Math.min(ray.length, 1000000);
  26875. point.copyFrom(ray.direction);
  26876. point.scaleInPlace(len);
  26877. point.addInPlace(ray.origin);
  26878. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26879. };
  26880. /**
  26881. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26882. * @param mesh Defines the mesh we want the helper attached to
  26883. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26884. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26885. * @param length Defines the length of the ray
  26886. */
  26887. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  26888. this._attachedToMesh = mesh;
  26889. var ray = this.ray;
  26890. if (!ray) {
  26891. return;
  26892. }
  26893. if (!ray.direction) {
  26894. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26895. }
  26896. if (!ray.origin) {
  26897. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26898. }
  26899. if (length) {
  26900. ray.length = length;
  26901. }
  26902. if (!meshSpaceOrigin) {
  26903. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26904. }
  26905. if (!meshSpaceDirection) {
  26906. // -1 so that this will work with Mesh.lookAt
  26907. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  26908. }
  26909. if (!this._meshSpaceDirection) {
  26910. this._meshSpaceDirection = meshSpaceDirection.clone();
  26911. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  26912. }
  26913. else {
  26914. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  26915. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  26916. }
  26917. if (!this._updateToMeshFunction) {
  26918. this._updateToMeshFunction = this._updateToMesh.bind(this);
  26919. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  26920. }
  26921. this._updateToMesh();
  26922. };
  26923. /**
  26924. * Detach the ray helper from the mesh it has previously been attached to.
  26925. */
  26926. RayHelper.prototype.detachFromMesh = function () {
  26927. if (this._attachedToMesh) {
  26928. if (this._updateToMeshFunction) {
  26929. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  26930. }
  26931. this._attachedToMesh = null;
  26932. this._updateToMeshFunction = null;
  26933. }
  26934. };
  26935. RayHelper.prototype._updateToMesh = function () {
  26936. var ray = this.ray;
  26937. if (!this._attachedToMesh || !ray) {
  26938. return;
  26939. }
  26940. if (this._attachedToMesh._isDisposed) {
  26941. this.detachFromMesh();
  26942. return;
  26943. }
  26944. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  26945. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  26946. };
  26947. /**
  26948. * Dispose the helper and release its associated resources.
  26949. */
  26950. RayHelper.prototype.dispose = function () {
  26951. this.hide();
  26952. this.detachFromMesh();
  26953. this.ray = null;
  26954. };
  26955. return RayHelper;
  26956. }());
  26957. /***/ }),
  26958. /***/ "./Debug/skeletonViewer.ts":
  26959. /*!*********************************!*\
  26960. !*** ./Debug/skeletonViewer.ts ***!
  26961. \*********************************/
  26962. /*! exports provided: SkeletonViewer */
  26963. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26964. "use strict";
  26965. __webpack_require__.r(__webpack_exports__);
  26966. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  26967. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26968. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26969. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26970. /**
  26971. * Class used to render a debug view of a given skeleton
  26972. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  26973. */
  26974. var SkeletonViewer = /** @class */ (function () {
  26975. /**
  26976. * Creates a new SkeletonViewer
  26977. * @param skeleton defines the skeleton to render
  26978. * @param mesh defines the mesh attached to the skeleton
  26979. * @param scene defines the hosting scene
  26980. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  26981. * @param renderingGroupId defines the rendering group id to use with the viewer
  26982. */
  26983. function SkeletonViewer(
  26984. /** defines the skeleton to render */
  26985. skeleton,
  26986. /** defines the mesh attached to the skeleton */
  26987. mesh, scene,
  26988. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  26989. autoUpdateBonesMatrices,
  26990. /** defines the rendering group id to use with the viewer */
  26991. renderingGroupId) {
  26992. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  26993. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  26994. this.skeleton = skeleton;
  26995. this.mesh = mesh;
  26996. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  26997. this.renderingGroupId = renderingGroupId;
  26998. /** Gets or sets the color used to render the skeleton */
  26999. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  27000. this._debugLines = new Array();
  27001. this._isEnabled = false;
  27002. this._scene = scene;
  27003. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  27004. this._utilityLayer.pickUtilitySceneFirst = false;
  27005. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  27006. this.update();
  27007. this._renderFunction = this.update.bind(this);
  27008. }
  27009. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  27010. /**
  27011. * Returns the mesh used to render the bones
  27012. */
  27013. get: function () {
  27014. return this._debugMesh;
  27015. },
  27016. enumerable: true,
  27017. configurable: true
  27018. });
  27019. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  27020. get: function () {
  27021. return this._isEnabled;
  27022. },
  27023. /** Gets or sets a boolean indicating if the viewer is enabled */
  27024. set: function (value) {
  27025. if (this._isEnabled === value) {
  27026. return;
  27027. }
  27028. this._isEnabled = value;
  27029. if (value) {
  27030. this._scene.registerBeforeRender(this._renderFunction);
  27031. }
  27032. else {
  27033. this._scene.unregisterBeforeRender(this._renderFunction);
  27034. }
  27035. },
  27036. enumerable: true,
  27037. configurable: true
  27038. });
  27039. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  27040. if (x === void 0) { x = 0; }
  27041. if (y === void 0) { y = 0; }
  27042. if (z === void 0) { z = 0; }
  27043. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  27044. var parentBone = bone.getParent();
  27045. tmat.copyFrom(bone.getLocalMatrix());
  27046. if (x !== 0 || y !== 0 || z !== 0) {
  27047. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  27048. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  27049. tmat2.setTranslationFromFloats(x, y, z);
  27050. tmat2.multiplyToRef(tmat, tmat);
  27051. }
  27052. if (parentBone) {
  27053. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  27054. }
  27055. tmat.multiplyToRef(meshMat, tmat);
  27056. position.x = tmat.m[12];
  27057. position.y = tmat.m[13];
  27058. position.z = tmat.m[14];
  27059. };
  27060. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  27061. var len = bones.length;
  27062. var meshPos = this.mesh.position;
  27063. for (var i = 0; i < len; i++) {
  27064. var bone = bones[i];
  27065. var points = this._debugLines[i];
  27066. if (!points) {
  27067. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27068. this._debugLines[i] = points;
  27069. }
  27070. this._getBonePosition(points[0], bone, meshMat);
  27071. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  27072. points[0].subtractInPlace(meshPos);
  27073. points[1].subtractInPlace(meshPos);
  27074. }
  27075. };
  27076. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  27077. var len = bones.length;
  27078. var boneNum = 0;
  27079. var meshPos = this.mesh.position;
  27080. for (var i = len - 1; i >= 0; i--) {
  27081. var childBone = bones[i];
  27082. var parentBone = childBone.getParent();
  27083. if (!parentBone) {
  27084. continue;
  27085. }
  27086. var points = this._debugLines[boneNum];
  27087. if (!points) {
  27088. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27089. this._debugLines[boneNum] = points;
  27090. }
  27091. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  27092. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  27093. points[0].subtractInPlace(meshPos);
  27094. points[1].subtractInPlace(meshPos);
  27095. boneNum++;
  27096. }
  27097. };
  27098. /** Update the viewer to sync with current skeleton state */
  27099. SkeletonViewer.prototype.update = function () {
  27100. if (!this._utilityLayer) {
  27101. return;
  27102. }
  27103. if (this.autoUpdateBonesMatrices) {
  27104. this.skeleton.computeAbsoluteTransforms();
  27105. }
  27106. if (this.skeleton.bones[0].length === undefined) {
  27107. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  27108. }
  27109. else {
  27110. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  27111. }
  27112. var targetScene = this._utilityLayer.utilityLayerScene;
  27113. if (!this._debugMesh) {
  27114. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  27115. this._debugMesh.renderingGroupId = this.renderingGroupId;
  27116. }
  27117. else {
  27118. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  27119. }
  27120. this._debugMesh.position.copyFrom(this.mesh.position);
  27121. this._debugMesh.color = this.color;
  27122. };
  27123. /** Release associated resources */
  27124. SkeletonViewer.prototype.dispose = function () {
  27125. this.isEnabled = false;
  27126. if (this._debugMesh) {
  27127. this.isEnabled = false;
  27128. this._debugMesh.dispose();
  27129. this._debugMesh = null;
  27130. }
  27131. if (this._utilityLayer) {
  27132. this._utilityLayer.dispose();
  27133. this._utilityLayer = null;
  27134. }
  27135. };
  27136. return SkeletonViewer;
  27137. }());
  27138. /***/ }),
  27139. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  27140. /*!*****************************************************!*\
  27141. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  27142. \*****************************************************/
  27143. /*! exports provided: _OcclusionDataStorage */
  27144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27145. "use strict";
  27146. __webpack_require__.r(__webpack_exports__);
  27147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  27148. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27149. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  27150. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  27151. /** @hidden */
  27152. var _OcclusionDataStorage = /** @class */ (function () {
  27153. function _OcclusionDataStorage() {
  27154. /** @hidden */
  27155. this.occlusionInternalRetryCounter = 0;
  27156. /** @hidden */
  27157. this.isOcclusionQueryInProgress = false;
  27158. /** @hidden */
  27159. this.isOccluded = false;
  27160. /** @hidden */
  27161. this.occlusionRetryCount = -1;
  27162. /** @hidden */
  27163. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  27164. /** @hidden */
  27165. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  27166. }
  27167. return _OcclusionDataStorage;
  27168. }());
  27169. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  27170. return this._gl.createQuery();
  27171. };
  27172. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  27173. this._gl.deleteQuery(query);
  27174. return this;
  27175. };
  27176. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  27177. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  27178. };
  27179. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  27180. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  27181. };
  27182. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  27183. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27184. this._gl.beginQuery(glAlgorithm, query);
  27185. return this;
  27186. };
  27187. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  27188. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27189. this._gl.endQuery(glAlgorithm);
  27190. return this;
  27191. };
  27192. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  27193. var timerQuery = this.getCaps().timerQuery;
  27194. if (timerQuery.createQueryEXT) {
  27195. return timerQuery.createQueryEXT();
  27196. }
  27197. return this.createQuery();
  27198. };
  27199. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  27200. var timerQuery = this.getCaps().timerQuery;
  27201. if (timerQuery.deleteQueryEXT) {
  27202. timerQuery.deleteQueryEXT(query);
  27203. return;
  27204. }
  27205. this.deleteQuery(query);
  27206. };
  27207. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  27208. var timerQuery = this.getCaps().timerQuery;
  27209. if (timerQuery.getQueryObjectEXT) {
  27210. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  27211. }
  27212. return this.getQueryResult(query);
  27213. };
  27214. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  27215. var timerQuery = this.getCaps().timerQuery;
  27216. if (timerQuery.getQueryObjectEXT) {
  27217. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  27218. }
  27219. return this.isQueryResultAvailable(query);
  27220. };
  27221. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  27222. var caps = this.getCaps();
  27223. var timerQuery = caps.timerQuery;
  27224. if (!timerQuery) {
  27225. return null;
  27226. }
  27227. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  27228. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27229. if (caps.canUseTimestampForTimerQuery) {
  27230. token._startTimeQuery = this._createTimeQuery();
  27231. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  27232. }
  27233. else {
  27234. if (this._currentNonTimestampToken) {
  27235. return this._currentNonTimestampToken;
  27236. }
  27237. token._timeElapsedQuery = this._createTimeQuery();
  27238. if (timerQuery.beginQueryEXT) {
  27239. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27240. }
  27241. else {
  27242. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27243. }
  27244. this._currentNonTimestampToken = token;
  27245. }
  27246. return token;
  27247. };
  27248. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  27249. var caps = this.getCaps();
  27250. var timerQuery = caps.timerQuery;
  27251. if (!timerQuery || !token) {
  27252. return -1;
  27253. }
  27254. if (caps.canUseTimestampForTimerQuery) {
  27255. if (!token._startTimeQuery) {
  27256. return -1;
  27257. }
  27258. if (!token._endTimeQuery) {
  27259. token._endTimeQuery = this._createTimeQuery();
  27260. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  27261. }
  27262. }
  27263. else if (!token._timeElapsedQueryEnded) {
  27264. if (!token._timeElapsedQuery) {
  27265. return -1;
  27266. }
  27267. if (timerQuery.endQueryEXT) {
  27268. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  27269. }
  27270. else {
  27271. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  27272. }
  27273. token._timeElapsedQueryEnded = true;
  27274. }
  27275. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27276. var available = false;
  27277. if (token._endTimeQuery) {
  27278. available = this._getTimeQueryAvailability(token._endTimeQuery);
  27279. }
  27280. else if (token._timeElapsedQuery) {
  27281. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  27282. }
  27283. if (available && !disjoint) {
  27284. var result = 0;
  27285. if (caps.canUseTimestampForTimerQuery) {
  27286. if (!token._startTimeQuery || !token._endTimeQuery) {
  27287. return -1;
  27288. }
  27289. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  27290. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  27291. result = timeEnd - timeStart;
  27292. this._deleteTimeQuery(token._startTimeQuery);
  27293. this._deleteTimeQuery(token._endTimeQuery);
  27294. token._startTimeQuery = null;
  27295. token._endTimeQuery = null;
  27296. }
  27297. else {
  27298. if (!token._timeElapsedQuery) {
  27299. return -1;
  27300. }
  27301. result = this._getTimeQueryResult(token._timeElapsedQuery);
  27302. this._deleteTimeQuery(token._timeElapsedQuery);
  27303. token._timeElapsedQuery = null;
  27304. token._timeElapsedQueryEnded = false;
  27305. this._currentNonTimestampToken = null;
  27306. }
  27307. return result;
  27308. }
  27309. return -1;
  27310. };
  27311. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  27312. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  27313. };
  27314. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  27315. get: function () {
  27316. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  27317. },
  27318. enumerable: false,
  27319. configurable: true
  27320. });
  27321. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  27322. get: function () {
  27323. if (!this.__occlusionDataStorage) {
  27324. this.__occlusionDataStorage = new _OcclusionDataStorage();
  27325. }
  27326. return this.__occlusionDataStorage;
  27327. },
  27328. enumerable: false,
  27329. configurable: true
  27330. });
  27331. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  27332. get: function () {
  27333. return this._occlusionDataStorage.isOccluded;
  27334. },
  27335. set: function (value) {
  27336. this._occlusionDataStorage.isOccluded = value;
  27337. },
  27338. enumerable: true,
  27339. configurable: true
  27340. });
  27341. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  27342. get: function () {
  27343. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  27344. },
  27345. set: function (value) {
  27346. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  27347. },
  27348. enumerable: true,
  27349. configurable: true
  27350. });
  27351. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  27352. get: function () {
  27353. return this._occlusionDataStorage.occlusionType;
  27354. },
  27355. set: function (value) {
  27356. this._occlusionDataStorage.occlusionType = value;
  27357. },
  27358. enumerable: true,
  27359. configurable: true
  27360. });
  27361. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  27362. get: function () {
  27363. return this._occlusionDataStorage.occlusionRetryCount;
  27364. },
  27365. set: function (value) {
  27366. this._occlusionDataStorage.occlusionRetryCount = value;
  27367. },
  27368. enumerable: true,
  27369. configurable: true
  27370. });
  27371. // We also need to update AbstractMesh as there is a portion of the code there
  27372. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  27373. var dataStorage = this._occlusionDataStorage;
  27374. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  27375. dataStorage.isOccluded = false;
  27376. return false;
  27377. }
  27378. var engine = this.getEngine();
  27379. if (engine.webGLVersion < 2) {
  27380. dataStorage.isOccluded = false;
  27381. return false;
  27382. }
  27383. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  27384. dataStorage.isOccluded = false;
  27385. return false;
  27386. }
  27387. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  27388. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  27389. if (isOcclusionQueryAvailable) {
  27390. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  27391. dataStorage.isOcclusionQueryInProgress = false;
  27392. dataStorage.occlusionInternalRetryCounter = 0;
  27393. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  27394. }
  27395. else {
  27396. dataStorage.occlusionInternalRetryCounter++;
  27397. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  27398. dataStorage.isOcclusionQueryInProgress = false;
  27399. dataStorage.occlusionInternalRetryCounter = 0;
  27400. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  27401. // if strict continue the last state of the object.
  27402. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  27403. }
  27404. else {
  27405. return false;
  27406. }
  27407. }
  27408. }
  27409. var scene = this.getScene();
  27410. if (scene.getBoundingBoxRenderer) {
  27411. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  27412. if (!this._occlusionQuery) {
  27413. this._occlusionQuery = engine.createQuery();
  27414. }
  27415. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  27416. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  27417. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  27418. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  27419. }
  27420. return dataStorage.isOccluded;
  27421. };
  27422. /***/ }),
  27423. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  27424. /*!********************************************************!*\
  27425. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  27426. \********************************************************/
  27427. /*! exports provided: _forceTransformFeedbackToBundle */
  27428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27429. "use strict";
  27430. __webpack_require__.r(__webpack_exports__);
  27431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  27432. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27433. /** @hidden */
  27434. var _forceTransformFeedbackToBundle = true;
  27435. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  27436. return this._gl.createTransformFeedback();
  27437. };
  27438. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  27439. this._gl.deleteTransformFeedback(value);
  27440. };
  27441. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  27442. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  27443. };
  27444. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  27445. if (usePoints === void 0) { usePoints = true; }
  27446. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  27447. };
  27448. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  27449. this._gl.endTransformFeedback();
  27450. };
  27451. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  27452. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  27453. };
  27454. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  27455. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  27456. };
  27457. /***/ }),
  27458. /***/ "./Engines/Extensions/index.ts":
  27459. /*!*************************************!*\
  27460. !*** ./Engines/Extensions/index.ts ***!
  27461. \*************************************/
  27462. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  27463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27464. "use strict";
  27465. __webpack_require__.r(__webpack_exports__);
  27466. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  27467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  27468. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  27469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  27470. /***/ }),
  27471. /***/ "./Engines/constants.ts":
  27472. /*!******************************!*\
  27473. !*** ./Engines/constants.ts ***!
  27474. \******************************/
  27475. /*! exports provided: Constants */
  27476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27477. "use strict";
  27478. __webpack_require__.r(__webpack_exports__);
  27479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  27480. /** Defines the cross module used constants to avoid circular dependncies */
  27481. var Constants = /** @class */ (function () {
  27482. function Constants() {
  27483. }
  27484. /** Defines that alpha blending is disabled */
  27485. Constants.ALPHA_DISABLE = 0;
  27486. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27487. Constants.ALPHA_ADD = 1;
  27488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27489. Constants.ALPHA_COMBINE = 2;
  27490. /** Defines that alpha blending to DEST - SRC * DEST */
  27491. Constants.ALPHA_SUBTRACT = 3;
  27492. /** Defines that alpha blending to SRC * DEST */
  27493. Constants.ALPHA_MULTIPLY = 4;
  27494. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27495. Constants.ALPHA_MAXIMIZED = 5;
  27496. /** Defines that alpha blending to SRC + DEST */
  27497. Constants.ALPHA_ONEONE = 6;
  27498. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27499. Constants.ALPHA_PREMULTIPLIED = 7;
  27500. /**
  27501. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27502. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27503. */
  27504. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27505. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27506. Constants.ALPHA_INTERPOLATE = 9;
  27507. /**
  27508. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27509. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27510. */
  27511. Constants.ALPHA_SCREENMODE = 10;
  27512. /** Defines that the ressource is not delayed*/
  27513. Constants.DELAYLOADSTATE_NONE = 0;
  27514. /** Defines that the ressource was successfully delay loaded */
  27515. Constants.DELAYLOADSTATE_LOADED = 1;
  27516. /** Defines that the ressource is currently delay loading */
  27517. Constants.DELAYLOADSTATE_LOADING = 2;
  27518. /** Defines that the ressource is delayed and has not started loading */
  27519. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27520. // Depht or Stencil test Constants.
  27521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27522. Constants.NEVER = 0x0200;
  27523. /** 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 */
  27524. Constants.ALWAYS = 0x0207;
  27525. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27526. Constants.LESS = 0x0201;
  27527. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27528. Constants.EQUAL = 0x0202;
  27529. /** 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 */
  27530. Constants.LEQUAL = 0x0203;
  27531. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27532. Constants.GREATER = 0x0204;
  27533. /** 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 */
  27534. Constants.GEQUAL = 0x0206;
  27535. /** 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 */
  27536. Constants.NOTEQUAL = 0x0205;
  27537. // Stencil Actions Constants.
  27538. /** Passed to stencilOperation to specify that stencil value must be kept */
  27539. Constants.KEEP = 0x1E00;
  27540. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27541. Constants.REPLACE = 0x1E01;
  27542. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27543. Constants.INCR = 0x1E02;
  27544. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27545. Constants.DECR = 0x1E03;
  27546. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27547. Constants.INVERT = 0x150A;
  27548. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27549. Constants.INCR_WRAP = 0x8507;
  27550. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27551. Constants.DECR_WRAP = 0x8508;
  27552. /** Texture is not repeating outside of 0..1 UVs */
  27553. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27554. /** Texture is repeating outside of 0..1 UVs */
  27555. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27556. /** Texture is repeating and mirrored */
  27557. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27558. /** ALPHA */
  27559. Constants.TEXTUREFORMAT_ALPHA = 0;
  27560. /** LUMINANCE */
  27561. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27562. /** LUMINANCE_ALPHA */
  27563. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27564. /** RGB */
  27565. Constants.TEXTUREFORMAT_RGB = 4;
  27566. /** RGBA */
  27567. Constants.TEXTUREFORMAT_RGBA = 5;
  27568. /** RED */
  27569. Constants.TEXTUREFORMAT_RED = 6;
  27570. /** RED (2nd reference) */
  27571. Constants.TEXTUREFORMAT_R = 6;
  27572. /** RG */
  27573. Constants.TEXTUREFORMAT_RG = 7;
  27574. /** RED_INTEGER */
  27575. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27576. /** RED_INTEGER (2nd reference) */
  27577. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27578. /** RG_INTEGER */
  27579. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27580. /** RGB_INTEGER */
  27581. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27582. /** RGBA_INTEGER */
  27583. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27584. /** UNSIGNED_BYTE */
  27585. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27586. /** UNSIGNED_BYTE (2nd reference) */
  27587. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27588. /** FLOAT */
  27589. Constants.TEXTURETYPE_FLOAT = 1;
  27590. /** HALF_FLOAT */
  27591. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27592. /** BYTE */
  27593. Constants.TEXTURETYPE_BYTE = 3;
  27594. /** SHORT */
  27595. Constants.TEXTURETYPE_SHORT = 4;
  27596. /** UNSIGNED_SHORT */
  27597. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27598. /** INT */
  27599. Constants.TEXTURETYPE_INT = 6;
  27600. /** UNSIGNED_INT */
  27601. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27602. /** UNSIGNED_SHORT_4_4_4_4 */
  27603. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27604. /** UNSIGNED_SHORT_5_5_5_1 */
  27605. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27606. /** UNSIGNED_SHORT_5_6_5 */
  27607. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27608. /** UNSIGNED_INT_2_10_10_10_REV */
  27609. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27610. /** UNSIGNED_INT_24_8 */
  27611. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27612. /** UNSIGNED_INT_10F_11F_11F_REV */
  27613. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27614. /** UNSIGNED_INT_5_9_9_9_REV */
  27615. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27616. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27617. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27618. /** nearest is mag = nearest and min = nearest and mip = linear */
  27619. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27620. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27621. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27622. /** Trilinear is mag = linear and min = linear and mip = linear */
  27623. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27624. /** nearest is mag = nearest and min = nearest and mip = linear */
  27625. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27626. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27627. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27628. /** Trilinear is mag = linear and min = linear and mip = linear */
  27629. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27630. /** mag = nearest and min = nearest and mip = nearest */
  27631. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27632. /** mag = nearest and min = linear and mip = nearest */
  27633. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27634. /** mag = nearest and min = linear and mip = linear */
  27635. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27636. /** mag = nearest and min = linear and mip = none */
  27637. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27638. /** mag = nearest and min = nearest and mip = none */
  27639. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27640. /** mag = linear and min = nearest and mip = nearest */
  27641. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27642. /** mag = linear and min = nearest and mip = linear */
  27643. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27644. /** mag = linear and min = linear and mip = none */
  27645. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27646. /** mag = linear and min = nearest and mip = none */
  27647. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27648. /** Explicit coordinates mode */
  27649. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27650. /** Spherical coordinates mode */
  27651. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27652. /** Planar coordinates mode */
  27653. Constants.TEXTURE_PLANAR_MODE = 2;
  27654. /** Cubic coordinates mode */
  27655. Constants.TEXTURE_CUBIC_MODE = 3;
  27656. /** Projection coordinates mode */
  27657. Constants.TEXTURE_PROJECTION_MODE = 4;
  27658. /** Skybox coordinates mode */
  27659. Constants.TEXTURE_SKYBOX_MODE = 5;
  27660. /** Inverse Cubic coordinates mode */
  27661. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27662. /** Equirectangular coordinates mode */
  27663. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27664. /** Equirectangular Fixed coordinates mode */
  27665. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27666. /** Equirectangular Fixed Mirrored coordinates mode */
  27667. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27668. // Texture rescaling mode
  27669. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27670. Constants.SCALEMODE_FLOOR = 1;
  27671. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27672. Constants.SCALEMODE_NEAREST = 2;
  27673. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27674. Constants.SCALEMODE_CEILING = 3;
  27675. /**
  27676. * The dirty texture flag value
  27677. */
  27678. Constants.MATERIAL_TextureDirtyFlag = 1;
  27679. /**
  27680. * The dirty light flag value
  27681. */
  27682. Constants.MATERIAL_LightDirtyFlag = 2;
  27683. /**
  27684. * The dirty fresnel flag value
  27685. */
  27686. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27687. /**
  27688. * The dirty attribute flag value
  27689. */
  27690. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27691. /**
  27692. * The dirty misc flag value
  27693. */
  27694. Constants.MATERIAL_MiscDirtyFlag = 16;
  27695. /**
  27696. * The all dirty flag value
  27697. */
  27698. Constants.MATERIAL_AllDirtyFlag = 31;
  27699. /**
  27700. * Returns the triangle fill mode
  27701. */
  27702. Constants.MATERIAL_TriangleFillMode = 0;
  27703. /**
  27704. * Returns the wireframe mode
  27705. */
  27706. Constants.MATERIAL_WireFrameFillMode = 1;
  27707. /**
  27708. * Returns the point fill mode
  27709. */
  27710. Constants.MATERIAL_PointFillMode = 2;
  27711. /**
  27712. * Returns the point list draw mode
  27713. */
  27714. Constants.MATERIAL_PointListDrawMode = 3;
  27715. /**
  27716. * Returns the line list draw mode
  27717. */
  27718. Constants.MATERIAL_LineListDrawMode = 4;
  27719. /**
  27720. * Returns the line loop draw mode
  27721. */
  27722. Constants.MATERIAL_LineLoopDrawMode = 5;
  27723. /**
  27724. * Returns the line strip draw mode
  27725. */
  27726. Constants.MATERIAL_LineStripDrawMode = 6;
  27727. /**
  27728. * Returns the triangle strip draw mode
  27729. */
  27730. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27731. /**
  27732. * Returns the triangle fan draw mode
  27733. */
  27734. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27735. /**
  27736. * Stores the clock-wise side orientation
  27737. */
  27738. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27739. /**
  27740. * Stores the counter clock-wise side orientation
  27741. */
  27742. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27743. /**
  27744. * Nothing
  27745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27746. */
  27747. Constants.ACTION_NothingTrigger = 0;
  27748. /**
  27749. * On pick
  27750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27751. */
  27752. Constants.ACTION_OnPickTrigger = 1;
  27753. /**
  27754. * On left pick
  27755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27756. */
  27757. Constants.ACTION_OnLeftPickTrigger = 2;
  27758. /**
  27759. * On right pick
  27760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27761. */
  27762. Constants.ACTION_OnRightPickTrigger = 3;
  27763. /**
  27764. * On center pick
  27765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27766. */
  27767. Constants.ACTION_OnCenterPickTrigger = 4;
  27768. /**
  27769. * On pick down
  27770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27771. */
  27772. Constants.ACTION_OnPickDownTrigger = 5;
  27773. /**
  27774. * On double pick
  27775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27776. */
  27777. Constants.ACTION_OnDoublePickTrigger = 6;
  27778. /**
  27779. * On pick up
  27780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27781. */
  27782. Constants.ACTION_OnPickUpTrigger = 7;
  27783. /**
  27784. * On pick out.
  27785. * This trigger will only be raised if you also declared a OnPickDown
  27786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27787. */
  27788. Constants.ACTION_OnPickOutTrigger = 16;
  27789. /**
  27790. * On long press
  27791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27792. */
  27793. Constants.ACTION_OnLongPressTrigger = 8;
  27794. /**
  27795. * On pointer over
  27796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27797. */
  27798. Constants.ACTION_OnPointerOverTrigger = 9;
  27799. /**
  27800. * On pointer out
  27801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27802. */
  27803. Constants.ACTION_OnPointerOutTrigger = 10;
  27804. /**
  27805. * On every frame
  27806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27807. */
  27808. Constants.ACTION_OnEveryFrameTrigger = 11;
  27809. /**
  27810. * On intersection enter
  27811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27812. */
  27813. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27814. /**
  27815. * On intersection exit
  27816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27817. */
  27818. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27819. /**
  27820. * On key down
  27821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27822. */
  27823. Constants.ACTION_OnKeyDownTrigger = 14;
  27824. /**
  27825. * On key up
  27826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27827. */
  27828. Constants.ACTION_OnKeyUpTrigger = 15;
  27829. /**
  27830. * Billboard mode will only apply to Y axis
  27831. */
  27832. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27833. /**
  27834. * Billboard mode will apply to all axes
  27835. */
  27836. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27837. /**
  27838. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27839. */
  27840. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27841. /**
  27842. * Gets or sets base Assets URL
  27843. */
  27844. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27845. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27846. * Test order :
  27847. * Is the bounding sphere outside the frustum ?
  27848. * If not, are the bounding box vertices outside the frustum ?
  27849. * It not, then the cullable object is in the frustum.
  27850. */
  27851. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27852. /** Culling strategy : Bounding Sphere Only.
  27853. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27854. * It's also less accurate than the standard because some not visible objects can still be selected.
  27855. * Test : is the bounding sphere outside the frustum ?
  27856. * If not, then the cullable object is in the frustum.
  27857. */
  27858. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27859. /** Culling strategy : Optimistic Inclusion.
  27860. * This in an inclusion test first, then the standard exclusion test.
  27861. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27862. * 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.
  27863. * Anyway, it's as accurate as the standard strategy.
  27864. * Test :
  27865. * Is the cullable object bounding sphere center in the frustum ?
  27866. * If not, apply the default culling strategy.
  27867. */
  27868. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27869. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27870. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27871. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27872. * 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.
  27873. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27874. * Test :
  27875. * Is the cullable object bounding sphere center in the frustum ?
  27876. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27877. */
  27878. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27879. /**
  27880. * No logging while loading
  27881. */
  27882. Constants.SCENELOADER_NO_LOGGING = 0;
  27883. /**
  27884. * Minimal logging while loading
  27885. */
  27886. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  27887. /**
  27888. * Summary logging while loading
  27889. */
  27890. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  27891. /**
  27892. * Detailled logging while loading
  27893. */
  27894. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  27895. return Constants;
  27896. }());
  27897. /***/ }),
  27898. /***/ "./Engines/engine.ts":
  27899. /*!***************************!*\
  27900. !*** ./Engines/engine.ts ***!
  27901. \***************************/
  27902. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  27903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27904. "use strict";
  27905. __webpack_require__.r(__webpack_exports__);
  27906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  27907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  27908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  27909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  27910. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27911. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27912. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  27913. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  27914. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  27915. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27916. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27917. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  27918. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  27919. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  27920. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  27921. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27922. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  27923. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  27924. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  27925. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  27926. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  27927. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  27928. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  27929. /**
  27930. * Keeps track of all the buffer info used in engine.
  27931. */
  27932. var BufferPointer = /** @class */ (function () {
  27933. function BufferPointer() {
  27934. }
  27935. return BufferPointer;
  27936. }());
  27937. /**
  27938. * Interface for attribute information associated with buffer instanciation
  27939. */
  27940. var InstancingAttributeInfo = /** @class */ (function () {
  27941. function InstancingAttributeInfo() {
  27942. }
  27943. return InstancingAttributeInfo;
  27944. }());
  27945. /**
  27946. * Define options used to create a depth texture
  27947. */
  27948. var DepthTextureCreationOptions = /** @class */ (function () {
  27949. function DepthTextureCreationOptions() {
  27950. }
  27951. return DepthTextureCreationOptions;
  27952. }());
  27953. /**
  27954. * Class used to describe the capabilities of the engine relatively to the current browser
  27955. */
  27956. var EngineCapabilities = /** @class */ (function () {
  27957. function EngineCapabilities() {
  27958. }
  27959. return EngineCapabilities;
  27960. }());
  27961. /**
  27962. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27963. */
  27964. var Engine = /** @class */ (function () {
  27965. /**
  27966. * Creates a new engine
  27967. * @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
  27968. * @param antialias defines enable antialiasing (default: false)
  27969. * @param options defines further options to be sent to the getContext() function
  27970. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27971. */
  27972. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  27973. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  27974. var _this = this;
  27975. // Public members
  27976. /**
  27977. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27978. */
  27979. this.forcePOTTextures = false;
  27980. /**
  27981. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27982. */
  27983. this.isFullscreen = false;
  27984. /**
  27985. * Gets a boolean indicating if the pointer is currently locked
  27986. */
  27987. this.isPointerLock = false;
  27988. /**
  27989. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27990. */
  27991. this.cullBackFaces = true;
  27992. /**
  27993. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27994. */
  27995. this.renderEvenInBackground = true;
  27996. /**
  27997. * Gets or sets a boolean indicating that cache can be kept between frames
  27998. */
  27999. this.preventCacheWipeBetweenFrames = false;
  28000. /**
  28001. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28002. **/
  28003. this.enableOfflineSupport = false;
  28004. /**
  28005. * 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)
  28006. **/
  28007. this.disableManifestCheck = false;
  28008. /**
  28009. * Gets the list of created scenes
  28010. */
  28011. this.scenes = new Array();
  28012. /**
  28013. * Event raised when a new scene is created
  28014. */
  28015. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28016. /**
  28017. * Gets the list of created postprocesses
  28018. */
  28019. this.postProcesses = new Array();
  28020. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28021. this.validateShaderPrograms = false;
  28022. // Observables
  28023. /**
  28024. * Observable event triggered each time the rendering canvas is resized
  28025. */
  28026. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28027. /**
  28028. * Observable event triggered each time the canvas loses focus
  28029. */
  28030. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28031. /**
  28032. * Observable event triggered each time the canvas gains focus
  28033. */
  28034. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28035. /**
  28036. * Observable event triggered each time the canvas receives pointerout event
  28037. */
  28038. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28039. /**
  28040. * Observable event triggered before each texture is initialized
  28041. */
  28042. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28043. //WebVR
  28044. this._vrDisplay = undefined;
  28045. this._vrSupported = false;
  28046. this._vrExclusivePointerMode = false;
  28047. // Uniform buffers list
  28048. /**
  28049. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28050. */
  28051. this.disableUniformBuffers = false;
  28052. /** @hidden */
  28053. this._uniformBuffers = new Array();
  28054. // Observables
  28055. /**
  28056. * Observable raised when the engine begins a new frame
  28057. */
  28058. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28059. /**
  28060. * If set, will be used to request the next animation frame for the render loop
  28061. */
  28062. this.customAnimationFrameRequester = null;
  28063. /**
  28064. * Observable raised when the engine ends the current frame
  28065. */
  28066. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28067. /**
  28068. * Observable raised when the engine is about to compile a shader
  28069. */
  28070. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28071. /**
  28072. * Observable raised when the engine has jsut compiled a shader
  28073. */
  28074. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28075. this._windowIsBackground = false;
  28076. this._webGLVersion = 1.0;
  28077. /** @hidden */
  28078. this._badOS = false;
  28079. /** @hidden */
  28080. this._badDesktopOS = false;
  28081. /**
  28082. * Gets or sets a value indicating if we want to disable texture binding optimization.
  28083. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  28084. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  28085. */
  28086. this.disableTextureBindingOptimization = false;
  28087. /**
  28088. * Observable signaled when VR display mode changes
  28089. */
  28090. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28091. /**
  28092. * Observable signaled when VR request present is complete
  28093. */
  28094. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28095. /**
  28096. * Observable signaled when VR request present starts
  28097. */
  28098. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28099. this._colorWrite = true;
  28100. /** @hidden */
  28101. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28102. /** @hidden */
  28103. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28104. this._renderingQueueLaunched = false;
  28105. this._activeRenderLoops = new Array();
  28106. // Deterministic lockstepMaxSteps
  28107. this._deterministicLockstep = false;
  28108. this._lockstepMaxSteps = 4;
  28109. // Lost context
  28110. /**
  28111. * Observable signaled when a context lost event is raised
  28112. */
  28113. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28114. /**
  28115. * Observable signaled when a context restored event is raised
  28116. */
  28117. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28118. this._contextWasLost = false;
  28119. this._doNotHandleContextLost = false;
  28120. // FPS
  28121. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  28122. this._fps = 60;
  28123. this._deltaTime = 0;
  28124. /**
  28125. * Turn this value on if you want to pause FPS computation when in background
  28126. */
  28127. this.disablePerformanceMonitorInBackground = false;
  28128. // States
  28129. /** @hidden */
  28130. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  28131. /** @hidden */
  28132. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  28133. /** @hidden */
  28134. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  28135. /** @hidden */
  28136. this._alphaMode = Engine.ALPHA_DISABLE;
  28137. // Cache
  28138. this._internalTexturesCache = new Array();
  28139. /** @hidden */
  28140. this._activeChannel = 0;
  28141. this._currentTextureChannel = -1;
  28142. /** @hidden */
  28143. this._boundTexturesCache = {};
  28144. this._compiledEffects = {};
  28145. this._vertexAttribArraysEnabled = [];
  28146. this._uintIndicesCurrentlySet = false;
  28147. this._currentBoundBuffer = new Array();
  28148. /** @hidden */
  28149. this._currentFramebuffer = null;
  28150. this._currentBufferPointers = new Array();
  28151. this._currentInstanceLocations = new Array();
  28152. this._currentInstanceBuffers = new Array();
  28153. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28154. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28155. this._vaoRecordInProgress = false;
  28156. this._mustWipeVertexAttributes = false;
  28157. this._nextFreeTextureSlots = new Array();
  28158. this._maxSimultaneousTextures = 0;
  28159. this._activeRequests = new Array();
  28160. // Hardware supported Compressed Textures
  28161. this._texturesSupported = new Array();
  28162. /**
  28163. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28164. */
  28165. this.premultipliedAlpha = true;
  28166. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  28167. this._onVRFullScreenTriggered = function () {
  28168. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  28169. //get the old size before we change
  28170. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  28171. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  28172. //get the width and height, change the render size
  28173. var leftEye = _this._vrDisplay.getEyeParameters('left');
  28174. _this.setHardwareScalingLevel(1);
  28175. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  28176. }
  28177. else {
  28178. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  28179. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  28180. }
  28181. };
  28182. this._unpackFlipYCached = null;
  28183. /**
  28184. * In case you are sharing the context with other applications, it might
  28185. * be interested to not cache the unpack flip y state to ensure a consistent
  28186. * value would be set.
  28187. */
  28188. this.enableUnpackFlipYCached = true;
  28189. this._boundUniforms = {};
  28190. // Register promises
  28191. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  28192. var canvas = null;
  28193. Engine.Instances.push(this);
  28194. if (!canvasOrContext) {
  28195. return;
  28196. }
  28197. options = options || {};
  28198. if (canvasOrContext.getContext) {
  28199. canvas = canvasOrContext;
  28200. this._renderingCanvas = canvas;
  28201. if (antialias != null) {
  28202. options.antialias = antialias;
  28203. }
  28204. if (options.deterministicLockstep === undefined) {
  28205. options.deterministicLockstep = false;
  28206. }
  28207. if (options.lockstepMaxSteps === undefined) {
  28208. options.lockstepMaxSteps = 4;
  28209. }
  28210. if (options.preserveDrawingBuffer === undefined) {
  28211. options.preserveDrawingBuffer = false;
  28212. }
  28213. if (options.audioEngine === undefined) {
  28214. options.audioEngine = true;
  28215. }
  28216. if (options.stencil === undefined) {
  28217. options.stencil = true;
  28218. }
  28219. if (options.premultipliedAlpha === false) {
  28220. this.premultipliedAlpha = false;
  28221. }
  28222. this._deterministicLockstep = options.deterministicLockstep;
  28223. this._lockstepMaxSteps = options.lockstepMaxSteps;
  28224. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  28225. // Exceptions
  28226. if (navigator && navigator.userAgent) {
  28227. var ua = navigator.userAgent;
  28228. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  28229. var exception = _a[_i];
  28230. var key = exception.key;
  28231. var targets = exception.targets;
  28232. if (ua.indexOf(key) > -1) {
  28233. if (exception.capture && exception.captureConstraint) {
  28234. var capture = exception.capture;
  28235. var constraint = exception.captureConstraint;
  28236. var regex = new RegExp(capture);
  28237. var matches = regex.exec(ua);
  28238. if (matches && matches.length > 0) {
  28239. var capturedValue = parseInt(matches[matches.length - 1]);
  28240. if (capturedValue >= constraint) {
  28241. continue;
  28242. }
  28243. }
  28244. }
  28245. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  28246. var target = targets_1[_b];
  28247. switch (target) {
  28248. case "uniformBuffer":
  28249. this.disableUniformBuffers = true;
  28250. break;
  28251. case "textureBindingOptimization":
  28252. this.disableTextureBindingOptimization = true;
  28253. break;
  28254. }
  28255. }
  28256. }
  28257. }
  28258. }
  28259. // GL
  28260. if (!options.disableWebGL2Support) {
  28261. try {
  28262. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  28263. if (this._gl) {
  28264. this._webGLVersion = 2.0;
  28265. // Prevent weird browsers to lie :-)
  28266. if (!this._gl.deleteQuery) {
  28267. this._webGLVersion = 1.0;
  28268. }
  28269. }
  28270. }
  28271. catch (e) {
  28272. // Do nothing
  28273. }
  28274. }
  28275. if (!this._gl) {
  28276. if (!canvas) {
  28277. throw new Error("The provided canvas is null or undefined.");
  28278. }
  28279. try {
  28280. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  28281. }
  28282. catch (e) {
  28283. throw new Error("WebGL not supported");
  28284. }
  28285. }
  28286. if (!this._gl) {
  28287. throw new Error("WebGL not supported");
  28288. }
  28289. // Ensures a consistent color space unpacking of textures cross browser.
  28290. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  28291. this._onCanvasFocus = function () {
  28292. _this.onCanvasFocusObservable.notifyObservers(_this);
  28293. };
  28294. this._onCanvasBlur = function () {
  28295. _this.onCanvasBlurObservable.notifyObservers(_this);
  28296. };
  28297. canvas.addEventListener("focus", this._onCanvasFocus);
  28298. canvas.addEventListener("blur", this._onCanvasBlur);
  28299. this._onBlur = function () {
  28300. if (_this.disablePerformanceMonitorInBackground) {
  28301. _this._performanceMonitor.disable();
  28302. }
  28303. _this._windowIsBackground = true;
  28304. };
  28305. this._onFocus = function () {
  28306. if (_this.disablePerformanceMonitorInBackground) {
  28307. _this._performanceMonitor.enable();
  28308. }
  28309. _this._windowIsBackground = false;
  28310. };
  28311. this._onCanvasPointerOut = function (ev) {
  28312. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  28313. };
  28314. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28315. window.addEventListener("blur", this._onBlur);
  28316. window.addEventListener("focus", this._onFocus);
  28317. }
  28318. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  28319. // Context lost
  28320. if (!this._doNotHandleContextLost) {
  28321. this._onContextLost = function (evt) {
  28322. evt.preventDefault();
  28323. _this._contextWasLost = true;
  28324. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  28325. _this.onContextLostObservable.notifyObservers(_this);
  28326. };
  28327. this._onContextRestored = function () {
  28328. // Adding a timeout to avoid race condition at browser level
  28329. setTimeout(function () {
  28330. // Rebuild gl context
  28331. _this._initGLContext();
  28332. // Rebuild effects
  28333. _this._rebuildEffects();
  28334. // Rebuild textures
  28335. _this._rebuildInternalTextures();
  28336. // Rebuild buffers
  28337. _this._rebuildBuffers();
  28338. // Cache
  28339. _this.wipeCaches(true);
  28340. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  28341. _this.onContextRestoredObservable.notifyObservers(_this);
  28342. _this._contextWasLost = false;
  28343. }, 0);
  28344. };
  28345. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  28346. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  28347. }
  28348. if (!options.doNotHandleTouchAction) {
  28349. this._disableTouchAction();
  28350. }
  28351. }
  28352. else {
  28353. this._gl = canvasOrContext;
  28354. this._renderingCanvas = this._gl.canvas;
  28355. if (this._gl.renderbufferStorageMultisample) {
  28356. this._webGLVersion = 2.0;
  28357. }
  28358. var attributes = this._gl.getContextAttributes();
  28359. if (attributes) {
  28360. options.stencil = attributes.stencil;
  28361. }
  28362. }
  28363. // Viewport
  28364. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  28365. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  28366. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  28367. this.resize();
  28368. this._isStencilEnable = options.stencil ? true : false;
  28369. this._initGLContext();
  28370. if (canvas) {
  28371. var anyDoc_1 = document;
  28372. // Fullscreen
  28373. this._onFullscreenChange = function () {
  28374. if (anyDoc_1.fullscreen !== undefined) {
  28375. _this.isFullscreen = anyDoc_1.fullscreen;
  28376. }
  28377. else if (anyDoc_1.mozFullScreen !== undefined) {
  28378. _this.isFullscreen = anyDoc_1.mozFullScreen;
  28379. }
  28380. else if (anyDoc_1.webkitIsFullScreen !== undefined) {
  28381. _this.isFullscreen = anyDoc_1.webkitIsFullScreen;
  28382. }
  28383. else if (anyDoc_1.msIsFullScreen !== undefined) {
  28384. _this.isFullscreen = anyDoc_1.msIsFullScreen;
  28385. }
  28386. // Pointer lock
  28387. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  28388. canvas.requestPointerLock = canvas.requestPointerLock ||
  28389. canvas.msRequestPointerLock ||
  28390. canvas.mozRequestPointerLock ||
  28391. canvas.webkitRequestPointerLock;
  28392. if (canvas.requestPointerLock) {
  28393. canvas.requestPointerLock();
  28394. }
  28395. }
  28396. };
  28397. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  28398. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  28399. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  28400. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  28401. // Pointer lock
  28402. this._onPointerLockChange = function () {
  28403. _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas ||
  28404. anyDoc_1.webkitPointerLockElement === canvas ||
  28405. anyDoc_1.msPointerLockElement === canvas ||
  28406. anyDoc_1.pointerLockElement === canvas);
  28407. };
  28408. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  28409. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  28410. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  28411. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  28412. this._onVRDisplayPointerRestricted = function () {
  28413. if (canvas) {
  28414. canvas.requestPointerLock();
  28415. }
  28416. };
  28417. this._onVRDisplayPointerUnrestricted = function () {
  28418. if (!anyDoc_1.exitPointerLock) {
  28419. return;
  28420. }
  28421. anyDoc_1.exitPointerLock();
  28422. };
  28423. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28424. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  28425. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  28426. }
  28427. }
  28428. // Create Audio Engine if needed.
  28429. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  28430. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  28431. }
  28432. // Prepare buffer pointers
  28433. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  28434. this._currentBufferPointers[i] = new BufferPointer();
  28435. }
  28436. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  28437. // Load WebVR Devices
  28438. if (options.autoEnableWebVR) {
  28439. this.initWebVR();
  28440. }
  28441. // Detect if we are running on a faulty buggy OS.
  28442. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  28443. // Detect if we are running on a faulty buggy desktop OS.
  28444. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  28445. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  28446. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  28447. }
  28448. Object.defineProperty(Engine, "Instances", {
  28449. /** Gets the list of created engines */
  28450. get: function () {
  28451. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  28452. },
  28453. enumerable: true,
  28454. configurable: true
  28455. });
  28456. Object.defineProperty(Engine, "LastCreatedEngine", {
  28457. /**
  28458. * Gets the latest created engine
  28459. */
  28460. get: function () {
  28461. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  28462. },
  28463. enumerable: true,
  28464. configurable: true
  28465. });
  28466. Object.defineProperty(Engine, "LastCreatedScene", {
  28467. /**
  28468. * Gets the latest created scene
  28469. */
  28470. get: function () {
  28471. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  28472. },
  28473. enumerable: true,
  28474. configurable: true
  28475. });
  28476. /**
  28477. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28478. * @param flag defines which part of the materials must be marked as dirty
  28479. * @param predicate defines a predicate used to filter which materials should be affected
  28480. */
  28481. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  28482. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  28483. var engine = Engine.Instances[engineIndex];
  28484. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  28485. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  28486. }
  28487. }
  28488. };
  28489. Object.defineProperty(Engine, "Version", {
  28490. /**
  28491. * Returns the current version of the framework
  28492. */
  28493. get: function () {
  28494. return "4.0.0-alpha.27";
  28495. },
  28496. enumerable: true,
  28497. configurable: true
  28498. });
  28499. Object.defineProperty(Engine.prototype, "description", {
  28500. /**
  28501. * Returns a string describing the current engine
  28502. */
  28503. get: function () {
  28504. var description = "WebGL" + this.webGLVersion;
  28505. if (this._caps.parallelShaderCompile) {
  28506. description += " - Parallel shader compilation";
  28507. }
  28508. return description;
  28509. },
  28510. enumerable: true,
  28511. configurable: true
  28512. });
  28513. Object.defineProperty(Engine, "ShadersRepository", {
  28514. /**
  28515. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28516. */
  28517. get: function () {
  28518. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28519. },
  28520. set: function (value) {
  28521. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28522. },
  28523. enumerable: true,
  28524. configurable: true
  28525. });
  28526. /**
  28527. * Method called to create the default loading screen.
  28528. * This can be overriden in your own app.
  28529. * @param canvas The rendering canvas element
  28530. * @returns The loading screen
  28531. */
  28532. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28533. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28534. };
  28535. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28536. /**
  28537. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28538. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28539. */
  28540. get: function () {
  28541. return this._vrExclusivePointerMode;
  28542. },
  28543. enumerable: true,
  28544. configurable: true
  28545. });
  28546. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28547. /**
  28548. * Gets a boolean indicating that the engine supports uniform buffers
  28549. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28550. */
  28551. get: function () {
  28552. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28553. },
  28554. enumerable: true,
  28555. configurable: true
  28556. });
  28557. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28558. /**
  28559. * Gets a boolean indicating that only power of 2 textures are supported
  28560. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28561. */
  28562. get: function () {
  28563. return this._webGLVersion < 2 || this.forcePOTTextures;
  28564. },
  28565. enumerable: true,
  28566. configurable: true
  28567. });
  28568. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28569. /**
  28570. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28571. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28572. */
  28573. get: function () {
  28574. return this._doNotHandleContextLost;
  28575. },
  28576. set: function (value) {
  28577. this._doNotHandleContextLost = value;
  28578. },
  28579. enumerable: true,
  28580. configurable: true
  28581. });
  28582. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28583. /**
  28584. * Gets the performance monitor attached to this engine
  28585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28586. */
  28587. get: function () {
  28588. return this._performanceMonitor;
  28589. },
  28590. enumerable: true,
  28591. configurable: true
  28592. });
  28593. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28594. /**
  28595. * Gets the list of texture formats supported
  28596. */
  28597. get: function () {
  28598. return this._texturesSupported;
  28599. },
  28600. enumerable: true,
  28601. configurable: true
  28602. });
  28603. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28604. /**
  28605. * Gets the list of texture formats in use
  28606. */
  28607. get: function () {
  28608. return this._textureFormatInUse;
  28609. },
  28610. enumerable: true,
  28611. configurable: true
  28612. });
  28613. Object.defineProperty(Engine.prototype, "currentViewport", {
  28614. /**
  28615. * Gets the current viewport
  28616. */
  28617. get: function () {
  28618. return this._cachedViewport;
  28619. },
  28620. enumerable: true,
  28621. configurable: true
  28622. });
  28623. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28624. /**
  28625. * Gets the default empty texture
  28626. */
  28627. get: function () {
  28628. if (!this._emptyTexture) {
  28629. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28630. }
  28631. return this._emptyTexture;
  28632. },
  28633. enumerable: true,
  28634. configurable: true
  28635. });
  28636. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28637. /**
  28638. * Gets the default empty 3D texture
  28639. */
  28640. get: function () {
  28641. if (!this._emptyTexture3D) {
  28642. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28643. }
  28644. return this._emptyTexture3D;
  28645. },
  28646. enumerable: true,
  28647. configurable: true
  28648. });
  28649. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28650. /**
  28651. * Gets the default empty cube texture
  28652. */
  28653. get: function () {
  28654. if (!this._emptyCubeTexture) {
  28655. var faceData = new Uint8Array(4);
  28656. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28657. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28658. }
  28659. return this._emptyCubeTexture;
  28660. },
  28661. enumerable: true,
  28662. configurable: true
  28663. });
  28664. Engine.prototype._disableTouchAction = function () {
  28665. if (!this._renderingCanvas) {
  28666. return;
  28667. }
  28668. this._renderingCanvas.setAttribute("touch-action", "none");
  28669. this._renderingCanvas.style.touchAction = "none";
  28670. this._renderingCanvas.style.msTouchAction = "none";
  28671. };
  28672. Engine.prototype._rebuildInternalTextures = function () {
  28673. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28674. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28675. var internalTexture = currentState_1[_i];
  28676. internalTexture._rebuild();
  28677. }
  28678. };
  28679. Engine.prototype._rebuildEffects = function () {
  28680. for (var key in this._compiledEffects) {
  28681. var effect = this._compiledEffects[key];
  28682. effect._prepareEffect();
  28683. }
  28684. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  28685. };
  28686. /**
  28687. * Gets a boolean indicating if all created effects are ready
  28688. * @returns true if all effects are ready
  28689. */
  28690. Engine.prototype.areAllEffectsReady = function () {
  28691. for (var key in this._compiledEffects) {
  28692. var effect = this._compiledEffects[key];
  28693. if (!effect.isReady()) {
  28694. return false;
  28695. }
  28696. }
  28697. return true;
  28698. };
  28699. Engine.prototype._rebuildBuffers = function () {
  28700. // Index / Vertex
  28701. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28702. var scene = _a[_i];
  28703. scene.resetCachedMaterial();
  28704. scene._rebuildGeometries();
  28705. scene._rebuildTextures();
  28706. }
  28707. // Uniforms
  28708. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28709. var uniformBuffer = _c[_b];
  28710. uniformBuffer._rebuild();
  28711. }
  28712. };
  28713. Engine.prototype._initGLContext = function () {
  28714. // Caps
  28715. this._caps = new EngineCapabilities();
  28716. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28717. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28718. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28719. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28720. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28721. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28722. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28723. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28724. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28725. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28726. // Infos
  28727. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28728. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28729. if (rendererInfo != null) {
  28730. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28731. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28732. }
  28733. if (!this._glVendor) {
  28734. this._glVendor = "Unknown vendor";
  28735. }
  28736. if (!this._glRenderer) {
  28737. this._glRenderer = "Unknown renderer";
  28738. }
  28739. // Constants
  28740. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28741. if (this._gl.RGBA16F !== 0x881A) {
  28742. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28743. }
  28744. if (this._gl.RGBA32F !== 0x8814) {
  28745. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28746. }
  28747. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28748. this._gl.DEPTH24_STENCIL8 = 35056;
  28749. }
  28750. // Extensions
  28751. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28752. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28753. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28754. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28755. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28756. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28757. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28758. 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');
  28759. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28760. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28761. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28762. this._caps.highPrecisionShaderSupported = false;
  28763. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28764. if (this._caps.timerQuery) {
  28765. if (this._webGLVersion === 1) {
  28766. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28767. }
  28768. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28769. }
  28770. // Checks if some of the format renders first to allow the use of webgl inspector.
  28771. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28772. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28773. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28774. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28775. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28776. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28777. if (this._webGLVersion > 1) {
  28778. this._gl.HALF_FLOAT_OES = 0x140B;
  28779. }
  28780. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28781. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28782. // Draw buffers
  28783. if (this._webGLVersion > 1) {
  28784. this._caps.drawBuffersExtension = true;
  28785. }
  28786. else {
  28787. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28788. if (drawBuffersExtension !== null) {
  28789. this._caps.drawBuffersExtension = true;
  28790. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28791. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28792. for (var i = 0; i < 16; i++) {
  28793. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28794. }
  28795. }
  28796. else {
  28797. this._caps.drawBuffersExtension = false;
  28798. }
  28799. }
  28800. // Shader compiler threads
  28801. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28802. if (this._caps.parallelShaderCompile) {
  28803. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  28804. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  28805. }
  28806. // Depth Texture
  28807. if (this._webGLVersion > 1) {
  28808. this._caps.depthTextureExtension = true;
  28809. }
  28810. else {
  28811. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28812. if (depthTextureExtension != null) {
  28813. this._caps.depthTextureExtension = true;
  28814. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28815. }
  28816. }
  28817. // Vertex array object
  28818. if (this._webGLVersion > 1) {
  28819. this._caps.vertexArrayObject = true;
  28820. }
  28821. else {
  28822. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28823. if (vertexArrayObjectExtension != null) {
  28824. this._caps.vertexArrayObject = true;
  28825. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28826. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28827. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28828. }
  28829. else {
  28830. this._caps.vertexArrayObject = false;
  28831. }
  28832. }
  28833. // Instances count
  28834. if (this._webGLVersion > 1) {
  28835. this._caps.instancedArrays = true;
  28836. }
  28837. else {
  28838. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28839. if (instanceExtension != null) {
  28840. this._caps.instancedArrays = true;
  28841. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28842. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28843. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28844. }
  28845. else {
  28846. this._caps.instancedArrays = false;
  28847. }
  28848. }
  28849. // Intelligently add supported compressed formats in order to check for.
  28850. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28851. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28852. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28853. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28854. if (this._caps.astc) {
  28855. this.texturesSupported.push('-astc.ktx');
  28856. }
  28857. if (this._caps.s3tc) {
  28858. this.texturesSupported.push('-dxt.ktx');
  28859. }
  28860. if (this._caps.pvrtc) {
  28861. this.texturesSupported.push('-pvrtc.ktx');
  28862. }
  28863. if (this._caps.etc2) {
  28864. this.texturesSupported.push('-etc2.ktx');
  28865. }
  28866. if (this._caps.etc1) {
  28867. this.texturesSupported.push('-etc1.ktx');
  28868. }
  28869. if (this._gl.getShaderPrecisionFormat) {
  28870. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  28871. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  28872. if (vertex_highp && fragment_highp) {
  28873. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  28874. }
  28875. }
  28876. // Depth buffer
  28877. this.setDepthBuffer(true);
  28878. this.setDepthFunctionToLessOrEqual();
  28879. this.setDepthWrite(true);
  28880. // Texture maps
  28881. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  28882. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28883. this._nextFreeTextureSlots.push(slot);
  28884. }
  28885. };
  28886. Object.defineProperty(Engine.prototype, "webGLVersion", {
  28887. /**
  28888. * Gets version of the current webGL context
  28889. */
  28890. get: function () {
  28891. return this._webGLVersion;
  28892. },
  28893. enumerable: true,
  28894. configurable: true
  28895. });
  28896. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  28897. /**
  28898. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28899. */
  28900. get: function () {
  28901. return this._isStencilEnable;
  28902. },
  28903. enumerable: true,
  28904. configurable: true
  28905. });
  28906. Engine.prototype._prepareWorkingCanvas = function () {
  28907. if (this._workingCanvas) {
  28908. return;
  28909. }
  28910. this._workingCanvas = document.createElement("canvas");
  28911. var context = this._workingCanvas.getContext("2d");
  28912. if (context) {
  28913. this._workingContext = context;
  28914. }
  28915. };
  28916. /**
  28917. * Reset the texture cache to empty state
  28918. */
  28919. Engine.prototype.resetTextureCache = function () {
  28920. for (var key in this._boundTexturesCache) {
  28921. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  28922. continue;
  28923. }
  28924. var boundTexture = this._boundTexturesCache[key];
  28925. if (boundTexture) {
  28926. this._removeDesignatedSlot(boundTexture);
  28927. }
  28928. this._boundTexturesCache[key] = null;
  28929. }
  28930. if (!this.disableTextureBindingOptimization) {
  28931. this._nextFreeTextureSlots = [];
  28932. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28933. this._nextFreeTextureSlots.push(slot);
  28934. }
  28935. }
  28936. this._currentTextureChannel = -1;
  28937. };
  28938. /**
  28939. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28940. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28941. * @returns true if engine is in deterministic lock step mode
  28942. */
  28943. Engine.prototype.isDeterministicLockStep = function () {
  28944. return this._deterministicLockstep;
  28945. };
  28946. /**
  28947. * Gets the max steps when engine is running in deterministic lock step
  28948. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28949. * @returns the max steps
  28950. */
  28951. Engine.prototype.getLockstepMaxSteps = function () {
  28952. return this._lockstepMaxSteps;
  28953. };
  28954. /**
  28955. * Gets an object containing information about the current webGL context
  28956. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28957. */
  28958. Engine.prototype.getGlInfo = function () {
  28959. return {
  28960. vendor: this._glVendor,
  28961. renderer: this._glRenderer,
  28962. version: this._glVersion
  28963. };
  28964. };
  28965. /**
  28966. * Gets current aspect ratio
  28967. * @param camera defines the camera to use to get the aspect ratio
  28968. * @param useScreen defines if screen size must be used (or the current render target if any)
  28969. * @returns a number defining the aspect ratio
  28970. */
  28971. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  28972. if (useScreen === void 0) { useScreen = false; }
  28973. var viewport = camera.viewport;
  28974. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  28975. };
  28976. /**
  28977. * Gets current screen aspect ratio
  28978. * @returns a number defining the aspect ratio
  28979. */
  28980. Engine.prototype.getScreenAspectRatio = function () {
  28981. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  28982. };
  28983. /**
  28984. * Gets the current render width
  28985. * @param useScreen defines if screen size must be used (or the current render target if any)
  28986. * @returns a number defining the current render width
  28987. */
  28988. Engine.prototype.getRenderWidth = function (useScreen) {
  28989. if (useScreen === void 0) { useScreen = false; }
  28990. if (!useScreen && this._currentRenderTarget) {
  28991. return this._currentRenderTarget.width;
  28992. }
  28993. return this._gl.drawingBufferWidth;
  28994. };
  28995. /**
  28996. * Gets the current render height
  28997. * @param useScreen defines if screen size must be used (or the current render target if any)
  28998. * @returns a number defining the current render height
  28999. */
  29000. Engine.prototype.getRenderHeight = function (useScreen) {
  29001. if (useScreen === void 0) { useScreen = false; }
  29002. if (!useScreen && this._currentRenderTarget) {
  29003. return this._currentRenderTarget.height;
  29004. }
  29005. return this._gl.drawingBufferHeight;
  29006. };
  29007. /**
  29008. * Gets the HTML canvas attached with the current webGL context
  29009. * @returns a HTML canvas
  29010. */
  29011. Engine.prototype.getRenderingCanvas = function () {
  29012. return this._renderingCanvas;
  29013. };
  29014. /**
  29015. * Gets the client rect of the HTML canvas attached with the current webGL context
  29016. * @returns a client rectanglee
  29017. */
  29018. Engine.prototype.getRenderingCanvasClientRect = function () {
  29019. if (!this._renderingCanvas) {
  29020. return null;
  29021. }
  29022. return this._renderingCanvas.getBoundingClientRect();
  29023. };
  29024. /**
  29025. * Defines the hardware scaling level.
  29026. * By default the hardware scaling level is computed from the window device ratio.
  29027. * 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.
  29028. * @param level defines the level to use
  29029. */
  29030. Engine.prototype.setHardwareScalingLevel = function (level) {
  29031. this._hardwareScalingLevel = level;
  29032. this.resize();
  29033. };
  29034. /**
  29035. * Gets the current hardware scaling level.
  29036. * By default the hardware scaling level is computed from the window device ratio.
  29037. * 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.
  29038. * @returns a number indicating the current hardware scaling level
  29039. */
  29040. Engine.prototype.getHardwareScalingLevel = function () {
  29041. return this._hardwareScalingLevel;
  29042. };
  29043. /**
  29044. * Gets the list of loaded textures
  29045. * @returns an array containing all loaded textures
  29046. */
  29047. Engine.prototype.getLoadedTexturesCache = function () {
  29048. return this._internalTexturesCache;
  29049. };
  29050. /**
  29051. * Gets the object containing all engine capabilities
  29052. * @returns the EngineCapabilities object
  29053. */
  29054. Engine.prototype.getCaps = function () {
  29055. return this._caps;
  29056. };
  29057. /**
  29058. * Gets the current depth function
  29059. * @returns a number defining the depth function
  29060. */
  29061. Engine.prototype.getDepthFunction = function () {
  29062. return this._depthCullingState.depthFunc;
  29063. };
  29064. /**
  29065. * Sets the current depth function
  29066. * @param depthFunc defines the function to use
  29067. */
  29068. Engine.prototype.setDepthFunction = function (depthFunc) {
  29069. this._depthCullingState.depthFunc = depthFunc;
  29070. };
  29071. /**
  29072. * Sets the current depth function to GREATER
  29073. */
  29074. Engine.prototype.setDepthFunctionToGreater = function () {
  29075. this._depthCullingState.depthFunc = this._gl.GREATER;
  29076. };
  29077. /**
  29078. * Sets the current depth function to GEQUAL
  29079. */
  29080. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  29081. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  29082. };
  29083. /**
  29084. * Sets the current depth function to LESS
  29085. */
  29086. Engine.prototype.setDepthFunctionToLess = function () {
  29087. this._depthCullingState.depthFunc = this._gl.LESS;
  29088. };
  29089. /**
  29090. * Sets the current depth function to LEQUAL
  29091. */
  29092. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  29093. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  29094. };
  29095. /**
  29096. * Gets a boolean indicating if stencil buffer is enabled
  29097. * @returns the current stencil buffer state
  29098. */
  29099. Engine.prototype.getStencilBuffer = function () {
  29100. return this._stencilState.stencilTest;
  29101. };
  29102. /**
  29103. * Enable or disable the stencil buffer
  29104. * @param enable defines if the stencil buffer must be enabled or disabled
  29105. */
  29106. Engine.prototype.setStencilBuffer = function (enable) {
  29107. this._stencilState.stencilTest = enable;
  29108. };
  29109. /**
  29110. * Gets the current stencil mask
  29111. * @returns a number defining the new stencil mask to use
  29112. */
  29113. Engine.prototype.getStencilMask = function () {
  29114. return this._stencilState.stencilMask;
  29115. };
  29116. /**
  29117. * Sets the current stencil mask
  29118. * @param mask defines the new stencil mask to use
  29119. */
  29120. Engine.prototype.setStencilMask = function (mask) {
  29121. this._stencilState.stencilMask = mask;
  29122. };
  29123. /**
  29124. * Gets the current stencil function
  29125. * @returns a number defining the stencil function to use
  29126. */
  29127. Engine.prototype.getStencilFunction = function () {
  29128. return this._stencilState.stencilFunc;
  29129. };
  29130. /**
  29131. * Gets the current stencil reference value
  29132. * @returns a number defining the stencil reference value to use
  29133. */
  29134. Engine.prototype.getStencilFunctionReference = function () {
  29135. return this._stencilState.stencilFuncRef;
  29136. };
  29137. /**
  29138. * Gets the current stencil mask
  29139. * @returns a number defining the stencil mask to use
  29140. */
  29141. Engine.prototype.getStencilFunctionMask = function () {
  29142. return this._stencilState.stencilFuncMask;
  29143. };
  29144. /**
  29145. * Sets the current stencil function
  29146. * @param stencilFunc defines the new stencil function to use
  29147. */
  29148. Engine.prototype.setStencilFunction = function (stencilFunc) {
  29149. this._stencilState.stencilFunc = stencilFunc;
  29150. };
  29151. /**
  29152. * Sets the current stencil reference
  29153. * @param reference defines the new stencil reference to use
  29154. */
  29155. Engine.prototype.setStencilFunctionReference = function (reference) {
  29156. this._stencilState.stencilFuncRef = reference;
  29157. };
  29158. /**
  29159. * Sets the current stencil mask
  29160. * @param mask defines the new stencil mask to use
  29161. */
  29162. Engine.prototype.setStencilFunctionMask = function (mask) {
  29163. this._stencilState.stencilFuncMask = mask;
  29164. };
  29165. /**
  29166. * Gets the current stencil operation when stencil fails
  29167. * @returns a number defining stencil operation to use when stencil fails
  29168. */
  29169. Engine.prototype.getStencilOperationFail = function () {
  29170. return this._stencilState.stencilOpStencilFail;
  29171. };
  29172. /**
  29173. * Gets the current stencil operation when depth fails
  29174. * @returns a number defining stencil operation to use when depth fails
  29175. */
  29176. Engine.prototype.getStencilOperationDepthFail = function () {
  29177. return this._stencilState.stencilOpDepthFail;
  29178. };
  29179. /**
  29180. * Gets the current stencil operation when stencil passes
  29181. * @returns a number defining stencil operation to use when stencil passes
  29182. */
  29183. Engine.prototype.getStencilOperationPass = function () {
  29184. return this._stencilState.stencilOpStencilDepthPass;
  29185. };
  29186. /**
  29187. * Sets the stencil operation to use when stencil fails
  29188. * @param operation defines the stencil operation to use when stencil fails
  29189. */
  29190. Engine.prototype.setStencilOperationFail = function (operation) {
  29191. this._stencilState.stencilOpStencilFail = operation;
  29192. };
  29193. /**
  29194. * Sets the stencil operation to use when depth fails
  29195. * @param operation defines the stencil operation to use when depth fails
  29196. */
  29197. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  29198. this._stencilState.stencilOpDepthFail = operation;
  29199. };
  29200. /**
  29201. * Sets the stencil operation to use when stencil passes
  29202. * @param operation defines the stencil operation to use when stencil passes
  29203. */
  29204. Engine.prototype.setStencilOperationPass = function (operation) {
  29205. this._stencilState.stencilOpStencilDepthPass = operation;
  29206. };
  29207. /**
  29208. * Sets a boolean indicating if the dithering state is enabled or disabled
  29209. * @param value defines the dithering state
  29210. */
  29211. Engine.prototype.setDitheringState = function (value) {
  29212. if (value) {
  29213. this._gl.enable(this._gl.DITHER);
  29214. }
  29215. else {
  29216. this._gl.disable(this._gl.DITHER);
  29217. }
  29218. };
  29219. /**
  29220. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29221. * @param value defines the rasterizer state
  29222. */
  29223. Engine.prototype.setRasterizerState = function (value) {
  29224. if (value) {
  29225. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  29226. }
  29227. else {
  29228. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  29229. }
  29230. };
  29231. /**
  29232. * stop executing a render loop function and remove it from the execution array
  29233. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29234. */
  29235. Engine.prototype.stopRenderLoop = function (renderFunction) {
  29236. if (!renderFunction) {
  29237. this._activeRenderLoops = [];
  29238. return;
  29239. }
  29240. var index = this._activeRenderLoops.indexOf(renderFunction);
  29241. if (index >= 0) {
  29242. this._activeRenderLoops.splice(index, 1);
  29243. }
  29244. };
  29245. /** @hidden */
  29246. Engine.prototype._renderLoop = function () {
  29247. if (!this._contextWasLost) {
  29248. var shouldRender = true;
  29249. if (!this.renderEvenInBackground && this._windowIsBackground) {
  29250. shouldRender = false;
  29251. }
  29252. if (shouldRender) {
  29253. // Start new frame
  29254. this.beginFrame();
  29255. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  29256. var renderFunction = this._activeRenderLoops[index];
  29257. renderFunction();
  29258. }
  29259. // Present
  29260. this.endFrame();
  29261. }
  29262. }
  29263. if (this._activeRenderLoops.length > 0) {
  29264. // Register new frame
  29265. if (this.customAnimationFrameRequester) {
  29266. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  29267. this._frameHandler = this.customAnimationFrameRequester.requestID;
  29268. }
  29269. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29270. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  29271. }
  29272. else {
  29273. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29274. }
  29275. }
  29276. else {
  29277. this._renderingQueueLaunched = false;
  29278. }
  29279. };
  29280. /**
  29281. * Register and execute a render loop. The engine can have more than one render function
  29282. * @param renderFunction defines the function to continuously execute
  29283. */
  29284. Engine.prototype.runRenderLoop = function (renderFunction) {
  29285. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  29286. return;
  29287. }
  29288. this._activeRenderLoops.push(renderFunction);
  29289. if (!this._renderingQueueLaunched) {
  29290. this._renderingQueueLaunched = true;
  29291. this._bindedRenderFunction = this._renderLoop.bind(this);
  29292. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29293. }
  29294. };
  29295. /**
  29296. * Toggle full screen mode
  29297. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29298. */
  29299. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  29300. if (this.isFullscreen) {
  29301. this.exitFullscreen();
  29302. }
  29303. else {
  29304. this.enterFullscreen(requestPointerLock);
  29305. }
  29306. };
  29307. /**
  29308. * Enters full screen mode
  29309. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29310. */
  29311. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  29312. if (!this.isFullscreen) {
  29313. this._pointerLockRequested = requestPointerLock;
  29314. if (this._renderingCanvas) {
  29315. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  29316. }
  29317. }
  29318. };
  29319. /**
  29320. * Exits full screen mode
  29321. */
  29322. Engine.prototype.exitFullscreen = function () {
  29323. if (this.isFullscreen) {
  29324. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  29325. }
  29326. };
  29327. /**
  29328. * Clear the current render buffer or the current render target (if any is set up)
  29329. * @param color defines the color to use
  29330. * @param backBuffer defines if the back buffer must be cleared
  29331. * @param depth defines if the depth buffer must be cleared
  29332. * @param stencil defines if the stencil buffer must be cleared
  29333. */
  29334. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  29335. if (stencil === void 0) { stencil = false; }
  29336. this.applyStates();
  29337. var mode = 0;
  29338. if (backBuffer && color) {
  29339. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  29340. mode |= this._gl.COLOR_BUFFER_BIT;
  29341. }
  29342. if (depth) {
  29343. this._gl.clearDepth(1.0);
  29344. mode |= this._gl.DEPTH_BUFFER_BIT;
  29345. }
  29346. if (stencil) {
  29347. this._gl.clearStencil(0);
  29348. mode |= this._gl.STENCIL_BUFFER_BIT;
  29349. }
  29350. this._gl.clear(mode);
  29351. };
  29352. /**
  29353. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29354. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29355. * @param y defines the y-coordinate of the corner of the clear rectangle
  29356. * @param width defines the width of the clear rectangle
  29357. * @param height defines the height of the clear rectangle
  29358. * @param clearColor defines the clear color
  29359. */
  29360. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  29361. this.enableScissor(x, y, width, height);
  29362. this.clear(clearColor, true, true, true);
  29363. this.disableScissor();
  29364. };
  29365. /**
  29366. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29367. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29368. * @param y defines the y-coordinate of the corner of the clear rectangle
  29369. * @param width defines the width of the clear rectangle
  29370. * @param height defines the height of the clear rectangle
  29371. */
  29372. Engine.prototype.enableScissor = function (x, y, width, height) {
  29373. var gl = this._gl;
  29374. // Change state
  29375. gl.enable(gl.SCISSOR_TEST);
  29376. gl.scissor(x, y, width, height);
  29377. };
  29378. /**
  29379. * Disable previously set scissor test rectangle
  29380. */
  29381. Engine.prototype.disableScissor = function () {
  29382. var gl = this._gl;
  29383. gl.disable(gl.SCISSOR_TEST);
  29384. };
  29385. /** @hidden */
  29386. Engine.prototype._viewport = function (x, y, width, height) {
  29387. if (x !== this._viewportCached.x ||
  29388. y !== this._viewportCached.y ||
  29389. width !== this._viewportCached.z ||
  29390. height !== this._viewportCached.w) {
  29391. this._viewportCached.x = x;
  29392. this._viewportCached.y = y;
  29393. this._viewportCached.z = width;
  29394. this._viewportCached.w = height;
  29395. this._gl.viewport(x, y, width, height);
  29396. }
  29397. };
  29398. /**
  29399. * Set the WebGL's viewport
  29400. * @param viewport defines the viewport element to be used
  29401. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29402. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29403. */
  29404. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  29405. var width = requiredWidth || this.getRenderWidth();
  29406. var height = requiredHeight || this.getRenderHeight();
  29407. var x = viewport.x || 0;
  29408. var y = viewport.y || 0;
  29409. this._cachedViewport = viewport;
  29410. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  29411. };
  29412. /**
  29413. * Directly set the WebGL Viewport
  29414. * @param x defines the x coordinate of the viewport (in screen space)
  29415. * @param y defines the y coordinate of the viewport (in screen space)
  29416. * @param width defines the width of the viewport (in screen space)
  29417. * @param height defines the height of the viewport (in screen space)
  29418. * @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
  29419. */
  29420. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  29421. var currentViewport = this._cachedViewport;
  29422. this._cachedViewport = null;
  29423. this._viewport(x, y, width, height);
  29424. return currentViewport;
  29425. };
  29426. /**
  29427. * Begin a new frame
  29428. */
  29429. Engine.prototype.beginFrame = function () {
  29430. this.onBeginFrameObservable.notifyObservers(this);
  29431. this._measureFps();
  29432. };
  29433. /**
  29434. * Enf the current frame
  29435. */
  29436. Engine.prototype.endFrame = function () {
  29437. // Force a flush in case we are using a bad OS.
  29438. if (this._badOS) {
  29439. this.flushFramebuffer();
  29440. }
  29441. // Submit frame to the vr device, if enabled
  29442. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29443. // TODO: We should only submit the frame if we read frameData successfully.
  29444. try {
  29445. this._vrDisplay.submitFrame();
  29446. }
  29447. catch (e) {
  29448. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  29449. }
  29450. }
  29451. this.onEndFrameObservable.notifyObservers(this);
  29452. };
  29453. /**
  29454. * Resize the view according to the canvas' size
  29455. */
  29456. Engine.prototype.resize = function () {
  29457. // We're not resizing the size of the canvas while in VR mode & presenting
  29458. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  29459. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  29460. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  29461. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  29462. }
  29463. };
  29464. /**
  29465. * Force a specific size of the canvas
  29466. * @param width defines the new canvas' width
  29467. * @param height defines the new canvas' height
  29468. */
  29469. Engine.prototype.setSize = function (width, height) {
  29470. if (!this._renderingCanvas) {
  29471. return;
  29472. }
  29473. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  29474. return;
  29475. }
  29476. this._renderingCanvas.width = width;
  29477. this._renderingCanvas.height = height;
  29478. for (var index = 0; index < this.scenes.length; index++) {
  29479. var scene = this.scenes[index];
  29480. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  29481. var cam = scene.cameras[camIndex];
  29482. cam._currentRenderId = 0;
  29483. }
  29484. }
  29485. if (this.onResizeObservable.hasObservers) {
  29486. this.onResizeObservable.notifyObservers(this);
  29487. }
  29488. };
  29489. // WebVR functions
  29490. /**
  29491. * Gets a boolean indicating if a webVR device was detected
  29492. * @returns true if a webVR device was detected
  29493. */
  29494. Engine.prototype.isVRDevicePresent = function () {
  29495. return !!this._vrDisplay;
  29496. };
  29497. /**
  29498. * Gets the current webVR device
  29499. * @returns the current webVR device (or null)
  29500. */
  29501. Engine.prototype.getVRDevice = function () {
  29502. return this._vrDisplay;
  29503. };
  29504. /**
  29505. * Initializes a webVR display and starts listening to display change events
  29506. * The onVRDisplayChangedObservable will be notified upon these changes
  29507. * @returns The onVRDisplayChangedObservable
  29508. */
  29509. Engine.prototype.initWebVR = function () {
  29510. this.initWebVRAsync();
  29511. return this.onVRDisplayChangedObservable;
  29512. };
  29513. /**
  29514. * Initializes a webVR display and starts listening to display change events
  29515. * The onVRDisplayChangedObservable will be notified upon these changes
  29516. * @returns A promise containing a VRDisplay and if vr is supported
  29517. */
  29518. Engine.prototype.initWebVRAsync = function () {
  29519. var _this = this;
  29520. var notifyObservers = function () {
  29521. var eventArgs = {
  29522. vrDisplay: _this._vrDisplay,
  29523. vrSupported: _this._vrSupported
  29524. };
  29525. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29526. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29527. };
  29528. if (!this._onVrDisplayConnect) {
  29529. this._onVrDisplayConnect = function (event) {
  29530. _this._vrDisplay = event.display;
  29531. notifyObservers();
  29532. };
  29533. this._onVrDisplayDisconnect = function () {
  29534. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29535. _this._vrDisplay = undefined;
  29536. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29537. notifyObservers();
  29538. };
  29539. this._onVrDisplayPresentChange = function () {
  29540. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29541. };
  29542. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29543. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29544. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29545. }
  29546. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29547. this._webVRInitPromise.then(notifyObservers);
  29548. return this._webVRInitPromise;
  29549. };
  29550. /**
  29551. * Call this function to switch to webVR mode
  29552. * Will do nothing if webVR is not supported or if there is no webVR device
  29553. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29554. */
  29555. Engine.prototype.enableVR = function () {
  29556. var _this = this;
  29557. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29558. var onResolved = function () {
  29559. _this.onVRRequestPresentComplete.notifyObservers(true);
  29560. _this._onVRFullScreenTriggered();
  29561. };
  29562. var onRejected = function () {
  29563. _this.onVRRequestPresentComplete.notifyObservers(false);
  29564. };
  29565. this.onVRRequestPresentStart.notifyObservers(this);
  29566. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29567. }
  29568. };
  29569. /**
  29570. * Call this function to leave webVR mode
  29571. * Will do nothing if webVR is not supported or if there is no webVR device
  29572. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29573. */
  29574. Engine.prototype.disableVR = function () {
  29575. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29576. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29577. }
  29578. };
  29579. Engine.prototype._getVRDisplaysAsync = function () {
  29580. var _this = this;
  29581. return new Promise(function (res) {
  29582. if (navigator.getVRDisplays) {
  29583. navigator.getVRDisplays().then(function (devices) {
  29584. _this._vrSupported = true;
  29585. // note that devices may actually be an empty array. This is fine;
  29586. // we expect this._vrDisplay to be undefined in this case.
  29587. _this._vrDisplay = devices[0];
  29588. res({
  29589. vrDisplay: _this._vrDisplay,
  29590. vrSupported: _this._vrSupported
  29591. });
  29592. });
  29593. }
  29594. else {
  29595. _this._vrDisplay = undefined;
  29596. _this._vrSupported = false;
  29597. res({
  29598. vrDisplay: _this._vrDisplay,
  29599. vrSupported: _this._vrSupported
  29600. });
  29601. }
  29602. });
  29603. };
  29604. /**
  29605. * Binds the frame buffer to the specified texture.
  29606. * @param texture The texture to render to or null for the default canvas
  29607. * @param faceIndex The face of the texture to render to in case of cube texture
  29608. * @param requiredWidth The width of the target to render to
  29609. * @param requiredHeight The height of the target to render to
  29610. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29611. * @param depthStencilTexture The depth stencil texture to use to render
  29612. * @param lodLevel defines le lod level to bind to the frame buffer
  29613. */
  29614. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29615. if (lodLevel === void 0) { lodLevel = 0; }
  29616. if (this._currentRenderTarget) {
  29617. this.unBindFramebuffer(this._currentRenderTarget);
  29618. }
  29619. this._currentRenderTarget = texture;
  29620. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29621. var gl = this._gl;
  29622. if (texture.isCube) {
  29623. if (faceIndex === undefined) {
  29624. faceIndex = 0;
  29625. }
  29626. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29627. if (depthStencilTexture) {
  29628. if (depthStencilTexture._generateStencilBuffer) {
  29629. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29630. }
  29631. else {
  29632. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29633. }
  29634. }
  29635. }
  29636. if (this._cachedViewport && !forceFullscreenViewport) {
  29637. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29638. }
  29639. else {
  29640. if (!requiredWidth) {
  29641. requiredWidth = texture.width;
  29642. if (lodLevel) {
  29643. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29644. }
  29645. }
  29646. if (!requiredHeight) {
  29647. requiredHeight = texture.height;
  29648. if (lodLevel) {
  29649. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29650. }
  29651. }
  29652. this._viewport(0, 0, requiredWidth, requiredHeight);
  29653. }
  29654. this.wipeCaches();
  29655. };
  29656. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29657. if (this._currentFramebuffer !== framebuffer) {
  29658. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29659. this._currentFramebuffer = framebuffer;
  29660. }
  29661. };
  29662. /**
  29663. * Unbind the current render target texture from the webGL context
  29664. * @param texture defines the render target texture to unbind
  29665. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29666. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29667. */
  29668. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  29669. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29670. this._currentRenderTarget = null;
  29671. // If MSAA, we need to bitblt back to main texture
  29672. var gl = this._gl;
  29673. if (texture._MSAAFramebuffer) {
  29674. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  29675. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  29676. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29677. }
  29678. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29679. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  29680. gl.generateMipmap(gl.TEXTURE_2D);
  29681. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29682. }
  29683. if (onBeforeUnbind) {
  29684. if (texture._MSAAFramebuffer) {
  29685. // Bind the correct framebuffer
  29686. this.bindUnboundFramebuffer(texture._framebuffer);
  29687. }
  29688. onBeforeUnbind();
  29689. }
  29690. this.bindUnboundFramebuffer(null);
  29691. };
  29692. /**
  29693. * Unbind a list of render target textures from the webGL context
  29694. * This is used only when drawBuffer extension or webGL2 are active
  29695. * @param textures defines the render target textures to unbind
  29696. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29697. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29698. */
  29699. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  29700. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29701. this._currentRenderTarget = null;
  29702. // If MSAA, we need to bitblt back to main texture
  29703. var gl = this._gl;
  29704. if (textures[0]._MSAAFramebuffer) {
  29705. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  29706. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  29707. var attachments = textures[0]._attachments;
  29708. if (!attachments) {
  29709. attachments = new Array(textures.length);
  29710. textures[0]._attachments = attachments;
  29711. }
  29712. for (var i = 0; i < textures.length; i++) {
  29713. var texture = textures[i];
  29714. for (var j = 0; j < attachments.length; j++) {
  29715. attachments[j] = gl.NONE;
  29716. }
  29717. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29718. gl.readBuffer(attachments[i]);
  29719. gl.drawBuffers(attachments);
  29720. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29721. }
  29722. for (var i = 0; i < attachments.length; i++) {
  29723. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29724. }
  29725. gl.drawBuffers(attachments);
  29726. }
  29727. for (var i = 0; i < textures.length; i++) {
  29728. var texture = textures[i];
  29729. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29730. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29731. gl.generateMipmap(gl.TEXTURE_2D);
  29732. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29733. }
  29734. }
  29735. if (onBeforeUnbind) {
  29736. if (textures[0]._MSAAFramebuffer) {
  29737. // Bind the correct framebuffer
  29738. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29739. }
  29740. onBeforeUnbind();
  29741. }
  29742. this.bindUnboundFramebuffer(null);
  29743. };
  29744. /**
  29745. * Force the mipmap generation for the given render target texture
  29746. * @param texture defines the render target texture to use
  29747. */
  29748. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29749. if (texture.generateMipMaps) {
  29750. var gl = this._gl;
  29751. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29752. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29753. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29754. }
  29755. };
  29756. /**
  29757. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29758. */
  29759. Engine.prototype.flushFramebuffer = function () {
  29760. this._gl.flush();
  29761. };
  29762. /**
  29763. * Unbind the current render target and bind the default framebuffer
  29764. */
  29765. Engine.prototype.restoreDefaultFramebuffer = function () {
  29766. if (this._currentRenderTarget) {
  29767. this.unBindFramebuffer(this._currentRenderTarget);
  29768. }
  29769. else {
  29770. this.bindUnboundFramebuffer(null);
  29771. }
  29772. if (this._cachedViewport) {
  29773. this.setViewport(this._cachedViewport);
  29774. }
  29775. this.wipeCaches();
  29776. };
  29777. // UBOs
  29778. /**
  29779. * Create an uniform buffer
  29780. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29781. * @param elements defines the content of the uniform buffer
  29782. * @returns the webGL uniform buffer
  29783. */
  29784. Engine.prototype.createUniformBuffer = function (elements) {
  29785. var ubo = this._gl.createBuffer();
  29786. if (!ubo) {
  29787. throw new Error("Unable to create uniform buffer");
  29788. }
  29789. this.bindUniformBuffer(ubo);
  29790. if (elements instanceof Float32Array) {
  29791. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29792. }
  29793. else {
  29794. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29795. }
  29796. this.bindUniformBuffer(null);
  29797. ubo.references = 1;
  29798. return ubo;
  29799. };
  29800. /**
  29801. * Create a dynamic uniform buffer
  29802. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29803. * @param elements defines the content of the uniform buffer
  29804. * @returns the webGL uniform buffer
  29805. */
  29806. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29807. var ubo = this._gl.createBuffer();
  29808. if (!ubo) {
  29809. throw new Error("Unable to create dynamic uniform buffer");
  29810. }
  29811. this.bindUniformBuffer(ubo);
  29812. if (elements instanceof Float32Array) {
  29813. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29814. }
  29815. else {
  29816. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29817. }
  29818. this.bindUniformBuffer(null);
  29819. ubo.references = 1;
  29820. return ubo;
  29821. };
  29822. /**
  29823. * Update an existing uniform buffer
  29824. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29825. * @param uniformBuffer defines the target uniform buffer
  29826. * @param elements defines the content to update
  29827. * @param offset defines the offset in the uniform buffer where update should start
  29828. * @param count defines the size of the data to update
  29829. */
  29830. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29831. this.bindUniformBuffer(uniformBuffer);
  29832. if (offset === undefined) {
  29833. offset = 0;
  29834. }
  29835. if (count === undefined) {
  29836. if (elements instanceof Float32Array) {
  29837. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29838. }
  29839. else {
  29840. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29841. }
  29842. }
  29843. else {
  29844. if (elements instanceof Float32Array) {
  29845. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  29846. }
  29847. else {
  29848. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  29849. }
  29850. }
  29851. this.bindUniformBuffer(null);
  29852. };
  29853. // VBOs
  29854. Engine.prototype._resetVertexBufferBinding = function () {
  29855. this.bindArrayBuffer(null);
  29856. this._cachedVertexBuffers = null;
  29857. };
  29858. /**
  29859. * Creates a vertex buffer
  29860. * @param data the data for the vertex buffer
  29861. * @returns the new WebGL static buffer
  29862. */
  29863. Engine.prototype.createVertexBuffer = function (data) {
  29864. var vbo = this._gl.createBuffer();
  29865. if (!vbo) {
  29866. throw new Error("Unable to create vertex buffer");
  29867. }
  29868. this.bindArrayBuffer(vbo);
  29869. if (data instanceof Array) {
  29870. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  29871. }
  29872. else {
  29873. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  29874. }
  29875. this._resetVertexBufferBinding();
  29876. vbo.references = 1;
  29877. return vbo;
  29878. };
  29879. /**
  29880. * Creates a dynamic vertex buffer
  29881. * @param data the data for the dynamic vertex buffer
  29882. * @returns the new WebGL dynamic buffer
  29883. */
  29884. Engine.prototype.createDynamicVertexBuffer = function (data) {
  29885. var vbo = this._gl.createBuffer();
  29886. if (!vbo) {
  29887. throw new Error("Unable to create dynamic vertex buffer");
  29888. }
  29889. this.bindArrayBuffer(vbo);
  29890. if (data instanceof Array) {
  29891. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  29892. }
  29893. else {
  29894. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  29895. }
  29896. this._resetVertexBufferBinding();
  29897. vbo.references = 1;
  29898. return vbo;
  29899. };
  29900. /**
  29901. * Update a dynamic index buffer
  29902. * @param indexBuffer defines the target index buffer
  29903. * @param indices defines the data to update
  29904. * @param offset defines the offset in the target index buffer where update should start
  29905. */
  29906. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  29907. if (offset === void 0) { offset = 0; }
  29908. // Force cache update
  29909. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  29910. this.bindIndexBuffer(indexBuffer);
  29911. var arrayBuffer;
  29912. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  29913. arrayBuffer = indices;
  29914. }
  29915. else {
  29916. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29917. }
  29918. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  29919. this._resetIndexBufferBinding();
  29920. };
  29921. /**
  29922. * Updates a dynamic vertex buffer.
  29923. * @param vertexBuffer the vertex buffer to update
  29924. * @param data the data used to update the vertex buffer
  29925. * @param byteOffset the byte offset of the data
  29926. * @param byteLength the byte length of the data
  29927. */
  29928. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  29929. this.bindArrayBuffer(vertexBuffer);
  29930. if (byteOffset === undefined) {
  29931. byteOffset = 0;
  29932. }
  29933. if (byteLength === undefined) {
  29934. if (data instanceof Array) {
  29935. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  29936. }
  29937. else {
  29938. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  29939. }
  29940. }
  29941. else {
  29942. if (data instanceof Array) {
  29943. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  29944. }
  29945. else {
  29946. if (data instanceof ArrayBuffer) {
  29947. data = new Uint8Array(data, byteOffset, byteLength);
  29948. }
  29949. else {
  29950. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  29951. }
  29952. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29953. }
  29954. }
  29955. this._resetVertexBufferBinding();
  29956. };
  29957. Engine.prototype._resetIndexBufferBinding = function () {
  29958. this.bindIndexBuffer(null);
  29959. this._cachedIndexBuffer = null;
  29960. };
  29961. /**
  29962. * Creates a new index buffer
  29963. * @param indices defines the content of the index buffer
  29964. * @param updatable defines if the index buffer must be updatable
  29965. * @returns a new webGL buffer
  29966. */
  29967. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  29968. var vbo = this._gl.createBuffer();
  29969. if (!vbo) {
  29970. throw new Error("Unable to create index buffer");
  29971. }
  29972. this.bindIndexBuffer(vbo);
  29973. // Check for 32 bits indices
  29974. var arrayBuffer;
  29975. var need32Bits = false;
  29976. if (indices instanceof Uint16Array) {
  29977. arrayBuffer = indices;
  29978. }
  29979. else {
  29980. //check 32 bit support
  29981. if (this._caps.uintIndices) {
  29982. if (indices instanceof Uint32Array) {
  29983. arrayBuffer = indices;
  29984. need32Bits = true;
  29985. }
  29986. else {
  29987. //number[] or Int32Array, check if 32 bit is necessary
  29988. for (var index = 0; index < indices.length; index++) {
  29989. if (indices[index] > 65535) {
  29990. need32Bits = true;
  29991. break;
  29992. }
  29993. }
  29994. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29995. }
  29996. }
  29997. else {
  29998. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  29999. arrayBuffer = new Uint16Array(indices);
  30000. }
  30001. }
  30002. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  30003. this._resetIndexBufferBinding();
  30004. vbo.references = 1;
  30005. vbo.is32Bits = need32Bits;
  30006. return vbo;
  30007. };
  30008. /**
  30009. * Bind a webGL buffer to the webGL context
  30010. * @param buffer defines the buffer to bind
  30011. */
  30012. Engine.prototype.bindArrayBuffer = function (buffer) {
  30013. if (!this._vaoRecordInProgress) {
  30014. this._unbindVertexArrayObject();
  30015. }
  30016. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  30017. };
  30018. /**
  30019. * Bind an uniform buffer to the current webGL context
  30020. * @param buffer defines the buffer to bind
  30021. */
  30022. Engine.prototype.bindUniformBuffer = function (buffer) {
  30023. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  30024. };
  30025. /**
  30026. * Bind a buffer to the current webGL context at a given location
  30027. * @param buffer defines the buffer to bind
  30028. * @param location defines the index where to bind the buffer
  30029. */
  30030. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  30031. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  30032. };
  30033. /**
  30034. * Bind a specific block at a given index in a specific shader program
  30035. * @param shaderProgram defines the shader program
  30036. * @param blockName defines the block name
  30037. * @param index defines the index where to bind the block
  30038. */
  30039. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  30040. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  30041. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  30042. };
  30043. Engine.prototype.bindIndexBuffer = function (buffer) {
  30044. if (!this._vaoRecordInProgress) {
  30045. this._unbindVertexArrayObject();
  30046. }
  30047. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  30048. };
  30049. Engine.prototype.bindBuffer = function (buffer, target) {
  30050. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  30051. this._gl.bindBuffer(target, buffer);
  30052. this._currentBoundBuffer[target] = buffer;
  30053. }
  30054. };
  30055. /**
  30056. * update the bound buffer with the given data
  30057. * @param data defines the data to update
  30058. */
  30059. Engine.prototype.updateArrayBuffer = function (data) {
  30060. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30061. };
  30062. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  30063. var pointer = this._currentBufferPointers[indx];
  30064. var changed = false;
  30065. if (!pointer.active) {
  30066. changed = true;
  30067. pointer.active = true;
  30068. pointer.index = indx;
  30069. pointer.size = size;
  30070. pointer.type = type;
  30071. pointer.normalized = normalized;
  30072. pointer.stride = stride;
  30073. pointer.offset = offset;
  30074. pointer.buffer = buffer;
  30075. }
  30076. else {
  30077. if (pointer.buffer !== buffer) {
  30078. pointer.buffer = buffer;
  30079. changed = true;
  30080. }
  30081. if (pointer.size !== size) {
  30082. pointer.size = size;
  30083. changed = true;
  30084. }
  30085. if (pointer.type !== type) {
  30086. pointer.type = type;
  30087. changed = true;
  30088. }
  30089. if (pointer.normalized !== normalized) {
  30090. pointer.normalized = normalized;
  30091. changed = true;
  30092. }
  30093. if (pointer.stride !== stride) {
  30094. pointer.stride = stride;
  30095. changed = true;
  30096. }
  30097. if (pointer.offset !== offset) {
  30098. pointer.offset = offset;
  30099. changed = true;
  30100. }
  30101. }
  30102. if (changed || this._vaoRecordInProgress) {
  30103. this.bindArrayBuffer(buffer);
  30104. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  30105. }
  30106. };
  30107. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  30108. if (indexBuffer == null) {
  30109. return;
  30110. }
  30111. if (this._cachedIndexBuffer !== indexBuffer) {
  30112. this._cachedIndexBuffer = indexBuffer;
  30113. this.bindIndexBuffer(indexBuffer);
  30114. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  30115. }
  30116. };
  30117. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  30118. var attributes = effect.getAttributesNames();
  30119. if (!this._vaoRecordInProgress) {
  30120. this._unbindVertexArrayObject();
  30121. }
  30122. this.unbindAllAttributes();
  30123. for (var index = 0; index < attributes.length; index++) {
  30124. var order = effect.getAttributeLocation(index);
  30125. if (order >= 0) {
  30126. var vertexBuffer = vertexBuffers[attributes[index]];
  30127. if (!vertexBuffer) {
  30128. continue;
  30129. }
  30130. this._gl.enableVertexAttribArray(order);
  30131. if (!this._vaoRecordInProgress) {
  30132. this._vertexAttribArraysEnabled[order] = true;
  30133. }
  30134. var buffer = vertexBuffer.getBuffer();
  30135. if (buffer) {
  30136. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  30137. if (vertexBuffer.getIsInstanced()) {
  30138. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  30139. if (!this._vaoRecordInProgress) {
  30140. this._currentInstanceLocations.push(order);
  30141. this._currentInstanceBuffers.push(buffer);
  30142. }
  30143. }
  30144. }
  30145. }
  30146. }
  30147. };
  30148. /**
  30149. * Records a vertex array object
  30150. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30151. * @param vertexBuffers defines the list of vertex buffers to store
  30152. * @param indexBuffer defines the index buffer to store
  30153. * @param effect defines the effect to store
  30154. * @returns the new vertex array object
  30155. */
  30156. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  30157. var vao = this._gl.createVertexArray();
  30158. this._vaoRecordInProgress = true;
  30159. this._gl.bindVertexArray(vao);
  30160. this._mustWipeVertexAttributes = true;
  30161. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30162. this.bindIndexBuffer(indexBuffer);
  30163. this._vaoRecordInProgress = false;
  30164. this._gl.bindVertexArray(null);
  30165. return vao;
  30166. };
  30167. /**
  30168. * Bind a specific vertex array object
  30169. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30170. * @param vertexArrayObject defines the vertex array object to bind
  30171. * @param indexBuffer defines the index buffer to bind
  30172. */
  30173. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  30174. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  30175. this._cachedVertexArrayObject = vertexArrayObject;
  30176. this._gl.bindVertexArray(vertexArrayObject);
  30177. this._cachedVertexBuffers = null;
  30178. this._cachedIndexBuffer = null;
  30179. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  30180. this._mustWipeVertexAttributes = true;
  30181. }
  30182. };
  30183. /**
  30184. * Bind webGl buffers directly to the webGL context
  30185. * @param vertexBuffer defines the vertex buffer to bind
  30186. * @param indexBuffer defines the index buffer to bind
  30187. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30188. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30189. * @param effect defines the effect associated with the vertex buffer
  30190. */
  30191. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  30192. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  30193. this._cachedVertexBuffers = vertexBuffer;
  30194. this._cachedEffectForVertexBuffers = effect;
  30195. var attributesCount = effect.getAttributesCount();
  30196. this._unbindVertexArrayObject();
  30197. this.unbindAllAttributes();
  30198. var offset = 0;
  30199. for (var index = 0; index < attributesCount; index++) {
  30200. if (index < vertexDeclaration.length) {
  30201. var order = effect.getAttributeLocation(index);
  30202. if (order >= 0) {
  30203. this._gl.enableVertexAttribArray(order);
  30204. this._vertexAttribArraysEnabled[order] = true;
  30205. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  30206. }
  30207. offset += vertexDeclaration[index] * 4;
  30208. }
  30209. }
  30210. }
  30211. this._bindIndexBufferWithCache(indexBuffer);
  30212. };
  30213. Engine.prototype._unbindVertexArrayObject = function () {
  30214. if (!this._cachedVertexArrayObject) {
  30215. return;
  30216. }
  30217. this._cachedVertexArrayObject = null;
  30218. this._gl.bindVertexArray(null);
  30219. };
  30220. /**
  30221. * Bind a list of vertex buffers to the webGL context
  30222. * @param vertexBuffers defines the list of vertex buffers to bind
  30223. * @param indexBuffer defines the index buffer to bind
  30224. * @param effect defines the effect associated with the vertex buffers
  30225. */
  30226. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  30227. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  30228. this._cachedVertexBuffers = vertexBuffers;
  30229. this._cachedEffectForVertexBuffers = effect;
  30230. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30231. }
  30232. this._bindIndexBufferWithCache(indexBuffer);
  30233. };
  30234. /**
  30235. * Unbind all instance attributes
  30236. */
  30237. Engine.prototype.unbindInstanceAttributes = function () {
  30238. var boundBuffer;
  30239. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  30240. var instancesBuffer = this._currentInstanceBuffers[i];
  30241. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  30242. boundBuffer = instancesBuffer;
  30243. this.bindArrayBuffer(instancesBuffer);
  30244. }
  30245. var offsetLocation = this._currentInstanceLocations[i];
  30246. this._gl.vertexAttribDivisor(offsetLocation, 0);
  30247. }
  30248. this._currentInstanceBuffers.length = 0;
  30249. this._currentInstanceLocations.length = 0;
  30250. };
  30251. /**
  30252. * Release and free the memory of a vertex array object
  30253. * @param vao defines the vertex array object to delete
  30254. */
  30255. Engine.prototype.releaseVertexArrayObject = function (vao) {
  30256. this._gl.deleteVertexArray(vao);
  30257. };
  30258. /** @hidden */
  30259. Engine.prototype._releaseBuffer = function (buffer) {
  30260. buffer.references--;
  30261. if (buffer.references === 0) {
  30262. this._gl.deleteBuffer(buffer);
  30263. return true;
  30264. }
  30265. return false;
  30266. };
  30267. /**
  30268. * Creates a webGL buffer to use with instanciation
  30269. * @param capacity defines the size of the buffer
  30270. * @returns the webGL buffer
  30271. */
  30272. Engine.prototype.createInstancesBuffer = function (capacity) {
  30273. var buffer = this._gl.createBuffer();
  30274. if (!buffer) {
  30275. throw new Error("Unable to create instance buffer");
  30276. }
  30277. buffer.capacity = capacity;
  30278. this.bindArrayBuffer(buffer);
  30279. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  30280. return buffer;
  30281. };
  30282. /**
  30283. * Delete a webGL buffer used with instanciation
  30284. * @param buffer defines the webGL buffer to delete
  30285. */
  30286. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  30287. this._gl.deleteBuffer(buffer);
  30288. };
  30289. /**
  30290. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30291. * @param instancesBuffer defines the webGL buffer to update and bind
  30292. * @param data defines the data to store in the buffer
  30293. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30294. */
  30295. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  30296. this.bindArrayBuffer(instancesBuffer);
  30297. if (data) {
  30298. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30299. }
  30300. if (offsetLocations[0].index !== undefined) {
  30301. var stride = 0;
  30302. for (var i = 0; i < offsetLocations.length; i++) {
  30303. var ai = offsetLocations[i];
  30304. stride += ai.attributeSize * 4;
  30305. }
  30306. for (var i = 0; i < offsetLocations.length; i++) {
  30307. var ai = offsetLocations[i];
  30308. if (!this._vertexAttribArraysEnabled[ai.index]) {
  30309. this._gl.enableVertexAttribArray(ai.index);
  30310. this._vertexAttribArraysEnabled[ai.index] = true;
  30311. }
  30312. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  30313. this._gl.vertexAttribDivisor(ai.index, 1);
  30314. this._currentInstanceLocations.push(ai.index);
  30315. this._currentInstanceBuffers.push(instancesBuffer);
  30316. }
  30317. }
  30318. else {
  30319. for (var index = 0; index < 4; index++) {
  30320. var offsetLocation = offsetLocations[index];
  30321. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  30322. this._gl.enableVertexAttribArray(offsetLocation);
  30323. this._vertexAttribArraysEnabled[offsetLocation] = true;
  30324. }
  30325. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  30326. this._gl.vertexAttribDivisor(offsetLocation, 1);
  30327. this._currentInstanceLocations.push(offsetLocation);
  30328. this._currentInstanceBuffers.push(instancesBuffer);
  30329. }
  30330. }
  30331. };
  30332. /**
  30333. * Apply all cached states (depth, culling, stencil and alpha)
  30334. */
  30335. Engine.prototype.applyStates = function () {
  30336. this._depthCullingState.apply(this._gl);
  30337. this._stencilState.apply(this._gl);
  30338. this._alphaState.apply(this._gl);
  30339. };
  30340. /**
  30341. * Send a draw order
  30342. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30343. * @param indexStart defines the starting index
  30344. * @param indexCount defines the number of index to draw
  30345. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30346. */
  30347. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  30348. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  30349. };
  30350. /**
  30351. * Draw a list of points
  30352. * @param verticesStart defines the index of first vertex to draw
  30353. * @param verticesCount defines the count of vertices to draw
  30354. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30355. */
  30356. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  30357. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  30358. };
  30359. /**
  30360. * Draw a list of unindexed primitives
  30361. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30362. * @param verticesStart defines the index of first vertex to draw
  30363. * @param verticesCount defines the count of vertices to draw
  30364. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30365. */
  30366. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  30367. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  30368. };
  30369. /**
  30370. * Draw a list of indexed primitives
  30371. * @param fillMode defines the primitive to use
  30372. * @param indexStart defines the starting index
  30373. * @param indexCount defines the number of index to draw
  30374. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30375. */
  30376. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  30377. // Apply states
  30378. this.applyStates();
  30379. this._drawCalls.addCount(1, false);
  30380. // Render
  30381. var drawMode = this._drawMode(fillMode);
  30382. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  30383. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  30384. if (instancesCount) {
  30385. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  30386. }
  30387. else {
  30388. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  30389. }
  30390. };
  30391. /**
  30392. * Draw a list of unindexed primitives
  30393. * @param fillMode defines the primitive to use
  30394. * @param verticesStart defines the index of first vertex to draw
  30395. * @param verticesCount defines the count of vertices to draw
  30396. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30397. */
  30398. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  30399. // Apply states
  30400. this.applyStates();
  30401. this._drawCalls.addCount(1, false);
  30402. var drawMode = this._drawMode(fillMode);
  30403. if (instancesCount) {
  30404. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  30405. }
  30406. else {
  30407. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  30408. }
  30409. };
  30410. Engine.prototype._drawMode = function (fillMode) {
  30411. switch (fillMode) {
  30412. // Triangle views
  30413. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  30414. return this._gl.TRIANGLES;
  30415. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  30416. return this._gl.POINTS;
  30417. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  30418. return this._gl.LINES;
  30419. // Draw modes
  30420. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  30421. return this._gl.POINTS;
  30422. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  30423. return this._gl.LINES;
  30424. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  30425. return this._gl.LINE_LOOP;
  30426. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  30427. return this._gl.LINE_STRIP;
  30428. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  30429. return this._gl.TRIANGLE_STRIP;
  30430. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  30431. return this._gl.TRIANGLE_FAN;
  30432. default:
  30433. return this._gl.TRIANGLES;
  30434. }
  30435. };
  30436. // Shaders
  30437. /** @hidden */
  30438. Engine.prototype._releaseEffect = function (effect) {
  30439. if (this._compiledEffects[effect._key]) {
  30440. delete this._compiledEffects[effect._key];
  30441. this._deleteProgram(effect.getProgram());
  30442. }
  30443. };
  30444. /** @hidden */
  30445. Engine.prototype._deleteProgram = function (program) {
  30446. if (program) {
  30447. program.__SPECTOR_rebuildProgram = null;
  30448. if (program.transformFeedback) {
  30449. this.deleteTransformFeedback(program.transformFeedback);
  30450. program.transformFeedback = null;
  30451. }
  30452. this._gl.deleteProgram(program);
  30453. }
  30454. };
  30455. /**
  30456. * Create a new effect (used to store vertex/fragment shaders)
  30457. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30458. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30459. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30460. * @param samplers defines an array of string used to represent textures
  30461. * @param defines defines the string containing the defines to use to compile the shaders
  30462. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30463. * @param onCompiled defines a function to call when the effect creation is successful
  30464. * @param onError defines a function to call when the effect creation has failed
  30465. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30466. * @returns the new Effect
  30467. */
  30468. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  30469. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  30470. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  30471. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  30472. if (this._compiledEffects[name]) {
  30473. var compiledEffect = this._compiledEffects[name];
  30474. if (onCompiled && compiledEffect.isReady()) {
  30475. onCompiled(compiledEffect);
  30476. }
  30477. return compiledEffect;
  30478. }
  30479. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  30480. effect._key = name;
  30481. this._compiledEffects[name] = effect;
  30482. return effect;
  30483. };
  30484. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  30485. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  30486. };
  30487. Engine.prototype._compileRawShader = function (source, type) {
  30488. var gl = this._gl;
  30489. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  30490. if (!shader) {
  30491. throw new Error("Something went wrong while compile the shader.");
  30492. }
  30493. gl.shaderSource(shader, source);
  30494. gl.compileShader(shader);
  30495. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  30496. var log = gl.getShaderInfoLog(shader);
  30497. if (log) {
  30498. throw new Error(log);
  30499. }
  30500. }
  30501. return shader;
  30502. };
  30503. /**
  30504. * Directly creates a webGL program
  30505. * @param vertexCode defines the vertex shader code to use
  30506. * @param fragmentCode defines the fragment shader code to use
  30507. * @param context defines the webGL context to use (if not set, the current one will be used)
  30508. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30509. * @returns the new webGL program
  30510. */
  30511. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30512. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30513. context = context || this._gl;
  30514. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30515. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30516. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30517. };
  30518. /**
  30519. * Creates a webGL program
  30520. * @param vertexCode defines the vertex shader code to use
  30521. * @param fragmentCode defines the fragment shader code to use
  30522. * @param defines defines the string containing the defines to use to compile the shaders
  30523. * @param context defines the webGL context to use (if not set, the current one will be used)
  30524. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30525. * @returns the new webGL program
  30526. */
  30527. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30528. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30529. context = context || this._gl;
  30530. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30531. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30532. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30533. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30534. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30535. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30536. return program;
  30537. };
  30538. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30539. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30540. var shaderProgram = context.createProgram();
  30541. if (!shaderProgram) {
  30542. throw new Error("Unable to create program");
  30543. }
  30544. context.attachShader(shaderProgram, vertexShader);
  30545. context.attachShader(shaderProgram, fragmentShader);
  30546. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30547. var transformFeedback = this.createTransformFeedback();
  30548. this.bindTransformFeedback(transformFeedback);
  30549. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30550. shaderProgram.transformFeedback = transformFeedback;
  30551. }
  30552. context.linkProgram(shaderProgram);
  30553. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30554. this.bindTransformFeedback(null);
  30555. }
  30556. shaderProgram.context = context;
  30557. shaderProgram.vertexShader = vertexShader;
  30558. shaderProgram.fragmentShader = fragmentShader;
  30559. if (!this._caps.parallelShaderCompile) {
  30560. this._finalizeProgram(shaderProgram);
  30561. }
  30562. else {
  30563. shaderProgram.isParallelCompiled = true;
  30564. }
  30565. return shaderProgram;
  30566. };
  30567. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30568. var context = shaderProgram.context;
  30569. var vertexShader = shaderProgram.vertexShader;
  30570. var fragmentShader = shaderProgram.fragmentShader;
  30571. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30572. if (!linked) {
  30573. var error = context.getProgramInfoLog(shaderProgram);
  30574. if (error) {
  30575. throw new Error(error);
  30576. }
  30577. }
  30578. if (this.validateShaderPrograms) {
  30579. context.validateProgram(shaderProgram);
  30580. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30581. if (!validated) {
  30582. var error = context.getProgramInfoLog(shaderProgram);
  30583. if (error) {
  30584. throw new Error(error);
  30585. }
  30586. }
  30587. }
  30588. context.deleteShader(vertexShader);
  30589. context.deleteShader(fragmentShader);
  30590. shaderProgram.context = undefined;
  30591. shaderProgram.vertexShader = undefined;
  30592. shaderProgram.fragmentShader = undefined;
  30593. if (shaderProgram.onCompiled) {
  30594. shaderProgram.onCompiled();
  30595. shaderProgram.onCompiled = undefined;
  30596. }
  30597. };
  30598. /** @hidden */
  30599. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30600. if (!shaderProgram.isParallelCompiled) {
  30601. return true;
  30602. }
  30603. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30604. this._finalizeProgram(shaderProgram);
  30605. return true;
  30606. }
  30607. return false;
  30608. };
  30609. /** @hidden */
  30610. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30611. if (!shaderProgram.isParallelCompiled) {
  30612. action();
  30613. return;
  30614. }
  30615. shaderProgram.onCompiled = action;
  30616. };
  30617. /**
  30618. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30619. * @param shaderProgram defines the webGL program to use
  30620. * @param uniformsNames defines the list of uniform names
  30621. * @returns an array of webGL uniform locations
  30622. */
  30623. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30624. var results = new Array();
  30625. for (var index = 0; index < uniformsNames.length; index++) {
  30626. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30627. }
  30628. return results;
  30629. };
  30630. /**
  30631. * Gets the lsit of active attributes for a given webGL program
  30632. * @param shaderProgram defines the webGL program to use
  30633. * @param attributesNames defines the list of attribute names to get
  30634. * @returns an array of indices indicating the offset of each attribute
  30635. */
  30636. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30637. var results = [];
  30638. for (var index = 0; index < attributesNames.length; index++) {
  30639. try {
  30640. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30641. }
  30642. catch (e) {
  30643. results.push(-1);
  30644. }
  30645. }
  30646. return results;
  30647. };
  30648. /**
  30649. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30650. * @param effect defines the effect to activate
  30651. */
  30652. Engine.prototype.enableEffect = function (effect) {
  30653. if (!effect || effect === this._currentEffect) {
  30654. return;
  30655. }
  30656. // Use program
  30657. this.bindSamplers(effect);
  30658. this._currentEffect = effect;
  30659. if (effect.onBind) {
  30660. effect.onBind(effect);
  30661. }
  30662. if (effect._onBindObservable) {
  30663. effect._onBindObservable.notifyObservers(effect);
  30664. }
  30665. };
  30666. /**
  30667. * Set the value of an uniform to an array of int32
  30668. * @param uniform defines the webGL uniform location where to store the value
  30669. * @param array defines the array of int32 to store
  30670. */
  30671. Engine.prototype.setIntArray = function (uniform, array) {
  30672. if (!uniform) {
  30673. return;
  30674. }
  30675. this._gl.uniform1iv(uniform, array);
  30676. };
  30677. /**
  30678. * Set the value of an uniform to an array of int32 (stored as vec2)
  30679. * @param uniform defines the webGL uniform location where to store the value
  30680. * @param array defines the array of int32 to store
  30681. */
  30682. Engine.prototype.setIntArray2 = function (uniform, array) {
  30683. if (!uniform || array.length % 2 !== 0) {
  30684. return;
  30685. }
  30686. this._gl.uniform2iv(uniform, array);
  30687. };
  30688. /**
  30689. * Set the value of an uniform to an array of int32 (stored as vec3)
  30690. * @param uniform defines the webGL uniform location where to store the value
  30691. * @param array defines the array of int32 to store
  30692. */
  30693. Engine.prototype.setIntArray3 = function (uniform, array) {
  30694. if (!uniform || array.length % 3 !== 0) {
  30695. return;
  30696. }
  30697. this._gl.uniform3iv(uniform, array);
  30698. };
  30699. /**
  30700. * Set the value of an uniform to an array of int32 (stored as vec4)
  30701. * @param uniform defines the webGL uniform location where to store the value
  30702. * @param array defines the array of int32 to store
  30703. */
  30704. Engine.prototype.setIntArray4 = function (uniform, array) {
  30705. if (!uniform || array.length % 4 !== 0) {
  30706. return;
  30707. }
  30708. this._gl.uniform4iv(uniform, array);
  30709. };
  30710. /**
  30711. * Set the value of an uniform to an array of float32
  30712. * @param uniform defines the webGL uniform location where to store the value
  30713. * @param array defines the array of float32 to store
  30714. */
  30715. Engine.prototype.setFloatArray = function (uniform, array) {
  30716. if (!uniform) {
  30717. return;
  30718. }
  30719. this._gl.uniform1fv(uniform, array);
  30720. };
  30721. /**
  30722. * Set the value of an uniform to an array of float32 (stored as vec2)
  30723. * @param uniform defines the webGL uniform location where to store the value
  30724. * @param array defines the array of float32 to store
  30725. */
  30726. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30727. if (!uniform || array.length % 2 !== 0) {
  30728. return;
  30729. }
  30730. this._gl.uniform2fv(uniform, array);
  30731. };
  30732. /**
  30733. * Set the value of an uniform to an array of float32 (stored as vec3)
  30734. * @param uniform defines the webGL uniform location where to store the value
  30735. * @param array defines the array of float32 to store
  30736. */
  30737. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30738. if (!uniform || array.length % 3 !== 0) {
  30739. return;
  30740. }
  30741. this._gl.uniform3fv(uniform, array);
  30742. };
  30743. /**
  30744. * Set the value of an uniform to an array of float32 (stored as vec4)
  30745. * @param uniform defines the webGL uniform location where to store the value
  30746. * @param array defines the array of float32 to store
  30747. */
  30748. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30749. if (!uniform || array.length % 4 !== 0) {
  30750. return;
  30751. }
  30752. this._gl.uniform4fv(uniform, array);
  30753. };
  30754. /**
  30755. * Set the value of an uniform to an array of number
  30756. * @param uniform defines the webGL uniform location where to store the value
  30757. * @param array defines the array of number to store
  30758. */
  30759. Engine.prototype.setArray = function (uniform, array) {
  30760. if (!uniform) {
  30761. return;
  30762. }
  30763. this._gl.uniform1fv(uniform, array);
  30764. };
  30765. /**
  30766. * Set the value of an uniform to an array of number (stored as vec2)
  30767. * @param uniform defines the webGL uniform location where to store the value
  30768. * @param array defines the array of number to store
  30769. */
  30770. Engine.prototype.setArray2 = function (uniform, array) {
  30771. if (!uniform || array.length % 2 !== 0) {
  30772. return;
  30773. }
  30774. this._gl.uniform2fv(uniform, array);
  30775. };
  30776. /**
  30777. * Set the value of an uniform to an array of number (stored as vec3)
  30778. * @param uniform defines the webGL uniform location where to store the value
  30779. * @param array defines the array of number to store
  30780. */
  30781. Engine.prototype.setArray3 = function (uniform, array) {
  30782. if (!uniform || array.length % 3 !== 0) {
  30783. return;
  30784. }
  30785. this._gl.uniform3fv(uniform, array);
  30786. };
  30787. /**
  30788. * Set the value of an uniform to an array of number (stored as vec4)
  30789. * @param uniform defines the webGL uniform location where to store the value
  30790. * @param array defines the array of number to store
  30791. */
  30792. Engine.prototype.setArray4 = function (uniform, array) {
  30793. if (!uniform || array.length % 4 !== 0) {
  30794. return;
  30795. }
  30796. this._gl.uniform4fv(uniform, array);
  30797. };
  30798. /**
  30799. * Set the value of an uniform to an array of float32 (stored as matrices)
  30800. * @param uniform defines the webGL uniform location where to store the value
  30801. * @param matrices defines the array of float32 to store
  30802. */
  30803. Engine.prototype.setMatrices = function (uniform, matrices) {
  30804. if (!uniform) {
  30805. return;
  30806. }
  30807. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30808. };
  30809. /**
  30810. * Set the value of an uniform to a matrix
  30811. * @param uniform defines the webGL uniform location where to store the value
  30812. * @param matrix defines the matrix to store
  30813. */
  30814. Engine.prototype.setMatrix = function (uniform, matrix) {
  30815. if (!uniform) {
  30816. return;
  30817. }
  30818. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30819. };
  30820. /**
  30821. * Set the value of an uniform to a matrix (3x3)
  30822. * @param uniform defines the webGL uniform location where to store the value
  30823. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30824. */
  30825. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30826. if (!uniform) {
  30827. return;
  30828. }
  30829. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30830. };
  30831. /**
  30832. * Set the value of an uniform to a matrix (2x2)
  30833. * @param uniform defines the webGL uniform location where to store the value
  30834. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30835. */
  30836. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30837. if (!uniform) {
  30838. return;
  30839. }
  30840. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30841. };
  30842. /**
  30843. * Set the value of an uniform to a number (int)
  30844. * @param uniform defines the webGL uniform location where to store the value
  30845. * @param value defines the int number to store
  30846. */
  30847. Engine.prototype.setInt = function (uniform, value) {
  30848. if (!uniform) {
  30849. return;
  30850. }
  30851. this._gl.uniform1i(uniform, value);
  30852. };
  30853. /**
  30854. * Set the value of an uniform to a number (float)
  30855. * @param uniform defines the webGL uniform location where to store the value
  30856. * @param value defines the float number to store
  30857. */
  30858. Engine.prototype.setFloat = function (uniform, value) {
  30859. if (!uniform) {
  30860. return;
  30861. }
  30862. this._gl.uniform1f(uniform, value);
  30863. };
  30864. /**
  30865. * Set the value of an uniform to a vec2
  30866. * @param uniform defines the webGL uniform location where to store the value
  30867. * @param x defines the 1st component of the value
  30868. * @param y defines the 2nd component of the value
  30869. */
  30870. Engine.prototype.setFloat2 = function (uniform, x, y) {
  30871. if (!uniform) {
  30872. return;
  30873. }
  30874. this._gl.uniform2f(uniform, x, y);
  30875. };
  30876. /**
  30877. * Set the value of an uniform to a vec3
  30878. * @param uniform defines the webGL uniform location where to store the value
  30879. * @param x defines the 1st component of the value
  30880. * @param y defines the 2nd component of the value
  30881. * @param z defines the 3rd component of the value
  30882. */
  30883. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  30884. if (!uniform) {
  30885. return;
  30886. }
  30887. this._gl.uniform3f(uniform, x, y, z);
  30888. };
  30889. /**
  30890. * Set the value of an uniform to a boolean
  30891. * @param uniform defines the webGL uniform location where to store the value
  30892. * @param bool defines the boolean to store
  30893. */
  30894. Engine.prototype.setBool = function (uniform, bool) {
  30895. if (!uniform) {
  30896. return;
  30897. }
  30898. this._gl.uniform1i(uniform, bool);
  30899. };
  30900. /**
  30901. * Set the value of an uniform to a vec4
  30902. * @param uniform defines the webGL uniform location where to store the value
  30903. * @param x defines the 1st component of the value
  30904. * @param y defines the 2nd component of the value
  30905. * @param z defines the 3rd component of the value
  30906. * @param w defines the 4th component of the value
  30907. */
  30908. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  30909. if (!uniform) {
  30910. return;
  30911. }
  30912. this._gl.uniform4f(uniform, x, y, z, w);
  30913. };
  30914. /**
  30915. * Set the value of an uniform to a Color3
  30916. * @param uniform defines the webGL uniform location where to store the value
  30917. * @param color3 defines the color to store
  30918. */
  30919. Engine.prototype.setColor3 = function (uniform, color3) {
  30920. if (!uniform) {
  30921. return;
  30922. }
  30923. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  30924. };
  30925. /**
  30926. * Set the value of an uniform to a Color3 and an alpha value
  30927. * @param uniform defines the webGL uniform location where to store the value
  30928. * @param color3 defines the color to store
  30929. * @param alpha defines the alpha component to store
  30930. */
  30931. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  30932. if (!uniform) {
  30933. return;
  30934. }
  30935. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  30936. };
  30937. /**
  30938. * Sets a Color4 on a uniform variable
  30939. * @param uniform defines the uniform location
  30940. * @param color4 defines the value to be set
  30941. */
  30942. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  30943. if (!uniform) {
  30944. return;
  30945. }
  30946. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  30947. };
  30948. // States
  30949. /**
  30950. * Set various states to the webGL context
  30951. * @param culling defines backface culling state
  30952. * @param zOffset defines the value to apply to zOffset (0 by default)
  30953. * @param force defines if states must be applied even if cache is up to date
  30954. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30955. */
  30956. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  30957. if (zOffset === void 0) { zOffset = 0; }
  30958. if (reverseSide === void 0) { reverseSide = false; }
  30959. // Culling
  30960. if (this._depthCullingState.cull !== culling || force) {
  30961. this._depthCullingState.cull = culling;
  30962. }
  30963. // Cull face
  30964. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  30965. if (this._depthCullingState.cullFace !== cullFace || force) {
  30966. this._depthCullingState.cullFace = cullFace;
  30967. }
  30968. // Z offset
  30969. this.setZOffset(zOffset);
  30970. // Front face
  30971. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  30972. if (this._depthCullingState.frontFace !== frontFace || force) {
  30973. this._depthCullingState.frontFace = frontFace;
  30974. }
  30975. };
  30976. /**
  30977. * Set the z offset to apply to current rendering
  30978. * @param value defines the offset to apply
  30979. */
  30980. Engine.prototype.setZOffset = function (value) {
  30981. this._depthCullingState.zOffset = value;
  30982. };
  30983. /**
  30984. * Gets the current value of the zOffset
  30985. * @returns the current zOffset state
  30986. */
  30987. Engine.prototype.getZOffset = function () {
  30988. return this._depthCullingState.zOffset;
  30989. };
  30990. /**
  30991. * Enable or disable depth buffering
  30992. * @param enable defines the state to set
  30993. */
  30994. Engine.prototype.setDepthBuffer = function (enable) {
  30995. this._depthCullingState.depthTest = enable;
  30996. };
  30997. /**
  30998. * Gets a boolean indicating if depth writing is enabled
  30999. * @returns the current depth writing state
  31000. */
  31001. Engine.prototype.getDepthWrite = function () {
  31002. return this._depthCullingState.depthMask;
  31003. };
  31004. /**
  31005. * Enable or disable depth writing
  31006. * @param enable defines the state to set
  31007. */
  31008. Engine.prototype.setDepthWrite = function (enable) {
  31009. this._depthCullingState.depthMask = enable;
  31010. };
  31011. /**
  31012. * Enable or disable color writing
  31013. * @param enable defines the state to set
  31014. */
  31015. Engine.prototype.setColorWrite = function (enable) {
  31016. this._gl.colorMask(enable, enable, enable, enable);
  31017. this._colorWrite = enable;
  31018. };
  31019. /**
  31020. * Gets a boolean indicating if color writing is enabled
  31021. * @returns the current color writing state
  31022. */
  31023. Engine.prototype.getColorWrite = function () {
  31024. return this._colorWrite;
  31025. };
  31026. /**
  31027. * Sets alpha constants used by some alpha blending modes
  31028. * @param r defines the red component
  31029. * @param g defines the green component
  31030. * @param b defines the blue component
  31031. * @param a defines the alpha component
  31032. */
  31033. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  31034. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  31035. };
  31036. /**
  31037. * Sets the current alpha mode
  31038. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31039. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31040. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31041. */
  31042. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  31043. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  31044. if (this._alphaMode === mode) {
  31045. return;
  31046. }
  31047. switch (mode) {
  31048. case Engine.ALPHA_DISABLE:
  31049. this._alphaState.alphaBlend = false;
  31050. break;
  31051. case Engine.ALPHA_PREMULTIPLIED:
  31052. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31053. this._alphaState.alphaBlend = true;
  31054. break;
  31055. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  31056. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31057. this._alphaState.alphaBlend = true;
  31058. break;
  31059. case Engine.ALPHA_COMBINE:
  31060. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31061. this._alphaState.alphaBlend = true;
  31062. break;
  31063. case Engine.ALPHA_ONEONE:
  31064. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31065. this._alphaState.alphaBlend = true;
  31066. break;
  31067. case Engine.ALPHA_ADD:
  31068. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31069. this._alphaState.alphaBlend = true;
  31070. break;
  31071. case Engine.ALPHA_SUBTRACT:
  31072. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31073. this._alphaState.alphaBlend = true;
  31074. break;
  31075. case Engine.ALPHA_MULTIPLY:
  31076. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  31077. this._alphaState.alphaBlend = true;
  31078. break;
  31079. case Engine.ALPHA_MAXIMIZED:
  31080. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31081. this._alphaState.alphaBlend = true;
  31082. break;
  31083. case Engine.ALPHA_INTERPOLATE:
  31084. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  31085. this._alphaState.alphaBlend = true;
  31086. break;
  31087. case Engine.ALPHA_SCREENMODE:
  31088. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31089. this._alphaState.alphaBlend = true;
  31090. break;
  31091. }
  31092. if (!noDepthWriteChange) {
  31093. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  31094. }
  31095. this._alphaMode = mode;
  31096. };
  31097. /**
  31098. * Gets the current alpha mode
  31099. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31100. * @returns the current alpha mode
  31101. */
  31102. Engine.prototype.getAlphaMode = function () {
  31103. return this._alphaMode;
  31104. };
  31105. // Textures
  31106. /**
  31107. * Clears the list of texture accessible through engine.
  31108. * This can help preventing texture load conflict due to name collision.
  31109. */
  31110. Engine.prototype.clearInternalTexturesCache = function () {
  31111. this._internalTexturesCache = [];
  31112. };
  31113. /**
  31114. * Force the entire cache to be cleared
  31115. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31116. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31117. */
  31118. Engine.prototype.wipeCaches = function (bruteForce) {
  31119. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  31120. return;
  31121. }
  31122. this._currentEffect = null;
  31123. this._viewportCached.x = 0;
  31124. this._viewportCached.y = 0;
  31125. this._viewportCached.z = 0;
  31126. this._viewportCached.w = 0;
  31127. if (bruteForce) {
  31128. this.resetTextureCache();
  31129. this._currentProgram = null;
  31130. this._stencilState.reset();
  31131. this._depthCullingState.reset();
  31132. this.setDepthFunctionToLessOrEqual();
  31133. this._alphaState.reset();
  31134. this._unpackFlipYCached = null;
  31135. }
  31136. this._resetVertexBufferBinding();
  31137. this._cachedIndexBuffer = null;
  31138. this._cachedEffectForVertexBuffers = null;
  31139. this._unbindVertexArrayObject();
  31140. this.bindIndexBuffer(null);
  31141. };
  31142. /**
  31143. * Set the compressed texture format to use, based on the formats you have, and the formats
  31144. * supported by the hardware / browser.
  31145. *
  31146. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31147. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31148. * to API arguments needed to compressed textures. This puts the burden on the container
  31149. * generator to house the arcane code for determining these for current & future formats.
  31150. *
  31151. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31152. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31153. *
  31154. * Note: The result of this call is not taken into account when a texture is base64.
  31155. *
  31156. * @param formatsAvailable defines the list of those format families you have created
  31157. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31158. *
  31159. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31160. * @returns The extension selected.
  31161. */
  31162. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  31163. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  31164. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  31165. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  31166. return this._textureFormatInUse = this._texturesSupported[i];
  31167. }
  31168. }
  31169. }
  31170. // actively set format to nothing, to allow this to be called more than once
  31171. // and possibly fail the 2nd time
  31172. this._textureFormatInUse = null;
  31173. return null;
  31174. };
  31175. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  31176. var gl = this._gl;
  31177. var magFilter = gl.NEAREST;
  31178. var minFilter = gl.NEAREST;
  31179. switch (samplingMode) {
  31180. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  31181. magFilter = gl.LINEAR;
  31182. if (generateMipMaps) {
  31183. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31184. }
  31185. else {
  31186. minFilter = gl.LINEAR;
  31187. }
  31188. break;
  31189. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  31190. magFilter = gl.LINEAR;
  31191. if (generateMipMaps) {
  31192. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31193. }
  31194. else {
  31195. minFilter = gl.LINEAR;
  31196. }
  31197. break;
  31198. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  31199. magFilter = gl.NEAREST;
  31200. if (generateMipMaps) {
  31201. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31202. }
  31203. else {
  31204. minFilter = gl.NEAREST;
  31205. }
  31206. break;
  31207. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  31208. magFilter = gl.NEAREST;
  31209. if (generateMipMaps) {
  31210. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31211. }
  31212. else {
  31213. minFilter = gl.NEAREST;
  31214. }
  31215. break;
  31216. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  31217. magFilter = gl.NEAREST;
  31218. if (generateMipMaps) {
  31219. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31220. }
  31221. else {
  31222. minFilter = gl.LINEAR;
  31223. }
  31224. break;
  31225. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  31226. magFilter = gl.NEAREST;
  31227. if (generateMipMaps) {
  31228. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31229. }
  31230. else {
  31231. minFilter = gl.LINEAR;
  31232. }
  31233. break;
  31234. case Engine.TEXTURE_NEAREST_LINEAR:
  31235. magFilter = gl.NEAREST;
  31236. minFilter = gl.LINEAR;
  31237. break;
  31238. case Engine.TEXTURE_NEAREST_NEAREST:
  31239. magFilter = gl.NEAREST;
  31240. minFilter = gl.NEAREST;
  31241. break;
  31242. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  31243. magFilter = gl.LINEAR;
  31244. if (generateMipMaps) {
  31245. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31246. }
  31247. else {
  31248. minFilter = gl.NEAREST;
  31249. }
  31250. break;
  31251. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  31252. magFilter = gl.LINEAR;
  31253. if (generateMipMaps) {
  31254. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31255. }
  31256. else {
  31257. minFilter = gl.NEAREST;
  31258. }
  31259. break;
  31260. case Engine.TEXTURE_LINEAR_LINEAR:
  31261. magFilter = gl.LINEAR;
  31262. minFilter = gl.LINEAR;
  31263. break;
  31264. case Engine.TEXTURE_LINEAR_NEAREST:
  31265. magFilter = gl.LINEAR;
  31266. minFilter = gl.NEAREST;
  31267. break;
  31268. }
  31269. return {
  31270. min: minFilter,
  31271. mag: magFilter
  31272. };
  31273. };
  31274. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  31275. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  31276. var img;
  31277. var onload = function () {
  31278. loadedImages[index] = img;
  31279. loadedImages._internalCount++;
  31280. if (scene) {
  31281. scene._removePendingData(img);
  31282. }
  31283. if (loadedImages._internalCount === 6) {
  31284. onfinish(loadedImages);
  31285. }
  31286. };
  31287. var onerror = function (message, exception) {
  31288. if (scene) {
  31289. scene._removePendingData(img);
  31290. }
  31291. if (onErrorCallBack) {
  31292. onErrorCallBack(message, exception);
  31293. }
  31294. };
  31295. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  31296. if (scene) {
  31297. scene._addPendingData(img);
  31298. }
  31299. };
  31300. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  31301. if (onError === void 0) { onError = null; }
  31302. var loadedImages = [];
  31303. loadedImages._internalCount = 0;
  31304. for (var index = 0; index < 6; index++) {
  31305. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  31306. }
  31307. };
  31308. /** @hidden */
  31309. Engine.prototype._createTexture = function () {
  31310. var texture = this._gl.createTexture();
  31311. if (!texture) {
  31312. throw new Error("Unable to create texture");
  31313. }
  31314. return texture;
  31315. };
  31316. /**
  31317. * Usually called from Texture.ts.
  31318. * Passed information to create a WebGLTexture
  31319. * @param urlArg defines a value which contains one of the following:
  31320. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31321. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31322. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31323. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31324. * @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)
  31325. * @param scene needed for loading to the correct scene
  31326. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31327. * @param onLoad optional callback to be called upon successful completion
  31328. * @param onError optional callback to be called upon failure
  31329. * @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
  31330. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31331. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31332. * @param forcedExtension defines the extension to use to pick the right loader
  31333. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31334. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31335. */
  31336. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  31337. var _this = this;
  31338. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31339. if (onLoad === void 0) { onLoad = null; }
  31340. if (onError === void 0) { onError = null; }
  31341. if (buffer === void 0) { buffer = null; }
  31342. if (fallback === void 0) { fallback = null; }
  31343. if (format === void 0) { format = null; }
  31344. if (forcedExtension === void 0) { forcedExtension = null; }
  31345. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31346. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  31347. var fromData = url.substr(0, 5) === "data:";
  31348. var fromBlob = url.substr(0, 5) === "blob:";
  31349. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  31350. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  31351. // establish the file extension, if possible
  31352. var lastDot = url.lastIndexOf('.');
  31353. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  31354. var loader = null;
  31355. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31356. var availableLoader = _a[_i];
  31357. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  31358. loader = availableLoader;
  31359. break;
  31360. }
  31361. }
  31362. if (loader) {
  31363. url = loader.transformUrl(url, this._textureFormatInUse);
  31364. }
  31365. if (scene) {
  31366. scene._addPendingData(texture);
  31367. }
  31368. texture.url = url;
  31369. texture.generateMipMaps = !noMipmap;
  31370. texture.samplingMode = samplingMode;
  31371. texture.invertY = invertY;
  31372. if (!this._doNotHandleContextLost) {
  31373. // Keep a link to the buffer only if we plan to handle context lost
  31374. texture._buffer = buffer;
  31375. }
  31376. var onLoadObserver = null;
  31377. if (onLoad && !fallback) {
  31378. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  31379. }
  31380. if (!fallback) {
  31381. this._internalTexturesCache.push(texture);
  31382. }
  31383. var onInternalError = function (message, exception) {
  31384. if (scene) {
  31385. scene._removePendingData(texture);
  31386. }
  31387. var customFallback = false;
  31388. if (loader) {
  31389. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  31390. if (fallbackUrl) {
  31391. // Add Back
  31392. customFallback = true;
  31393. excludeLoaders.push(loader);
  31394. _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");
  31395. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  31396. }
  31397. }
  31398. if (!customFallback) {
  31399. if (onLoadObserver) {
  31400. texture.onLoadedObservable.remove(onLoadObserver);
  31401. }
  31402. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  31403. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  31404. }
  31405. }
  31406. if (onError) {
  31407. onError(message || "Unknown error", exception);
  31408. }
  31409. };
  31410. // processing for non-image formats
  31411. if (loader) {
  31412. var callback = function (data) {
  31413. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  31414. if (loadFailed) {
  31415. onInternalError("TextureLoader failed to load data");
  31416. }
  31417. else {
  31418. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  31419. done();
  31420. return false;
  31421. }, samplingMode);
  31422. }
  31423. });
  31424. };
  31425. if (!buffer) {
  31426. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  31427. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  31428. });
  31429. }
  31430. else {
  31431. callback(buffer);
  31432. }
  31433. }
  31434. else {
  31435. var onload = function (img) {
  31436. if (fromBlob && !_this._doNotHandleContextLost) {
  31437. // We need to store the image if we need to rebuild the texture
  31438. // in case of a webgl context lost
  31439. texture._buffer = img;
  31440. }
  31441. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  31442. var gl = _this._gl;
  31443. var isPot = (img.width === potWidth && img.height === potHeight);
  31444. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  31445. if (isPot) {
  31446. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31447. return false;
  31448. }
  31449. var maxTextureSize = _this._caps.maxTextureSize;
  31450. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  31451. _this._prepareWorkingCanvas();
  31452. if (!_this._workingCanvas || !_this._workingContext) {
  31453. return false;
  31454. }
  31455. _this._workingCanvas.width = potWidth;
  31456. _this._workingCanvas.height = potHeight;
  31457. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  31458. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31459. texture.width = potWidth;
  31460. texture.height = potHeight;
  31461. return false;
  31462. }
  31463. else {
  31464. // Using shaders when possible to rescale because canvas.drawImage is lossy
  31465. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  31466. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  31467. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31468. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31469. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  31470. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31471. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31472. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  31473. _this._releaseTexture(source_1);
  31474. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31475. continuationCallback();
  31476. });
  31477. }
  31478. return true;
  31479. }, samplingMode);
  31480. };
  31481. if (!fromData || isBase64) {
  31482. if (buffer instanceof HTMLImageElement) {
  31483. onload(buffer);
  31484. }
  31485. else {
  31486. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  31487. }
  31488. }
  31489. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  31490. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  31491. }
  31492. else {
  31493. onload(buffer);
  31494. }
  31495. }
  31496. return texture;
  31497. };
  31498. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  31499. var _this = this;
  31500. var rtt = this.createRenderTargetTexture({
  31501. width: destination.width,
  31502. height: destination.height,
  31503. }, {
  31504. generateMipMaps: false,
  31505. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31506. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31507. generateDepthBuffer: false,
  31508. generateStencilBuffer: false
  31509. });
  31510. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31511. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31512. }
  31513. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31514. _this._rescalePostProcess.onApply = function (effect) {
  31515. effect._bindTexture("textureSampler", source);
  31516. };
  31517. var hostingScene = scene;
  31518. if (!hostingScene) {
  31519. hostingScene = _this.scenes[_this.scenes.length - 1];
  31520. }
  31521. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31522. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31523. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31524. _this.unBindFramebuffer(rtt);
  31525. _this._releaseTexture(rtt);
  31526. if (onComplete) {
  31527. onComplete();
  31528. }
  31529. });
  31530. };
  31531. /**
  31532. * Update a raw texture
  31533. * @param texture defines the texture to update
  31534. * @param data defines the data to store in the texture
  31535. * @param format defines the format of the data
  31536. * @param invertY defines if data must be stored with Y axis inverted
  31537. * @param compression defines the compression used (null by default)
  31538. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31539. */
  31540. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31541. if (compression === void 0) { compression = null; }
  31542. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31543. if (!texture) {
  31544. return;
  31545. }
  31546. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31547. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31548. // babylon's internalFormat but gl's texImage2D format
  31549. var internalFormat = this._getInternalFormat(format);
  31550. var textureType = this._getWebGLTextureType(type);
  31551. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31552. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31553. if (!this._doNotHandleContextLost) {
  31554. texture._bufferView = data;
  31555. texture.format = format;
  31556. texture.type = type;
  31557. texture.invertY = invertY;
  31558. texture._compression = compression;
  31559. }
  31560. if (texture.width % 4 !== 0) {
  31561. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31562. }
  31563. if (compression && data) {
  31564. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31565. }
  31566. else {
  31567. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31568. }
  31569. if (texture.generateMipMaps) {
  31570. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31571. }
  31572. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31573. // this.resetTextureCache();
  31574. texture.isReady = true;
  31575. };
  31576. /**
  31577. * Creates a raw texture
  31578. * @param data defines the data to store in the texture
  31579. * @param width defines the width of the texture
  31580. * @param height defines the height of the texture
  31581. * @param format defines the format of the data
  31582. * @param generateMipMaps defines if the engine should generate the mip levels
  31583. * @param invertY defines if data must be stored with Y axis inverted
  31584. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31585. * @param compression defines the compression used (null by default)
  31586. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31587. * @returns the raw texture inside an InternalTexture
  31588. */
  31589. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31590. if (compression === void 0) { compression = null; }
  31591. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31592. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31593. texture.baseWidth = width;
  31594. texture.baseHeight = height;
  31595. texture.width = width;
  31596. texture.height = height;
  31597. texture.format = format;
  31598. texture.generateMipMaps = generateMipMaps;
  31599. texture.samplingMode = samplingMode;
  31600. texture.invertY = invertY;
  31601. texture._compression = compression;
  31602. texture.type = type;
  31603. if (!this._doNotHandleContextLost) {
  31604. texture._bufferView = data;
  31605. }
  31606. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31607. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31608. // Filters
  31609. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31610. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31611. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31612. if (generateMipMaps) {
  31613. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31614. }
  31615. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31616. this._internalTexturesCache.push(texture);
  31617. return texture;
  31618. };
  31619. /** @hidden */
  31620. Engine.prototype._unpackFlipY = function (value) {
  31621. if (this._unpackFlipYCached !== value) {
  31622. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31623. if (this.enableUnpackFlipYCached) {
  31624. this._unpackFlipYCached = value;
  31625. }
  31626. }
  31627. };
  31628. /** @hidden */
  31629. Engine.prototype._getUnpackAlignement = function () {
  31630. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31631. };
  31632. /**
  31633. * Creates a dynamic texture
  31634. * @param width defines the width of the texture
  31635. * @param height defines the height of the texture
  31636. * @param generateMipMaps defines if the engine should generate the mip levels
  31637. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31638. * @returns the dynamic texture inside an InternalTexture
  31639. */
  31640. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31641. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31642. texture.baseWidth = width;
  31643. texture.baseHeight = height;
  31644. if (generateMipMaps) {
  31645. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31646. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31647. }
  31648. // this.resetTextureCache();
  31649. texture.width = width;
  31650. texture.height = height;
  31651. texture.isReady = false;
  31652. texture.generateMipMaps = generateMipMaps;
  31653. texture.samplingMode = samplingMode;
  31654. this.updateTextureSamplingMode(samplingMode, texture);
  31655. this._internalTexturesCache.push(texture);
  31656. return texture;
  31657. };
  31658. /**
  31659. * Update the sampling mode of a given texture
  31660. * @param samplingMode defines the required sampling mode
  31661. * @param texture defines the texture to update
  31662. */
  31663. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  31664. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  31665. if (texture.isCube) {
  31666. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31667. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31668. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31669. }
  31670. else if (texture.is3D) {
  31671. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31672. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31673. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31674. }
  31675. else {
  31676. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31677. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31678. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31679. }
  31680. texture.samplingMode = samplingMode;
  31681. };
  31682. /**
  31683. * Update the content of a dynamic texture
  31684. * @param texture defines the texture to update
  31685. * @param canvas defines the canvas containing the source
  31686. * @param invertY defines if data must be stored with Y axis inverted
  31687. * @param premulAlpha defines if alpha is stored as premultiplied
  31688. * @param format defines the format of the data
  31689. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31690. */
  31691. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  31692. if (premulAlpha === void 0) { premulAlpha = false; }
  31693. if (forceBindTexture === void 0) { forceBindTexture = false; }
  31694. if (!texture) {
  31695. return;
  31696. }
  31697. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  31698. this._unpackFlipY(invertY);
  31699. if (premulAlpha) {
  31700. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  31701. }
  31702. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  31703. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  31704. if (texture.generateMipMaps) {
  31705. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31706. }
  31707. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31708. if (premulAlpha) {
  31709. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  31710. }
  31711. texture.isReady = true;
  31712. };
  31713. /**
  31714. * Update a video texture
  31715. * @param texture defines the texture to update
  31716. * @param video defines the video element to use
  31717. * @param invertY defines if data must be stored with Y axis inverted
  31718. */
  31719. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31720. if (!texture || texture._isDisabled) {
  31721. return;
  31722. }
  31723. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31724. this._unpackFlipY(!invertY); // Video are upside down by default
  31725. try {
  31726. // Testing video texture support
  31727. if (this._videoTextureSupported === undefined) {
  31728. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31729. if (this._gl.getError() !== 0) {
  31730. this._videoTextureSupported = false;
  31731. }
  31732. else {
  31733. this._videoTextureSupported = true;
  31734. }
  31735. }
  31736. // Copy video through the current working canvas if video texture is not supported
  31737. if (!this._videoTextureSupported) {
  31738. if (!texture._workingCanvas) {
  31739. texture._workingCanvas = document.createElement("canvas");
  31740. var context = texture._workingCanvas.getContext("2d");
  31741. if (!context) {
  31742. throw new Error("Unable to get 2d context");
  31743. }
  31744. texture._workingContext = context;
  31745. texture._workingCanvas.width = texture.width;
  31746. texture._workingCanvas.height = texture.height;
  31747. }
  31748. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31749. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31750. }
  31751. else {
  31752. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31753. }
  31754. if (texture.generateMipMaps) {
  31755. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31756. }
  31757. if (!wasPreviouslyBound) {
  31758. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31759. }
  31760. // this.resetTextureCache();
  31761. texture.isReady = true;
  31762. }
  31763. catch (ex) {
  31764. // Something unexpected
  31765. // Let's disable the texture
  31766. texture._isDisabled = true;
  31767. }
  31768. };
  31769. /**
  31770. * Updates a depth texture Comparison Mode and Function.
  31771. * If the comparison Function is equal to 0, the mode will be set to none.
  31772. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31773. * @param texture The texture to set the comparison function for
  31774. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31775. */
  31776. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31777. if (this.webGLVersion === 1) {
  31778. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31779. return;
  31780. }
  31781. var gl = this._gl;
  31782. if (texture.isCube) {
  31783. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31784. if (comparisonFunction === 0) {
  31785. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31786. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31787. }
  31788. else {
  31789. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31790. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31791. }
  31792. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31793. }
  31794. else {
  31795. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31796. if (comparisonFunction === 0) {
  31797. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31798. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31799. }
  31800. else {
  31801. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31802. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31803. }
  31804. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31805. }
  31806. texture._comparisonFunction = comparisonFunction;
  31807. };
  31808. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31809. var width = size.width || size;
  31810. var height = size.height || size;
  31811. internalTexture.baseWidth = width;
  31812. internalTexture.baseHeight = height;
  31813. internalTexture.width = width;
  31814. internalTexture.height = height;
  31815. internalTexture.isReady = true;
  31816. internalTexture.samples = 1;
  31817. internalTexture.generateMipMaps = false;
  31818. internalTexture._generateDepthBuffer = true;
  31819. internalTexture._generateStencilBuffer = generateStencil;
  31820. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31821. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31822. internalTexture._comparisonFunction = comparisonFunction;
  31823. var gl = this._gl;
  31824. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31825. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31826. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31827. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31828. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31829. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31830. if (comparisonFunction === 0) {
  31831. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31832. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31833. }
  31834. else {
  31835. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31836. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31837. }
  31838. };
  31839. /**
  31840. * Creates a depth stencil texture.
  31841. * This is only available in WebGL 2 or with the depth texture extension available.
  31842. * @param size The size of face edge in the texture.
  31843. * @param options The options defining the texture.
  31844. * @returns The texture
  31845. */
  31846. Engine.prototype.createDepthStencilTexture = function (size, options) {
  31847. if (options.isCube) {
  31848. var width = size.width || size;
  31849. return this._createDepthStencilCubeTexture(width, options);
  31850. }
  31851. else {
  31852. return this._createDepthStencilTexture(size, options);
  31853. }
  31854. };
  31855. /**
  31856. * Creates a depth stencil texture.
  31857. * This is only available in WebGL 2 or with the depth texture extension available.
  31858. * @param size The size of face edge in the texture.
  31859. * @param options The options defining the texture.
  31860. * @returns The texture
  31861. */
  31862. Engine.prototype._createDepthStencilTexture = function (size, options) {
  31863. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  31864. if (!this._caps.depthTextureExtension) {
  31865. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  31866. return internalTexture;
  31867. }
  31868. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31869. var gl = this._gl;
  31870. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  31871. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31872. if (this.webGLVersion > 1) {
  31873. if (internalOptions.generateStencil) {
  31874. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31875. }
  31876. else {
  31877. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31878. }
  31879. }
  31880. else {
  31881. if (internalOptions.generateStencil) {
  31882. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31883. }
  31884. else {
  31885. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31886. }
  31887. }
  31888. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31889. return internalTexture;
  31890. };
  31891. /**
  31892. * Creates a depth stencil cube texture.
  31893. * This is only available in WebGL 2.
  31894. * @param size The size of face edge in the cube texture.
  31895. * @param options The options defining the cube texture.
  31896. * @returns The cube texture
  31897. */
  31898. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  31899. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  31900. internalTexture.isCube = true;
  31901. if (this.webGLVersion === 1) {
  31902. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  31903. return internalTexture;
  31904. }
  31905. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31906. var gl = this._gl;
  31907. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  31908. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31909. // Create the depth/stencil buffer
  31910. for (var face = 0; face < 6; face++) {
  31911. if (internalOptions.generateStencil) {
  31912. 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);
  31913. }
  31914. else {
  31915. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31916. }
  31917. }
  31918. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31919. return internalTexture;
  31920. };
  31921. /**
  31922. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31923. * @param renderTarget The render target to set the frame buffer for
  31924. */
  31925. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  31926. // Create the framebuffer
  31927. var internalTexture = renderTarget.getInternalTexture();
  31928. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  31929. return;
  31930. }
  31931. var gl = this._gl;
  31932. var depthStencilTexture = renderTarget.depthStencilTexture;
  31933. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  31934. if (depthStencilTexture.isCube) {
  31935. if (depthStencilTexture._generateStencilBuffer) {
  31936. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31937. }
  31938. else {
  31939. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31940. }
  31941. }
  31942. else {
  31943. if (depthStencilTexture._generateStencilBuffer) {
  31944. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31945. }
  31946. else {
  31947. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31948. }
  31949. }
  31950. this.bindUnboundFramebuffer(null);
  31951. };
  31952. /**
  31953. * Creates a new render target texture
  31954. * @param size defines the size of the texture
  31955. * @param options defines the options used to create the texture
  31956. * @returns a new render target texture stored in an InternalTexture
  31957. */
  31958. Engine.prototype.createRenderTargetTexture = function (size, options) {
  31959. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  31960. if (options !== undefined && typeof options === "object") {
  31961. fullOptions.generateMipMaps = options.generateMipMaps;
  31962. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31963. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  31964. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  31965. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  31966. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  31967. }
  31968. else {
  31969. fullOptions.generateMipMaps = options;
  31970. fullOptions.generateDepthBuffer = true;
  31971. fullOptions.generateStencilBuffer = false;
  31972. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31973. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31974. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  31975. }
  31976. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31977. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31978. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31979. }
  31980. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31981. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31982. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31983. }
  31984. var gl = this._gl;
  31985. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31986. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31987. var width = size.width || size;
  31988. var height = size.height || size;
  31989. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  31990. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31991. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31992. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31993. }
  31994. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31995. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31996. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31997. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31998. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  31999. // Create the framebuffer
  32000. var currentFrameBuffer = this._currentFramebuffer;
  32001. var framebuffer = gl.createFramebuffer();
  32002. this.bindUnboundFramebuffer(framebuffer);
  32003. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32004. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  32005. if (fullOptions.generateMipMaps) {
  32006. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32007. }
  32008. // Unbind
  32009. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32010. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32011. this.bindUnboundFramebuffer(currentFrameBuffer);
  32012. texture._framebuffer = framebuffer;
  32013. texture.baseWidth = width;
  32014. texture.baseHeight = height;
  32015. texture.width = width;
  32016. texture.height = height;
  32017. texture.isReady = true;
  32018. texture.samples = 1;
  32019. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  32020. texture.samplingMode = fullOptions.samplingMode;
  32021. texture.type = fullOptions.type;
  32022. texture.format = fullOptions.format;
  32023. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32024. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  32025. // this.resetTextureCache();
  32026. this._internalTexturesCache.push(texture);
  32027. return texture;
  32028. };
  32029. /**
  32030. * Create a multi render target texture
  32031. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  32032. * @param size defines the size of the texture
  32033. * @param options defines the creation options
  32034. * @returns the cube texture as an InternalTexture
  32035. */
  32036. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  32037. var generateMipMaps = false;
  32038. var generateDepthBuffer = true;
  32039. var generateStencilBuffer = false;
  32040. var generateDepthTexture = false;
  32041. var textureCount = 1;
  32042. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  32043. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32044. var types = new Array();
  32045. var samplingModes = new Array();
  32046. if (options !== undefined) {
  32047. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  32048. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32049. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  32050. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  32051. textureCount = options.textureCount || 1;
  32052. if (options.types) {
  32053. types = options.types;
  32054. }
  32055. if (options.samplingModes) {
  32056. samplingModes = options.samplingModes;
  32057. }
  32058. }
  32059. var gl = this._gl;
  32060. // Create the framebuffer
  32061. var framebuffer = gl.createFramebuffer();
  32062. this.bindUnboundFramebuffer(framebuffer);
  32063. var width = size.width || size;
  32064. var height = size.height || size;
  32065. var textures = [];
  32066. var attachments = [];
  32067. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  32068. for (var i = 0; i < textureCount; i++) {
  32069. var samplingMode = samplingModes[i] || defaultSamplingMode;
  32070. var type = types[i] || defaultType;
  32071. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32072. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32073. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32074. }
  32075. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32076. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32077. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32078. }
  32079. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32080. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32081. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32082. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32083. }
  32084. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32085. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32086. textures.push(texture);
  32087. attachments.push(attachment);
  32088. gl.activeTexture(gl["TEXTURE" + i]);
  32089. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  32090. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32091. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32092. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32093. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32094. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32095. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32096. if (generateMipMaps) {
  32097. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32098. }
  32099. // Unbind
  32100. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32101. texture._framebuffer = framebuffer;
  32102. texture._depthStencilBuffer = depthStencilBuffer;
  32103. texture.baseWidth = width;
  32104. texture.baseHeight = height;
  32105. texture.width = width;
  32106. texture.height = height;
  32107. texture.isReady = true;
  32108. texture.samples = 1;
  32109. texture.generateMipMaps = generateMipMaps;
  32110. texture.samplingMode = samplingMode;
  32111. texture.type = type;
  32112. texture._generateDepthBuffer = generateDepthBuffer;
  32113. texture._generateStencilBuffer = generateStencilBuffer;
  32114. texture._attachments = attachments;
  32115. this._internalTexturesCache.push(texture);
  32116. }
  32117. if (generateDepthTexture && this._caps.depthTextureExtension) {
  32118. // Depth texture
  32119. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32120. gl.activeTexture(gl.TEXTURE0);
  32121. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  32122. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32123. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32124. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32125. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32126. 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);
  32127. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  32128. depthTexture._framebuffer = framebuffer;
  32129. depthTexture.baseWidth = width;
  32130. depthTexture.baseHeight = height;
  32131. depthTexture.width = width;
  32132. depthTexture.height = height;
  32133. depthTexture.isReady = true;
  32134. depthTexture.samples = 1;
  32135. depthTexture.generateMipMaps = generateMipMaps;
  32136. depthTexture.samplingMode = gl.NEAREST;
  32137. depthTexture._generateDepthBuffer = generateDepthBuffer;
  32138. depthTexture._generateStencilBuffer = generateStencilBuffer;
  32139. textures.push(depthTexture);
  32140. this._internalTexturesCache.push(depthTexture);
  32141. }
  32142. gl.drawBuffers(attachments);
  32143. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32144. this.bindUnboundFramebuffer(null);
  32145. this.resetTextureCache();
  32146. return textures;
  32147. };
  32148. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  32149. if (samples === void 0) { samples = 1; }
  32150. var depthStencilBuffer = null;
  32151. var gl = this._gl;
  32152. // Create the depth/stencil buffer
  32153. if (generateStencilBuffer) {
  32154. depthStencilBuffer = gl.createRenderbuffer();
  32155. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32156. if (samples > 1) {
  32157. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  32158. }
  32159. else {
  32160. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  32161. }
  32162. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32163. }
  32164. else if (generateDepthBuffer) {
  32165. depthStencilBuffer = gl.createRenderbuffer();
  32166. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32167. if (samples > 1) {
  32168. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  32169. }
  32170. else {
  32171. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  32172. }
  32173. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32174. }
  32175. return depthStencilBuffer;
  32176. };
  32177. /**
  32178. * Updates the sample count of a render target texture
  32179. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32180. * @param texture defines the texture to update
  32181. * @param samples defines the sample count to set
  32182. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32183. */
  32184. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  32185. if (this.webGLVersion < 2 || !texture) {
  32186. return 1;
  32187. }
  32188. if (texture.samples === samples) {
  32189. return samples;
  32190. }
  32191. var gl = this._gl;
  32192. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32193. // Dispose previous render buffers
  32194. if (texture._depthStencilBuffer) {
  32195. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32196. texture._depthStencilBuffer = null;
  32197. }
  32198. if (texture._MSAAFramebuffer) {
  32199. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32200. texture._MSAAFramebuffer = null;
  32201. }
  32202. if (texture._MSAARenderBuffer) {
  32203. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32204. texture._MSAARenderBuffer = null;
  32205. }
  32206. if (samples > 1) {
  32207. var framebuffer = gl.createFramebuffer();
  32208. if (!framebuffer) {
  32209. throw new Error("Unable to create multi sampled framebuffer");
  32210. }
  32211. texture._MSAAFramebuffer = framebuffer;
  32212. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  32213. var colorRenderbuffer = gl.createRenderbuffer();
  32214. if (!colorRenderbuffer) {
  32215. throw new Error("Unable to create multi sampled framebuffer");
  32216. }
  32217. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32218. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32219. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  32220. texture._MSAARenderBuffer = colorRenderbuffer;
  32221. }
  32222. else {
  32223. this.bindUnboundFramebuffer(texture._framebuffer);
  32224. }
  32225. texture.samples = samples;
  32226. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  32227. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32228. this.bindUnboundFramebuffer(null);
  32229. return samples;
  32230. };
  32231. /**
  32232. * Update the sample count for a given multiple render target texture
  32233. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32234. * @param textures defines the textures to update
  32235. * @param samples defines the sample count to set
  32236. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32237. */
  32238. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  32239. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  32240. return 1;
  32241. }
  32242. if (textures[0].samples === samples) {
  32243. return samples;
  32244. }
  32245. var gl = this._gl;
  32246. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32247. // Dispose previous render buffers
  32248. if (textures[0]._depthStencilBuffer) {
  32249. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  32250. textures[0]._depthStencilBuffer = null;
  32251. }
  32252. if (textures[0]._MSAAFramebuffer) {
  32253. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  32254. textures[0]._MSAAFramebuffer = null;
  32255. }
  32256. for (var i = 0; i < textures.length; i++) {
  32257. if (textures[i]._MSAARenderBuffer) {
  32258. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  32259. textures[i]._MSAARenderBuffer = null;
  32260. }
  32261. }
  32262. if (samples > 1) {
  32263. var framebuffer = gl.createFramebuffer();
  32264. if (!framebuffer) {
  32265. throw new Error("Unable to create multi sampled framebuffer");
  32266. }
  32267. this.bindUnboundFramebuffer(framebuffer);
  32268. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  32269. var attachments = [];
  32270. for (var i = 0; i < textures.length; i++) {
  32271. var texture = textures[i];
  32272. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32273. var colorRenderbuffer = gl.createRenderbuffer();
  32274. if (!colorRenderbuffer) {
  32275. throw new Error("Unable to create multi sampled framebuffer");
  32276. }
  32277. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32278. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32279. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  32280. texture._MSAAFramebuffer = framebuffer;
  32281. texture._MSAARenderBuffer = colorRenderbuffer;
  32282. texture.samples = samples;
  32283. texture._depthStencilBuffer = depthStencilBuffer;
  32284. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32285. attachments.push(attachment);
  32286. }
  32287. gl.drawBuffers(attachments);
  32288. }
  32289. else {
  32290. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  32291. }
  32292. this.bindUnboundFramebuffer(null);
  32293. return samples;
  32294. };
  32295. /** @hidden */
  32296. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  32297. if (faceIndex === void 0) { faceIndex = 0; }
  32298. if (lod === void 0) { lod = 0; }
  32299. var gl = this._gl;
  32300. var target = gl.TEXTURE_2D;
  32301. if (texture.isCube) {
  32302. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32303. }
  32304. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  32305. };
  32306. /** @hidden */
  32307. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  32308. if (faceIndex === void 0) { faceIndex = 0; }
  32309. if (lod === void 0) { lod = 0; }
  32310. var gl = this._gl;
  32311. var textureType = this._getWebGLTextureType(texture.type);
  32312. var format = this._getInternalFormat(texture.format);
  32313. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32314. this._unpackFlipY(texture.invertY);
  32315. var target = gl.TEXTURE_2D;
  32316. if (texture.isCube) {
  32317. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32318. }
  32319. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  32320. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  32321. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  32322. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  32323. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  32324. };
  32325. /** @hidden */
  32326. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  32327. if (faceIndex === void 0) { faceIndex = 0; }
  32328. if (lod === void 0) { lod = 0; }
  32329. var gl = this._gl;
  32330. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32331. this._bindTextureDirectly(bindTarget, texture, true);
  32332. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  32333. this._bindTextureDirectly(bindTarget, null, true);
  32334. };
  32335. /** @hidden */
  32336. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  32337. if (faceIndex === void 0) { faceIndex = 0; }
  32338. if (lod === void 0) { lod = 0; }
  32339. var gl = this._gl;
  32340. var textureType = this._getWebGLTextureType(texture.type);
  32341. var format = this._getInternalFormat(texture.format);
  32342. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32343. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32344. this._bindTextureDirectly(bindTarget, texture, true);
  32345. this._unpackFlipY(texture.invertY);
  32346. var target = gl.TEXTURE_2D;
  32347. if (texture.isCube) {
  32348. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32349. }
  32350. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  32351. this._bindTextureDirectly(bindTarget, null, true);
  32352. };
  32353. /**
  32354. * Creates a new render target cube texture
  32355. * @param size defines the size of the texture
  32356. * @param options defines the options used to create the texture
  32357. * @returns a new render target cube texture stored in an InternalTexture
  32358. */
  32359. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  32360. 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);
  32361. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  32362. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32363. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32364. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32365. }
  32366. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32367. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32368. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32369. }
  32370. var gl = this._gl;
  32371. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32372. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32373. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  32374. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32375. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32376. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  32377. }
  32378. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32379. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32380. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32381. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32382. for (var face = 0; face < 6; face++) {
  32383. 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);
  32384. }
  32385. // Create the framebuffer
  32386. var framebuffer = gl.createFramebuffer();
  32387. this.bindUnboundFramebuffer(framebuffer);
  32388. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  32389. // MipMaps
  32390. if (fullOptions.generateMipMaps) {
  32391. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32392. }
  32393. // Unbind
  32394. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32395. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32396. this.bindUnboundFramebuffer(null);
  32397. texture._framebuffer = framebuffer;
  32398. texture.width = size;
  32399. texture.height = size;
  32400. texture.isReady = true;
  32401. texture.isCube = true;
  32402. texture.samples = 1;
  32403. texture.generateMipMaps = fullOptions.generateMipMaps;
  32404. texture.samplingMode = fullOptions.samplingMode;
  32405. texture.type = fullOptions.type;
  32406. texture.format = fullOptions.format;
  32407. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32408. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  32409. this._internalTexturesCache.push(texture);
  32410. return texture;
  32411. };
  32412. /**
  32413. * Creates a cube texture
  32414. * @param rootUrl defines the url where the files to load is located
  32415. * @param scene defines the current scene
  32416. * @param files defines the list of files to load (1 per face)
  32417. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  32418. * @param onLoad defines an optional callback raised when the texture is loaded
  32419. * @param onError defines an optional callback raised if there is an issue to load the texture
  32420. * @param format defines the format of the data
  32421. * @param forcedExtension defines the extension to use to pick the right loader
  32422. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  32423. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  32424. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  32425. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  32426. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  32427. * @returns the cube texture as an InternalTexture
  32428. */
  32429. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  32430. var _this = this;
  32431. if (onLoad === void 0) { onLoad = null; }
  32432. if (onError === void 0) { onError = null; }
  32433. if (forcedExtension === void 0) { forcedExtension = null; }
  32434. if (createPolynomials === void 0) { createPolynomials = false; }
  32435. if (lodScale === void 0) { lodScale = 0; }
  32436. if (lodOffset === void 0) { lodOffset = 0; }
  32437. if (fallback === void 0) { fallback = null; }
  32438. if (excludeLoaders === void 0) { excludeLoaders = []; }
  32439. var gl = this._gl;
  32440. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  32441. texture.isCube = true;
  32442. texture.url = rootUrl;
  32443. texture.generateMipMaps = !noMipmap;
  32444. texture._lodGenerationScale = lodScale;
  32445. texture._lodGenerationOffset = lodOffset;
  32446. if (!this._doNotHandleContextLost) {
  32447. texture._extension = forcedExtension;
  32448. texture._files = files;
  32449. }
  32450. var lastDot = rootUrl.lastIndexOf('.');
  32451. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  32452. var loader = null;
  32453. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  32454. var availableLoader = _a[_i];
  32455. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  32456. loader = availableLoader;
  32457. break;
  32458. }
  32459. }
  32460. var onInternalError = function (request, exception) {
  32461. if (loader) {
  32462. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  32463. _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");
  32464. if (fallbackUrl) {
  32465. excludeLoaders.push(loader);
  32466. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  32467. return;
  32468. }
  32469. }
  32470. if (onError && request) {
  32471. onError(request.status + " " + request.statusText, exception);
  32472. }
  32473. };
  32474. if (loader) {
  32475. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  32476. var onloaddata = function (data) {
  32477. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32478. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  32479. };
  32480. if (files && files.length === 6) {
  32481. if (loader.supportCascades) {
  32482. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  32483. }
  32484. else if (onError) {
  32485. onError("Textures type does not support cascades.");
  32486. }
  32487. }
  32488. else {
  32489. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  32490. }
  32491. }
  32492. else {
  32493. if (!files) {
  32494. throw new Error("Cannot load cubemap because files were not defined");
  32495. }
  32496. this._cascadeLoadImgs(scene, function (imgs) {
  32497. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  32498. var height = width;
  32499. _this._prepareWorkingCanvas();
  32500. if (!_this._workingCanvas || !_this._workingContext) {
  32501. return;
  32502. }
  32503. _this._workingCanvas.width = width;
  32504. _this._workingCanvas.height = height;
  32505. var faces = [
  32506. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32507. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32508. ];
  32509. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32510. _this._unpackFlipY(false);
  32511. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32512. for (var index = 0; index < faces.length; index++) {
  32513. if (imgs[index].width !== width || imgs[index].height !== height) {
  32514. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32515. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32516. }
  32517. else {
  32518. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, imgs[index]);
  32519. }
  32520. }
  32521. if (!noMipmap) {
  32522. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32523. }
  32524. _this._setCubeMapTextureParams(!noMipmap);
  32525. texture.width = width;
  32526. texture.height = height;
  32527. texture.isReady = true;
  32528. if (format) {
  32529. texture.format = format;
  32530. }
  32531. texture.onLoadedObservable.notifyObservers(texture);
  32532. texture.onLoadedObservable.clear();
  32533. if (onLoad) {
  32534. onLoad();
  32535. }
  32536. }, files, onError);
  32537. }
  32538. this._internalTexturesCache.push(texture);
  32539. return texture;
  32540. };
  32541. /**
  32542. * @hidden
  32543. */
  32544. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32545. var gl = this._gl;
  32546. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32547. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32548. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32549. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32550. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32551. // this.resetTextureCache();
  32552. };
  32553. /**
  32554. * Update a raw cube texture
  32555. * @param texture defines the texture to udpdate
  32556. * @param data defines the data to store
  32557. * @param format defines the data format
  32558. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32559. * @param invertY defines if data must be stored with Y axis inverted
  32560. * @param compression defines the compression used (null by default)
  32561. * @param level defines which level of the texture to update
  32562. */
  32563. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32564. if (compression === void 0) { compression = null; }
  32565. if (level === void 0) { level = 0; }
  32566. texture._bufferViewArray = data;
  32567. texture.format = format;
  32568. texture.type = type;
  32569. texture.invertY = invertY;
  32570. texture._compression = compression;
  32571. var gl = this._gl;
  32572. var textureType = this._getWebGLTextureType(type);
  32573. var internalFormat = this._getInternalFormat(format);
  32574. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32575. var needConversion = false;
  32576. if (internalFormat === gl.RGB) {
  32577. internalFormat = gl.RGBA;
  32578. needConversion = true;
  32579. }
  32580. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32581. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32582. if (texture.width % 4 !== 0) {
  32583. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32584. }
  32585. // Data are known to be in +X +Y +Z -X -Y -Z
  32586. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32587. var faceData = data[faceIndex];
  32588. if (compression) {
  32589. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32590. }
  32591. else {
  32592. if (needConversion) {
  32593. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32594. }
  32595. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32596. }
  32597. }
  32598. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32599. if (isPot && texture.generateMipMaps && level === 0) {
  32600. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32601. }
  32602. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32603. // this.resetTextureCache();
  32604. texture.isReady = true;
  32605. };
  32606. /**
  32607. * Creates a new raw cube texture
  32608. * @param data defines the array of data to use to create each face
  32609. * @param size defines the size of the textures
  32610. * @param format defines the format of the data
  32611. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32612. * @param generateMipMaps defines if the engine should generate the mip levels
  32613. * @param invertY defines if data must be stored with Y axis inverted
  32614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32615. * @param compression defines the compression used (null by default)
  32616. * @returns the cube texture as an InternalTexture
  32617. */
  32618. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32619. if (compression === void 0) { compression = null; }
  32620. var gl = this._gl;
  32621. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32622. texture.isCube = true;
  32623. texture.format = format;
  32624. texture.type = type;
  32625. if (!this._doNotHandleContextLost) {
  32626. texture._bufferViewArray = data;
  32627. }
  32628. var textureType = this._getWebGLTextureType(type);
  32629. var internalFormat = this._getInternalFormat(format);
  32630. if (internalFormat === gl.RGB) {
  32631. internalFormat = gl.RGBA;
  32632. }
  32633. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32634. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32635. generateMipMaps = false;
  32636. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32637. _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.");
  32638. }
  32639. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32640. generateMipMaps = false;
  32641. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32642. _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.");
  32643. }
  32644. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32645. generateMipMaps = false;
  32646. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32647. }
  32648. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  32649. generateMipMaps = false;
  32650. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  32651. }
  32652. var width = size;
  32653. var height = width;
  32654. texture.width = width;
  32655. texture.height = height;
  32656. // Double check on POT to generate Mips.
  32657. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32658. if (!isPot) {
  32659. generateMipMaps = false;
  32660. }
  32661. // Upload data if needed. The texture won't be ready until then.
  32662. if (data) {
  32663. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  32664. }
  32665. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32666. // Filters
  32667. if (data && generateMipMaps) {
  32668. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32669. }
  32670. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32671. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32672. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32673. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32674. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32675. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32676. texture.generateMipMaps = generateMipMaps;
  32677. return texture;
  32678. };
  32679. /**
  32680. * Creates a new raw cube texture from a specified url
  32681. * @param url defines the url where the data is located
  32682. * @param scene defines the current scene
  32683. * @param size defines the size of the textures
  32684. * @param format defines the format of the data
  32685. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32686. * @param noMipmap defines if the engine should avoid generating the mip levels
  32687. * @param callback defines a callback used to extract texture data from loaded data
  32688. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  32689. * @param onLoad defines a callback called when texture is loaded
  32690. * @param onError defines a callback called if there is an error
  32691. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32692. * @param invertY defines if data must be stored with Y axis inverted
  32693. * @returns the cube texture as an InternalTexture
  32694. */
  32695. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  32696. var _this = this;
  32697. if (onLoad === void 0) { onLoad = null; }
  32698. if (onError === void 0) { onError = null; }
  32699. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32700. if (invertY === void 0) { invertY = false; }
  32701. var gl = this._gl;
  32702. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  32703. scene._addPendingData(texture);
  32704. texture.url = url;
  32705. this._internalTexturesCache.push(texture);
  32706. var onerror = function (request, exception) {
  32707. scene._removePendingData(texture);
  32708. if (onError && request) {
  32709. onError(request.status + " " + request.statusText, exception);
  32710. }
  32711. };
  32712. var internalCallback = function (data) {
  32713. var width = texture.width;
  32714. var faceDataArrays = callback(data);
  32715. if (!faceDataArrays) {
  32716. return;
  32717. }
  32718. if (mipmapGenerator) {
  32719. var textureType = _this._getWebGLTextureType(type);
  32720. var internalFormat = _this._getInternalFormat(format);
  32721. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32722. var needConversion = false;
  32723. if (internalFormat === gl.RGB) {
  32724. internalFormat = gl.RGBA;
  32725. needConversion = true;
  32726. }
  32727. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32728. _this._unpackFlipY(false);
  32729. var mipData = mipmapGenerator(faceDataArrays);
  32730. for (var level = 0; level < mipData.length; level++) {
  32731. var mipSize = width >> level;
  32732. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32733. var mipFaceData = mipData[level][faceIndex];
  32734. if (needConversion) {
  32735. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32736. }
  32737. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32738. }
  32739. }
  32740. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32741. }
  32742. else {
  32743. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32744. }
  32745. texture.isReady = true;
  32746. // this.resetTextureCache();
  32747. scene._removePendingData(texture);
  32748. if (onLoad) {
  32749. onLoad();
  32750. }
  32751. };
  32752. this._loadFile(url, function (data) {
  32753. internalCallback(data);
  32754. }, undefined, scene.offlineProvider, true, onerror);
  32755. return texture;
  32756. };
  32757. /**
  32758. * Update a raw 3D texture
  32759. * @param texture defines the texture to update
  32760. * @param data defines the data to store
  32761. * @param format defines the data format
  32762. * @param invertY defines if data must be stored with Y axis inverted
  32763. * @param compression defines the used compression (can be null)
  32764. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32765. */
  32766. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32767. if (compression === void 0) { compression = null; }
  32768. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32769. var internalType = this._getWebGLTextureType(textureType);
  32770. var internalFormat = this._getInternalFormat(format);
  32771. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32772. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32773. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32774. if (!this._doNotHandleContextLost) {
  32775. texture._bufferView = data;
  32776. texture.format = format;
  32777. texture.invertY = invertY;
  32778. texture._compression = compression;
  32779. }
  32780. if (texture.width % 4 !== 0) {
  32781. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32782. }
  32783. if (compression && data) {
  32784. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32785. }
  32786. else {
  32787. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32788. }
  32789. if (texture.generateMipMaps) {
  32790. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32791. }
  32792. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32793. // this.resetTextureCache();
  32794. texture.isReady = true;
  32795. };
  32796. /**
  32797. * Creates a new raw 3D texture
  32798. * @param data defines the data used to create the texture
  32799. * @param width defines the width of the texture
  32800. * @param height defines the height of the texture
  32801. * @param depth defines the depth of the texture
  32802. * @param format defines the format of the texture
  32803. * @param generateMipMaps defines if the engine must generate mip levels
  32804. * @param invertY defines if data must be stored with Y axis inverted
  32805. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32806. * @param compression defines the compressed used (can be null)
  32807. * @param textureType defines the compressed used (can be null)
  32808. * @returns a new raw 3D texture (stored in an InternalTexture)
  32809. */
  32810. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  32811. if (compression === void 0) { compression = null; }
  32812. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32813. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  32814. texture.baseWidth = width;
  32815. texture.baseHeight = height;
  32816. texture.baseDepth = depth;
  32817. texture.width = width;
  32818. texture.height = height;
  32819. texture.depth = depth;
  32820. texture.format = format;
  32821. texture.type = textureType;
  32822. texture.generateMipMaps = generateMipMaps;
  32823. texture.samplingMode = samplingMode;
  32824. texture.is3D = true;
  32825. if (!this._doNotHandleContextLost) {
  32826. texture._bufferView = data;
  32827. }
  32828. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  32829. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32830. // Filters
  32831. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32832. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32833. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32834. if (generateMipMaps) {
  32835. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32836. }
  32837. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32838. this._internalTexturesCache.push(texture);
  32839. return texture;
  32840. };
  32841. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  32842. var gl = this._gl;
  32843. if (!gl) {
  32844. return;
  32845. }
  32846. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  32847. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32848. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32849. if (!noMipmap && !isCompressed) {
  32850. gl.generateMipmap(gl.TEXTURE_2D);
  32851. }
  32852. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32853. // this.resetTextureCache();
  32854. if (scene) {
  32855. scene._removePendingData(texture);
  32856. }
  32857. texture.onLoadedObservable.notifyObservers(texture);
  32858. texture.onLoadedObservable.clear();
  32859. };
  32860. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  32861. var _this = this;
  32862. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32863. var maxTextureSize = this.getCaps().maxTextureSize;
  32864. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  32865. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  32866. var gl = this._gl;
  32867. if (!gl) {
  32868. return;
  32869. }
  32870. if (!texture._webGLTexture) {
  32871. // this.resetTextureCache();
  32872. if (scene) {
  32873. scene._removePendingData(texture);
  32874. }
  32875. return;
  32876. }
  32877. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32878. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32879. texture.baseWidth = width;
  32880. texture.baseHeight = height;
  32881. texture.width = potWidth;
  32882. texture.height = potHeight;
  32883. texture.isReady = true;
  32884. if (processFunction(potWidth, potHeight, function () {
  32885. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32886. })) {
  32887. // Returning as texture needs extra async steps
  32888. return;
  32889. }
  32890. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32891. };
  32892. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  32893. // Create new RGBA data container.
  32894. var rgbaData;
  32895. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  32896. rgbaData = new Float32Array(width * height * 4);
  32897. }
  32898. else {
  32899. rgbaData = new Uint32Array(width * height * 4);
  32900. }
  32901. // Convert each pixel.
  32902. for (var x = 0; x < width; x++) {
  32903. for (var y = 0; y < height; y++) {
  32904. var index = (y * width + x) * 3;
  32905. var newIndex = (y * width + x) * 4;
  32906. // Map Old Value to new value.
  32907. rgbaData[newIndex + 0] = rgbData[index + 0];
  32908. rgbaData[newIndex + 1] = rgbData[index + 1];
  32909. rgbaData[newIndex + 2] = rgbData[index + 2];
  32910. // Add fully opaque alpha channel.
  32911. rgbaData[newIndex + 3] = 1;
  32912. }
  32913. }
  32914. return rgbaData;
  32915. };
  32916. /** @hidden */
  32917. Engine.prototype._releaseFramebufferObjects = function (texture) {
  32918. var gl = this._gl;
  32919. if (texture._framebuffer) {
  32920. gl.deleteFramebuffer(texture._framebuffer);
  32921. texture._framebuffer = null;
  32922. }
  32923. if (texture._depthStencilBuffer) {
  32924. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32925. texture._depthStencilBuffer = null;
  32926. }
  32927. if (texture._MSAAFramebuffer) {
  32928. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32929. texture._MSAAFramebuffer = null;
  32930. }
  32931. if (texture._MSAARenderBuffer) {
  32932. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32933. texture._MSAARenderBuffer = null;
  32934. }
  32935. };
  32936. /** @hidden */
  32937. Engine.prototype._releaseTexture = function (texture) {
  32938. var gl = this._gl;
  32939. this._releaseFramebufferObjects(texture);
  32940. gl.deleteTexture(texture._webGLTexture);
  32941. // Unbind channels
  32942. this.unbindAllTextures();
  32943. var index = this._internalTexturesCache.indexOf(texture);
  32944. if (index !== -1) {
  32945. this._internalTexturesCache.splice(index, 1);
  32946. }
  32947. // Integrated fixed lod samplers.
  32948. if (texture._lodTextureHigh) {
  32949. texture._lodTextureHigh.dispose();
  32950. }
  32951. if (texture._lodTextureMid) {
  32952. texture._lodTextureMid.dispose();
  32953. }
  32954. if (texture._lodTextureLow) {
  32955. texture._lodTextureLow.dispose();
  32956. }
  32957. // Set output texture of post process to null if the texture has been released/disposed
  32958. this.scenes.forEach(function (scene) {
  32959. scene.postProcesses.forEach(function (postProcess) {
  32960. if (postProcess._outputTexture == texture) {
  32961. postProcess._outputTexture = null;
  32962. }
  32963. });
  32964. scene.cameras.forEach(function (camera) {
  32965. camera._postProcesses.forEach(function (postProcess) {
  32966. if (postProcess) {
  32967. if (postProcess._outputTexture == texture) {
  32968. postProcess._outputTexture = null;
  32969. }
  32970. }
  32971. });
  32972. });
  32973. });
  32974. };
  32975. Engine.prototype.setProgram = function (program) {
  32976. if (this._currentProgram !== program) {
  32977. this._gl.useProgram(program);
  32978. this._currentProgram = program;
  32979. }
  32980. };
  32981. /**
  32982. * Binds an effect to the webGL context
  32983. * @param effect defines the effect to bind
  32984. */
  32985. Engine.prototype.bindSamplers = function (effect) {
  32986. this.setProgram(effect.getProgram());
  32987. var samplers = effect.getSamplers();
  32988. for (var index = 0; index < samplers.length; index++) {
  32989. var uniform = effect.getUniform(samplers[index]);
  32990. if (uniform) {
  32991. this._boundUniforms[index] = uniform;
  32992. }
  32993. }
  32994. this._currentEffect = null;
  32995. };
  32996. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  32997. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  32998. return;
  32999. }
  33000. // Remove
  33001. this._linkTrackers(internalTexture.previous, internalTexture.next);
  33002. // Bind last to it
  33003. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  33004. // Bind to dummy
  33005. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  33006. };
  33007. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  33008. if (!internalTexture) {
  33009. return -1;
  33010. }
  33011. internalTexture._initialSlot = channel;
  33012. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  33013. if (channel !== internalTexture._designatedSlot) {
  33014. this._textureCollisions.addCount(1, false);
  33015. }
  33016. }
  33017. else {
  33018. if (channel !== internalTexture._designatedSlot) {
  33019. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  33020. return internalTexture._designatedSlot;
  33021. }
  33022. else {
  33023. // No slot for this texture, let's pick a new one (if we find a free slot)
  33024. if (this._nextFreeTextureSlots.length) {
  33025. return this._nextFreeTextureSlots[0];
  33026. }
  33027. // We need to recycle the oldest bound texture, sorry.
  33028. this._textureCollisions.addCount(1, false);
  33029. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  33030. }
  33031. }
  33032. }
  33033. return channel;
  33034. };
  33035. Engine.prototype._linkTrackers = function (previous, next) {
  33036. previous.next = next;
  33037. next.previous = previous;
  33038. };
  33039. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  33040. var currentSlot = internalTexture._designatedSlot;
  33041. if (currentSlot === -1) {
  33042. return -1;
  33043. }
  33044. internalTexture._designatedSlot = -1;
  33045. if (this.disableTextureBindingOptimization) {
  33046. return -1;
  33047. }
  33048. // Remove from bound list
  33049. this._linkTrackers(internalTexture.previous, internalTexture.next);
  33050. // Free the slot
  33051. this._boundTexturesCache[currentSlot] = null;
  33052. this._nextFreeTextureSlots.push(currentSlot);
  33053. return currentSlot;
  33054. };
  33055. Engine.prototype._activateCurrentTexture = function () {
  33056. if (this._currentTextureChannel !== this._activeChannel) {
  33057. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  33058. this._currentTextureChannel = this._activeChannel;
  33059. }
  33060. };
  33061. /** @hidden */
  33062. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  33063. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  33064. if (force === void 0) { force = false; }
  33065. var wasPreviouslyBound = false;
  33066. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  33067. this._activeChannel = texture._designatedSlot;
  33068. }
  33069. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  33070. var isTextureForRendering = texture && texture._initialSlot > -1;
  33071. if (currentTextureBound !== texture || force) {
  33072. if (currentTextureBound) {
  33073. this._removeDesignatedSlot(currentTextureBound);
  33074. }
  33075. this._activateCurrentTexture();
  33076. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  33077. this._boundTexturesCache[this._activeChannel] = texture;
  33078. if (texture) {
  33079. if (!this.disableTextureBindingOptimization) {
  33080. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  33081. if (slotIndex > -1) {
  33082. this._nextFreeTextureSlots.splice(slotIndex, 1);
  33083. }
  33084. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  33085. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  33086. }
  33087. texture._designatedSlot = this._activeChannel;
  33088. }
  33089. }
  33090. else if (forTextureDataUpdate) {
  33091. wasPreviouslyBound = true;
  33092. this._activateCurrentTexture();
  33093. }
  33094. if (isTextureForRendering && !forTextureDataUpdate) {
  33095. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  33096. }
  33097. return wasPreviouslyBound;
  33098. };
  33099. /** @hidden */
  33100. Engine.prototype._bindTexture = function (channel, texture) {
  33101. if (channel < 0) {
  33102. return;
  33103. }
  33104. if (texture) {
  33105. channel = this._getCorrectTextureChannel(channel, texture);
  33106. }
  33107. this._activeChannel = channel;
  33108. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  33109. };
  33110. /**
  33111. * Sets a texture to the webGL context from a postprocess
  33112. * @param channel defines the channel to use
  33113. * @param postProcess defines the source postprocess
  33114. */
  33115. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  33116. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  33117. };
  33118. /**
  33119. * Binds the output of the passed in post process to the texture channel specified
  33120. * @param channel The channel the texture should be bound to
  33121. * @param postProcess The post process which's output should be bound
  33122. */
  33123. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  33124. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  33125. };
  33126. /**
  33127. * Unbind all textures from the webGL context
  33128. */
  33129. Engine.prototype.unbindAllTextures = function () {
  33130. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  33131. this._activeChannel = channel;
  33132. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33133. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33134. if (this.webGLVersion > 1) {
  33135. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33136. }
  33137. }
  33138. };
  33139. /**
  33140. * Sets a texture to the according uniform.
  33141. * @param channel The texture channel
  33142. * @param uniform The uniform to set
  33143. * @param texture The texture to apply
  33144. */
  33145. Engine.prototype.setTexture = function (channel, uniform, texture) {
  33146. if (channel < 0) {
  33147. return;
  33148. }
  33149. if (uniform) {
  33150. this._boundUniforms[channel] = uniform;
  33151. }
  33152. this._setTexture(channel, texture);
  33153. };
  33154. /**
  33155. * Sets a depth stencil texture from a render target to the according uniform.
  33156. * @param channel The texture channel
  33157. * @param uniform The uniform to set
  33158. * @param texture The render target texture containing the depth stencil texture to apply
  33159. */
  33160. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  33161. if (channel < 0) {
  33162. return;
  33163. }
  33164. if (uniform) {
  33165. this._boundUniforms[channel] = uniform;
  33166. }
  33167. if (!texture || !texture.depthStencilTexture) {
  33168. this._setTexture(channel, null);
  33169. }
  33170. else {
  33171. this._setTexture(channel, texture, false, true);
  33172. }
  33173. };
  33174. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  33175. var uniform = this._boundUniforms[sourceSlot];
  33176. if (uniform._currentState === destination) {
  33177. return;
  33178. }
  33179. this._gl.uniform1i(uniform, destination);
  33180. uniform._currentState = destination;
  33181. };
  33182. Engine.prototype._getTextureWrapMode = function (mode) {
  33183. switch (mode) {
  33184. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  33185. return this._gl.REPEAT;
  33186. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  33187. return this._gl.CLAMP_TO_EDGE;
  33188. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  33189. return this._gl.MIRRORED_REPEAT;
  33190. }
  33191. return this._gl.REPEAT;
  33192. };
  33193. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  33194. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  33195. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  33196. // Not ready?
  33197. if (!texture) {
  33198. if (this._boundTexturesCache[channel] != null) {
  33199. this._activeChannel = channel;
  33200. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33201. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33202. if (this.webGLVersion > 1) {
  33203. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33204. }
  33205. }
  33206. return false;
  33207. }
  33208. // Video
  33209. if (texture.video) {
  33210. this._activeChannel = channel;
  33211. texture.update();
  33212. }
  33213. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  33214. texture.delayLoad();
  33215. return false;
  33216. }
  33217. var internalTexture;
  33218. if (depthStencilTexture) {
  33219. internalTexture = texture.depthStencilTexture;
  33220. }
  33221. else if (texture.isReady()) {
  33222. internalTexture = texture.getInternalTexture();
  33223. }
  33224. else if (texture.isCube) {
  33225. internalTexture = this.emptyCubeTexture;
  33226. }
  33227. else if (texture.is3D) {
  33228. internalTexture = this.emptyTexture3D;
  33229. }
  33230. else {
  33231. internalTexture = this.emptyTexture;
  33232. }
  33233. if (!isPartOfTextureArray) {
  33234. channel = this._getCorrectTextureChannel(channel, internalTexture);
  33235. }
  33236. var needToBind = true;
  33237. if (this._boundTexturesCache[channel] === internalTexture) {
  33238. this._moveBoundTextureOnTop(internalTexture);
  33239. if (!isPartOfTextureArray) {
  33240. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  33241. }
  33242. needToBind = false;
  33243. }
  33244. this._activeChannel = channel;
  33245. if (internalTexture && internalTexture.is3D) {
  33246. if (needToBind) {
  33247. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  33248. }
  33249. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33250. internalTexture._cachedWrapU = texture.wrapU;
  33251. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33252. }
  33253. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33254. internalTexture._cachedWrapV = texture.wrapV;
  33255. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33256. }
  33257. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  33258. internalTexture._cachedWrapR = texture.wrapR;
  33259. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  33260. }
  33261. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  33262. }
  33263. else if (internalTexture && internalTexture.isCube) {
  33264. if (needToBind) {
  33265. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  33266. }
  33267. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  33268. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  33269. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  33270. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  33271. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  33272. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  33273. }
  33274. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  33275. }
  33276. else {
  33277. if (needToBind) {
  33278. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  33279. }
  33280. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33281. internalTexture._cachedWrapU = texture.wrapU;
  33282. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33283. }
  33284. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33285. internalTexture._cachedWrapV = texture.wrapV;
  33286. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33287. }
  33288. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  33289. }
  33290. return true;
  33291. };
  33292. /**
  33293. * Sets an array of texture to the webGL context
  33294. * @param channel defines the channel where the texture array must be set
  33295. * @param uniform defines the associated uniform location
  33296. * @param textures defines the array of textures to bind
  33297. */
  33298. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  33299. if (channel < 0 || !uniform) {
  33300. return;
  33301. }
  33302. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  33303. this._textureUnits = new Int32Array(textures.length);
  33304. }
  33305. for (var i = 0; i < textures.length; i++) {
  33306. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  33307. }
  33308. this._gl.uniform1iv(uniform, this._textureUnits);
  33309. for (var index = 0; index < textures.length; index++) {
  33310. this._setTexture(this._textureUnits[index], textures[index], true);
  33311. }
  33312. };
  33313. /** @hidden */
  33314. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  33315. var internalTexture = texture.getInternalTexture();
  33316. if (!internalTexture) {
  33317. return;
  33318. }
  33319. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  33320. var value = texture.anisotropicFilteringLevel;
  33321. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  33322. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  33323. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  33324. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  33325. }
  33326. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  33327. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  33328. internalTexture._cachedAnisotropicFilteringLevel = value;
  33329. }
  33330. };
  33331. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  33332. this._bindTextureDirectly(target, texture, true, true);
  33333. this._gl.texParameterf(target, parameter, value);
  33334. };
  33335. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  33336. if (texture) {
  33337. this._bindTextureDirectly(target, texture, true, true);
  33338. }
  33339. this._gl.texParameteri(target, parameter, value);
  33340. };
  33341. /**
  33342. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33343. * @param x defines the x coordinate of the rectangle where pixels must be read
  33344. * @param y defines the y coordinate of the rectangle where pixels must be read
  33345. * @param width defines the width of the rectangle where pixels must be read
  33346. * @param height defines the height of the rectangle where pixels must be read
  33347. * @returns a Uint8Array containing RGBA colors
  33348. */
  33349. Engine.prototype.readPixels = function (x, y, width, height) {
  33350. var data = new Uint8Array(height * width * 4);
  33351. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  33352. return data;
  33353. };
  33354. /**
  33355. * Add an externaly attached data from its key.
  33356. * This method call will fail and return false, if such key already exists.
  33357. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33358. * @param key the unique key that identifies the data
  33359. * @param data the data object to associate to the key for this Engine instance
  33360. * @return true if no such key were already present and the data was added successfully, false otherwise
  33361. */
  33362. Engine.prototype.addExternalData = function (key, data) {
  33363. if (!this._externalData) {
  33364. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33365. }
  33366. return this._externalData.add(key, data);
  33367. };
  33368. /**
  33369. * Get an externaly attached data from its key
  33370. * @param key the unique key that identifies the data
  33371. * @return the associated data, if present (can be null), or undefined if not present
  33372. */
  33373. Engine.prototype.getExternalData = function (key) {
  33374. if (!this._externalData) {
  33375. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33376. }
  33377. return this._externalData.get(key);
  33378. };
  33379. /**
  33380. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33381. * @param key the unique key that identifies the data
  33382. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33383. * @return the associated data, can be null if the factory returned null.
  33384. */
  33385. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  33386. if (!this._externalData) {
  33387. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33388. }
  33389. return this._externalData.getOrAddWithFactory(key, factory);
  33390. };
  33391. /**
  33392. * Remove an externaly attached data from the Engine instance
  33393. * @param key the unique key that identifies the data
  33394. * @return true if the data was successfully removed, false if it doesn't exist
  33395. */
  33396. Engine.prototype.removeExternalData = function (key) {
  33397. if (!this._externalData) {
  33398. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33399. }
  33400. return this._externalData.remove(key);
  33401. };
  33402. /**
  33403. * Unbind all vertex attributes from the webGL context
  33404. */
  33405. Engine.prototype.unbindAllAttributes = function () {
  33406. if (this._mustWipeVertexAttributes) {
  33407. this._mustWipeVertexAttributes = false;
  33408. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  33409. this._gl.disableVertexAttribArray(i);
  33410. this._vertexAttribArraysEnabled[i] = false;
  33411. this._currentBufferPointers[i].active = false;
  33412. }
  33413. return;
  33414. }
  33415. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  33416. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  33417. continue;
  33418. }
  33419. this._gl.disableVertexAttribArray(i);
  33420. this._vertexAttribArraysEnabled[i] = false;
  33421. this._currentBufferPointers[i].active = false;
  33422. }
  33423. };
  33424. /**
  33425. * 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
  33426. */
  33427. Engine.prototype.releaseEffects = function () {
  33428. for (var name in this._compiledEffects) {
  33429. this._deleteProgram(this._compiledEffects[name]._program);
  33430. }
  33431. this._compiledEffects = {};
  33432. };
  33433. /**
  33434. * Dispose and release all associated resources
  33435. */
  33436. Engine.prototype.dispose = function () {
  33437. this.hideLoadingUI();
  33438. this.stopRenderLoop();
  33439. this.onNewSceneAddedObservable.clear();
  33440. // Release postProcesses
  33441. while (this.postProcesses.length) {
  33442. this.postProcesses[0].dispose();
  33443. }
  33444. // Empty texture
  33445. if (this._emptyTexture) {
  33446. this._releaseTexture(this._emptyTexture);
  33447. this._emptyTexture = null;
  33448. }
  33449. if (this._emptyCubeTexture) {
  33450. this._releaseTexture(this._emptyCubeTexture);
  33451. this._emptyCubeTexture = null;
  33452. }
  33453. // Rescale PP
  33454. if (this._rescalePostProcess) {
  33455. this._rescalePostProcess.dispose();
  33456. }
  33457. // Release scenes
  33458. while (this.scenes.length) {
  33459. this.scenes[0].dispose();
  33460. }
  33461. // Release audio engine
  33462. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  33463. Engine.audioEngine.dispose();
  33464. }
  33465. // Release effects
  33466. this.releaseEffects();
  33467. // Unbind
  33468. this.unbindAllAttributes();
  33469. this._boundUniforms = [];
  33470. if (this._dummyFramebuffer) {
  33471. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  33472. }
  33473. //WebVR
  33474. this.disableVR();
  33475. // Events
  33476. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33477. window.removeEventListener("blur", this._onBlur);
  33478. window.removeEventListener("focus", this._onFocus);
  33479. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  33480. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  33481. if (this._renderingCanvas) {
  33482. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  33483. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  33484. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  33485. if (!this._doNotHandleContextLost) {
  33486. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  33487. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  33488. }
  33489. }
  33490. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  33491. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  33492. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  33493. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  33494. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  33495. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  33496. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  33497. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  33498. if (this._onVrDisplayConnect) {
  33499. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  33500. if (this._onVrDisplayDisconnect) {
  33501. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  33502. }
  33503. if (this._onVrDisplayPresentChange) {
  33504. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  33505. }
  33506. this._onVrDisplayConnect = null;
  33507. this._onVrDisplayDisconnect = null;
  33508. }
  33509. }
  33510. // Remove from Instances
  33511. var index = Engine.Instances.indexOf(this);
  33512. if (index >= 0) {
  33513. Engine.Instances.splice(index, 1);
  33514. }
  33515. this._workingCanvas = null;
  33516. this._workingContext = null;
  33517. this._currentBufferPointers = [];
  33518. this._renderingCanvas = null;
  33519. this._currentProgram = null;
  33520. this._bindedRenderFunction = null;
  33521. this.onResizeObservable.clear();
  33522. this.onCanvasBlurObservable.clear();
  33523. this.onCanvasFocusObservable.clear();
  33524. this.onCanvasPointerOutObservable.clear();
  33525. this.onBeginFrameObservable.clear();
  33526. this.onEndFrameObservable.clear();
  33527. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33528. // Abort active requests
  33529. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33530. var request = _a[_i];
  33531. request.abort();
  33532. }
  33533. };
  33534. // Loading screen
  33535. /**
  33536. * Display the loading screen
  33537. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33538. */
  33539. Engine.prototype.displayLoadingUI = function () {
  33540. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33541. return;
  33542. }
  33543. var loadingScreen = this.loadingScreen;
  33544. if (loadingScreen) {
  33545. loadingScreen.displayLoadingUI();
  33546. }
  33547. };
  33548. /**
  33549. * Hide the loading screen
  33550. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33551. */
  33552. Engine.prototype.hideLoadingUI = function () {
  33553. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33554. return;
  33555. }
  33556. var loadingScreen = this.loadingScreen;
  33557. if (loadingScreen) {
  33558. loadingScreen.hideLoadingUI();
  33559. }
  33560. };
  33561. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33562. /**
  33563. * Gets the current loading screen object
  33564. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33565. */
  33566. get: function () {
  33567. if (!this._loadingScreen && this._renderingCanvas) {
  33568. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33569. }
  33570. return this._loadingScreen;
  33571. },
  33572. /**
  33573. * Sets the current loading screen object
  33574. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33575. */
  33576. set: function (loadingScreen) {
  33577. this._loadingScreen = loadingScreen;
  33578. },
  33579. enumerable: true,
  33580. configurable: true
  33581. });
  33582. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33583. /**
  33584. * Sets the current loading screen text
  33585. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33586. */
  33587. set: function (text) {
  33588. this.loadingScreen.loadingUIText = text;
  33589. },
  33590. enumerable: true,
  33591. configurable: true
  33592. });
  33593. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33594. /**
  33595. * Sets the current loading screen background color
  33596. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33597. */
  33598. set: function (color) {
  33599. this.loadingScreen.loadingUIBackgroundColor = color;
  33600. },
  33601. enumerable: true,
  33602. configurable: true
  33603. });
  33604. /**
  33605. * Attach a new callback raised when context lost event is fired
  33606. * @param callback defines the callback to call
  33607. */
  33608. Engine.prototype.attachContextLostEvent = function (callback) {
  33609. if (this._renderingCanvas) {
  33610. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33611. }
  33612. };
  33613. /**
  33614. * Attach a new callback raised when context restored event is fired
  33615. * @param callback defines the callback to call
  33616. */
  33617. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33618. if (this._renderingCanvas) {
  33619. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33620. }
  33621. };
  33622. /**
  33623. * Gets the source code of the vertex shader associated with a specific webGL program
  33624. * @param program defines the program to use
  33625. * @returns a string containing the source code of the vertex shader associated with the program
  33626. */
  33627. Engine.prototype.getVertexShaderSource = function (program) {
  33628. var shaders = this._gl.getAttachedShaders(program);
  33629. if (!shaders) {
  33630. return null;
  33631. }
  33632. return this._gl.getShaderSource(shaders[0]);
  33633. };
  33634. /**
  33635. * Gets the source code of the fragment shader associated with a specific webGL program
  33636. * @param program defines the program to use
  33637. * @returns a string containing the source code of the fragment shader associated with the program
  33638. */
  33639. Engine.prototype.getFragmentShaderSource = function (program) {
  33640. var shaders = this._gl.getAttachedShaders(program);
  33641. if (!shaders) {
  33642. return null;
  33643. }
  33644. return this._gl.getShaderSource(shaders[1]);
  33645. };
  33646. /**
  33647. * Get the current error code of the webGL context
  33648. * @returns the error code
  33649. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33650. */
  33651. Engine.prototype.getError = function () {
  33652. return this._gl.getError();
  33653. };
  33654. // FPS
  33655. /**
  33656. * Gets the current framerate
  33657. * @returns a number representing the framerate
  33658. */
  33659. Engine.prototype.getFps = function () {
  33660. return this._fps;
  33661. };
  33662. /**
  33663. * Gets the time spent between current and previous frame
  33664. * @returns a number representing the delta time in ms
  33665. */
  33666. Engine.prototype.getDeltaTime = function () {
  33667. return this._deltaTime;
  33668. };
  33669. Engine.prototype._measureFps = function () {
  33670. this._performanceMonitor.sampleFrame();
  33671. this._fps = this._performanceMonitor.averageFPS;
  33672. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  33673. };
  33674. /** @hidden */
  33675. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  33676. if (faceIndex === void 0) { faceIndex = -1; }
  33677. if (level === void 0) { level = 0; }
  33678. if (buffer === void 0) { buffer = null; }
  33679. var gl = this._gl;
  33680. if (!this._dummyFramebuffer) {
  33681. var dummy = gl.createFramebuffer();
  33682. if (!dummy) {
  33683. throw new Error("Unable to create dummy framebuffer");
  33684. }
  33685. this._dummyFramebuffer = dummy;
  33686. }
  33687. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  33688. if (faceIndex > -1) {
  33689. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  33690. }
  33691. else {
  33692. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  33693. }
  33694. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  33695. switch (readType) {
  33696. case gl.UNSIGNED_BYTE:
  33697. if (!buffer) {
  33698. buffer = new Uint8Array(4 * width * height);
  33699. }
  33700. readType = gl.UNSIGNED_BYTE;
  33701. break;
  33702. default:
  33703. if (!buffer) {
  33704. buffer = new Float32Array(4 * width * height);
  33705. }
  33706. readType = gl.FLOAT;
  33707. break;
  33708. }
  33709. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  33710. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  33711. return buffer;
  33712. };
  33713. Engine.prototype._canRenderToFloatFramebuffer = function () {
  33714. if (this._webGLVersion > 1) {
  33715. return this._caps.colorBufferFloat;
  33716. }
  33717. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  33718. };
  33719. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33720. if (this._webGLVersion > 1) {
  33721. return this._caps.colorBufferFloat;
  33722. }
  33723. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33724. };
  33725. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33726. Engine.prototype._canRenderToFramebuffer = function (type) {
  33727. var gl = this._gl;
  33728. //clear existing errors
  33729. while (gl.getError() !== gl.NO_ERROR) { }
  33730. var successful = true;
  33731. var texture = gl.createTexture();
  33732. gl.bindTexture(gl.TEXTURE_2D, texture);
  33733. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33734. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33735. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33736. var fb = gl.createFramebuffer();
  33737. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33738. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33739. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33740. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33741. successful = successful && (gl.getError() === gl.NO_ERROR);
  33742. //try render by clearing frame buffer's color buffer
  33743. if (successful) {
  33744. gl.clear(gl.COLOR_BUFFER_BIT);
  33745. successful = successful && (gl.getError() === gl.NO_ERROR);
  33746. }
  33747. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33748. if (successful) {
  33749. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33750. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33751. var readFormat = gl.RGBA;
  33752. var readType = gl.UNSIGNED_BYTE;
  33753. var buffer = new Uint8Array(4);
  33754. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33755. successful = successful && (gl.getError() === gl.NO_ERROR);
  33756. }
  33757. //clean up
  33758. gl.deleteTexture(texture);
  33759. gl.deleteFramebuffer(fb);
  33760. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33761. //clear accumulated errors
  33762. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33763. return successful;
  33764. };
  33765. /** @hidden */
  33766. Engine.prototype._getWebGLTextureType = function (type) {
  33767. if (this._webGLVersion === 1) {
  33768. switch (type) {
  33769. case Engine.TEXTURETYPE_FLOAT:
  33770. return this._gl.FLOAT;
  33771. case Engine.TEXTURETYPE_HALF_FLOAT:
  33772. return this._gl.HALF_FLOAT_OES;
  33773. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33774. return this._gl.UNSIGNED_BYTE;
  33775. }
  33776. return this._gl.UNSIGNED_BYTE;
  33777. }
  33778. switch (type) {
  33779. case Engine.TEXTURETYPE_BYTE:
  33780. return this._gl.BYTE;
  33781. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33782. return this._gl.UNSIGNED_BYTE;
  33783. case Engine.TEXTURETYPE_SHORT:
  33784. return this._gl.SHORT;
  33785. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33786. return this._gl.UNSIGNED_SHORT;
  33787. case Engine.TEXTURETYPE_INT:
  33788. return this._gl.INT;
  33789. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33790. return this._gl.UNSIGNED_INT;
  33791. case Engine.TEXTURETYPE_FLOAT:
  33792. return this._gl.FLOAT;
  33793. case Engine.TEXTURETYPE_HALF_FLOAT:
  33794. return this._gl.HALF_FLOAT;
  33795. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33796. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  33797. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33798. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  33799. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33800. return this._gl.UNSIGNED_SHORT_5_6_5;
  33801. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33802. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  33803. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  33804. return this._gl.UNSIGNED_INT_24_8;
  33805. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33806. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  33807. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33808. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  33809. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  33810. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  33811. }
  33812. return this._gl.UNSIGNED_BYTE;
  33813. };
  33814. Engine.prototype._getInternalFormat = function (format) {
  33815. var internalFormat = this._gl.RGBA;
  33816. switch (format) {
  33817. case Engine.TEXTUREFORMAT_ALPHA:
  33818. internalFormat = this._gl.ALPHA;
  33819. break;
  33820. case Engine.TEXTUREFORMAT_LUMINANCE:
  33821. internalFormat = this._gl.LUMINANCE;
  33822. break;
  33823. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33824. internalFormat = this._gl.LUMINANCE_ALPHA;
  33825. break;
  33826. case Engine.TEXTUREFORMAT_RED:
  33827. internalFormat = this._gl.RED;
  33828. break;
  33829. case Engine.TEXTUREFORMAT_RG:
  33830. internalFormat = this._gl.RG;
  33831. break;
  33832. case Engine.TEXTUREFORMAT_RGB:
  33833. internalFormat = this._gl.RGB;
  33834. break;
  33835. case Engine.TEXTUREFORMAT_RGBA:
  33836. internalFormat = this._gl.RGBA;
  33837. break;
  33838. }
  33839. if (this._webGLVersion > 1) {
  33840. switch (format) {
  33841. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33842. internalFormat = this._gl.RED_INTEGER;
  33843. break;
  33844. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33845. internalFormat = this._gl.RG_INTEGER;
  33846. break;
  33847. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33848. internalFormat = this._gl.RGB_INTEGER;
  33849. break;
  33850. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33851. internalFormat = this._gl.RGBA_INTEGER;
  33852. break;
  33853. }
  33854. }
  33855. return internalFormat;
  33856. };
  33857. /** @hidden */
  33858. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  33859. if (this._webGLVersion === 1) {
  33860. if (format !== undefined) {
  33861. switch (format) {
  33862. case Engine.TEXTUREFORMAT_ALPHA:
  33863. return this._gl.ALPHA;
  33864. case Engine.TEXTUREFORMAT_LUMINANCE:
  33865. return this._gl.LUMINANCE;
  33866. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33867. return this._gl.LUMINANCE_ALPHA;
  33868. }
  33869. }
  33870. return this._gl.RGBA;
  33871. }
  33872. switch (type) {
  33873. case Engine.TEXTURETYPE_BYTE:
  33874. switch (format) {
  33875. case Engine.TEXTUREFORMAT_RED:
  33876. return this._gl.R8_SNORM;
  33877. case Engine.TEXTUREFORMAT_RG:
  33878. return this._gl.RG8_SNORM;
  33879. case Engine.TEXTUREFORMAT_RGB:
  33880. return this._gl.RGB8_SNORM;
  33881. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33882. return this._gl.R8I;
  33883. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33884. return this._gl.RG8I;
  33885. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33886. return this._gl.RGB8I;
  33887. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33888. return this._gl.RGBA8I;
  33889. default:
  33890. return this._gl.RGBA8_SNORM;
  33891. }
  33892. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33893. switch (format) {
  33894. case Engine.TEXTUREFORMAT_RED:
  33895. return this._gl.R8;
  33896. case Engine.TEXTUREFORMAT_RG:
  33897. return this._gl.RG8;
  33898. case Engine.TEXTUREFORMAT_RGB:
  33899. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  33900. case Engine.TEXTUREFORMAT_RGBA:
  33901. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  33902. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33903. return this._gl.R8UI;
  33904. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33905. return this._gl.RG8UI;
  33906. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33907. return this._gl.RGB8UI;
  33908. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33909. return this._gl.RGBA8UI;
  33910. default:
  33911. return this._gl.RGBA8;
  33912. }
  33913. case Engine.TEXTURETYPE_SHORT:
  33914. switch (format) {
  33915. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33916. return this._gl.R16I;
  33917. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33918. return this._gl.RG16I;
  33919. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33920. return this._gl.RGB16I;
  33921. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33922. return this._gl.RGBA16I;
  33923. default:
  33924. return this._gl.RGBA16I;
  33925. }
  33926. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33927. switch (format) {
  33928. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33929. return this._gl.R16UI;
  33930. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33931. return this._gl.RG16UI;
  33932. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33933. return this._gl.RGB16UI;
  33934. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33935. return this._gl.RGBA16UI;
  33936. default:
  33937. return this._gl.RGBA16UI;
  33938. }
  33939. case Engine.TEXTURETYPE_INT:
  33940. switch (format) {
  33941. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33942. return this._gl.R32I;
  33943. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33944. return this._gl.RG32I;
  33945. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33946. return this._gl.RGB32I;
  33947. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33948. return this._gl.RGBA32I;
  33949. default:
  33950. return this._gl.RGBA32I;
  33951. }
  33952. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33953. switch (format) {
  33954. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33955. return this._gl.R32UI;
  33956. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33957. return this._gl.RG32UI;
  33958. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33959. return this._gl.RGB32UI;
  33960. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33961. return this._gl.RGBA32UI;
  33962. default:
  33963. return this._gl.RGBA32UI;
  33964. }
  33965. case Engine.TEXTURETYPE_FLOAT:
  33966. switch (format) {
  33967. case Engine.TEXTUREFORMAT_RED:
  33968. return this._gl.R32F; // By default. Other possibility is R16F.
  33969. case Engine.TEXTUREFORMAT_RG:
  33970. return this._gl.RG32F; // By default. Other possibility is RG16F.
  33971. case Engine.TEXTUREFORMAT_RGB:
  33972. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  33973. case Engine.TEXTUREFORMAT_RGBA:
  33974. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  33975. default:
  33976. return this._gl.RGBA32F;
  33977. }
  33978. case Engine.TEXTURETYPE_HALF_FLOAT:
  33979. switch (format) {
  33980. case Engine.TEXTUREFORMAT_RED:
  33981. return this._gl.R16F;
  33982. case Engine.TEXTUREFORMAT_RG:
  33983. return this._gl.RG16F;
  33984. case Engine.TEXTUREFORMAT_RGB:
  33985. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  33986. case Engine.TEXTUREFORMAT_RGBA:
  33987. return this._gl.RGBA16F;
  33988. default:
  33989. return this._gl.RGBA16F;
  33990. }
  33991. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33992. return this._gl.RGB565;
  33993. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33994. return this._gl.R11F_G11F_B10F;
  33995. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33996. return this._gl.RGB9_E5;
  33997. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33998. return this._gl.RGBA4;
  33999. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34000. return this._gl.RGB5_A1;
  34001. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34002. switch (format) {
  34003. case Engine.TEXTUREFORMAT_RGBA:
  34004. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  34005. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34006. return this._gl.RGB10_A2UI;
  34007. default:
  34008. return this._gl.RGB10_A2;
  34009. }
  34010. }
  34011. return this._gl.RGBA8;
  34012. };
  34013. /** @hidden */
  34014. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  34015. if (type === Engine.TEXTURETYPE_FLOAT) {
  34016. return this._gl.RGBA32F;
  34017. }
  34018. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  34019. return this._gl.RGBA16F;
  34020. }
  34021. return this._gl.RGBA8;
  34022. };
  34023. /** @hidden */
  34024. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  34025. var _this = this;
  34026. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  34027. this._activeRequests.push(request);
  34028. request.onCompleteObservable.add(function (request) {
  34029. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  34030. });
  34031. return request;
  34032. };
  34033. /** @hidden */
  34034. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  34035. var _this = this;
  34036. return new Promise(function (resolve, reject) {
  34037. _this._loadFile(url, function (data) {
  34038. resolve(data);
  34039. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  34040. reject(exception);
  34041. });
  34042. });
  34043. };
  34044. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  34045. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  34046. var onload = function (data) {
  34047. loadedFiles[index] = data;
  34048. loadedFiles._internalCount++;
  34049. if (loadedFiles._internalCount === 6) {
  34050. onfinish(loadedFiles);
  34051. }
  34052. };
  34053. var onerror = function (request, exception) {
  34054. if (onErrorCallBack && request) {
  34055. onErrorCallBack(request.status + " " + request.statusText, exception);
  34056. }
  34057. };
  34058. this._loadFile(url, onload, undefined, undefined, true, onerror);
  34059. };
  34060. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  34061. if (onError === void 0) { onError = null; }
  34062. var loadedFiles = [];
  34063. loadedFiles._internalCount = 0;
  34064. for (var index = 0; index < 6; index++) {
  34065. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  34066. }
  34067. };
  34068. // Statics
  34069. /**
  34070. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34071. * @returns true if the engine can be created
  34072. * @ignorenaming
  34073. */
  34074. Engine.isSupported = function () {
  34075. try {
  34076. var tempcanvas = document.createElement("canvas");
  34077. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  34078. return gl != null && !!window.WebGLRenderingContext;
  34079. }
  34080. catch (e) {
  34081. return false;
  34082. }
  34083. };
  34084. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34085. Engine.ExceptionList = [
  34086. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  34087. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34088. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34089. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34090. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34091. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  34092. ];
  34093. /**
  34094. * Hidden
  34095. */
  34096. Engine._TextureLoaders = [];
  34097. // Const statics
  34098. /** Defines that alpha blending is disabled */
  34099. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  34100. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34101. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  34102. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34103. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  34104. /** Defines that alpha blending to DEST - SRC * DEST */
  34105. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  34106. /** Defines that alpha blending to SRC * DEST */
  34107. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  34108. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34109. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  34110. /** Defines that alpha blending to SRC + DEST */
  34111. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  34112. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34113. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  34114. /**
  34115. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34116. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34117. */
  34118. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  34119. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34120. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  34121. /**
  34122. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34123. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34124. */
  34125. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  34126. /** Defines that the ressource is not delayed*/
  34127. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  34128. /** Defines that the ressource was successfully delay loaded */
  34129. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  34130. /** Defines that the ressource is currently delay loading */
  34131. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  34132. /** Defines that the ressource is delayed and has not started loading */
  34133. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  34134. // Depht or Stencil test Constants.
  34135. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34136. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  34137. /** 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 */
  34138. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  34139. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34140. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  34141. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34142. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  34143. /** 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 */
  34144. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  34145. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34146. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  34147. /** 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 */
  34148. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  34149. /** 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 */
  34150. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  34151. // Stencil Actions Constants.
  34152. /** Passed to stencilOperation to specify that stencil value must be kept */
  34153. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  34154. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34155. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  34156. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34157. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  34158. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34159. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  34160. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34161. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  34162. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34163. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  34164. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34165. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  34166. /** Texture is not repeating outside of 0..1 UVs */
  34167. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  34168. /** Texture is repeating outside of 0..1 UVs */
  34169. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  34170. /** Texture is repeating and mirrored */
  34171. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  34172. /** ALPHA */
  34173. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  34174. /** LUMINANCE */
  34175. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  34176. /** LUMINANCE_ALPHA */
  34177. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  34178. /** RGB */
  34179. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  34180. /** RGBA */
  34181. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  34182. /** RED */
  34183. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  34184. /** RED (2nd reference) */
  34185. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  34186. /** RG */
  34187. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  34188. /** RED_INTEGER */
  34189. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  34190. /** RED_INTEGER (2nd reference) */
  34191. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  34192. /** RG_INTEGER */
  34193. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  34194. /** RGB_INTEGER */
  34195. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  34196. /** RGBA_INTEGER */
  34197. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  34198. /** UNSIGNED_BYTE */
  34199. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  34200. /** UNSIGNED_BYTE (2nd reference) */
  34201. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34202. /** FLOAT */
  34203. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  34204. /** HALF_FLOAT */
  34205. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  34206. /** BYTE */
  34207. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  34208. /** SHORT */
  34209. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  34210. /** UNSIGNED_SHORT */
  34211. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  34212. /** INT */
  34213. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  34214. /** UNSIGNED_INT */
  34215. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  34216. /** UNSIGNED_SHORT_4_4_4_4 */
  34217. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  34218. /** UNSIGNED_SHORT_5_5_5_1 */
  34219. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  34220. /** UNSIGNED_SHORT_5_6_5 */
  34221. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  34222. /** UNSIGNED_INT_2_10_10_10_REV */
  34223. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  34224. /** UNSIGNED_INT_24_8 */
  34225. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  34226. /** UNSIGNED_INT_10F_11F_11F_REV */
  34227. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  34228. /** UNSIGNED_INT_5_9_9_9_REV */
  34229. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  34230. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34231. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  34232. /** nearest is mag = nearest and min = nearest and mip = linear */
  34233. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  34234. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34235. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  34236. /** Trilinear is mag = linear and min = linear and mip = linear */
  34237. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34238. /** nearest is mag = nearest and min = nearest and mip = linear */
  34239. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  34240. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34241. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  34242. /** Trilinear is mag = linear and min = linear and mip = linear */
  34243. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  34244. /** mag = nearest and min = nearest and mip = nearest */
  34245. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  34246. /** mag = nearest and min = linear and mip = nearest */
  34247. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  34248. /** mag = nearest and min = linear and mip = linear */
  34249. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  34250. /** mag = nearest and min = linear and mip = none */
  34251. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  34252. /** mag = nearest and min = nearest and mip = none */
  34253. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  34254. /** mag = linear and min = nearest and mip = nearest */
  34255. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  34256. /** mag = linear and min = nearest and mip = linear */
  34257. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  34258. /** mag = linear and min = linear and mip = none */
  34259. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  34260. /** mag = linear and min = nearest and mip = none */
  34261. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  34262. /** Explicit coordinates mode */
  34263. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  34264. /** Spherical coordinates mode */
  34265. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  34266. /** Planar coordinates mode */
  34267. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  34268. /** Cubic coordinates mode */
  34269. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  34270. /** Projection coordinates mode */
  34271. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  34272. /** Skybox coordinates mode */
  34273. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  34274. /** Inverse Cubic coordinates mode */
  34275. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  34276. /** Equirectangular coordinates mode */
  34277. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  34278. /** Equirectangular Fixed coordinates mode */
  34279. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  34280. /** Equirectangular Fixed Mirrored coordinates mode */
  34281. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  34282. // Texture rescaling mode
  34283. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34284. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  34285. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34286. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  34287. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34288. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  34289. // Updatable statics so stick with vars here
  34290. /**
  34291. * Gets or sets the epsilon value used by collision engine
  34292. */
  34293. Engine.CollisionsEpsilon = 0.001;
  34294. /**
  34295. * Method called to create the default rescale post process on each engine.
  34296. */
  34297. Engine._RescalePostProcessFactory = null;
  34298. return Engine;
  34299. }());
  34300. /***/ }),
  34301. /***/ "./Engines/engineStore.ts":
  34302. /*!********************************!*\
  34303. !*** ./Engines/engineStore.ts ***!
  34304. \********************************/
  34305. /*! exports provided: EngineStore */
  34306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34307. "use strict";
  34308. __webpack_require__.r(__webpack_exports__);
  34309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  34310. /**
  34311. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34312. * during the life time of the application.
  34313. */
  34314. var EngineStore = /** @class */ (function () {
  34315. function EngineStore() {
  34316. }
  34317. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  34318. /**
  34319. * Gets the latest created engine
  34320. */
  34321. get: function () {
  34322. if (this.Instances.length === 0) {
  34323. return null;
  34324. }
  34325. return this.Instances[this.Instances.length - 1];
  34326. },
  34327. enumerable: true,
  34328. configurable: true
  34329. });
  34330. Object.defineProperty(EngineStore, "LastCreatedScene", {
  34331. /**
  34332. * Gets the latest created scene
  34333. */
  34334. get: function () {
  34335. var lastCreatedEngine = this.LastCreatedEngine;
  34336. if (!lastCreatedEngine) {
  34337. return null;
  34338. }
  34339. if (lastCreatedEngine.scenes.length === 0) {
  34340. return null;
  34341. }
  34342. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  34343. },
  34344. enumerable: true,
  34345. configurable: true
  34346. });
  34347. /** Gets the list of created engines */
  34348. EngineStore.Instances = new Array();
  34349. return EngineStore;
  34350. }());
  34351. /***/ }),
  34352. /***/ "./Engines/index.ts":
  34353. /*!**************************!*\
  34354. !*** ./Engines/index.ts ***!
  34355. \**************************/
  34356. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  34357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34358. "use strict";
  34359. __webpack_require__.r(__webpack_exports__);
  34360. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  34362. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  34363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  34364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  34365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  34366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  34367. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  34368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  34369. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  34370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  34371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  34372. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  34373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  34374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  34375. /***/ }),
  34376. /***/ "./Engines/nullEngine.ts":
  34377. /*!*******************************!*\
  34378. !*** ./Engines/nullEngine.ts ***!
  34379. \*******************************/
  34380. /*! exports provided: NullEngineOptions, NullEngine */
  34381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34382. "use strict";
  34383. __webpack_require__.r(__webpack_exports__);
  34384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  34385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  34386. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34387. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  34388. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  34389. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  34390. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  34391. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34392. /**
  34393. * Options to create the null engine
  34394. */
  34395. var NullEngineOptions = /** @class */ (function () {
  34396. function NullEngineOptions() {
  34397. /**
  34398. * Render width (Default: 512)
  34399. */
  34400. this.renderWidth = 512;
  34401. /**
  34402. * Render height (Default: 256)
  34403. */
  34404. this.renderHeight = 256;
  34405. /**
  34406. * Texture size (Default: 512)
  34407. */
  34408. this.textureSize = 512;
  34409. /**
  34410. * If delta time between frames should be constant
  34411. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34412. */
  34413. this.deterministicLockstep = false;
  34414. /**
  34415. * Maximum about of steps between frames (Default: 4)
  34416. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34417. */
  34418. this.lockstepMaxSteps = 4;
  34419. }
  34420. return NullEngineOptions;
  34421. }());
  34422. /**
  34423. * The null engine class provides support for headless version of babylon.js.
  34424. * This can be used in server side scenario or for testing purposes
  34425. */
  34426. var NullEngine = /** @class */ (function (_super) {
  34427. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  34428. function NullEngine(options) {
  34429. if (options === void 0) { options = new NullEngineOptions(); }
  34430. var _this = _super.call(this, null) || this;
  34431. if (options.deterministicLockstep === undefined) {
  34432. options.deterministicLockstep = false;
  34433. }
  34434. if (options.lockstepMaxSteps === undefined) {
  34435. options.lockstepMaxSteps = 4;
  34436. }
  34437. _this._options = options;
  34438. // Init caps
  34439. // We consider we are on a webgl1 capable device
  34440. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  34441. _this._caps.maxTexturesImageUnits = 16;
  34442. _this._caps.maxVertexTextureImageUnits = 16;
  34443. _this._caps.maxTextureSize = 512;
  34444. _this._caps.maxCubemapTextureSize = 512;
  34445. _this._caps.maxRenderTextureSize = 512;
  34446. _this._caps.maxVertexAttribs = 16;
  34447. _this._caps.maxVaryingVectors = 16;
  34448. _this._caps.maxFragmentUniformVectors = 16;
  34449. _this._caps.maxVertexUniformVectors = 16;
  34450. // Extensions
  34451. _this._caps.standardDerivatives = false;
  34452. _this._caps.astc = null;
  34453. _this._caps.s3tc = null;
  34454. _this._caps.pvrtc = null;
  34455. _this._caps.etc1 = null;
  34456. _this._caps.etc2 = null;
  34457. _this._caps.textureAnisotropicFilterExtension = null;
  34458. _this._caps.maxAnisotropy = 0;
  34459. _this._caps.uintIndices = false;
  34460. _this._caps.fragmentDepthSupported = false;
  34461. _this._caps.highPrecisionShaderSupported = true;
  34462. _this._caps.colorBufferFloat = false;
  34463. _this._caps.textureFloat = false;
  34464. _this._caps.textureFloatLinearFiltering = false;
  34465. _this._caps.textureFloatRender = false;
  34466. _this._caps.textureHalfFloat = false;
  34467. _this._caps.textureHalfFloatLinearFiltering = false;
  34468. _this._caps.textureHalfFloatRender = false;
  34469. _this._caps.textureLOD = false;
  34470. _this._caps.drawBuffersExtension = false;
  34471. _this._caps.depthTextureExtension = false;
  34472. _this._caps.vertexArrayObject = false;
  34473. _this._caps.instancedArrays = false;
  34474. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  34475. // Wrappers
  34476. if (typeof URL === "undefined") {
  34477. URL = {
  34478. createObjectURL: function () { },
  34479. revokeObjectURL: function () { }
  34480. };
  34481. }
  34482. if (typeof Blob === "undefined") {
  34483. Blob = function () { };
  34484. }
  34485. return _this;
  34486. }
  34487. /**
  34488. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34489. */
  34490. NullEngine.prototype.isDeterministicLockStep = function () {
  34491. return this._options.deterministicLockstep;
  34492. };
  34493. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  34494. NullEngine.prototype.getLockstepMaxSteps = function () {
  34495. return this._options.lockstepMaxSteps;
  34496. };
  34497. /**
  34498. * Sets hardware scaling, used to save performance if needed
  34499. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34500. */
  34501. NullEngine.prototype.getHardwareScalingLevel = function () {
  34502. return 1.0;
  34503. };
  34504. NullEngine.prototype.createVertexBuffer = function (vertices) {
  34505. return {
  34506. capacity: 0,
  34507. references: 1,
  34508. is32Bits: false
  34509. };
  34510. };
  34511. NullEngine.prototype.createIndexBuffer = function (indices) {
  34512. return {
  34513. capacity: 0,
  34514. references: 1,
  34515. is32Bits: false
  34516. };
  34517. };
  34518. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34519. if (stencil === void 0) { stencil = false; }
  34520. };
  34521. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34522. if (useScreen === void 0) { useScreen = false; }
  34523. if (!useScreen && this._currentRenderTarget) {
  34524. return this._currentRenderTarget.width;
  34525. }
  34526. return this._options.renderWidth;
  34527. };
  34528. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34529. if (useScreen === void 0) { useScreen = false; }
  34530. if (!useScreen && this._currentRenderTarget) {
  34531. return this._currentRenderTarget.height;
  34532. }
  34533. return this._options.renderHeight;
  34534. };
  34535. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34536. this._cachedViewport = viewport;
  34537. };
  34538. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34539. return {
  34540. transformFeedback: null,
  34541. __SPECTOR_rebuildProgram: null,
  34542. isParallelCompiled: false
  34543. };
  34544. };
  34545. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34546. return [];
  34547. };
  34548. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34549. return [];
  34550. };
  34551. NullEngine.prototype.bindSamplers = function (effect) {
  34552. this._currentEffect = null;
  34553. };
  34554. NullEngine.prototype.enableEffect = function (effect) {
  34555. this._currentEffect = effect;
  34556. if (effect.onBind) {
  34557. effect.onBind(effect);
  34558. }
  34559. if (effect._onBindObservable) {
  34560. effect._onBindObservable.notifyObservers(effect);
  34561. }
  34562. };
  34563. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34564. if (zOffset === void 0) { zOffset = 0; }
  34565. if (reverseSide === void 0) { reverseSide = false; }
  34566. };
  34567. NullEngine.prototype.setIntArray = function (uniform, array) {
  34568. };
  34569. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34570. };
  34571. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34572. };
  34573. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34574. };
  34575. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34576. };
  34577. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34578. };
  34579. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34580. };
  34581. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34582. };
  34583. NullEngine.prototype.setArray = function (uniform, array) {
  34584. };
  34585. NullEngine.prototype.setArray2 = function (uniform, array) {
  34586. };
  34587. NullEngine.prototype.setArray3 = function (uniform, array) {
  34588. };
  34589. NullEngine.prototype.setArray4 = function (uniform, array) {
  34590. };
  34591. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34592. };
  34593. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34594. };
  34595. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34596. };
  34597. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34598. };
  34599. NullEngine.prototype.setFloat = function (uniform, value) {
  34600. };
  34601. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34602. };
  34603. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34604. };
  34605. NullEngine.prototype.setBool = function (uniform, bool) {
  34606. };
  34607. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34608. };
  34609. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34610. };
  34611. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34612. };
  34613. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34614. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34615. if (this._alphaMode === mode) {
  34616. return;
  34617. }
  34618. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34619. if (!noDepthWriteChange) {
  34620. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34621. }
  34622. this._alphaMode = mode;
  34623. };
  34624. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34625. };
  34626. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34627. if (this.preventCacheWipeBetweenFrames) {
  34628. return;
  34629. }
  34630. this.resetTextureCache();
  34631. this._currentEffect = null;
  34632. if (bruteForce) {
  34633. this._currentProgram = null;
  34634. this._stencilState.reset();
  34635. this._depthCullingState.reset();
  34636. this._alphaState.reset();
  34637. }
  34638. this._cachedVertexBuffers = null;
  34639. this._cachedIndexBuffer = null;
  34640. this._cachedEffectForVertexBuffers = null;
  34641. };
  34642. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  34643. };
  34644. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  34645. };
  34646. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  34647. };
  34648. /** @hidden */
  34649. NullEngine.prototype._createTexture = function () {
  34650. return {};
  34651. };
  34652. /** @hidden */
  34653. NullEngine.prototype._releaseTexture = function (texture) {
  34654. };
  34655. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  34656. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34657. if (onLoad === void 0) { onLoad = null; }
  34658. if (onError === void 0) { onError = null; }
  34659. if (buffer === void 0) { buffer = null; }
  34660. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  34661. var url = String(urlArg);
  34662. texture.url = url;
  34663. texture.generateMipMaps = !noMipmap;
  34664. texture.samplingMode = samplingMode;
  34665. texture.invertY = invertY;
  34666. texture.baseWidth = this._options.textureSize;
  34667. texture.baseHeight = this._options.textureSize;
  34668. texture.width = this._options.textureSize;
  34669. texture.height = this._options.textureSize;
  34670. if (format) {
  34671. texture.format = format;
  34672. }
  34673. texture.isReady = true;
  34674. if (onLoad) {
  34675. onLoad();
  34676. }
  34677. this._internalTexturesCache.push(texture);
  34678. return texture;
  34679. };
  34680. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  34681. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  34682. if (options !== undefined && typeof options === "object") {
  34683. fullOptions.generateMipMaps = options.generateMipMaps;
  34684. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34685. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34686. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  34687. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34688. }
  34689. else {
  34690. fullOptions.generateMipMaps = options;
  34691. fullOptions.generateDepthBuffer = true;
  34692. fullOptions.generateStencilBuffer = false;
  34693. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34694. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34695. }
  34696. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34697. var width = size.width || size;
  34698. var height = size.height || size;
  34699. texture._depthStencilBuffer = {};
  34700. texture._framebuffer = {};
  34701. texture.baseWidth = width;
  34702. texture.baseHeight = height;
  34703. texture.width = width;
  34704. texture.height = height;
  34705. texture.isReady = true;
  34706. texture.samples = 1;
  34707. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34708. texture.samplingMode = fullOptions.samplingMode;
  34709. texture.type = fullOptions.type;
  34710. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34711. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34712. this._internalTexturesCache.push(texture);
  34713. return texture;
  34714. };
  34715. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34716. texture.samplingMode = samplingMode;
  34717. };
  34718. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34719. if (this._currentRenderTarget) {
  34720. this.unBindFramebuffer(this._currentRenderTarget);
  34721. }
  34722. this._currentRenderTarget = texture;
  34723. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34724. if (this._cachedViewport && !forceFullscreenViewport) {
  34725. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34726. }
  34727. };
  34728. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34729. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34730. this._currentRenderTarget = null;
  34731. if (onBeforeUnbind) {
  34732. if (texture._MSAAFramebuffer) {
  34733. this._currentFramebuffer = texture._framebuffer;
  34734. }
  34735. onBeforeUnbind();
  34736. }
  34737. this._currentFramebuffer = null;
  34738. };
  34739. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34740. var vbo = {
  34741. capacity: 1,
  34742. references: 1,
  34743. is32Bits: false
  34744. };
  34745. return vbo;
  34746. };
  34747. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34748. if (premulAlpha === void 0) { premulAlpha = false; }
  34749. };
  34750. NullEngine.prototype.areAllEffectsReady = function () {
  34751. return true;
  34752. };
  34753. /**
  34754. * @hidden
  34755. * Get the current error code of the webGL context
  34756. * @returns the error code
  34757. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34758. */
  34759. NullEngine.prototype.getError = function () {
  34760. return 0;
  34761. };
  34762. /** @hidden */
  34763. NullEngine.prototype._getUnpackAlignement = function () {
  34764. return 1;
  34765. };
  34766. /** @hidden */
  34767. NullEngine.prototype._unpackFlipY = function (value) {
  34768. };
  34769. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34770. if (offset === void 0) { offset = 0; }
  34771. };
  34772. /**
  34773. * Updates a dynamic vertex buffer.
  34774. * @param vertexBuffer the vertex buffer to update
  34775. * @param data the data used to update the vertex buffer
  34776. * @param byteOffset the byte offset of the data (optional)
  34777. * @param byteLength the byte length of the data (optional)
  34778. */
  34779. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34780. };
  34781. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34782. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34783. this._boundTexturesCache[this._activeChannel] = texture;
  34784. return true;
  34785. }
  34786. return false;
  34787. };
  34788. /** @hidden */
  34789. NullEngine.prototype._bindTexture = function (channel, texture) {
  34790. if (channel < 0) {
  34791. return;
  34792. }
  34793. this._bindTextureDirectly(0, texture);
  34794. };
  34795. /** @hidden */
  34796. NullEngine.prototype._releaseBuffer = function (buffer) {
  34797. buffer.references--;
  34798. if (buffer.references === 0) {
  34799. return true;
  34800. }
  34801. return false;
  34802. };
  34803. NullEngine.prototype.releaseEffects = function () {
  34804. };
  34805. NullEngine.prototype.displayLoadingUI = function () {
  34806. };
  34807. NullEngine.prototype.hideLoadingUI = function () {
  34808. };
  34809. /** @hidden */
  34810. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34811. if (faceIndex === void 0) { faceIndex = 0; }
  34812. if (lod === void 0) { lod = 0; }
  34813. };
  34814. /** @hidden */
  34815. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  34816. if (faceIndex === void 0) { faceIndex = 0; }
  34817. if (lod === void 0) { lod = 0; }
  34818. };
  34819. /** @hidden */
  34820. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34821. if (faceIndex === void 0) { faceIndex = 0; }
  34822. if (lod === void 0) { lod = 0; }
  34823. };
  34824. /** @hidden */
  34825. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34826. if (faceIndex === void 0) { faceIndex = 0; }
  34827. if (lod === void 0) { lod = 0; }
  34828. };
  34829. return NullEngine;
  34830. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  34831. /***/ }),
  34832. /***/ "./Events/clipboardEvents.ts":
  34833. /*!***********************************!*\
  34834. !*** ./Events/clipboardEvents.ts ***!
  34835. \***********************************/
  34836. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  34837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34838. "use strict";
  34839. __webpack_require__.r(__webpack_exports__);
  34840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  34841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  34842. /**
  34843. * Gather the list of clipboard event types as constants.
  34844. */
  34845. var ClipboardEventTypes = /** @class */ (function () {
  34846. function ClipboardEventTypes() {
  34847. }
  34848. /**
  34849. * The clipboard event is fired when a copy command is active (pressed).
  34850. */
  34851. ClipboardEventTypes.COPY = 0x01; //
  34852. /**
  34853. * The clipboard event is fired when a cut command is active (pressed).
  34854. */
  34855. ClipboardEventTypes.CUT = 0x02;
  34856. /**
  34857. * The clipboard event is fired when a paste command is active (pressed).
  34858. */
  34859. ClipboardEventTypes.PASTE = 0x03;
  34860. return ClipboardEventTypes;
  34861. }());
  34862. /**
  34863. * This class is used to store clipboard related info for the onClipboardObservable event.
  34864. */
  34865. var ClipboardInfo = /** @class */ (function () {
  34866. /**
  34867. *Creates an instance of ClipboardInfo.
  34868. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  34869. * @param event Defines the related dom event
  34870. */
  34871. function ClipboardInfo(
  34872. /**
  34873. * Defines the type of event (BABYLON.ClipboardEventTypes)
  34874. */
  34875. type,
  34876. /**
  34877. * Defines the related dom event
  34878. */
  34879. event) {
  34880. this.type = type;
  34881. this.event = event;
  34882. }
  34883. /**
  34884. * Get the clipboard event's type from the keycode.
  34885. * @param keyCode Defines the keyCode for the current keyboard event.
  34886. * @return {number}
  34887. */
  34888. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  34889. var charCode = keyCode;
  34890. //TODO: add codes for extended ASCII
  34891. switch (charCode) {
  34892. case 67: return ClipboardEventTypes.COPY;
  34893. case 86: return ClipboardEventTypes.PASTE;
  34894. case 88: return ClipboardEventTypes.CUT;
  34895. default: return -1;
  34896. }
  34897. };
  34898. return ClipboardInfo;
  34899. }());
  34900. /***/ }),
  34901. /***/ "./Events/index.ts":
  34902. /*!*************************!*\
  34903. !*** ./Events/index.ts ***!
  34904. \*************************/
  34905. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  34906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34907. "use strict";
  34908. __webpack_require__.r(__webpack_exports__);
  34909. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  34910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  34911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  34912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  34913. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  34914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  34915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  34916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  34917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  34918. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  34919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  34920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  34921. /***/ }),
  34922. /***/ "./Events/keyboardEvents.ts":
  34923. /*!**********************************!*\
  34924. !*** ./Events/keyboardEvents.ts ***!
  34925. \**********************************/
  34926. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  34927. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34928. "use strict";
  34929. __webpack_require__.r(__webpack_exports__);
  34930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  34931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  34932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  34933. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34934. /**
  34935. * Gather the list of keyboard event types as constants.
  34936. */
  34937. var KeyboardEventTypes = /** @class */ (function () {
  34938. function KeyboardEventTypes() {
  34939. }
  34940. /**
  34941. * The keydown event is fired when a key becomes active (pressed).
  34942. */
  34943. KeyboardEventTypes.KEYDOWN = 0x01;
  34944. /**
  34945. * The keyup event is fired when a key has been released.
  34946. */
  34947. KeyboardEventTypes.KEYUP = 0x02;
  34948. return KeyboardEventTypes;
  34949. }());
  34950. /**
  34951. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34952. */
  34953. var KeyboardInfo = /** @class */ (function () {
  34954. /**
  34955. * Instantiates a new keyboard info.
  34956. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34957. * @param type Defines the type of event (KeyboardEventTypes)
  34958. * @param event Defines the related dom event
  34959. */
  34960. function KeyboardInfo(
  34961. /**
  34962. * Defines the type of event (KeyboardEventTypes)
  34963. */
  34964. type,
  34965. /**
  34966. * Defines the related dom event
  34967. */
  34968. event) {
  34969. this.type = type;
  34970. this.event = event;
  34971. }
  34972. return KeyboardInfo;
  34973. }());
  34974. /**
  34975. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34976. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  34977. */
  34978. var KeyboardInfoPre = /** @class */ (function (_super) {
  34979. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  34980. /**
  34981. * Instantiates a new keyboard pre info.
  34982. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34983. * @param type Defines the type of event (KeyboardEventTypes)
  34984. * @param event Defines the related dom event
  34985. */
  34986. function KeyboardInfoPre(
  34987. /**
  34988. * Defines the type of event (KeyboardEventTypes)
  34989. */
  34990. type,
  34991. /**
  34992. * Defines the related dom event
  34993. */
  34994. event) {
  34995. var _this = _super.call(this, type, event) || this;
  34996. _this.type = type;
  34997. _this.event = event;
  34998. _this.skipOnPointerObservable = false;
  34999. return _this;
  35000. }
  35001. return KeyboardInfoPre;
  35002. }(KeyboardInfo));
  35003. /***/ }),
  35004. /***/ "./Events/pointerEvents.ts":
  35005. /*!*********************************!*\
  35006. !*** ./Events/pointerEvents.ts ***!
  35007. \*********************************/
  35008. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  35009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35010. "use strict";
  35011. __webpack_require__.r(__webpack_exports__);
  35012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  35013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  35014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  35015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  35016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35017. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  35018. /**
  35019. * Gather the list of pointer event types as constants.
  35020. */
  35021. var PointerEventTypes = /** @class */ (function () {
  35022. function PointerEventTypes() {
  35023. }
  35024. /**
  35025. * 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.
  35026. */
  35027. PointerEventTypes.POINTERDOWN = 0x01;
  35028. /**
  35029. * The pointerup event is fired when a pointer is no longer active.
  35030. */
  35031. PointerEventTypes.POINTERUP = 0x02;
  35032. /**
  35033. * The pointermove event is fired when a pointer changes coordinates.
  35034. */
  35035. PointerEventTypes.POINTERMOVE = 0x04;
  35036. /**
  35037. * The pointerwheel event is fired when a mouse wheel has been rotated.
  35038. */
  35039. PointerEventTypes.POINTERWHEEL = 0x08;
  35040. /**
  35041. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  35042. */
  35043. PointerEventTypes.POINTERPICK = 0x10;
  35044. /**
  35045. * The pointertap event is fired when a the object has been touched and released without drag.
  35046. */
  35047. PointerEventTypes.POINTERTAP = 0x20;
  35048. /**
  35049. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  35050. */
  35051. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  35052. return PointerEventTypes;
  35053. }());
  35054. /**
  35055. * Base class of pointer info types.
  35056. */
  35057. var PointerInfoBase = /** @class */ (function () {
  35058. /**
  35059. * Instantiates the base class of pointers info.
  35060. * @param type Defines the type of event (PointerEventTypes)
  35061. * @param event Defines the related dom event
  35062. */
  35063. function PointerInfoBase(
  35064. /**
  35065. * Defines the type of event (PointerEventTypes)
  35066. */
  35067. type,
  35068. /**
  35069. * Defines the related dom event
  35070. */
  35071. event) {
  35072. this.type = type;
  35073. this.event = event;
  35074. }
  35075. return PointerInfoBase;
  35076. }());
  35077. /**
  35078. * This class is used to store pointer related info for the onPrePointerObservable event.
  35079. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  35080. */
  35081. var PointerInfoPre = /** @class */ (function (_super) {
  35082. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  35083. /**
  35084. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  35085. * @param type Defines the type of event (PointerEventTypes)
  35086. * @param event Defines the related dom event
  35087. * @param localX Defines the local x coordinates of the pointer when the event occured
  35088. * @param localY Defines the local y coordinates of the pointer when the event occured
  35089. */
  35090. function PointerInfoPre(type, event, localX, localY) {
  35091. var _this = _super.call(this, type, event) || this;
  35092. /**
  35093. * Ray from a pointer if availible (eg. 6dof controller)
  35094. */
  35095. _this.ray = null;
  35096. _this.skipOnPointerObservable = false;
  35097. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  35098. return _this;
  35099. }
  35100. return PointerInfoPre;
  35101. }(PointerInfoBase));
  35102. /**
  35103. * This type contains all the data related to a pointer event in Babylon.js.
  35104. * 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.
  35105. */
  35106. var PointerInfo = /** @class */ (function (_super) {
  35107. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  35108. /**
  35109. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  35110. * @param type Defines the type of event (PointerEventTypes)
  35111. * @param event Defines the related dom event
  35112. * @param pickInfo Defines the picking info associated to the info (if any)\
  35113. */
  35114. function PointerInfo(type, event,
  35115. /**
  35116. * Defines the picking info associated to the info (if any)\
  35117. */
  35118. pickInfo) {
  35119. var _this = _super.call(this, type, event) || this;
  35120. _this.pickInfo = pickInfo;
  35121. return _this;
  35122. }
  35123. return PointerInfo;
  35124. }(PointerInfoBase));
  35125. /***/ }),
  35126. /***/ "./Gamepads/Controllers/daydreamController.ts":
  35127. /*!****************************************************!*\
  35128. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  35129. \****************************************************/
  35130. /*! exports provided: DaydreamController */
  35131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35132. "use strict";
  35133. __webpack_require__.r(__webpack_exports__);
  35134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  35135. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35136. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35137. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35138. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35139. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35140. /**
  35141. * Google Daydream controller
  35142. */
  35143. var DaydreamController = /** @class */ (function (_super) {
  35144. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  35145. /**
  35146. * Creates a new DaydreamController from a gamepad
  35147. * @param vrGamepad the gamepad that the controller should be created from
  35148. */
  35149. function DaydreamController(vrGamepad) {
  35150. var _this = _super.call(this, vrGamepad) || this;
  35151. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  35152. return _this;
  35153. }
  35154. /**
  35155. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35156. * @param scene scene in which to add meshes
  35157. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35158. */
  35159. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35160. var _this = this;
  35161. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  35162. _this._defaultModel = newMeshes[1];
  35163. _this.attachToMesh(_this._defaultModel);
  35164. if (meshLoaded) {
  35165. meshLoaded(_this._defaultModel);
  35166. }
  35167. });
  35168. };
  35169. /**
  35170. * Called once for each button that changed state since the last frame
  35171. * @param buttonIdx Which button index changed
  35172. * @param state New state of the button
  35173. * @param changes Which properties on the state changed since last frame
  35174. */
  35175. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35176. // Daydream controller only has 1 GamepadButton (on the trackpad).
  35177. if (buttonIdx === 0) {
  35178. var observable = this.onTriggerStateChangedObservable;
  35179. if (observable) {
  35180. observable.notifyObservers(state);
  35181. }
  35182. }
  35183. else {
  35184. // If the app or home buttons are ever made available
  35185. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  35186. }
  35187. };
  35188. /**
  35189. * Base Url for the controller model.
  35190. */
  35191. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35192. /**
  35193. * File name for the controller model.
  35194. */
  35195. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  35196. /**
  35197. * Gamepad Id prefix used to identify Daydream Controller.
  35198. */
  35199. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  35200. return DaydreamController;
  35201. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35202. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35203. canCreate: function (gamepadInfo) {
  35204. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  35205. },
  35206. create: function (gamepadInfo) {
  35207. return new DaydreamController(gamepadInfo);
  35208. }
  35209. });
  35210. /***/ }),
  35211. /***/ "./Gamepads/Controllers/gearVRController.ts":
  35212. /*!**************************************************!*\
  35213. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  35214. \**************************************************/
  35215. /*! exports provided: GearVRController */
  35216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35217. "use strict";
  35218. __webpack_require__.r(__webpack_exports__);
  35219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  35220. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35221. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35222. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35223. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35224. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35225. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35226. /**
  35227. * Gear VR Controller
  35228. */
  35229. var GearVRController = /** @class */ (function (_super) {
  35230. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  35231. /**
  35232. * Creates a new GearVRController from a gamepad
  35233. * @param vrGamepad the gamepad that the controller should be created from
  35234. */
  35235. function GearVRController(vrGamepad) {
  35236. var _this = _super.call(this, vrGamepad) || this;
  35237. _this._buttonIndexToObservableNameMap = [
  35238. 'onTrackpadChangedObservable',
  35239. 'onTriggerStateChangedObservable' // Trigger
  35240. ];
  35241. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  35242. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  35243. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  35244. _this._disableTrackPosition(_this._calculatedPosition);
  35245. return _this;
  35246. }
  35247. /**
  35248. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35249. * @param scene scene in which to add meshes
  35250. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35251. */
  35252. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35253. var _this = this;
  35254. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  35255. // Offset the controller so it will rotate around the users wrist
  35256. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  35257. newMeshes[1].parent = mesh;
  35258. newMeshes[1].position.z = -0.15;
  35259. _this._defaultModel = mesh;
  35260. _this.attachToMesh(_this._defaultModel);
  35261. if (meshLoaded) {
  35262. meshLoaded(_this._defaultModel);
  35263. }
  35264. });
  35265. };
  35266. /**
  35267. * Called once for each button that changed state since the last frame
  35268. * @param buttonIdx Which button index changed
  35269. * @param state New state of the button
  35270. * @param changes Which properties on the state changed since last frame
  35271. */
  35272. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35273. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  35274. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  35275. // Only emit events for buttons that we know how to map from index to observable
  35276. var observable = this[observableName];
  35277. if (observable) {
  35278. observable.notifyObservers(state);
  35279. }
  35280. }
  35281. };
  35282. /**
  35283. * Base Url for the controller model.
  35284. */
  35285. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35286. /**
  35287. * File name for the controller model.
  35288. */
  35289. GearVRController.MODEL_FILENAME = 'generic.babylon';
  35290. /**
  35291. * Gamepad Id prefix used to identify this controller.
  35292. */
  35293. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  35294. return GearVRController;
  35295. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  35296. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35297. canCreate: function (gamepadInfo) {
  35298. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  35299. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  35300. },
  35301. create: function (gamepadInfo) {
  35302. return new GearVRController(gamepadInfo);
  35303. }
  35304. });
  35305. /***/ }),
  35306. /***/ "./Gamepads/Controllers/genericController.ts":
  35307. /*!***************************************************!*\
  35308. !*** ./Gamepads/Controllers/genericController.ts ***!
  35309. \***************************************************/
  35310. /*! exports provided: GenericController */
  35311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35312. "use strict";
  35313. __webpack_require__.r(__webpack_exports__);
  35314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  35315. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35316. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35317. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35318. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35319. /**
  35320. * Generic Controller
  35321. */
  35322. var GenericController = /** @class */ (function (_super) {
  35323. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  35324. /**
  35325. * Creates a new GenericController from a gamepad
  35326. * @param vrGamepad the gamepad that the controller should be created from
  35327. */
  35328. function GenericController(vrGamepad) {
  35329. return _super.call(this, vrGamepad) || this;
  35330. }
  35331. /**
  35332. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35333. * @param scene scene in which to add meshes
  35334. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35335. */
  35336. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35337. var _this = this;
  35338. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  35339. _this._defaultModel = newMeshes[1];
  35340. _this.attachToMesh(_this._defaultModel);
  35341. if (meshLoaded) {
  35342. meshLoaded(_this._defaultModel);
  35343. }
  35344. });
  35345. };
  35346. /**
  35347. * Called once for each button that changed state since the last frame
  35348. * @param buttonIdx Which button index changed
  35349. * @param state New state of the button
  35350. * @param changes Which properties on the state changed since last frame
  35351. */
  35352. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35353. console.log("Button id: " + buttonIdx + "state: ");
  35354. console.dir(state);
  35355. };
  35356. /**
  35357. * Base Url for the controller model.
  35358. */
  35359. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35360. /**
  35361. * File name for the controller model.
  35362. */
  35363. GenericController.MODEL_FILENAME = 'generic.babylon';
  35364. return GenericController;
  35365. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35366. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  35367. /***/ }),
  35368. /***/ "./Gamepads/Controllers/index.ts":
  35369. /*!***************************************!*\
  35370. !*** ./Gamepads/Controllers/index.ts ***!
  35371. \***************************************/
  35372. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  35373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35374. "use strict";
  35375. __webpack_require__.r(__webpack_exports__);
  35376. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  35377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35378. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  35379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  35380. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  35382. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  35383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  35384. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  35386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  35387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  35388. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  35389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  35390. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  35392. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  35393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  35394. /***/ }),
  35395. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  35396. /*!*******************************************************!*\
  35397. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  35398. \*******************************************************/
  35399. /*! exports provided: OculusTouchController */
  35400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35401. "use strict";
  35402. __webpack_require__.r(__webpack_exports__);
  35403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  35404. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35405. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35406. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35407. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35408. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35409. /**
  35410. * Oculus Touch Controller
  35411. */
  35412. var OculusTouchController = /** @class */ (function (_super) {
  35413. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  35414. /**
  35415. * Creates a new OculusTouchController from a gamepad
  35416. * @param vrGamepad the gamepad that the controller should be created from
  35417. */
  35418. function OculusTouchController(vrGamepad) {
  35419. var _this = _super.call(this, vrGamepad) || this;
  35420. /**
  35421. * Fired when the secondary trigger on this controller is modified
  35422. */
  35423. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35424. /**
  35425. * Fired when the thumb rest on this controller is modified
  35426. */
  35427. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35428. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  35429. return _this;
  35430. }
  35431. /**
  35432. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35433. * @param scene scene in which to add meshes
  35434. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35435. */
  35436. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35437. var _this = this;
  35438. var meshName;
  35439. // Hand
  35440. if (this.hand === 'left') {
  35441. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  35442. }
  35443. else { // Right is the default if no hand is specified
  35444. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  35445. }
  35446. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  35447. /*
  35448. Parent Mesh name: oculus_touch_left
  35449. - body
  35450. - trigger
  35451. - thumbstick
  35452. - grip
  35453. - button_y
  35454. - button_x
  35455. - button_enter
  35456. */
  35457. _this._defaultModel = newMeshes[1];
  35458. _this.attachToMesh(_this._defaultModel);
  35459. if (meshLoaded) {
  35460. meshLoaded(_this._defaultModel);
  35461. }
  35462. });
  35463. };
  35464. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  35465. /**
  35466. * Fired when the A button on this controller is modified
  35467. */
  35468. get: function () {
  35469. if (this.hand === 'right') {
  35470. return this.onMainButtonStateChangedObservable;
  35471. }
  35472. else {
  35473. throw new Error('No A button on left hand');
  35474. }
  35475. },
  35476. enumerable: true,
  35477. configurable: true
  35478. });
  35479. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  35480. /**
  35481. * Fired when the B button on this controller is modified
  35482. */
  35483. get: function () {
  35484. if (this.hand === 'right') {
  35485. return this.onSecondaryButtonStateChangedObservable;
  35486. }
  35487. else {
  35488. throw new Error('No B button on left hand');
  35489. }
  35490. },
  35491. enumerable: true,
  35492. configurable: true
  35493. });
  35494. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  35495. /**
  35496. * Fired when the X button on this controller is modified
  35497. */
  35498. get: function () {
  35499. if (this.hand === 'left') {
  35500. return this.onMainButtonStateChangedObservable;
  35501. }
  35502. else {
  35503. throw new Error('No X button on right hand');
  35504. }
  35505. },
  35506. enumerable: true,
  35507. configurable: true
  35508. });
  35509. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  35510. /**
  35511. * Fired when the Y button on this controller is modified
  35512. */
  35513. get: function () {
  35514. if (this.hand === 'left') {
  35515. return this.onSecondaryButtonStateChangedObservable;
  35516. }
  35517. else {
  35518. throw new Error('No Y button on right hand');
  35519. }
  35520. },
  35521. enumerable: true,
  35522. configurable: true
  35523. });
  35524. /**
  35525. * Called once for each button that changed state since the last frame
  35526. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35527. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35528. * 2) secondary trigger (same)
  35529. * 3) A (right) X (left), touch, pressed = value
  35530. * 4) B / Y
  35531. * 5) thumb rest
  35532. * @param buttonIdx Which button index changed
  35533. * @param state New state of the button
  35534. * @param changes Which properties on the state changed since last frame
  35535. */
  35536. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35537. var notifyObject = state; //{ state: state, changes: changes };
  35538. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35539. switch (buttonIdx) {
  35540. case 0:
  35541. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35542. return;
  35543. case 1: // index trigger
  35544. if (this._defaultModel) {
  35545. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35546. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35547. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35548. }
  35549. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35550. return;
  35551. case 2: // secondary trigger
  35552. if (this._defaultModel) {
  35553. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35554. }
  35555. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35556. return;
  35557. case 3:
  35558. if (this._defaultModel) {
  35559. if (notifyObject.pressed) {
  35560. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35561. }
  35562. else {
  35563. (this._defaultModel.getChildren()[1]).position.y = 0;
  35564. }
  35565. }
  35566. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35567. return;
  35568. case 4:
  35569. if (this._defaultModel) {
  35570. if (notifyObject.pressed) {
  35571. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35572. }
  35573. else {
  35574. (this._defaultModel.getChildren()[2]).position.y = 0;
  35575. }
  35576. }
  35577. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35578. return;
  35579. case 5:
  35580. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35581. return;
  35582. }
  35583. };
  35584. /**
  35585. * Base Url for the controller model.
  35586. */
  35587. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35588. /**
  35589. * File name for the left controller model.
  35590. */
  35591. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35592. /**
  35593. * File name for the right controller model.
  35594. */
  35595. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35596. return OculusTouchController;
  35597. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35598. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35599. canCreate: function (gamepadInfo) {
  35600. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35601. },
  35602. create: function (gamepadInfo) {
  35603. return new OculusTouchController(gamepadInfo);
  35604. }
  35605. });
  35606. /***/ }),
  35607. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35608. /*!*******************************************************!*\
  35609. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35610. \*******************************************************/
  35611. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35613. "use strict";
  35614. __webpack_require__.r(__webpack_exports__);
  35615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35618. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35619. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35620. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35621. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35622. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35623. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35624. /**
  35625. * Defines the types of pose enabled controllers that are supported
  35626. */
  35627. var PoseEnabledControllerType;
  35628. (function (PoseEnabledControllerType) {
  35629. /**
  35630. * HTC Vive
  35631. */
  35632. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  35633. /**
  35634. * Oculus Rift
  35635. */
  35636. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  35637. /**
  35638. * Windows mixed reality
  35639. */
  35640. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  35641. /**
  35642. * Samsung gear VR
  35643. */
  35644. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  35645. /**
  35646. * Google Daydream
  35647. */
  35648. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  35649. /**
  35650. * Generic
  35651. */
  35652. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  35653. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  35654. /**
  35655. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35656. */
  35657. var PoseEnabledControllerHelper = /** @class */ (function () {
  35658. function PoseEnabledControllerHelper() {
  35659. }
  35660. /**
  35661. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35662. * @param vrGamepad the gamepad to initialized
  35663. * @returns a vr controller of the type the gamepad identified as
  35664. */
  35665. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  35666. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  35667. var factory = _a[_i];
  35668. if (factory.canCreate(vrGamepad)) {
  35669. return factory.create(vrGamepad);
  35670. }
  35671. }
  35672. if (this._DefaultControllerFactory) {
  35673. return this._DefaultControllerFactory(vrGamepad);
  35674. }
  35675. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  35676. };
  35677. /** @hidden */
  35678. PoseEnabledControllerHelper._ControllerFactories = [];
  35679. /** @hidden */
  35680. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  35681. return PoseEnabledControllerHelper;
  35682. }());
  35683. /**
  35684. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35685. */
  35686. var PoseEnabledController = /** @class */ (function (_super) {
  35687. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  35688. /**
  35689. * Creates a new PoseEnabledController from a gamepad
  35690. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35691. */
  35692. function PoseEnabledController(browserGamepad) {
  35693. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  35694. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  35695. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35696. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35697. /**
  35698. * The device position in babylon space
  35699. */
  35700. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35701. /**
  35702. * The device rotation in babylon space
  35703. */
  35704. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35705. /**
  35706. * The scale factor of the device in babylon space
  35707. */
  35708. _this.deviceScaleFactor = 1;
  35709. // Used to convert 6dof controllers to 3dof
  35710. _this._trackPosition = true;
  35711. _this._maxRotationDistFromHeadset = Math.PI / 5;
  35712. _this._draggedRoomRotation = 0;
  35713. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35714. /**
  35715. * Internal, matrix used to convert room space to babylon space
  35716. * @hidden
  35717. */
  35718. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35719. /**
  35720. * Node to be used when casting a ray from the controller
  35721. * @hidden
  35722. */
  35723. _this._pointingPoseNode = null;
  35724. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35725. /**
  35726. * @hidden
  35727. */
  35728. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35729. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35730. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35731. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35732. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35733. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35734. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35735. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35736. return _this;
  35737. }
  35738. /**
  35739. * @hidden
  35740. */
  35741. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35742. if (this._trackPosition) {
  35743. this._calculatedPosition.copyFrom(fixedPosition);
  35744. this._trackPosition = false;
  35745. }
  35746. };
  35747. /**
  35748. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35749. */
  35750. PoseEnabledController.prototype.update = function () {
  35751. _super.prototype.update.call(this);
  35752. this._updatePoseAndMesh();
  35753. };
  35754. /**
  35755. * Updates only the pose device and mesh without doing any button event checking
  35756. */
  35757. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35758. var pose = this.browserGamepad.pose;
  35759. this.updateFromDevice(pose);
  35760. 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) {
  35761. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35762. camera._computeDevicePosition();
  35763. this._deviceToWorld.setTranslation(camera.devicePosition);
  35764. if (camera.deviceRotationQuaternion) {
  35765. var camera = camera;
  35766. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35767. // Find the radian distance away that the headset is from the controllers rotation
  35768. 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));
  35769. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35770. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35771. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35772. this._draggedRoomRotation += rotationAmount;
  35773. // Rotate controller around headset
  35774. var sin = Math.sin(-rotationAmount);
  35775. var cos = Math.cos(-rotationAmount);
  35776. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35777. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35778. }
  35779. }
  35780. }
  35781. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35782. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35783. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35784. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35785. if (this._mesh) {
  35786. this._mesh.position.copyFrom(this.devicePosition);
  35787. if (this._mesh.rotationQuaternion) {
  35788. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  35789. }
  35790. }
  35791. };
  35792. /**
  35793. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35794. * @param poseData raw pose fromthe device
  35795. */
  35796. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  35797. if (poseData) {
  35798. this.rawPose = poseData;
  35799. if (poseData.position) {
  35800. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  35801. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  35802. this._deviceRoomPosition.z *= -1;
  35803. }
  35804. if (this._trackPosition) {
  35805. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  35806. }
  35807. this._calculatedPosition.addInPlace(this.position);
  35808. }
  35809. var pose = this.rawPose;
  35810. if (poseData.orientation && pose.orientation) {
  35811. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  35812. if (this._mesh) {
  35813. if (this._mesh.getScene().useRightHandedSystem) {
  35814. this._deviceRoomRotationQuaternion.z *= -1;
  35815. this._deviceRoomRotationQuaternion.w *= -1;
  35816. }
  35817. else {
  35818. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  35819. }
  35820. }
  35821. // if the camera is set, rotate to the camera's rotation
  35822. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  35823. }
  35824. }
  35825. };
  35826. /**
  35827. * Attaches a mesh to the controller
  35828. * @param mesh the mesh to be attached
  35829. */
  35830. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  35831. if (this._mesh) {
  35832. this._mesh.parent = null;
  35833. }
  35834. this._mesh = mesh;
  35835. if (this._poseControlledCamera) {
  35836. this._mesh.parent = this._poseControlledCamera;
  35837. }
  35838. if (!this._mesh.rotationQuaternion) {
  35839. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35840. }
  35841. // 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
  35842. this._updatePoseAndMesh();
  35843. if (this._pointingPoseNode) {
  35844. var parents = [];
  35845. var obj = this._pointingPoseNode;
  35846. while (obj.parent) {
  35847. parents.push(obj.parent);
  35848. obj = obj.parent;
  35849. }
  35850. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  35851. }
  35852. this._meshAttachedObservable.notifyObservers(mesh);
  35853. };
  35854. /**
  35855. * Attaches the controllers mesh to a camera
  35856. * @param camera the camera the mesh should be attached to
  35857. */
  35858. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  35859. this._poseControlledCamera = camera;
  35860. if (this._mesh) {
  35861. this._mesh.parent = this._poseControlledCamera;
  35862. }
  35863. };
  35864. /**
  35865. * Disposes of the controller
  35866. */
  35867. PoseEnabledController.prototype.dispose = function () {
  35868. if (this._mesh) {
  35869. this._mesh.dispose();
  35870. }
  35871. this._mesh = null;
  35872. _super.prototype.dispose.call(this);
  35873. };
  35874. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  35875. /**
  35876. * The mesh that is attached to the controller
  35877. */
  35878. get: function () {
  35879. return this._mesh;
  35880. },
  35881. enumerable: true,
  35882. configurable: true
  35883. });
  35884. /**
  35885. * Gets the ray of the controller in the direction the controller is pointing
  35886. * @param length the length the resulting ray should be
  35887. * @returns a ray in the direction the controller is pointing
  35888. */
  35889. PoseEnabledController.prototype.getForwardRay = function (length) {
  35890. if (length === void 0) { length = 100; }
  35891. if (!this.mesh) {
  35892. 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);
  35893. }
  35894. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  35895. var origin = m.getTranslation();
  35896. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  35897. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  35898. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  35899. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  35900. };
  35901. /**
  35902. * Name of the child mesh that can be used to cast a ray from the controller
  35903. */
  35904. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  35905. return PoseEnabledController;
  35906. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  35907. /***/ }),
  35908. /***/ "./Gamepads/Controllers/viveController.ts":
  35909. /*!************************************************!*\
  35910. !*** ./Gamepads/Controllers/viveController.ts ***!
  35911. \************************************************/
  35912. /*! exports provided: ViveController */
  35913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35914. "use strict";
  35915. __webpack_require__.r(__webpack_exports__);
  35916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  35917. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35918. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35919. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35920. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35921. /**
  35922. * Vive Controller
  35923. */
  35924. var ViveController = /** @class */ (function (_super) {
  35925. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  35926. /**
  35927. * Creates a new ViveController from a gamepad
  35928. * @param vrGamepad the gamepad that the controller should be created from
  35929. */
  35930. function ViveController(vrGamepad) {
  35931. var _this = _super.call(this, vrGamepad) || this;
  35932. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  35933. _this._invertLeftStickY = true;
  35934. return _this;
  35935. }
  35936. /**
  35937. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35938. * @param scene scene in which to add meshes
  35939. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35940. */
  35941. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35942. var _this = this;
  35943. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  35944. /*
  35945. Parent Mesh name: ViveWand
  35946. - body
  35947. - r_gripper
  35948. - l_gripper
  35949. - menu_button
  35950. - system_button
  35951. - trackpad
  35952. - trigger
  35953. - LED
  35954. */
  35955. _this._defaultModel = newMeshes[1];
  35956. _this.attachToMesh(_this._defaultModel);
  35957. if (meshLoaded) {
  35958. meshLoaded(_this._defaultModel);
  35959. }
  35960. });
  35961. };
  35962. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  35963. /**
  35964. * Fired when the left button on this controller is modified
  35965. */
  35966. get: function () {
  35967. return this.onMainButtonStateChangedObservable;
  35968. },
  35969. enumerable: true,
  35970. configurable: true
  35971. });
  35972. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  35973. /**
  35974. * Fired when the right button on this controller is modified
  35975. */
  35976. get: function () {
  35977. return this.onMainButtonStateChangedObservable;
  35978. },
  35979. enumerable: true,
  35980. configurable: true
  35981. });
  35982. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  35983. /**
  35984. * Fired when the menu button on this controller is modified
  35985. */
  35986. get: function () {
  35987. return this.onSecondaryButtonStateChangedObservable;
  35988. },
  35989. enumerable: true,
  35990. configurable: true
  35991. });
  35992. /**
  35993. * Called once for each button that changed state since the last frame
  35994. * Vive mapping:
  35995. * 0: touchpad
  35996. * 1: trigger
  35997. * 2: left AND right buttons
  35998. * 3: menu button
  35999. * @param buttonIdx Which button index changed
  36000. * @param state New state of the button
  36001. * @param changes Which properties on the state changed since last frame
  36002. */
  36003. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36004. var notifyObject = state; //{ state: state, changes: changes };
  36005. switch (buttonIdx) {
  36006. case 0:
  36007. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  36008. return;
  36009. case 1: // index trigger
  36010. if (this._defaultModel) {
  36011. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  36012. }
  36013. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  36014. return;
  36015. case 2: // left AND right button
  36016. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  36017. return;
  36018. case 3:
  36019. if (this._defaultModel) {
  36020. if (notifyObject.pressed) {
  36021. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36022. }
  36023. else {
  36024. (this._defaultModel.getChildren()[2]).position.y = 0;
  36025. }
  36026. }
  36027. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36028. return;
  36029. }
  36030. };
  36031. /**
  36032. * Base Url for the controller model.
  36033. */
  36034. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  36035. /**
  36036. * File name for the controller model.
  36037. */
  36038. ViveController.MODEL_FILENAME = 'wand.babylon';
  36039. return ViveController;
  36040. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  36041. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36042. canCreate: function (gamepadInfo) {
  36043. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  36044. },
  36045. create: function (gamepadInfo) {
  36046. return new ViveController(gamepadInfo);
  36047. }
  36048. });
  36049. /***/ }),
  36050. /***/ "./Gamepads/Controllers/webVRController.ts":
  36051. /*!*************************************************!*\
  36052. !*** ./Gamepads/Controllers/webVRController.ts ***!
  36053. \*************************************************/
  36054. /*! exports provided: WebVRController */
  36055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36056. "use strict";
  36057. __webpack_require__.r(__webpack_exports__);
  36058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  36059. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36060. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36061. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36062. /**
  36063. * Defines the WebVRController object that represents controllers tracked in 3D space
  36064. */
  36065. var WebVRController = /** @class */ (function (_super) {
  36066. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  36067. /**
  36068. * Creates a new WebVRController from a gamepad
  36069. * @param vrGamepad the gamepad that the WebVRController should be created from
  36070. */
  36071. function WebVRController(vrGamepad) {
  36072. var _this = _super.call(this, vrGamepad) || this;
  36073. // Observables
  36074. /**
  36075. * Fired when the trigger state has changed
  36076. */
  36077. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36078. /**
  36079. * Fired when the main button state has changed
  36080. */
  36081. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36082. /**
  36083. * Fired when the secondary button state has changed
  36084. */
  36085. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36086. /**
  36087. * Fired when the pad state has changed
  36088. */
  36089. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36090. /**
  36091. * Fired when controllers stick values have changed
  36092. */
  36093. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36094. /**
  36095. * X and Y axis corrisponding to the controllers joystick
  36096. */
  36097. _this.pad = { x: 0, y: 0 };
  36098. // avoid GC, store state in a tmp object
  36099. _this._changes = {
  36100. pressChanged: false,
  36101. touchChanged: false,
  36102. valueChanged: false,
  36103. changed: false
  36104. };
  36105. _this._buttons = new Array(vrGamepad.buttons.length);
  36106. _this.hand = vrGamepad.hand;
  36107. return _this;
  36108. }
  36109. /**
  36110. * Fired when a controller button's state has changed
  36111. * @param callback the callback containing the button that was modified
  36112. */
  36113. WebVRController.prototype.onButtonStateChange = function (callback) {
  36114. this._onButtonStateChange = callback;
  36115. };
  36116. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  36117. /**
  36118. * The default controller model for the controller
  36119. */
  36120. get: function () {
  36121. return this._defaultModel;
  36122. },
  36123. enumerable: true,
  36124. configurable: true
  36125. });
  36126. /**
  36127. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  36128. */
  36129. WebVRController.prototype.update = function () {
  36130. _super.prototype.update.call(this);
  36131. for (var index = 0; index < this._buttons.length; index++) {
  36132. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  36133. }
  36134. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  36135. this.pad.x = this.leftStick.x;
  36136. this.pad.y = this.leftStick.y;
  36137. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  36138. }
  36139. };
  36140. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  36141. if (!newState) {
  36142. newState = {
  36143. pressed: false,
  36144. touched: false,
  36145. value: 0
  36146. };
  36147. }
  36148. if (!currentState) {
  36149. this._buttons[buttonIndex] = {
  36150. pressed: newState.pressed,
  36151. touched: newState.touched,
  36152. value: newState.value
  36153. };
  36154. return;
  36155. }
  36156. this._checkChanges(newState, currentState);
  36157. if (this._changes.changed) {
  36158. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  36159. this._handleButtonChange(buttonIndex, newState, this._changes);
  36160. }
  36161. this._buttons[buttonIndex].pressed = newState.pressed;
  36162. this._buttons[buttonIndex].touched = newState.touched;
  36163. // oculus triggers are never 0, thou not touched.
  36164. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  36165. };
  36166. WebVRController.prototype._checkChanges = function (newState, currentState) {
  36167. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  36168. this._changes.touchChanged = newState.touched !== currentState.touched;
  36169. this._changes.valueChanged = newState.value !== currentState.value;
  36170. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  36171. return this._changes;
  36172. };
  36173. /**
  36174. * Disposes of th webVRCOntroller
  36175. */
  36176. WebVRController.prototype.dispose = function () {
  36177. _super.prototype.dispose.call(this);
  36178. this.onTriggerStateChangedObservable.clear();
  36179. this.onMainButtonStateChangedObservable.clear();
  36180. this.onSecondaryButtonStateChangedObservable.clear();
  36181. this.onPadStateChangedObservable.clear();
  36182. this.onPadValuesChangedObservable.clear();
  36183. };
  36184. return WebVRController;
  36185. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  36186. /***/ }),
  36187. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  36188. /*!*********************************************************!*\
  36189. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  36190. \*********************************************************/
  36191. /*! exports provided: WindowsMotionController */
  36192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36193. "use strict";
  36194. __webpack_require__.r(__webpack_exports__);
  36195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  36196. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36197. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  36198. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36199. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36200. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  36201. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36202. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36203. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36204. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  36205. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36206. /**
  36207. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  36208. */
  36209. var LoadedMeshInfo = /** @class */ (function () {
  36210. function LoadedMeshInfo() {
  36211. /**
  36212. * Map of the button meshes contained in the controller
  36213. */
  36214. this.buttonMeshes = {};
  36215. /**
  36216. * Map of the axis meshes contained in the controller
  36217. */
  36218. this.axisMeshes = {};
  36219. }
  36220. return LoadedMeshInfo;
  36221. }());
  36222. /**
  36223. * Defines the WindowsMotionController object that the state of the windows motion controller
  36224. */
  36225. var WindowsMotionController = /** @class */ (function (_super) {
  36226. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  36227. /**
  36228. * Creates a new WindowsMotionController from a gamepad
  36229. * @param vrGamepad the gamepad that the controller should be created from
  36230. */
  36231. function WindowsMotionController(vrGamepad) {
  36232. var _this = _super.call(this, vrGamepad) || this;
  36233. _this._mapping = {
  36234. // Semantic button names
  36235. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  36236. // A mapping of the button name to glTF model node name
  36237. // that should be transformed by button value.
  36238. buttonMeshNames: {
  36239. 'trigger': 'SELECT',
  36240. 'menu': 'MENU',
  36241. 'grip': 'GRASP',
  36242. 'thumbstick': 'THUMBSTICK_PRESS',
  36243. 'trackpad': 'TOUCHPAD_PRESS'
  36244. },
  36245. // This mapping is used to translate from the Motion Controller to Babylon semantics
  36246. buttonObservableNames: {
  36247. 'trigger': 'onTriggerStateChangedObservable',
  36248. 'menu': 'onSecondaryButtonStateChangedObservable',
  36249. 'grip': 'onMainButtonStateChangedObservable',
  36250. 'thumbstick': 'onPadStateChangedObservable',
  36251. 'trackpad': 'onTrackpadChangedObservable'
  36252. },
  36253. // A mapping of the axis name to glTF model node name
  36254. // that should be transformed by axis value.
  36255. // This array mirrors the browserGamepad.axes array, such that
  36256. // the mesh corresponding to axis 0 is in this array index 0.
  36257. axisMeshNames: [
  36258. 'THUMBSTICK_X',
  36259. 'THUMBSTICK_Y',
  36260. 'TOUCHPAD_TOUCH_X',
  36261. 'TOUCHPAD_TOUCH_Y'
  36262. ],
  36263. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  36264. };
  36265. /**
  36266. * Fired when the trackpad on this controller is clicked
  36267. */
  36268. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36269. /**
  36270. * Fired when the trackpad on this controller is modified
  36271. */
  36272. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36273. /**
  36274. * The current x and y values of this controller's trackpad
  36275. */
  36276. _this.trackpad = { x: 0, y: 0 };
  36277. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  36278. _this._loadedMeshInfo = null;
  36279. return _this;
  36280. }
  36281. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  36282. /**
  36283. * Fired when the trigger on this controller is modified
  36284. */
  36285. get: function () {
  36286. return this.onTriggerStateChangedObservable;
  36287. },
  36288. enumerable: true,
  36289. configurable: true
  36290. });
  36291. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  36292. /**
  36293. * Fired when the menu button on this controller is modified
  36294. */
  36295. get: function () {
  36296. return this.onSecondaryButtonStateChangedObservable;
  36297. },
  36298. enumerable: true,
  36299. configurable: true
  36300. });
  36301. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  36302. /**
  36303. * Fired when the grip button on this controller is modified
  36304. */
  36305. get: function () {
  36306. return this.onMainButtonStateChangedObservable;
  36307. },
  36308. enumerable: true,
  36309. configurable: true
  36310. });
  36311. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  36312. /**
  36313. * Fired when the thumbstick button on this controller is modified
  36314. */
  36315. get: function () {
  36316. return this.onPadStateChangedObservable;
  36317. },
  36318. enumerable: true,
  36319. configurable: true
  36320. });
  36321. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  36322. /**
  36323. * Fired when the touchpad button on this controller is modified
  36324. */
  36325. get: function () {
  36326. return this.onTrackpadChangedObservable;
  36327. },
  36328. enumerable: true,
  36329. configurable: true
  36330. });
  36331. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  36332. /**
  36333. * Fired when the touchpad values on this controller are modified
  36334. */
  36335. get: function () {
  36336. return this.onTrackpadValuesChangedObservable;
  36337. },
  36338. enumerable: true,
  36339. configurable: true
  36340. });
  36341. WindowsMotionController.prototype._updateTrackpad = function () {
  36342. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  36343. this.trackpad.x = this.browserGamepad["axes"][2];
  36344. this.trackpad.y = this.browserGamepad["axes"][3];
  36345. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  36346. }
  36347. };
  36348. /**
  36349. * Called once per frame by the engine.
  36350. */
  36351. WindowsMotionController.prototype.update = function () {
  36352. _super.prototype.update.call(this);
  36353. if (this.browserGamepad.axes) {
  36354. this._updateTrackpad();
  36355. // Only need to animate axes if there is a loaded mesh
  36356. if (this._loadedMeshInfo) {
  36357. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  36358. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  36359. }
  36360. }
  36361. }
  36362. };
  36363. /**
  36364. * Called once for each button that changed state since the last frame
  36365. * @param buttonIdx Which button index changed
  36366. * @param state New state of the button
  36367. * @param changes Which properties on the state changed since last frame
  36368. */
  36369. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36370. var buttonName = this._mapping.buttons[buttonIdx];
  36371. if (!buttonName) {
  36372. return;
  36373. }
  36374. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  36375. this._updateTrackpad();
  36376. // Only emit events for buttons that we know how to map from index to name
  36377. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  36378. if (observable) {
  36379. observable.notifyObservers(state);
  36380. }
  36381. this._lerpButtonTransform(buttonName, state.value);
  36382. };
  36383. /**
  36384. * Moves the buttons on the controller mesh based on their current state
  36385. * @param buttonName the name of the button to move
  36386. * @param buttonValue the value of the button which determines the buttons new position
  36387. */
  36388. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  36389. // If there is no loaded mesh, there is nothing to transform.
  36390. if (!this._loadedMeshInfo) {
  36391. return;
  36392. }
  36393. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  36394. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36395. return;
  36396. }
  36397. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  36398. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  36399. };
  36400. /**
  36401. * Moves the axis on the controller mesh based on its current state
  36402. * @param axis the index of the axis
  36403. * @param axisValue the value of the axis which determines the meshes new position
  36404. * @hidden
  36405. */
  36406. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  36407. if (!this._loadedMeshInfo) {
  36408. return;
  36409. }
  36410. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  36411. if (!meshInfo) {
  36412. return;
  36413. }
  36414. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36415. return;
  36416. }
  36417. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  36418. var lerpValue = axisValue * 0.5 + 0.5;
  36419. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  36420. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  36421. };
  36422. /**
  36423. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36424. * @param scene scene in which to add meshes
  36425. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36426. */
  36427. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  36428. var _this = this;
  36429. if (forceDefault === void 0) { forceDefault = false; }
  36430. var path;
  36431. var filename;
  36432. // Checking if GLB loader is present
  36433. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  36434. // Determine the device specific folder based on the ID suffix
  36435. var device = 'default';
  36436. if (this.id && !forceDefault) {
  36437. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  36438. device = ((match && match[0]) || device);
  36439. }
  36440. // Hand
  36441. if (this.hand === 'left') {
  36442. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  36443. }
  36444. else { // Right is the default if no hand is specified
  36445. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  36446. }
  36447. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  36448. }
  36449. else {
  36450. _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");
  36451. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  36452. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  36453. }
  36454. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  36455. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  36456. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  36457. if (!_this._loadedMeshInfo) {
  36458. return;
  36459. }
  36460. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  36461. _this.attachToMesh(_this._defaultModel);
  36462. if (meshLoaded) {
  36463. meshLoaded(_this._defaultModel);
  36464. }
  36465. }, null, function (scene, message) {
  36466. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  36467. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  36468. if (!forceDefault) {
  36469. _this.initControllerMesh(scene, meshLoaded, true);
  36470. }
  36471. });
  36472. };
  36473. /**
  36474. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  36475. * can be transformed by button presses and axes values, based on this._mapping.
  36476. *
  36477. * @param scene scene in which the meshes exist
  36478. * @param meshes list of meshes that make up the controller model to process
  36479. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  36480. */
  36481. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  36482. var loadedMeshInfo = null;
  36483. // Create a new mesh to contain the glTF hierarchy
  36484. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  36485. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  36486. var childMesh = null;
  36487. for (var i = 0; i < meshes.length; i++) {
  36488. var mesh = meshes[i];
  36489. if (!mesh.parent) {
  36490. // Exclude controller meshes from picking results
  36491. mesh.isPickable = false;
  36492. // Handle root node, attach to the new parentMesh
  36493. childMesh = mesh;
  36494. break;
  36495. }
  36496. }
  36497. if (childMesh) {
  36498. childMesh.setParent(parentMesh);
  36499. // Create our mesh info. Note that this method will always return non-null.
  36500. loadedMeshInfo = this.createMeshInfo(parentMesh);
  36501. }
  36502. else {
  36503. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  36504. }
  36505. return loadedMeshInfo;
  36506. };
  36507. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  36508. var loadedMeshInfo = new LoadedMeshInfo();
  36509. var i;
  36510. loadedMeshInfo.rootNode = rootNode;
  36511. // Reset the caches
  36512. loadedMeshInfo.buttonMeshes = {};
  36513. loadedMeshInfo.axisMeshes = {};
  36514. // Button Meshes
  36515. for (i = 0; i < this._mapping.buttons.length; i++) {
  36516. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36517. if (!buttonMeshName) {
  36518. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36519. continue;
  36520. }
  36521. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36522. if (!buttonMesh) {
  36523. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36524. continue;
  36525. }
  36526. var buttonMeshInfo = {
  36527. index: i,
  36528. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36529. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36530. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36531. };
  36532. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36533. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36534. }
  36535. else {
  36536. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36537. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36538. '(VALUE: ' + !!buttonMeshInfo.value +
  36539. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36540. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36541. ')');
  36542. }
  36543. }
  36544. // Axis Meshes
  36545. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36546. var axisMeshName = this._mapping.axisMeshNames[i];
  36547. if (!axisMeshName) {
  36548. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36549. continue;
  36550. }
  36551. var axisMesh = getChildByName(rootNode, axisMeshName);
  36552. if (!axisMesh) {
  36553. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36554. continue;
  36555. }
  36556. var axisMeshInfo = {
  36557. index: i,
  36558. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36559. min: getImmediateChildByName(axisMesh, 'MIN'),
  36560. max: getImmediateChildByName(axisMesh, 'MAX')
  36561. };
  36562. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36563. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36564. }
  36565. else {
  36566. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36567. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36568. '(VALUE: ' + !!axisMeshInfo.value +
  36569. ', MIN: ' + !!axisMeshInfo.min +
  36570. ', MAX:' + !!axisMeshInfo.max +
  36571. ')');
  36572. }
  36573. }
  36574. // Pointing Ray
  36575. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36576. if (!loadedMeshInfo.pointingPoseNode) {
  36577. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36578. }
  36579. else {
  36580. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36581. }
  36582. return loadedMeshInfo;
  36583. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36584. function getChildByName(node, name) {
  36585. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36586. }
  36587. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36588. function getImmediateChildByName(node, name) {
  36589. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36590. }
  36591. };
  36592. /**
  36593. * Gets the ray of the controller in the direction the controller is pointing
  36594. * @param length the length the resulting ray should be
  36595. * @returns a ray in the direction the controller is pointing
  36596. */
  36597. WindowsMotionController.prototype.getForwardRay = function (length) {
  36598. if (length === void 0) { length = 100; }
  36599. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36600. return _super.prototype.getForwardRay.call(this, length);
  36601. }
  36602. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36603. var origin = m.getTranslation();
  36604. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36605. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36606. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36607. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36608. };
  36609. /**
  36610. * Disposes of the controller
  36611. */
  36612. WindowsMotionController.prototype.dispose = function () {
  36613. _super.prototype.dispose.call(this);
  36614. this.onTrackpadChangedObservable.clear();
  36615. };
  36616. /**
  36617. * The base url used to load the left and right controller models
  36618. */
  36619. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36620. /**
  36621. * The name of the left controller model file
  36622. */
  36623. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36624. /**
  36625. * The name of the right controller model file
  36626. */
  36627. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36628. /**
  36629. * The controller name prefix for this controller type
  36630. */
  36631. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  36632. /**
  36633. * The controller id pattern for this controller type
  36634. */
  36635. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  36636. return WindowsMotionController;
  36637. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  36638. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36639. canCreate: function (gamepadInfo) {
  36640. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  36641. },
  36642. create: function (gamepadInfo) {
  36643. return new WindowsMotionController(gamepadInfo);
  36644. }
  36645. });
  36646. /***/ }),
  36647. /***/ "./Gamepads/gamepad.ts":
  36648. /*!*****************************!*\
  36649. !*** ./Gamepads/gamepad.ts ***!
  36650. \*****************************/
  36651. /*! exports provided: StickValues, Gamepad, GenericPad */
  36652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36653. "use strict";
  36654. __webpack_require__.r(__webpack_exports__);
  36655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  36656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  36657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  36658. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36659. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36660. /**
  36661. * Represents a gamepad control stick position
  36662. */
  36663. var StickValues = /** @class */ (function () {
  36664. /**
  36665. * Initializes the gamepad x and y control stick values
  36666. * @param x The x component of the gamepad control stick value
  36667. * @param y The y component of the gamepad control stick value
  36668. */
  36669. function StickValues(
  36670. /**
  36671. * The x component of the control stick
  36672. */
  36673. x,
  36674. /**
  36675. * The y component of the control stick
  36676. */
  36677. y) {
  36678. this.x = x;
  36679. this.y = y;
  36680. }
  36681. return StickValues;
  36682. }());
  36683. /**
  36684. * Represents a gamepad
  36685. */
  36686. var Gamepad = /** @class */ (function () {
  36687. /**
  36688. * Initializes the gamepad
  36689. * @param id The id of the gamepad
  36690. * @param index The index of the gamepad
  36691. * @param browserGamepad The browser gamepad
  36692. * @param leftStickX The x component of the left joystick
  36693. * @param leftStickY The y component of the left joystick
  36694. * @param rightStickX The x component of the right joystick
  36695. * @param rightStickY The y component of the right joystick
  36696. */
  36697. function Gamepad(
  36698. /**
  36699. * The id of the gamepad
  36700. */
  36701. id,
  36702. /**
  36703. * The index of the gamepad
  36704. */
  36705. index,
  36706. /**
  36707. * The browser gamepad
  36708. */
  36709. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  36710. if (leftStickX === void 0) { leftStickX = 0; }
  36711. if (leftStickY === void 0) { leftStickY = 1; }
  36712. if (rightStickX === void 0) { rightStickX = 2; }
  36713. if (rightStickY === void 0) { rightStickY = 3; }
  36714. this.id = id;
  36715. this.index = index;
  36716. this.browserGamepad = browserGamepad;
  36717. this._leftStick = { x: 0, y: 0 };
  36718. this._rightStick = { x: 0, y: 0 };
  36719. /** @hidden */
  36720. this._isConnected = true;
  36721. /**
  36722. * Specifies whether the left control stick should be Y-inverted
  36723. */
  36724. this._invertLeftStickY = false;
  36725. this.type = Gamepad.GAMEPAD;
  36726. this._leftStickAxisX = leftStickX;
  36727. this._leftStickAxisY = leftStickY;
  36728. this._rightStickAxisX = rightStickX;
  36729. this._rightStickAxisY = rightStickY;
  36730. if (this.browserGamepad.axes.length >= 2) {
  36731. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36732. }
  36733. if (this.browserGamepad.axes.length >= 4) {
  36734. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36735. }
  36736. }
  36737. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36738. /**
  36739. * Specifies if the gamepad has been connected
  36740. */
  36741. get: function () {
  36742. return this._isConnected;
  36743. },
  36744. enumerable: true,
  36745. configurable: true
  36746. });
  36747. /**
  36748. * Callback triggered when the left joystick has changed
  36749. * @param callback
  36750. */
  36751. Gamepad.prototype.onleftstickchanged = function (callback) {
  36752. this._onleftstickchanged = callback;
  36753. };
  36754. /**
  36755. * Callback triggered when the right joystick has changed
  36756. * @param callback
  36757. */
  36758. Gamepad.prototype.onrightstickchanged = function (callback) {
  36759. this._onrightstickchanged = callback;
  36760. };
  36761. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36762. /**
  36763. * Gets the left joystick
  36764. */
  36765. get: function () {
  36766. return this._leftStick;
  36767. },
  36768. /**
  36769. * Sets the left joystick values
  36770. */
  36771. set: function (newValues) {
  36772. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36773. this._onleftstickchanged(newValues);
  36774. }
  36775. this._leftStick = newValues;
  36776. },
  36777. enumerable: true,
  36778. configurable: true
  36779. });
  36780. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36781. /**
  36782. * Gets the right joystick
  36783. */
  36784. get: function () {
  36785. return this._rightStick;
  36786. },
  36787. /**
  36788. * Sets the right joystick value
  36789. */
  36790. set: function (newValues) {
  36791. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  36792. this._onrightstickchanged(newValues);
  36793. }
  36794. this._rightStick = newValues;
  36795. },
  36796. enumerable: true,
  36797. configurable: true
  36798. });
  36799. /**
  36800. * Updates the gamepad joystick positions
  36801. */
  36802. Gamepad.prototype.update = function () {
  36803. if (this._leftStick) {
  36804. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36805. if (this._invertLeftStickY) {
  36806. this.leftStick.y *= -1;
  36807. }
  36808. }
  36809. if (this._rightStick) {
  36810. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36811. }
  36812. };
  36813. /**
  36814. * Disposes the gamepad
  36815. */
  36816. Gamepad.prototype.dispose = function () {
  36817. };
  36818. /**
  36819. * Represents a gamepad controller
  36820. */
  36821. Gamepad.GAMEPAD = 0;
  36822. /**
  36823. * Represents a generic controller
  36824. */
  36825. Gamepad.GENERIC = 1;
  36826. /**
  36827. * Represents an XBox controller
  36828. */
  36829. Gamepad.XBOX = 2;
  36830. /**
  36831. * Represents a pose-enabled controller
  36832. */
  36833. Gamepad.POSE_ENABLED = 3;
  36834. return Gamepad;
  36835. }());
  36836. /**
  36837. * Represents a generic gamepad
  36838. */
  36839. var GenericPad = /** @class */ (function (_super) {
  36840. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  36841. /**
  36842. * Initializes the generic gamepad
  36843. * @param id The id of the generic gamepad
  36844. * @param index The index of the generic gamepad
  36845. * @param browserGamepad The browser gamepad
  36846. */
  36847. function GenericPad(id, index, browserGamepad) {
  36848. var _this = _super.call(this, id, index, browserGamepad) || this;
  36849. /**
  36850. * Observable triggered when a button has been pressed
  36851. */
  36852. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36853. /**
  36854. * Observable triggered when a button has been released
  36855. */
  36856. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36857. _this.type = Gamepad.GENERIC;
  36858. _this._buttons = new Array(browserGamepad.buttons.length);
  36859. return _this;
  36860. }
  36861. /**
  36862. * Callback triggered when a button has been pressed
  36863. * @param callback Called when a button has been pressed
  36864. */
  36865. GenericPad.prototype.onbuttondown = function (callback) {
  36866. this._onbuttondown = callback;
  36867. };
  36868. /**
  36869. * Callback triggered when a button has been released
  36870. * @param callback Called when a button has been released
  36871. */
  36872. GenericPad.prototype.onbuttonup = function (callback) {
  36873. this._onbuttonup = callback;
  36874. };
  36875. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  36876. if (newValue !== currentValue) {
  36877. if (newValue === 1) {
  36878. if (this._onbuttondown) {
  36879. this._onbuttondown(buttonIndex);
  36880. }
  36881. this.onButtonDownObservable.notifyObservers(buttonIndex);
  36882. }
  36883. if (newValue === 0) {
  36884. if (this._onbuttonup) {
  36885. this._onbuttonup(buttonIndex);
  36886. }
  36887. this.onButtonUpObservable.notifyObservers(buttonIndex);
  36888. }
  36889. }
  36890. return newValue;
  36891. };
  36892. /**
  36893. * Updates the generic gamepad
  36894. */
  36895. GenericPad.prototype.update = function () {
  36896. _super.prototype.update.call(this);
  36897. for (var index = 0; index < this._buttons.length; index++) {
  36898. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  36899. }
  36900. };
  36901. /**
  36902. * Disposes the generic gamepad
  36903. */
  36904. GenericPad.prototype.dispose = function () {
  36905. _super.prototype.dispose.call(this);
  36906. this.onButtonDownObservable.clear();
  36907. this.onButtonUpObservable.clear();
  36908. };
  36909. return GenericPad;
  36910. }(Gamepad));
  36911. /***/ }),
  36912. /***/ "./Gamepads/gamepadManager.ts":
  36913. /*!************************************!*\
  36914. !*** ./Gamepads/gamepadManager.ts ***!
  36915. \************************************/
  36916. /*! exports provided: GamepadManager */
  36917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36918. "use strict";
  36919. __webpack_require__.r(__webpack_exports__);
  36920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  36921. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  36922. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36923. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  36924. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36925. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36926. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36927. /**
  36928. * Manager for handling gamepads
  36929. */
  36930. var GamepadManager = /** @class */ (function () {
  36931. /**
  36932. * Initializes the gamepad manager
  36933. * @param _scene BabylonJS scene
  36934. */
  36935. function GamepadManager(_scene) {
  36936. var _this = this;
  36937. this._scene = _scene;
  36938. this._babylonGamepads = [];
  36939. this._oneGamepadConnected = false;
  36940. /** @hidden */
  36941. this._isMonitoring = false;
  36942. /**
  36943. * observable to be triggered when the gamepad controller has been disconnected
  36944. */
  36945. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36946. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  36947. this._gamepadEventSupported = false;
  36948. }
  36949. else {
  36950. this._gamepadEventSupported = 'GamepadEvent' in window;
  36951. this._gamepadSupport = (navigator.getGamepads ||
  36952. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  36953. }
  36954. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  36955. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  36956. for (var i in _this._babylonGamepads) {
  36957. var gamepad = _this._babylonGamepads[i];
  36958. if (gamepad && gamepad._isConnected) {
  36959. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  36960. }
  36961. }
  36962. });
  36963. this._onGamepadConnectedEvent = function (evt) {
  36964. var gamepad = evt.gamepad;
  36965. if (gamepad.index in _this._babylonGamepads) {
  36966. if (_this._babylonGamepads[gamepad.index].isConnected) {
  36967. return;
  36968. }
  36969. }
  36970. var newGamepad;
  36971. if (_this._babylonGamepads[gamepad.index]) {
  36972. newGamepad = _this._babylonGamepads[gamepad.index];
  36973. newGamepad.browserGamepad = gamepad;
  36974. newGamepad._isConnected = true;
  36975. }
  36976. else {
  36977. newGamepad = _this._addNewGamepad(gamepad);
  36978. }
  36979. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36980. _this._startMonitoringGamepads();
  36981. };
  36982. this._onGamepadDisconnectedEvent = function (evt) {
  36983. var gamepad = evt.gamepad;
  36984. // Remove the gamepad from the list of gamepads to monitor.
  36985. for (var i in _this._babylonGamepads) {
  36986. if (_this._babylonGamepads[i].index === gamepad.index) {
  36987. var disconnectedGamepad = _this._babylonGamepads[i];
  36988. disconnectedGamepad._isConnected = false;
  36989. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  36990. break;
  36991. }
  36992. }
  36993. };
  36994. if (this._gamepadSupport) {
  36995. //first add already-connected gamepads
  36996. this._updateGamepadObjects();
  36997. if (this._babylonGamepads.length) {
  36998. this._startMonitoringGamepads();
  36999. }
  37000. // Checking if the gamepad connected event is supported (like in Firefox)
  37001. if (this._gamepadEventSupported) {
  37002. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  37003. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  37004. }
  37005. else {
  37006. this._startMonitoringGamepads();
  37007. }
  37008. }
  37009. }
  37010. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  37011. /**
  37012. * The gamepads in the game pad manager
  37013. */
  37014. get: function () {
  37015. return this._babylonGamepads;
  37016. },
  37017. enumerable: true,
  37018. configurable: true
  37019. });
  37020. /**
  37021. * Get the gamepad controllers based on type
  37022. * @param type The type of gamepad controller
  37023. * @returns Nullable gamepad
  37024. */
  37025. GamepadManager.prototype.getGamepadByType = function (type) {
  37026. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  37027. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  37028. var gamepad = _a[_i];
  37029. if (gamepad && gamepad.type === type) {
  37030. return gamepad;
  37031. }
  37032. }
  37033. return null;
  37034. };
  37035. /**
  37036. * Disposes the gamepad manager
  37037. */
  37038. GamepadManager.prototype.dispose = function () {
  37039. if (this._gamepadEventSupported) {
  37040. if (this._onGamepadConnectedEvent) {
  37041. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  37042. }
  37043. if (this._onGamepadDisconnectedEvent) {
  37044. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  37045. }
  37046. this._onGamepadConnectedEvent = null;
  37047. this._onGamepadDisconnectedEvent = null;
  37048. }
  37049. this._babylonGamepads.forEach(function (gamepad) {
  37050. gamepad.dispose();
  37051. });
  37052. this.onGamepadConnectedObservable.clear();
  37053. this.onGamepadDisconnectedObservable.clear();
  37054. this._oneGamepadConnected = false;
  37055. this._stopMonitoringGamepads();
  37056. this._babylonGamepads = [];
  37057. };
  37058. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  37059. if (!this._oneGamepadConnected) {
  37060. this._oneGamepadConnected = true;
  37061. }
  37062. var newGamepad;
  37063. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  37064. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  37065. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  37066. }
  37067. // if pose is supported, use the (WebVR) pose enabled controller
  37068. else if (gamepad.pose) {
  37069. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  37070. }
  37071. else {
  37072. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  37073. }
  37074. this._babylonGamepads[newGamepad.index] = newGamepad;
  37075. return newGamepad;
  37076. };
  37077. GamepadManager.prototype._startMonitoringGamepads = function () {
  37078. if (!this._isMonitoring) {
  37079. this._isMonitoring = true;
  37080. //back-comp
  37081. if (!this._scene) {
  37082. this._checkGamepadsStatus();
  37083. }
  37084. }
  37085. };
  37086. GamepadManager.prototype._stopMonitoringGamepads = function () {
  37087. this._isMonitoring = false;
  37088. };
  37089. /** @hidden */
  37090. GamepadManager.prototype._checkGamepadsStatus = function () {
  37091. var _this = this;
  37092. // Hack to be compatible Chrome
  37093. this._updateGamepadObjects();
  37094. for (var i in this._babylonGamepads) {
  37095. var gamepad = this._babylonGamepads[i];
  37096. if (!gamepad || !gamepad.isConnected) {
  37097. continue;
  37098. }
  37099. gamepad.update();
  37100. }
  37101. if (this._isMonitoring && !this._scene) {
  37102. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  37103. }
  37104. };
  37105. // This function is called only on Chrome, which does not properly support
  37106. // connection/disconnection events and forces you to recopy again the gamepad object
  37107. GamepadManager.prototype._updateGamepadObjects = function () {
  37108. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  37109. for (var i = 0; i < gamepads.length; i++) {
  37110. var gamepad = gamepads[i];
  37111. if (gamepad) {
  37112. if (!this._babylonGamepads[gamepad.index]) {
  37113. var newGamepad = this._addNewGamepad(gamepad);
  37114. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37115. }
  37116. else {
  37117. // Forced to copy again this object for Chrome for unknown reason
  37118. this._babylonGamepads[i].browserGamepad = gamepad;
  37119. if (!this._babylonGamepads[i].isConnected) {
  37120. this._babylonGamepads[i]._isConnected = true;
  37121. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  37122. }
  37123. }
  37124. }
  37125. }
  37126. };
  37127. return GamepadManager;
  37128. }());
  37129. /***/ }),
  37130. /***/ "./Gamepads/gamepadSceneComponent.ts":
  37131. /*!*******************************************!*\
  37132. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  37133. \*******************************************/
  37134. /*! exports provided: GamepadSystemSceneComponent */
  37135. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37136. "use strict";
  37137. __webpack_require__.r(__webpack_exports__);
  37138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  37139. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  37140. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  37141. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37142. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  37143. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  37144. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  37145. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  37146. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  37147. get: function () {
  37148. if (!this._gamepadManager) {
  37149. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  37150. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  37151. if (!component) {
  37152. component = new GamepadSystemSceneComponent(this);
  37153. this._addComponent(component);
  37154. }
  37155. }
  37156. return this._gamepadManager;
  37157. },
  37158. enumerable: true,
  37159. configurable: true
  37160. });
  37161. /**
  37162. * Adds a gamepad to the free camera inputs manager
  37163. */
  37164. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  37165. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  37166. return this;
  37167. };
  37168. /**
  37169. * Adds a gamepad to the arc rotate camera inputs manager
  37170. */
  37171. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  37172. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  37173. return this;
  37174. };
  37175. /**
  37176. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37177. */
  37178. var GamepadSystemSceneComponent = /** @class */ (function () {
  37179. /**
  37180. * Creates a new instance of the component for the given scene
  37181. * @param scene Defines the scene to register the component in
  37182. */
  37183. function GamepadSystemSceneComponent(scene) {
  37184. /**
  37185. * The component name helpfull to identify the component in the list of scene components.
  37186. */
  37187. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  37188. this.scene = scene;
  37189. }
  37190. /**
  37191. * Registers the component in a given scene
  37192. */
  37193. GamepadSystemSceneComponent.prototype.register = function () {
  37194. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  37195. };
  37196. /**
  37197. * Rebuilds the elements related to this component in case of
  37198. * context lost for instance.
  37199. */
  37200. GamepadSystemSceneComponent.prototype.rebuild = function () {
  37201. // Nothing to do for gamepads
  37202. };
  37203. /**
  37204. * Disposes the component and the associated ressources
  37205. */
  37206. GamepadSystemSceneComponent.prototype.dispose = function () {
  37207. var gamepadManager = this.scene._gamepadManager;
  37208. if (gamepadManager) {
  37209. gamepadManager.dispose();
  37210. this.scene._gamepadManager = null;
  37211. }
  37212. };
  37213. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  37214. var gamepadManager = this.scene._gamepadManager;
  37215. if (gamepadManager && gamepadManager._isMonitoring) {
  37216. gamepadManager._checkGamepadsStatus();
  37217. }
  37218. };
  37219. return GamepadSystemSceneComponent;
  37220. }());
  37221. /***/ }),
  37222. /***/ "./Gamepads/index.ts":
  37223. /*!***************************!*\
  37224. !*** ./Gamepads/index.ts ***!
  37225. \***************************/
  37226. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37228. "use strict";
  37229. __webpack_require__.r(__webpack_exports__);
  37230. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  37231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  37233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  37234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  37235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  37236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  37237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  37238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  37239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  37240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  37241. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  37243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  37244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  37245. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  37247. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  37248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  37249. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  37251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  37252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  37253. /***/ }),
  37254. /***/ "./Gamepads/xboxGamepad.ts":
  37255. /*!*********************************!*\
  37256. !*** ./Gamepads/xboxGamepad.ts ***!
  37257. \*********************************/
  37258. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37260. "use strict";
  37261. __webpack_require__.r(__webpack_exports__);
  37262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  37263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  37264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  37265. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37266. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37267. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37268. /**
  37269. * Defines supported buttons for XBox360 compatible gamepads
  37270. */
  37271. var Xbox360Button;
  37272. (function (Xbox360Button) {
  37273. /** A */
  37274. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  37275. /** B */
  37276. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  37277. /** X */
  37278. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  37279. /** Y */
  37280. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  37281. /** Start */
  37282. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  37283. /** Back */
  37284. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  37285. /** Left button */
  37286. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  37287. /** Right button */
  37288. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  37289. /** Left stick */
  37290. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  37291. /** Right stick */
  37292. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  37293. })(Xbox360Button || (Xbox360Button = {}));
  37294. /** Defines values for XBox360 DPad */
  37295. var Xbox360Dpad;
  37296. (function (Xbox360Dpad) {
  37297. /** Up */
  37298. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  37299. /** Down */
  37300. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  37301. /** Left */
  37302. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  37303. /** Right */
  37304. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  37305. })(Xbox360Dpad || (Xbox360Dpad = {}));
  37306. /**
  37307. * Defines a XBox360 gamepad
  37308. */
  37309. var Xbox360Pad = /** @class */ (function (_super) {
  37310. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  37311. /**
  37312. * Creates a new XBox360 gamepad object
  37313. * @param id defines the id of this gamepad
  37314. * @param index defines its index
  37315. * @param gamepad defines the internal HTML gamepad object
  37316. * @param xboxOne defines if it is a XBox One gamepad
  37317. */
  37318. function Xbox360Pad(id, index, gamepad, xboxOne) {
  37319. if (xboxOne === void 0) { xboxOne = false; }
  37320. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  37321. _this._leftTrigger = 0;
  37322. _this._rightTrigger = 0;
  37323. /** Observable raised when a button is pressed */
  37324. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37325. /** Observable raised when a button is released */
  37326. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37327. /** Observable raised when a pad is pressed */
  37328. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37329. /** Observable raised when a pad is released */
  37330. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37331. _this._buttonA = 0;
  37332. _this._buttonB = 0;
  37333. _this._buttonX = 0;
  37334. _this._buttonY = 0;
  37335. _this._buttonBack = 0;
  37336. _this._buttonStart = 0;
  37337. _this._buttonLB = 0;
  37338. _this._buttonRB = 0;
  37339. _this._buttonLeftStick = 0;
  37340. _this._buttonRightStick = 0;
  37341. _this._dPadUp = 0;
  37342. _this._dPadDown = 0;
  37343. _this._dPadLeft = 0;
  37344. _this._dPadRight = 0;
  37345. _this._isXboxOnePad = false;
  37346. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  37347. _this._isXboxOnePad = xboxOne;
  37348. return _this;
  37349. }
  37350. /**
  37351. * Defines the callback to call when left trigger is pressed
  37352. * @param callback defines the callback to use
  37353. */
  37354. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  37355. this._onlefttriggerchanged = callback;
  37356. };
  37357. /**
  37358. * Defines the callback to call when right trigger is pressed
  37359. * @param callback defines the callback to use
  37360. */
  37361. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  37362. this._onrighttriggerchanged = callback;
  37363. };
  37364. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  37365. /**
  37366. * Gets the left trigger value
  37367. */
  37368. get: function () {
  37369. return this._leftTrigger;
  37370. },
  37371. /**
  37372. * Sets the left trigger value
  37373. */
  37374. set: function (newValue) {
  37375. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  37376. this._onlefttriggerchanged(newValue);
  37377. }
  37378. this._leftTrigger = newValue;
  37379. },
  37380. enumerable: true,
  37381. configurable: true
  37382. });
  37383. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  37384. /**
  37385. * Gets the right trigger value
  37386. */
  37387. get: function () {
  37388. return this._rightTrigger;
  37389. },
  37390. /**
  37391. * Sets the right trigger value
  37392. */
  37393. set: function (newValue) {
  37394. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  37395. this._onrighttriggerchanged(newValue);
  37396. }
  37397. this._rightTrigger = newValue;
  37398. },
  37399. enumerable: true,
  37400. configurable: true
  37401. });
  37402. /**
  37403. * Defines the callback to call when a button is pressed
  37404. * @param callback defines the callback to use
  37405. */
  37406. Xbox360Pad.prototype.onbuttondown = function (callback) {
  37407. this._onbuttondown = callback;
  37408. };
  37409. /**
  37410. * Defines the callback to call when a button is released
  37411. * @param callback defines the callback to use
  37412. */
  37413. Xbox360Pad.prototype.onbuttonup = function (callback) {
  37414. this._onbuttonup = callback;
  37415. };
  37416. /**
  37417. * Defines the callback to call when a pad is pressed
  37418. * @param callback defines the callback to use
  37419. */
  37420. Xbox360Pad.prototype.ondpaddown = function (callback) {
  37421. this._ondpaddown = callback;
  37422. };
  37423. /**
  37424. * Defines the callback to call when a pad is released
  37425. * @param callback defines the callback to use
  37426. */
  37427. Xbox360Pad.prototype.ondpadup = function (callback) {
  37428. this._ondpadup = callback;
  37429. };
  37430. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  37431. if (newValue !== currentValue) {
  37432. if (newValue === 1) {
  37433. if (this._onbuttondown) {
  37434. this._onbuttondown(buttonType);
  37435. }
  37436. this.onButtonDownObservable.notifyObservers(buttonType);
  37437. }
  37438. if (newValue === 0) {
  37439. if (this._onbuttonup) {
  37440. this._onbuttonup(buttonType);
  37441. }
  37442. this.onButtonUpObservable.notifyObservers(buttonType);
  37443. }
  37444. }
  37445. return newValue;
  37446. };
  37447. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  37448. if (newValue !== currentValue) {
  37449. if (newValue === 1) {
  37450. if (this._ondpaddown) {
  37451. this._ondpaddown(buttonType);
  37452. }
  37453. this.onPadDownObservable.notifyObservers(buttonType);
  37454. }
  37455. if (newValue === 0) {
  37456. if (this._ondpadup) {
  37457. this._ondpadup(buttonType);
  37458. }
  37459. this.onPadUpObservable.notifyObservers(buttonType);
  37460. }
  37461. }
  37462. return newValue;
  37463. };
  37464. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  37465. /**
  37466. * Gets the value of the `A` button
  37467. */
  37468. get: function () {
  37469. return this._buttonA;
  37470. },
  37471. /**
  37472. * Sets the value of the `A` button
  37473. */
  37474. set: function (value) {
  37475. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  37476. },
  37477. enumerable: true,
  37478. configurable: true
  37479. });
  37480. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  37481. /**
  37482. * Gets the value of the `B` button
  37483. */
  37484. get: function () {
  37485. return this._buttonB;
  37486. },
  37487. /**
  37488. * Sets the value of the `B` button
  37489. */
  37490. set: function (value) {
  37491. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  37492. },
  37493. enumerable: true,
  37494. configurable: true
  37495. });
  37496. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  37497. /**
  37498. * Gets the value of the `X` button
  37499. */
  37500. get: function () {
  37501. return this._buttonX;
  37502. },
  37503. /**
  37504. * Sets the value of the `X` button
  37505. */
  37506. set: function (value) {
  37507. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  37508. },
  37509. enumerable: true,
  37510. configurable: true
  37511. });
  37512. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37513. /**
  37514. * Gets the value of the `Y` button
  37515. */
  37516. get: function () {
  37517. return this._buttonY;
  37518. },
  37519. /**
  37520. * Sets the value of the `Y` button
  37521. */
  37522. set: function (value) {
  37523. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37524. },
  37525. enumerable: true,
  37526. configurable: true
  37527. });
  37528. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37529. /**
  37530. * Gets the value of the `Start` button
  37531. */
  37532. get: function () {
  37533. return this._buttonStart;
  37534. },
  37535. /**
  37536. * Sets the value of the `Start` button
  37537. */
  37538. set: function (value) {
  37539. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37540. },
  37541. enumerable: true,
  37542. configurable: true
  37543. });
  37544. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37545. /**
  37546. * Gets the value of the `Back` button
  37547. */
  37548. get: function () {
  37549. return this._buttonBack;
  37550. },
  37551. /**
  37552. * Sets the value of the `Back` button
  37553. */
  37554. set: function (value) {
  37555. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37556. },
  37557. enumerable: true,
  37558. configurable: true
  37559. });
  37560. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37561. /**
  37562. * Gets the value of the `Left` button
  37563. */
  37564. get: function () {
  37565. return this._buttonLB;
  37566. },
  37567. /**
  37568. * Sets the value of the `Left` button
  37569. */
  37570. set: function (value) {
  37571. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37572. },
  37573. enumerable: true,
  37574. configurable: true
  37575. });
  37576. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37577. /**
  37578. * Gets the value of the `Right` button
  37579. */
  37580. get: function () {
  37581. return this._buttonRB;
  37582. },
  37583. /**
  37584. * Sets the value of the `Right` button
  37585. */
  37586. set: function (value) {
  37587. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37588. },
  37589. enumerable: true,
  37590. configurable: true
  37591. });
  37592. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37593. /**
  37594. * Gets the value of the Left joystick
  37595. */
  37596. get: function () {
  37597. return this._buttonLeftStick;
  37598. },
  37599. /**
  37600. * Sets the value of the Left joystick
  37601. */
  37602. set: function (value) {
  37603. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37604. },
  37605. enumerable: true,
  37606. configurable: true
  37607. });
  37608. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37609. /**
  37610. * Gets the value of the Right joystick
  37611. */
  37612. get: function () {
  37613. return this._buttonRightStick;
  37614. },
  37615. /**
  37616. * Sets the value of the Right joystick
  37617. */
  37618. set: function (value) {
  37619. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37620. },
  37621. enumerable: true,
  37622. configurable: true
  37623. });
  37624. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37625. /**
  37626. * Gets the value of D-pad up
  37627. */
  37628. get: function () {
  37629. return this._dPadUp;
  37630. },
  37631. /**
  37632. * Sets the value of D-pad up
  37633. */
  37634. set: function (value) {
  37635. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  37636. },
  37637. enumerable: true,
  37638. configurable: true
  37639. });
  37640. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  37641. /**
  37642. * Gets the value of D-pad down
  37643. */
  37644. get: function () {
  37645. return this._dPadDown;
  37646. },
  37647. /**
  37648. * Sets the value of D-pad down
  37649. */
  37650. set: function (value) {
  37651. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  37652. },
  37653. enumerable: true,
  37654. configurable: true
  37655. });
  37656. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  37657. /**
  37658. * Gets the value of D-pad left
  37659. */
  37660. get: function () {
  37661. return this._dPadLeft;
  37662. },
  37663. /**
  37664. * Sets the value of D-pad left
  37665. */
  37666. set: function (value) {
  37667. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  37668. },
  37669. enumerable: true,
  37670. configurable: true
  37671. });
  37672. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  37673. /**
  37674. * Gets the value of D-pad right
  37675. */
  37676. get: function () {
  37677. return this._dPadRight;
  37678. },
  37679. /**
  37680. * Sets the value of D-pad right
  37681. */
  37682. set: function (value) {
  37683. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  37684. },
  37685. enumerable: true,
  37686. configurable: true
  37687. });
  37688. /**
  37689. * Force the gamepad to synchronize with device values
  37690. */
  37691. Xbox360Pad.prototype.update = function () {
  37692. _super.prototype.update.call(this);
  37693. if (this._isXboxOnePad) {
  37694. this.buttonA = this.browserGamepad.buttons[0].value;
  37695. this.buttonB = this.browserGamepad.buttons[1].value;
  37696. this.buttonX = this.browserGamepad.buttons[2].value;
  37697. this.buttonY = this.browserGamepad.buttons[3].value;
  37698. this.buttonLB = this.browserGamepad.buttons[4].value;
  37699. this.buttonRB = this.browserGamepad.buttons[5].value;
  37700. this.leftTrigger = this.browserGamepad.axes[2];
  37701. this.rightTrigger = this.browserGamepad.axes[5];
  37702. this.buttonBack = this.browserGamepad.buttons[9].value;
  37703. this.buttonStart = this.browserGamepad.buttons[8].value;
  37704. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  37705. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  37706. this.dPadUp = this.browserGamepad.buttons[11].value;
  37707. this.dPadDown = this.browserGamepad.buttons[12].value;
  37708. this.dPadLeft = this.browserGamepad.buttons[13].value;
  37709. this.dPadRight = this.browserGamepad.buttons[14].value;
  37710. }
  37711. else {
  37712. this.buttonA = this.browserGamepad.buttons[0].value;
  37713. this.buttonB = this.browserGamepad.buttons[1].value;
  37714. this.buttonX = this.browserGamepad.buttons[2].value;
  37715. this.buttonY = this.browserGamepad.buttons[3].value;
  37716. this.buttonLB = this.browserGamepad.buttons[4].value;
  37717. this.buttonRB = this.browserGamepad.buttons[5].value;
  37718. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37719. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37720. this.buttonBack = this.browserGamepad.buttons[8].value;
  37721. this.buttonStart = this.browserGamepad.buttons[9].value;
  37722. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37723. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37724. this.dPadUp = this.browserGamepad.buttons[12].value;
  37725. this.dPadDown = this.browserGamepad.buttons[13].value;
  37726. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37727. this.dPadRight = this.browserGamepad.buttons[15].value;
  37728. }
  37729. };
  37730. /**
  37731. * Disposes the gamepad
  37732. */
  37733. Xbox360Pad.prototype.dispose = function () {
  37734. _super.prototype.dispose.call(this);
  37735. this.onButtonDownObservable.clear();
  37736. this.onButtonUpObservable.clear();
  37737. this.onPadDownObservable.clear();
  37738. this.onPadUpObservable.clear();
  37739. };
  37740. return Xbox360Pad;
  37741. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37742. /***/ }),
  37743. /***/ "./Gizmos/axisDragGizmo.ts":
  37744. /*!*********************************!*\
  37745. !*** ./Gizmos/axisDragGizmo.ts ***!
  37746. \*********************************/
  37747. /*! exports provided: AxisDragGizmo */
  37748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37749. "use strict";
  37750. __webpack_require__.r(__webpack_exports__);
  37751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37752. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37753. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37754. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37755. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37756. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37757. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37758. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37759. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37760. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37761. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37762. /**
  37763. * Single axis drag gizmo
  37764. */
  37765. var AxisDragGizmo = /** @class */ (function (_super) {
  37766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37767. /**
  37768. * Creates an AxisDragGizmo
  37769. * @param gizmoLayer The utility layer the gizmo will be added to
  37770. * @param dragAxis The axis which the gizmo will be able to drag on
  37771. * @param color The color of the gizmo
  37772. */
  37773. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37774. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37775. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37776. var _this = _super.call(this, gizmoLayer) || this;
  37777. _this._pointerObserver = null;
  37778. /**
  37779. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37780. */
  37781. _this.snapDistance = 0;
  37782. /**
  37783. * Event that fires each time the gizmo snaps to a new location.
  37784. * * snapDistance is the the change in distance
  37785. */
  37786. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37787. // Create Material
  37788. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37789. coloredMaterial.disableLighting = true;
  37790. coloredMaterial.emissiveColor = color;
  37791. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37792. hoverMaterial.disableLighting = true;
  37793. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37794. // Build mesh on root node
  37795. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  37796. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37797. arrow.scaling.scaleInPlace(1 / 3);
  37798. arrow.parent = _this._rootMesh;
  37799. var currentSnapDragDistance = 0;
  37800. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37801. var tmpSnapEvent = { snapDistance: 0 };
  37802. // Add drag behavior to handle events when the gizmo is dragged
  37803. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37804. _this.dragBehavior.moveAttached = false;
  37805. _this._rootMesh.addBehavior(_this.dragBehavior);
  37806. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37807. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37808. _this.dragBehavior.onDragObservable.add(function (event) {
  37809. if (_this.attachedMesh) {
  37810. // Convert delta to local translation if it has a parent
  37811. if (_this.attachedMesh.parent) {
  37812. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37813. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  37814. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  37815. }
  37816. else {
  37817. localDelta.copyFrom(event.delta);
  37818. }
  37819. // Snapping logic
  37820. if (_this.snapDistance == 0) {
  37821. _this.attachedMesh.position.addInPlace(localDelta);
  37822. }
  37823. else {
  37824. currentSnapDragDistance += event.dragDistance;
  37825. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37826. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37827. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37828. localDelta.normalizeToRef(tmpVector);
  37829. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  37830. _this.attachedMesh.position.addInPlace(tmpVector);
  37831. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37832. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37833. }
  37834. }
  37835. }
  37836. });
  37837. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37838. if (_this._customMeshSet) {
  37839. return;
  37840. }
  37841. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37842. var material = isHovered ? hoverMaterial : coloredMaterial;
  37843. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37844. m.material = material;
  37845. if (m.color) {
  37846. m.color = material.emissiveColor;
  37847. }
  37848. });
  37849. });
  37850. return _this;
  37851. }
  37852. /** @hidden */
  37853. AxisDragGizmo._CreateArrow = function (scene, material) {
  37854. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37855. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  37856. 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);
  37857. line.color = material.emissiveColor;
  37858. cylinder.parent = arrow;
  37859. line.parent = arrow;
  37860. // Position arrow pointing in its drag axis
  37861. cylinder.scaling.scaleInPlace(0.05);
  37862. cylinder.material = material;
  37863. cylinder.rotation.x = Math.PI / 2;
  37864. cylinder.position.z += 0.3;
  37865. line.scaling.scaleInPlace(0.26);
  37866. line.rotation.x = Math.PI / 2;
  37867. line.material = material;
  37868. return arrow;
  37869. };
  37870. /** @hidden */
  37871. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  37872. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37873. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  37874. var mesh = _a[_i];
  37875. var childInstance = mesh.createInstance(mesh.name);
  37876. childInstance.parent = instance;
  37877. }
  37878. return instance;
  37879. };
  37880. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  37881. if (this.dragBehavior) {
  37882. this.dragBehavior.enabled = value ? true : false;
  37883. }
  37884. };
  37885. /**
  37886. * Disposes of the gizmo
  37887. */
  37888. AxisDragGizmo.prototype.dispose = function () {
  37889. this.onSnapObservable.clear();
  37890. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37891. this.dragBehavior.detach();
  37892. _super.prototype.dispose.call(this);
  37893. };
  37894. return AxisDragGizmo;
  37895. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  37896. /***/ }),
  37897. /***/ "./Gizmos/axisScaleGizmo.ts":
  37898. /*!**********************************!*\
  37899. !*** ./Gizmos/axisScaleGizmo.ts ***!
  37900. \**********************************/
  37901. /*! exports provided: AxisScaleGizmo */
  37902. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37903. "use strict";
  37904. __webpack_require__.r(__webpack_exports__);
  37905. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  37906. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37907. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37908. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37909. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37910. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37911. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37912. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37913. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37914. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37915. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37916. /**
  37917. * Single axis scale gizmo
  37918. */
  37919. var AxisScaleGizmo = /** @class */ (function (_super) {
  37920. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  37921. /**
  37922. * Creates an AxisScaleGizmo
  37923. * @param gizmoLayer The utility layer the gizmo will be added to
  37924. * @param dragAxis The axis which the gizmo will be able to scale on
  37925. * @param color The color of the gizmo
  37926. */
  37927. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  37928. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37929. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37930. var _this = _super.call(this, gizmoLayer) || this;
  37931. _this._pointerObserver = null;
  37932. /**
  37933. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37934. */
  37935. _this.snapDistance = 0;
  37936. /**
  37937. * Event that fires each time the gizmo snaps to a new location.
  37938. * * snapDistance is the the change in distance
  37939. */
  37940. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37941. /**
  37942. * If the scaling operation should be done on all axis (default: false)
  37943. */
  37944. _this.uniformScaling = false;
  37945. // Create Material
  37946. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37947. _this._coloredMaterial.disableLighting = true;
  37948. _this._coloredMaterial.emissiveColor = color;
  37949. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37950. hoverMaterial.disableLighting = true;
  37951. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37952. // Build mesh on root node
  37953. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37954. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  37955. 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);
  37956. arrowTail.color = _this._coloredMaterial.emissiveColor;
  37957. arrow.addChild(arrowMesh);
  37958. arrow.addChild(arrowTail);
  37959. // Position arrow pointing in its drag axis
  37960. arrowMesh.scaling.scaleInPlace(0.1);
  37961. arrowMesh.material = _this._coloredMaterial;
  37962. arrowMesh.rotation.x = Math.PI / 2;
  37963. arrowMesh.position.z += 0.3;
  37964. arrowTail.scaling.scaleInPlace(0.26);
  37965. arrowTail.rotation.x = Math.PI / 2;
  37966. arrowTail.material = _this._coloredMaterial;
  37967. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37968. _this._rootMesh.addChild(arrow);
  37969. arrow.scaling.scaleInPlace(1 / 3);
  37970. // Add drag behavior to handle events when the gizmo is dragged
  37971. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37972. _this.dragBehavior.moveAttached = false;
  37973. _this._rootMesh.addBehavior(_this.dragBehavior);
  37974. var currentSnapDragDistance = 0;
  37975. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37976. var tmpSnapEvent = { snapDistance: 0 };
  37977. _this.dragBehavior.onDragObservable.add(function (event) {
  37978. if (_this.attachedMesh) {
  37979. // Snapping logic
  37980. var snapped = false;
  37981. var dragSteps = 0;
  37982. if (_this.uniformScaling) {
  37983. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  37984. if (tmpVector.y < 0) {
  37985. tmpVector.scaleInPlace(-1);
  37986. }
  37987. }
  37988. else {
  37989. tmpVector.copyFrom(dragAxis);
  37990. }
  37991. if (_this.snapDistance == 0) {
  37992. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  37993. }
  37994. else {
  37995. currentSnapDragDistance += event.dragDistance;
  37996. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37997. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37998. if (currentSnapDragDistance < 0) {
  37999. dragSteps *= -1;
  38000. }
  38001. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38002. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  38003. snapped = true;
  38004. }
  38005. else {
  38006. tmpVector.scaleInPlace(0);
  38007. }
  38008. }
  38009. _this.attachedMesh.scaling.addInPlace(tmpVector);
  38010. if (snapped) {
  38011. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38012. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38013. }
  38014. }
  38015. });
  38016. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38017. if (_this._customMeshSet) {
  38018. return;
  38019. }
  38020. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38021. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  38022. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38023. m.material = material;
  38024. if (m.color) {
  38025. m.color = material.emissiveColor;
  38026. }
  38027. });
  38028. });
  38029. return _this;
  38030. }
  38031. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  38032. if (this.dragBehavior) {
  38033. this.dragBehavior.enabled = value ? true : false;
  38034. }
  38035. };
  38036. /**
  38037. * Disposes of the gizmo
  38038. */
  38039. AxisScaleGizmo.prototype.dispose = function () {
  38040. this.onSnapObservable.clear();
  38041. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38042. this.dragBehavior.detach();
  38043. _super.prototype.dispose.call(this);
  38044. };
  38045. /**
  38046. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38047. * @param mesh The mesh to replace the default mesh of the gizmo
  38048. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  38049. */
  38050. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  38051. var _this = this;
  38052. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  38053. _super.prototype.setCustomMesh.call(this, mesh);
  38054. if (useGizmoMaterial) {
  38055. this._rootMesh.getChildMeshes().forEach(function (m) {
  38056. m.material = _this._coloredMaterial;
  38057. if (m.color) {
  38058. m.color = _this._coloredMaterial.emissiveColor;
  38059. }
  38060. });
  38061. this._customMeshSet = false;
  38062. }
  38063. };
  38064. return AxisScaleGizmo;
  38065. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  38066. /***/ }),
  38067. /***/ "./Gizmos/boundingBoxGizmo.ts":
  38068. /*!************************************!*\
  38069. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  38070. \************************************/
  38071. /*! exports provided: BoundingBoxGizmo */
  38072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38073. "use strict";
  38074. __webpack_require__.r(__webpack_exports__);
  38075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  38076. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38077. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38078. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38079. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38080. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38081. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38082. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  38083. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38084. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38085. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38086. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38087. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38088. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38089. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  38090. /**
  38091. * Bounding box gizmo
  38092. */
  38093. var BoundingBoxGizmo = /** @class */ (function (_super) {
  38094. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  38095. /**
  38096. * Creates an BoundingBoxGizmo
  38097. * @param gizmoLayer The utility layer the gizmo will be added to
  38098. * @param color The color of the gizmo
  38099. */
  38100. function BoundingBoxGizmo(color, gizmoLayer) {
  38101. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  38102. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  38103. var _this = _super.call(this, gizmoLayer) || this;
  38104. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  38105. _this._renderObserver = null;
  38106. _this._pointerObserver = null;
  38107. _this._scaleDragSpeed = 0.2;
  38108. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38109. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  38110. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  38111. /**
  38112. * 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)
  38113. */
  38114. _this.ignoreChildren = false;
  38115. /**
  38116. * 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)
  38117. */
  38118. _this.includeChildPredicate = null;
  38119. /**
  38120. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38121. */
  38122. _this.rotationSphereSize = 0.1;
  38123. /**
  38124. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38125. */
  38126. _this.scaleBoxSize = 0.1;
  38127. /**
  38128. * 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)
  38129. */
  38130. _this.fixedDragMeshScreenSize = false;
  38131. /**
  38132. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38133. */
  38134. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  38135. /**
  38136. * Fired when a rotation sphere or scale box is dragged
  38137. */
  38138. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38139. /**
  38140. * Fired when a scale box is dragged
  38141. */
  38142. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38143. /**
  38144. * Fired when a scale box drag is ended
  38145. */
  38146. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38147. /**
  38148. * Fired when a rotation sphere is dragged
  38149. */
  38150. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38151. /**
  38152. * Fired when a rotation sphere drag is ended
  38153. */
  38154. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38155. /**
  38156. * 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)
  38157. */
  38158. _this.scalePivot = null;
  38159. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  38160. // Dragging
  38161. _this._dragMesh = null;
  38162. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  38163. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  38164. _this._updateScale = false;
  38165. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  38166. // Create Materials
  38167. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38168. _this.coloredMaterial.disableLighting = true;
  38169. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38170. _this.hoverColoredMaterial.disableLighting = true;
  38171. // Build bounding box out of lines
  38172. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38173. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38174. var lines = [];
  38175. 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));
  38176. 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));
  38177. 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));
  38178. 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));
  38179. 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));
  38180. 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));
  38181. 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));
  38182. 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));
  38183. 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));
  38184. 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));
  38185. 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));
  38186. 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));
  38187. lines.forEach(function (l) {
  38188. l.color = color;
  38189. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  38190. l.isPickable = false;
  38191. _this._lineBoundingBox.addChild(l);
  38192. });
  38193. _this._rootMesh.addChild(_this._lineBoundingBox);
  38194. _this.setColor(color);
  38195. // Create rotation spheres
  38196. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38197. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38198. var _loop_1 = function (i_1) {
  38199. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  38200. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38201. sphere.material = this_1.coloredMaterial;
  38202. // Drag behavior
  38203. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  38204. _dragBehavior.moveAttached = false;
  38205. _dragBehavior.updateDragPlane = false;
  38206. sphere.addBehavior(_dragBehavior);
  38207. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  38208. var totalTurnAmountOfDrag = 0;
  38209. _dragBehavior.onDragStartObservable.add(function () {
  38210. startingTurnDirection.copyFrom(sphere.forward);
  38211. totalTurnAmountOfDrag = 0;
  38212. });
  38213. _dragBehavior.onDragObservable.add(function (event) {
  38214. _this.onRotationSphereDragObservable.notifyObservers({});
  38215. if (_this.attachedMesh) {
  38216. var originalParent = _this.attachedMesh.parent;
  38217. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38218. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38219. return;
  38220. }
  38221. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38222. var worldDragDirection = startingTurnDirection;
  38223. // Project the world right on to the drag plane
  38224. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  38225. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  38226. // project drag delta on to the resulting drag axis and rotate based on that
  38227. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  38228. // Make rotation relative to size of mesh.
  38229. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38230. // Rotate based on axis
  38231. if (!_this.attachedMesh.rotationQuaternion) {
  38232. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38233. }
  38234. if (!_this._anchorMesh.rotationQuaternion) {
  38235. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  38236. }
  38237. // Do not allow the object to turn more than a full circle
  38238. totalTurnAmountOfDrag += projectDist;
  38239. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  38240. if (i_1 >= 8) {
  38241. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  38242. }
  38243. else if (i_1 >= 4) {
  38244. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  38245. }
  38246. else {
  38247. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  38248. }
  38249. // Rotate around center of bounding box
  38250. _this._anchorMesh.addChild(_this.attachedMesh);
  38251. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  38252. _this._anchorMesh.removeChild(_this.attachedMesh);
  38253. _this.attachedMesh.setParent(originalParent);
  38254. }
  38255. _this.updateBoundingBox();
  38256. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38257. }
  38258. _this._updateDummy();
  38259. });
  38260. // Selection/deselection
  38261. _dragBehavior.onDragStartObservable.add(function () {
  38262. _this.onDragStartObservable.notifyObservers({});
  38263. _this._selectNode(sphere);
  38264. });
  38265. _dragBehavior.onDragEndObservable.add(function () {
  38266. _this.onRotationSphereDragEndObservable.notifyObservers({});
  38267. _this._selectNode(null);
  38268. _this._updateDummy();
  38269. });
  38270. this_1._rotateSpheresParent.addChild(sphere);
  38271. };
  38272. var this_1 = this, _dragBehavior;
  38273. for (var i_1 = 0; i_1 < 12; i_1++) {
  38274. _loop_1(i_1);
  38275. }
  38276. _this._rootMesh.addChild(_this._rotateSpheresParent);
  38277. // Create scale cubes
  38278. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38279. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38280. for (var i = 0; i < 2; i++) {
  38281. for (var j = 0; j < 2; j++) {
  38282. var _loop_2 = function () {
  38283. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  38284. box.material = this_2.coloredMaterial;
  38285. // Dragging logic
  38286. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  38287. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38288. _dragBehavior.moveAttached = false;
  38289. box.addBehavior(_dragBehavior);
  38290. _dragBehavior.onDragObservable.add(function (event) {
  38291. _this.onScaleBoxDragObservable.notifyObservers({});
  38292. if (_this.attachedMesh) {
  38293. var originalParent = _this.attachedMesh.parent;
  38294. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38295. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38296. return;
  38297. }
  38298. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38299. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38300. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  38301. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  38302. _this.updateBoundingBox();
  38303. if (_this.scalePivot) {
  38304. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  38305. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  38306. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  38307. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38308. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38309. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  38310. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38311. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  38312. }
  38313. else {
  38314. // Scale from the position of the opposite corner
  38315. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  38316. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38317. }
  38318. _this._anchorMesh.addChild(_this.attachedMesh);
  38319. _this._anchorMesh.scaling.addInPlace(deltaScale);
  38320. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  38321. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  38322. }
  38323. _this._anchorMesh.removeChild(_this.attachedMesh);
  38324. _this.attachedMesh.setParent(originalParent);
  38325. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38326. }
  38327. _this._updateDummy();
  38328. });
  38329. // Selection/deselection
  38330. _dragBehavior.onDragStartObservable.add(function () {
  38331. _this.onDragStartObservable.notifyObservers({});
  38332. _this._selectNode(box);
  38333. });
  38334. _dragBehavior.onDragEndObservable.add(function () {
  38335. _this.onScaleBoxDragEndObservable.notifyObservers({});
  38336. _this._selectNode(null);
  38337. _this._updateDummy();
  38338. });
  38339. this_2._scaleBoxesParent.addChild(box);
  38340. };
  38341. var this_2 = this, _dragBehavior;
  38342. for (var k = 0; k < 2; k++) {
  38343. _loop_2();
  38344. }
  38345. }
  38346. }
  38347. _this._rootMesh.addChild(_this._scaleBoxesParent);
  38348. // Hover color change
  38349. var pointerIds = new Array();
  38350. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38351. if (!pointerIds[pointerInfo.event.pointerId]) {
  38352. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  38353. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  38354. pointerIds[pointerInfo.event.pointerId] = mesh;
  38355. mesh.material = _this.hoverColoredMaterial;
  38356. }
  38357. });
  38358. }
  38359. else {
  38360. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  38361. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  38362. delete pointerIds[pointerInfo.event.pointerId];
  38363. }
  38364. }
  38365. });
  38366. // Update bounding box positions
  38367. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  38368. // Only update the bouding box if scaling has changed
  38369. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  38370. _this.updateBoundingBox();
  38371. }
  38372. else if (_this.fixedDragMeshScreenSize) {
  38373. _this._updateRotationSpheres();
  38374. _this._updateScaleBoxes();
  38375. }
  38376. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  38377. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  38378. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  38379. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  38380. }
  38381. });
  38382. _this.updateBoundingBox();
  38383. return _this;
  38384. }
  38385. /**
  38386. * Sets the color of the bounding box gizmo
  38387. * @param color the color to set
  38388. */
  38389. BoundingBoxGizmo.prototype.setColor = function (color) {
  38390. this.coloredMaterial.emissiveColor = color;
  38391. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  38392. this._lineBoundingBox.getChildren().forEach(function (l) {
  38393. if (l.color) {
  38394. l.color = color;
  38395. }
  38396. });
  38397. };
  38398. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  38399. var _this = this;
  38400. if (value) {
  38401. // Reset anchor mesh to match attached mesh's scale
  38402. // This is needed to avoid invalid box/sphere position on first drag
  38403. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  38404. var originalParent = value.parent;
  38405. this._anchorMesh.addChild(value);
  38406. this._anchorMesh.removeChild(value);
  38407. value.setParent(originalParent);
  38408. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  38409. this.updateBoundingBox();
  38410. value.getChildMeshes(false).forEach(function (m) {
  38411. m.markAsDirty("scaling");
  38412. });
  38413. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  38414. _this._updateDummy();
  38415. });
  38416. }
  38417. };
  38418. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  38419. this._rotateSpheresParent.getChildMeshes()
  38420. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  38421. m.isVisible = (!selectedMesh || m == selectedMesh);
  38422. });
  38423. };
  38424. /**
  38425. * Updates the bounding box information for the Gizmo
  38426. */
  38427. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  38428. if (this.attachedMesh) {
  38429. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  38430. var originalParent = this.attachedMesh.parent;
  38431. this.attachedMesh.setParent(null);
  38432. this._update();
  38433. // Rotate based on axis
  38434. if (!this.attachedMesh.rotationQuaternion) {
  38435. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  38436. }
  38437. if (!this._anchorMesh.rotationQuaternion) {
  38438. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  38439. }
  38440. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38441. // Store original position and reset mesh to origin before computing the bounding box
  38442. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38443. this._tmpVector.copyFrom(this.attachedMesh.position);
  38444. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  38445. this.attachedMesh.position.set(0, 0, 0);
  38446. // Update bounding dimensions/positions
  38447. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  38448. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  38449. // Update gizmo to match bounding box scaling and rotation
  38450. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  38451. 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);
  38452. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  38453. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  38454. this._lineBoundingBox.computeWorldMatrix();
  38455. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  38456. // restore position/rotation values
  38457. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  38458. this.attachedMesh.position.copyFrom(this._tmpVector);
  38459. this.attachedMesh.setParent(originalParent);
  38460. }
  38461. this._updateRotationSpheres();
  38462. this._updateScaleBoxes();
  38463. if (this.attachedMesh) {
  38464. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  38465. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  38466. }
  38467. };
  38468. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  38469. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  38470. for (var i = 0; i < 3; i++) {
  38471. for (var j = 0; j < 2; j++) {
  38472. for (var k = 0; k < 2; k++) {
  38473. var index = ((i * 4) + (j * 2)) + k;
  38474. if (i == 0) {
  38475. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38476. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38477. 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));
  38478. }
  38479. if (i == 1) {
  38480. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  38481. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38482. 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));
  38483. }
  38484. if (i == 2) {
  38485. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  38486. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38487. 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));
  38488. }
  38489. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38490. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38491. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38492. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38493. }
  38494. else {
  38495. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  38496. }
  38497. }
  38498. }
  38499. }
  38500. };
  38501. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  38502. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  38503. for (var i = 0; i < 2; i++) {
  38504. for (var j = 0; j < 2; j++) {
  38505. for (var k = 0; k < 2; k++) {
  38506. var index = ((i * 4) + (j * 2)) + k;
  38507. if (scaleBoxes[index]) {
  38508. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38509. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38510. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38511. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38512. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38513. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38514. }
  38515. else {
  38516. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  38517. }
  38518. }
  38519. }
  38520. }
  38521. }
  38522. };
  38523. /**
  38524. * Enables rotation on the specified axis and disables rotation on the others
  38525. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38526. */
  38527. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38528. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38529. if (i < 4) {
  38530. m.setEnabled(axis.indexOf("x") != -1);
  38531. }
  38532. else if (i < 8) {
  38533. m.setEnabled(axis.indexOf("y") != -1);
  38534. }
  38535. else {
  38536. m.setEnabled(axis.indexOf("z") != -1);
  38537. }
  38538. });
  38539. };
  38540. /**
  38541. * Enables/disables scaling
  38542. * @param enable if scaling should be enabled
  38543. */
  38544. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38545. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38546. m.setEnabled(enable);
  38547. });
  38548. };
  38549. BoundingBoxGizmo.prototype._updateDummy = function () {
  38550. if (this._dragMesh) {
  38551. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38552. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38553. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38554. }
  38555. };
  38556. /**
  38557. * Enables a pointer drag behavior on the bounding box of the gizmo
  38558. */
  38559. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38560. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38561. this._dragMesh.visibility = 0;
  38562. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38563. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38564. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38565. };
  38566. /**
  38567. * Disposes of the gizmo
  38568. */
  38569. BoundingBoxGizmo.prototype.dispose = function () {
  38570. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38571. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38572. this._lineBoundingBox.dispose();
  38573. this._rotateSpheresParent.dispose();
  38574. this._scaleBoxesParent.dispose();
  38575. if (this._dragMesh) {
  38576. this._dragMesh.dispose();
  38577. }
  38578. _super.prototype.dispose.call(this);
  38579. };
  38580. /**
  38581. * 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)
  38582. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38583. * @returns the bounding box mesh with the passed in mesh as a child
  38584. */
  38585. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38586. var makeNotPickable = function (root) {
  38587. root.isPickable = false;
  38588. root.getChildMeshes().forEach(function (c) {
  38589. makeNotPickable(c);
  38590. });
  38591. };
  38592. makeNotPickable(mesh);
  38593. // Reset position to get boudning box from origin with no rotation
  38594. if (!mesh.rotationQuaternion) {
  38595. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38596. }
  38597. var oldPos = mesh.position.clone();
  38598. var oldRot = mesh.rotationQuaternion.clone();
  38599. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38600. mesh.position.set(0, 0, 0);
  38601. // Update bounding dimensions/positions
  38602. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38603. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38604. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38605. // Adjust scale to avoid undefined behavior when adding child
  38606. if (box.scaling.y === 0) {
  38607. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38608. }
  38609. if (box.scaling.x === 0) {
  38610. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38611. }
  38612. if (box.scaling.z === 0) {
  38613. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38614. }
  38615. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38616. // Restore original positions
  38617. mesh.addChild(box);
  38618. mesh.rotationQuaternion.copyFrom(oldRot);
  38619. mesh.position.copyFrom(oldPos);
  38620. // Reverse parenting
  38621. mesh.removeChild(box);
  38622. box.addChild(mesh);
  38623. box.visibility = 0;
  38624. return box;
  38625. };
  38626. /**
  38627. * CustomMeshes are not supported by this gizmo
  38628. * @param mesh The mesh to replace the default mesh of the gizmo
  38629. */
  38630. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38631. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38632. };
  38633. return BoundingBoxGizmo;
  38634. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  38635. /***/ }),
  38636. /***/ "./Gizmos/gizmo.ts":
  38637. /*!*************************!*\
  38638. !*** ./Gizmos/gizmo.ts ***!
  38639. \*************************/
  38640. /*! exports provided: Gizmo */
  38641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38642. "use strict";
  38643. __webpack_require__.r(__webpack_exports__);
  38644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  38645. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38646. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38647. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38648. /**
  38649. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38650. */
  38651. var Gizmo = /** @class */ (function () {
  38652. /**
  38653. * Creates a gizmo
  38654. * @param gizmoLayer The utility layer the gizmo will be added to
  38655. */
  38656. function Gizmo(
  38657. /** The utility layer the gizmo will be added to */
  38658. gizmoLayer) {
  38659. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38660. var _this = this;
  38661. this.gizmoLayer = gizmoLayer;
  38662. /**
  38663. * Ratio for the scale of the gizmo (Default: 1)
  38664. */
  38665. this.scaleRatio = 1;
  38666. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  38667. /**
  38668. * If a custom mesh has been set (Default: false)
  38669. */
  38670. this._customMeshSet = false;
  38671. /**
  38672. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38673. */
  38674. this.updateGizmoRotationToMatchAttachedMesh = true;
  38675. /**
  38676. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38677. */
  38678. this.updateGizmoPositionToMatchAttachedMesh = true;
  38679. /**
  38680. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38681. */
  38682. this._updateScale = true;
  38683. this._interactionsEnabled = true;
  38684. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  38685. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  38686. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  38687. _this._update();
  38688. });
  38689. this.attachedMesh = null;
  38690. }
  38691. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  38692. /**
  38693. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38694. * * When set, interactions will be enabled
  38695. */
  38696. get: function () {
  38697. return this._attachedMesh;
  38698. },
  38699. set: function (value) {
  38700. this._attachedMesh = value;
  38701. this._rootMesh.setEnabled(value ? true : false);
  38702. this._attachedMeshChanged(value);
  38703. },
  38704. enumerable: true,
  38705. configurable: true
  38706. });
  38707. /**
  38708. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38709. * @param mesh The mesh to replace the default mesh of the gizmo
  38710. */
  38711. Gizmo.prototype.setCustomMesh = function (mesh) {
  38712. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  38713. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  38714. }
  38715. this._rootMesh.getChildMeshes().forEach(function (c) {
  38716. c.dispose();
  38717. });
  38718. mesh.parent = this._rootMesh;
  38719. this._customMeshSet = true;
  38720. };
  38721. Gizmo.prototype._attachedMeshChanged = function (value) {
  38722. };
  38723. /**
  38724. * @hidden
  38725. * Updates the gizmo to match the attached mesh's position/rotation
  38726. */
  38727. Gizmo.prototype._update = function () {
  38728. if (this.attachedMesh) {
  38729. if (this.updateGizmoRotationToMatchAttachedMesh) {
  38730. if (!this._rootMesh.rotationQuaternion) {
  38731. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38732. }
  38733. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38734. this._tempVector.copyFrom(this.attachedMesh.scaling);
  38735. if (this.attachedMesh.scaling.x < 0) {
  38736. this.attachedMesh.scaling.x *= -1;
  38737. }
  38738. if (this.attachedMesh.scaling.y < 0) {
  38739. this.attachedMesh.scaling.y *= -1;
  38740. }
  38741. if (this.attachedMesh.scaling.z < 0) {
  38742. this.attachedMesh.scaling.z *= -1;
  38743. }
  38744. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38745. this.attachedMesh.scaling.copyFrom(this._tempVector);
  38746. this.attachedMesh.computeWorldMatrix();
  38747. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38748. }
  38749. else if (this._rootMesh.rotationQuaternion) {
  38750. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38751. }
  38752. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38753. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  38754. }
  38755. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38756. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38757. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38758. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38759. }
  38760. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38761. var dist = this._tempVector.length() * this.scaleRatio;
  38762. this._rootMesh.scaling.set(dist, dist, dist);
  38763. }
  38764. }
  38765. };
  38766. /**
  38767. * Disposes of the gizmo
  38768. */
  38769. Gizmo.prototype.dispose = function () {
  38770. this._rootMesh.dispose();
  38771. if (this._beforeRenderObserver) {
  38772. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38773. }
  38774. };
  38775. return Gizmo;
  38776. }());
  38777. /***/ }),
  38778. /***/ "./Gizmos/gizmoManager.ts":
  38779. /*!********************************!*\
  38780. !*** ./Gizmos/gizmoManager.ts ***!
  38781. \********************************/
  38782. /*! exports provided: GizmoManager */
  38783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38784. "use strict";
  38785. __webpack_require__.r(__webpack_exports__);
  38786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  38787. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38788. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38789. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38790. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38791. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38792. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38793. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38794. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38795. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38796. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38797. /**
  38798. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  38799. */
  38800. var GizmoManager = /** @class */ (function () {
  38801. /**
  38802. * Instatiates a gizmo manager
  38803. * @param scene the scene to overlay the gizmos on top of
  38804. */
  38805. function GizmoManager(scene) {
  38806. var _this = this;
  38807. this.scene = scene;
  38808. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  38809. this.clearGizmoOnEmptyPointerEvent = false;
  38810. /** Fires an event when the manager is attached to a mesh */
  38811. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  38812. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  38813. this._pointerObserver = null;
  38814. this._attachedMesh = null;
  38815. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  38816. /**
  38817. * When bounding box gizmo is enabled, this can be used to track drag/end events
  38818. */
  38819. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  38820. /**
  38821. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  38822. */
  38823. this.attachableMeshes = null;
  38824. /**
  38825. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  38826. */
  38827. this.usePointerToAttachGizmos = true;
  38828. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38829. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  38830. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38831. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  38832. // Instatiate/dispose gizmos based on pointer actions
  38833. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  38834. if (!_this.usePointerToAttachGizmos) {
  38835. return;
  38836. }
  38837. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  38838. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  38839. var node = pointerInfo.pickInfo.pickedMesh;
  38840. if (_this.attachableMeshes == null) {
  38841. // Attach to the most parent node
  38842. while (node && node.parent != null) {
  38843. node = node.parent;
  38844. }
  38845. }
  38846. else {
  38847. // Attach to the parent node that is an attachableMesh
  38848. var found = false;
  38849. _this.attachableMeshes.forEach(function (mesh) {
  38850. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  38851. node = mesh;
  38852. found = true;
  38853. }
  38854. });
  38855. if (!found) {
  38856. node = null;
  38857. }
  38858. }
  38859. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  38860. if (_this._attachedMesh != node) {
  38861. _this.attachToMesh(node);
  38862. }
  38863. }
  38864. else {
  38865. if (_this.clearGizmoOnEmptyPointerEvent) {
  38866. _this.attachToMesh(null);
  38867. }
  38868. }
  38869. }
  38870. else {
  38871. if (_this.clearGizmoOnEmptyPointerEvent) {
  38872. _this.attachToMesh(null);
  38873. }
  38874. }
  38875. }
  38876. });
  38877. }
  38878. /**
  38879. * Attaches a set of gizmos to the specified mesh
  38880. * @param mesh The mesh the gizmo's should be attached to
  38881. */
  38882. GizmoManager.prototype.attachToMesh = function (mesh) {
  38883. if (this._attachedMesh) {
  38884. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38885. }
  38886. this._attachedMesh = mesh;
  38887. for (var key in this.gizmos) {
  38888. var gizmo = (this.gizmos[key]);
  38889. if (gizmo && this._gizmosEnabled[key]) {
  38890. gizmo.attachedMesh = mesh;
  38891. }
  38892. }
  38893. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  38894. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38895. }
  38896. this.onAttachedToMeshObservable.notifyObservers(mesh);
  38897. };
  38898. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  38899. get: function () {
  38900. return this._gizmosEnabled.positionGizmo;
  38901. },
  38902. /**
  38903. * If the position gizmo is enabled
  38904. */
  38905. set: function (value) {
  38906. if (value) {
  38907. if (!this.gizmos.positionGizmo) {
  38908. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  38909. }
  38910. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  38911. }
  38912. else if (this.gizmos.positionGizmo) {
  38913. this.gizmos.positionGizmo.attachedMesh = null;
  38914. }
  38915. this._gizmosEnabled.positionGizmo = value;
  38916. },
  38917. enumerable: true,
  38918. configurable: true
  38919. });
  38920. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  38921. get: function () {
  38922. return this._gizmosEnabled.rotationGizmo;
  38923. },
  38924. /**
  38925. * If the rotation gizmo is enabled
  38926. */
  38927. set: function (value) {
  38928. if (value) {
  38929. if (!this.gizmos.rotationGizmo) {
  38930. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  38931. }
  38932. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  38933. }
  38934. else if (this.gizmos.rotationGizmo) {
  38935. this.gizmos.rotationGizmo.attachedMesh = null;
  38936. }
  38937. this._gizmosEnabled.rotationGizmo = value;
  38938. },
  38939. enumerable: true,
  38940. configurable: true
  38941. });
  38942. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  38943. get: function () {
  38944. return this._gizmosEnabled.scaleGizmo;
  38945. },
  38946. /**
  38947. * If the scale gizmo is enabled
  38948. */
  38949. set: function (value) {
  38950. if (value) {
  38951. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  38952. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  38953. }
  38954. else if (this.gizmos.scaleGizmo) {
  38955. this.gizmos.scaleGizmo.attachedMesh = null;
  38956. }
  38957. this._gizmosEnabled.scaleGizmo = value;
  38958. },
  38959. enumerable: true,
  38960. configurable: true
  38961. });
  38962. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  38963. get: function () {
  38964. return this._gizmosEnabled.boundingBoxGizmo;
  38965. },
  38966. /**
  38967. * If the boundingBox gizmo is enabled
  38968. */
  38969. set: function (value) {
  38970. if (value) {
  38971. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  38972. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  38973. if (this._attachedMesh) {
  38974. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38975. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38976. }
  38977. }
  38978. else if (this.gizmos.boundingBoxGizmo) {
  38979. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  38980. }
  38981. this._gizmosEnabled.boundingBoxGizmo = value;
  38982. },
  38983. enumerable: true,
  38984. configurable: true
  38985. });
  38986. /**
  38987. * Disposes of the gizmo manager
  38988. */
  38989. GizmoManager.prototype.dispose = function () {
  38990. this.scene.onPointerObservable.remove(this._pointerObserver);
  38991. for (var key in this.gizmos) {
  38992. var gizmo = (this.gizmos[key]);
  38993. if (gizmo) {
  38994. gizmo.dispose();
  38995. }
  38996. }
  38997. this._defaultKeepDepthUtilityLayer.dispose();
  38998. this._defaultUtilityLayer.dispose();
  38999. this.boundingBoxDragBehavior.detach();
  39000. this.onAttachedToMeshObservable.clear();
  39001. };
  39002. return GizmoManager;
  39003. }());
  39004. /***/ }),
  39005. /***/ "./Gizmos/index.ts":
  39006. /*!*************************!*\
  39007. !*** ./Gizmos/index.ts ***!
  39008. \*************************/
  39009. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  39010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39011. "use strict";
  39012. __webpack_require__.r(__webpack_exports__);
  39013. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  39015. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  39017. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  39019. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  39021. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  39022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  39023. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  39025. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  39027. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  39029. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  39031. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  39032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  39033. /***/ }),
  39034. /***/ "./Gizmos/lightGizmo.ts":
  39035. /*!******************************!*\
  39036. !*** ./Gizmos/lightGizmo.ts ***!
  39037. \******************************/
  39038. /*! exports provided: LightGizmo */
  39039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39040. "use strict";
  39041. __webpack_require__.r(__webpack_exports__);
  39042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  39043. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39044. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39045. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39046. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39047. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39048. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39049. /**
  39050. * Gizmo that enables viewing a light
  39051. */
  39052. var LightGizmo = /** @class */ (function (_super) {
  39053. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  39054. /**
  39055. * Creates a LightGizmo
  39056. * @param gizmoLayer The utility layer the gizmo will be added to
  39057. */
  39058. function LightGizmo(gizmoLayer) {
  39059. var _this = _super.call(this, gizmoLayer) || this;
  39060. _this._light = null;
  39061. _this._box = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("light", 0.02, 0, 0.02, 16, 1, _this.gizmoLayer.utilityLayerScene);
  39062. _this._box.rotation.x = -Math.PI / 2;
  39063. _this._box.bakeCurrentTransformIntoVertices();
  39064. _this._box.material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", _this.gizmoLayer.utilityLayerScene);
  39065. _this._box.material.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Yellow();
  39066. _this._rootMesh.addChild(_this._box);
  39067. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  39068. return _this;
  39069. }
  39070. Object.defineProperty(LightGizmo.prototype, "light", {
  39071. get: function () {
  39072. return this._light;
  39073. },
  39074. /**
  39075. * The light that the gizmo is attached to
  39076. */
  39077. set: function (light) {
  39078. this._light = light;
  39079. if (light.position) {
  39080. this.attachedMesh.position.copyFrom(light.position);
  39081. }
  39082. if (light.direction) {
  39083. this._box.setDirection(light.direction);
  39084. }
  39085. },
  39086. enumerable: true,
  39087. configurable: true
  39088. });
  39089. /**
  39090. * @hidden
  39091. * Updates the gizmo to match the attached mesh's position/rotation
  39092. */
  39093. LightGizmo.prototype._update = function () {
  39094. _super.prototype._update.call(this);
  39095. if (!this._light) {
  39096. return;
  39097. }
  39098. if (this._light.position) {
  39099. this._light.position.copyFrom(this.attachedMesh.position);
  39100. }
  39101. if (this._light.direction) {
  39102. this._light.direction.copyFrom(this._box.forward);
  39103. }
  39104. if (!this._light.isEnabled()) {
  39105. this._box.material.emissiveColor.set(0, 0, 0);
  39106. }
  39107. else {
  39108. this._box.material.emissiveColor.set(1, 1, 1);
  39109. }
  39110. };
  39111. return LightGizmo;
  39112. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39113. /***/ }),
  39114. /***/ "./Gizmos/planeRotationGizmo.ts":
  39115. /*!**************************************!*\
  39116. !*** ./Gizmos/planeRotationGizmo.ts ***!
  39117. \**************************************/
  39118. /*! exports provided: PlaneRotationGizmo */
  39119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39120. "use strict";
  39121. __webpack_require__.r(__webpack_exports__);
  39122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  39123. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39124. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39125. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39126. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39127. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39128. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  39129. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39130. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39131. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39132. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  39133. /**
  39134. * Single plane rotation gizmo
  39135. */
  39136. var PlaneRotationGizmo = /** @class */ (function (_super) {
  39137. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  39138. /**
  39139. * Creates a PlaneRotationGizmo
  39140. * @param gizmoLayer The utility layer the gizmo will be added to
  39141. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  39142. * @param color The color of the gizmo
  39143. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39144. */
  39145. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  39146. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  39147. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39148. if (tessellation === void 0) { tessellation = 32; }
  39149. var _this = _super.call(this, gizmoLayer) || this;
  39150. _this._pointerObserver = null;
  39151. /**
  39152. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  39153. */
  39154. _this.snapDistance = 0;
  39155. /**
  39156. * Event that fires each time the gizmo snaps to a new location.
  39157. * * snapDistance is the the change in distance
  39158. */
  39159. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39160. // Create Material
  39161. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39162. coloredMaterial.disableLighting = true;
  39163. coloredMaterial.emissiveColor = color;
  39164. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39165. hoverMaterial.disableLighting = true;
  39166. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  39167. // Build mesh on root node
  39168. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  39169. // Create circle out of lines
  39170. var radius = 0.8;
  39171. var points = new Array();
  39172. for (var i = 0; i < tessellation; i++) {
  39173. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  39174. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  39175. }
  39176. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  39177. rotationMesh.color = coloredMaterial.emissiveColor;
  39178. // Position arrow pointing in its drag axis
  39179. rotationMesh.scaling.scaleInPlace(0.26);
  39180. rotationMesh.material = coloredMaterial;
  39181. rotationMesh.rotation.x = Math.PI / 2;
  39182. parentMesh.addChild(rotationMesh);
  39183. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  39184. _this._rootMesh.addChild(parentMesh);
  39185. parentMesh.scaling.scaleInPlace(1 / 3);
  39186. // Add drag behavior to handle events when the gizmo is dragged
  39187. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  39188. _this.dragBehavior.moveAttached = false;
  39189. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  39190. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  39191. _this._rootMesh.addBehavior(_this.dragBehavior);
  39192. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39193. _this.dragBehavior.onDragStartObservable.add(function (e) {
  39194. if (_this.attachedMesh) {
  39195. lastDragPosition.copyFrom(e.dragPlanePoint);
  39196. }
  39197. });
  39198. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39199. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39200. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39201. var tmpSnapEvent = { snapDistance: 0 };
  39202. var currentSnapDragDistance = 0;
  39203. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39204. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39205. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  39206. _this.dragBehavior.onDragObservable.add(function (event) {
  39207. if (_this.attachedMesh) {
  39208. if (!_this.attachedMesh.rotationQuaternion) {
  39209. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  39210. }
  39211. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  39212. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  39213. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  39214. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  39215. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  39216. var angle = Math.atan2(cross.length(), dot);
  39217. planeNormalTowardsCamera.copyFrom(planeNormal);
  39218. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  39219. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39220. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  39221. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  39222. }
  39223. // Flip up vector depending on which side the camera is on
  39224. if (gizmoLayer.utilityLayerScene.activeCamera) {
  39225. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  39226. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  39227. planeNormalTowardsCamera.scaleInPlace(-1);
  39228. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  39229. }
  39230. }
  39231. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  39232. if (halfCircleSide) {
  39233. angle = -angle;
  39234. }
  39235. // Snapping logic
  39236. var snapped = false;
  39237. if (_this.snapDistance != 0) {
  39238. currentSnapDragDistance += angle;
  39239. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  39240. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  39241. if (currentSnapDragDistance < 0) {
  39242. dragSteps *= -1;
  39243. }
  39244. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  39245. angle = _this.snapDistance * dragSteps;
  39246. snapped = true;
  39247. }
  39248. else {
  39249. angle = 0;
  39250. }
  39251. }
  39252. // If the mesh has a parent, convert needed world rotation to local rotation
  39253. tmpMatrix.reset();
  39254. if (_this.attachedMesh.parent) {
  39255. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  39256. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  39257. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  39258. }
  39259. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  39260. var quaternionCoefficient = Math.sin(angle / 2);
  39261. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  39262. // 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
  39263. if (tmpMatrix.determinant() > 0) {
  39264. amountToRotate.toEulerAnglesToRef(tmpVector);
  39265. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  39266. }
  39267. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39268. // Rotate selected mesh quaternion over fixed axis
  39269. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  39270. }
  39271. else {
  39272. // Rotate selected mesh quaternion over rotated axis
  39273. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  39274. }
  39275. lastDragPosition.copyFrom(event.dragPlanePoint);
  39276. if (snapped) {
  39277. tmpSnapEvent.snapDistance = angle;
  39278. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  39279. }
  39280. }
  39281. });
  39282. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  39283. if (_this._customMeshSet) {
  39284. return;
  39285. }
  39286. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  39287. var material = isHovered ? hoverMaterial : coloredMaterial;
  39288. _this._rootMesh.getChildMeshes().forEach(function (m) {
  39289. m.material = material;
  39290. if (m.color) {
  39291. m.color = material.emissiveColor;
  39292. }
  39293. });
  39294. });
  39295. return _this;
  39296. }
  39297. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  39298. if (this.dragBehavior) {
  39299. this.dragBehavior.enabled = value ? true : false;
  39300. }
  39301. };
  39302. /**
  39303. * Disposes of the gizmo
  39304. */
  39305. PlaneRotationGizmo.prototype.dispose = function () {
  39306. this.onSnapObservable.clear();
  39307. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  39308. this.dragBehavior.detach();
  39309. _super.prototype.dispose.call(this);
  39310. };
  39311. return PlaneRotationGizmo;
  39312. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  39313. /***/ }),
  39314. /***/ "./Gizmos/positionGizmo.ts":
  39315. /*!*********************************!*\
  39316. !*** ./Gizmos/positionGizmo.ts ***!
  39317. \*********************************/
  39318. /*! exports provided: PositionGizmo */
  39319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39320. "use strict";
  39321. __webpack_require__.r(__webpack_exports__);
  39322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  39323. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39324. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39325. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39326. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39327. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39328. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39329. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39330. /**
  39331. * Gizmo that enables dragging a mesh along 3 axis
  39332. */
  39333. var PositionGizmo = /** @class */ (function (_super) {
  39334. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  39335. /**
  39336. * Creates a PositionGizmo
  39337. * @param gizmoLayer The utility layer the gizmo will be added to
  39338. */
  39339. function PositionGizmo(gizmoLayer) {
  39340. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39341. var _this = _super.call(this, gizmoLayer) || this;
  39342. /** Fires an event when any of it's sub gizmos are dragged */
  39343. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39344. /** Fires an event when any of it's sub gizmos are released from dragging */
  39345. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39346. _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);
  39347. _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);
  39348. _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);
  39349. // Relay drag events
  39350. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39351. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39352. _this.onDragStartObservable.notifyObservers({});
  39353. });
  39354. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39355. _this.onDragEndObservable.notifyObservers({});
  39356. });
  39357. });
  39358. _this.attachedMesh = null;
  39359. return _this;
  39360. }
  39361. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  39362. set: function (mesh) {
  39363. if (this.xGizmo) {
  39364. this.xGizmo.attachedMesh = mesh;
  39365. this.yGizmo.attachedMesh = mesh;
  39366. this.zGizmo.attachedMesh = mesh;
  39367. }
  39368. },
  39369. enumerable: true,
  39370. configurable: true
  39371. });
  39372. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39373. get: function () {
  39374. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39375. },
  39376. set: function (value) {
  39377. if (this.xGizmo) {
  39378. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39379. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39380. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39381. }
  39382. },
  39383. enumerable: true,
  39384. configurable: true
  39385. });
  39386. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  39387. get: function () {
  39388. return this.xGizmo.snapDistance;
  39389. },
  39390. /**
  39391. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39392. */
  39393. set: function (value) {
  39394. if (this.xGizmo) {
  39395. this.xGizmo.snapDistance = value;
  39396. this.yGizmo.snapDistance = value;
  39397. this.zGizmo.snapDistance = value;
  39398. }
  39399. },
  39400. enumerable: true,
  39401. configurable: true
  39402. });
  39403. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  39404. get: function () {
  39405. return this.xGizmo.scaleRatio;
  39406. },
  39407. /**
  39408. * Ratio for the scale of the gizmo (Default: 1)
  39409. */
  39410. set: function (value) {
  39411. if (this.xGizmo) {
  39412. this.xGizmo.scaleRatio = value;
  39413. this.yGizmo.scaleRatio = value;
  39414. this.zGizmo.scaleRatio = value;
  39415. }
  39416. },
  39417. enumerable: true,
  39418. configurable: true
  39419. });
  39420. /**
  39421. * Disposes of the gizmo
  39422. */
  39423. PositionGizmo.prototype.dispose = function () {
  39424. this.xGizmo.dispose();
  39425. this.yGizmo.dispose();
  39426. this.zGizmo.dispose();
  39427. this.onDragStartObservable.clear();
  39428. this.onDragEndObservable.clear();
  39429. };
  39430. /**
  39431. * CustomMeshes are not supported by this gizmo
  39432. * @param mesh The mesh to replace the default mesh of the gizmo
  39433. */
  39434. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  39435. _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)");
  39436. };
  39437. return PositionGizmo;
  39438. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39439. /***/ }),
  39440. /***/ "./Gizmos/rotationGizmo.ts":
  39441. /*!*********************************!*\
  39442. !*** ./Gizmos/rotationGizmo.ts ***!
  39443. \*********************************/
  39444. /*! exports provided: RotationGizmo */
  39445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39446. "use strict";
  39447. __webpack_require__.r(__webpack_exports__);
  39448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  39449. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39450. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39451. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39452. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39453. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39454. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39455. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39456. /**
  39457. * Gizmo that enables rotating a mesh along 3 axis
  39458. */
  39459. var RotationGizmo = /** @class */ (function (_super) {
  39460. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  39461. /**
  39462. * Creates a RotationGizmo
  39463. * @param gizmoLayer The utility layer the gizmo will be added to
  39464. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39465. */
  39466. function RotationGizmo(gizmoLayer, tessellation) {
  39467. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39468. if (tessellation === void 0) { tessellation = 32; }
  39469. var _this = _super.call(this, gizmoLayer) || this;
  39470. /** Fires an event when any of it's sub gizmos are dragged */
  39471. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39472. /** Fires an event when any of it's sub gizmos are released from dragging */
  39473. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39474. _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);
  39475. _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);
  39476. _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);
  39477. // Relay drag events
  39478. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39479. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39480. _this.onDragStartObservable.notifyObservers({});
  39481. });
  39482. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39483. _this.onDragEndObservable.notifyObservers({});
  39484. });
  39485. });
  39486. _this.attachedMesh = null;
  39487. return _this;
  39488. }
  39489. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  39490. set: function (mesh) {
  39491. if (this.xGizmo) {
  39492. this.xGizmo.attachedMesh = mesh;
  39493. this.yGizmo.attachedMesh = mesh;
  39494. this.zGizmo.attachedMesh = mesh;
  39495. }
  39496. },
  39497. enumerable: true,
  39498. configurable: true
  39499. });
  39500. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39501. get: function () {
  39502. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39503. },
  39504. set: function (value) {
  39505. if (this.xGizmo) {
  39506. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39507. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39508. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39509. }
  39510. },
  39511. enumerable: true,
  39512. configurable: true
  39513. });
  39514. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  39515. get: function () {
  39516. return this.xGizmo.snapDistance;
  39517. },
  39518. /**
  39519. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39520. */
  39521. set: function (value) {
  39522. if (this.xGizmo) {
  39523. this.xGizmo.snapDistance = value;
  39524. this.yGizmo.snapDistance = value;
  39525. this.zGizmo.snapDistance = value;
  39526. }
  39527. },
  39528. enumerable: true,
  39529. configurable: true
  39530. });
  39531. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  39532. get: function () {
  39533. return this.xGizmo.scaleRatio;
  39534. },
  39535. /**
  39536. * Ratio for the scale of the gizmo (Default: 1)
  39537. */
  39538. set: function (value) {
  39539. if (this.xGizmo) {
  39540. this.xGizmo.scaleRatio = value;
  39541. this.yGizmo.scaleRatio = value;
  39542. this.zGizmo.scaleRatio = value;
  39543. }
  39544. },
  39545. enumerable: true,
  39546. configurable: true
  39547. });
  39548. /**
  39549. * Disposes of the gizmo
  39550. */
  39551. RotationGizmo.prototype.dispose = function () {
  39552. this.xGizmo.dispose();
  39553. this.yGizmo.dispose();
  39554. this.zGizmo.dispose();
  39555. this.onDragStartObservable.clear();
  39556. this.onDragEndObservable.clear();
  39557. };
  39558. /**
  39559. * CustomMeshes are not supported by this gizmo
  39560. * @param mesh The mesh to replace the default mesh of the gizmo
  39561. */
  39562. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  39563. _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)");
  39564. };
  39565. return RotationGizmo;
  39566. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39567. /***/ }),
  39568. /***/ "./Gizmos/scaleGizmo.ts":
  39569. /*!******************************!*\
  39570. !*** ./Gizmos/scaleGizmo.ts ***!
  39571. \******************************/
  39572. /*! exports provided: ScaleGizmo */
  39573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39574. "use strict";
  39575. __webpack_require__.r(__webpack_exports__);
  39576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  39577. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39578. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39579. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39580. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39581. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  39582. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39583. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39584. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39585. /**
  39586. * Gizmo that enables scaling a mesh along 3 axis
  39587. */
  39588. var ScaleGizmo = /** @class */ (function (_super) {
  39589. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  39590. /**
  39591. * Creates a ScaleGizmo
  39592. * @param gizmoLayer The utility layer the gizmo will be added to
  39593. */
  39594. function ScaleGizmo(gizmoLayer) {
  39595. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39596. var _this = _super.call(this, gizmoLayer) || this;
  39597. /** Fires an event when any of it's sub gizmos are dragged */
  39598. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39599. /** Fires an event when any of it's sub gizmos are released from dragging */
  39600. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39601. _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);
  39602. _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);
  39603. _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);
  39604. // Create uniform scale gizmo
  39605. _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);
  39606. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  39607. _this.uniformScaleGizmo.uniformScaling = true;
  39608. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39609. uniformScalingMesh.scaling.scaleInPlace(0.02);
  39610. uniformScalingMesh.visibility = 0;
  39611. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39612. octahedron.scaling.scaleInPlace(0.007);
  39613. uniformScalingMesh.addChild(octahedron);
  39614. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  39615. // Relay drag events
  39616. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  39617. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39618. _this.onDragStartObservable.notifyObservers({});
  39619. });
  39620. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39621. _this.onDragEndObservable.notifyObservers({});
  39622. });
  39623. });
  39624. _this.attachedMesh = null;
  39625. return _this;
  39626. }
  39627. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  39628. set: function (mesh) {
  39629. if (this.xGizmo) {
  39630. this.xGizmo.attachedMesh = mesh;
  39631. this.yGizmo.attachedMesh = mesh;
  39632. this.zGizmo.attachedMesh = mesh;
  39633. this.uniformScaleGizmo.attachedMesh = mesh;
  39634. }
  39635. },
  39636. enumerable: true,
  39637. configurable: true
  39638. });
  39639. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39640. get: function () {
  39641. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39642. },
  39643. set: function (value) {
  39644. if (!value) {
  39645. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  39646. }
  39647. if (this.xGizmo) {
  39648. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39649. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39650. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39651. }
  39652. },
  39653. enumerable: true,
  39654. configurable: true
  39655. });
  39656. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  39657. get: function () {
  39658. return this.xGizmo.snapDistance;
  39659. },
  39660. /**
  39661. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39662. */
  39663. set: function (value) {
  39664. if (this.xGizmo) {
  39665. this.xGizmo.snapDistance = value;
  39666. this.yGizmo.snapDistance = value;
  39667. this.zGizmo.snapDistance = value;
  39668. this.uniformScaleGizmo.snapDistance = value;
  39669. }
  39670. },
  39671. enumerable: true,
  39672. configurable: true
  39673. });
  39674. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  39675. get: function () {
  39676. return this.xGizmo.scaleRatio;
  39677. },
  39678. /**
  39679. * Ratio for the scale of the gizmo (Default: 1)
  39680. */
  39681. set: function (value) {
  39682. if (this.xGizmo) {
  39683. this.xGizmo.scaleRatio = value;
  39684. this.yGizmo.scaleRatio = value;
  39685. this.zGizmo.scaleRatio = value;
  39686. this.uniformScaleGizmo.scaleRatio = value;
  39687. }
  39688. },
  39689. enumerable: true,
  39690. configurable: true
  39691. });
  39692. /**
  39693. * Disposes of the gizmo
  39694. */
  39695. ScaleGizmo.prototype.dispose = function () {
  39696. this.xGizmo.dispose();
  39697. this.yGizmo.dispose();
  39698. this.zGizmo.dispose();
  39699. this.uniformScaleGizmo.dispose();
  39700. this.onDragStartObservable.clear();
  39701. this.onDragEndObservable.clear();
  39702. };
  39703. return ScaleGizmo;
  39704. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  39705. /***/ }),
  39706. /***/ "./Helpers/environmentHelper.ts":
  39707. /*!**************************************!*\
  39708. !*** ./Helpers/environmentHelper.ts ***!
  39709. \**************************************/
  39710. /*! exports provided: EnvironmentHelper */
  39711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39712. "use strict";
  39713. __webpack_require__.r(__webpack_exports__);
  39714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  39715. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39716. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39717. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39718. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39719. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39720. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  39721. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39722. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  39723. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  39724. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39725. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39726. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  39727. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39728. /**
  39729. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  39730. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  39731. * It also helps with the default setup of your imageProcessing configuration.
  39732. */
  39733. var EnvironmentHelper = /** @class */ (function () {
  39734. /**
  39735. * constructor
  39736. * @param options Defines the options we want to customize the helper
  39737. * @param scene The scene to add the material to
  39738. */
  39739. function EnvironmentHelper(options, scene) {
  39740. var _this = this;
  39741. this._errorHandler = function (message, exception) {
  39742. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  39743. };
  39744. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  39745. this._scene = scene;
  39746. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39747. this._setupBackground();
  39748. this._setupImageProcessing();
  39749. }
  39750. /**
  39751. * Creates the default options for the helper.
  39752. */
  39753. EnvironmentHelper._getDefaultOptions = function () {
  39754. return {
  39755. createGround: true,
  39756. groundSize: 15,
  39757. groundTexture: this._groundTextureCDNUrl,
  39758. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39759. groundOpacity: 0.9,
  39760. enableGroundShadow: true,
  39761. groundShadowLevel: 0.5,
  39762. enableGroundMirror: false,
  39763. groundMirrorSizeRatio: 0.3,
  39764. groundMirrorBlurKernel: 64,
  39765. groundMirrorAmount: 1,
  39766. groundMirrorFresnelWeight: 1,
  39767. groundMirrorFallOffDistance: 0,
  39768. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  39769. groundYBias: 0.00001,
  39770. createSkybox: true,
  39771. skyboxSize: 20,
  39772. skyboxTexture: this._skyboxTextureCDNUrl,
  39773. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39774. backgroundYRotation: 0,
  39775. sizeAuto: true,
  39776. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  39777. setupImageProcessing: true,
  39778. environmentTexture: this._environmentTextureCDNUrl,
  39779. cameraExposure: 0.8,
  39780. cameraContrast: 1.2,
  39781. toneMappingEnabled: true,
  39782. };
  39783. };
  39784. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  39785. /**
  39786. * Gets the root mesh created by the helper.
  39787. */
  39788. get: function () {
  39789. return this._rootMesh;
  39790. },
  39791. enumerable: true,
  39792. configurable: true
  39793. });
  39794. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  39795. /**
  39796. * Gets the skybox created by the helper.
  39797. */
  39798. get: function () {
  39799. return this._skybox;
  39800. },
  39801. enumerable: true,
  39802. configurable: true
  39803. });
  39804. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  39805. /**
  39806. * Gets the skybox texture created by the helper.
  39807. */
  39808. get: function () {
  39809. return this._skyboxTexture;
  39810. },
  39811. enumerable: true,
  39812. configurable: true
  39813. });
  39814. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  39815. /**
  39816. * Gets the skybox material created by the helper.
  39817. */
  39818. get: function () {
  39819. return this._skyboxMaterial;
  39820. },
  39821. enumerable: true,
  39822. configurable: true
  39823. });
  39824. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  39825. /**
  39826. * Gets the ground mesh created by the helper.
  39827. */
  39828. get: function () {
  39829. return this._ground;
  39830. },
  39831. enumerable: true,
  39832. configurable: true
  39833. });
  39834. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  39835. /**
  39836. * Gets the ground texture created by the helper.
  39837. */
  39838. get: function () {
  39839. return this._groundTexture;
  39840. },
  39841. enumerable: true,
  39842. configurable: true
  39843. });
  39844. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  39845. /**
  39846. * Gets the ground mirror created by the helper.
  39847. */
  39848. get: function () {
  39849. return this._groundMirror;
  39850. },
  39851. enumerable: true,
  39852. configurable: true
  39853. });
  39854. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  39855. /**
  39856. * Gets the ground mirror render list to helps pushing the meshes
  39857. * you wish in the ground reflection.
  39858. */
  39859. get: function () {
  39860. if (this._groundMirror) {
  39861. return this._groundMirror.renderList;
  39862. }
  39863. return null;
  39864. },
  39865. enumerable: true,
  39866. configurable: true
  39867. });
  39868. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  39869. /**
  39870. * Gets the ground material created by the helper.
  39871. */
  39872. get: function () {
  39873. return this._groundMaterial;
  39874. },
  39875. enumerable: true,
  39876. configurable: true
  39877. });
  39878. /**
  39879. * Updates the background according to the new options
  39880. * @param options
  39881. */
  39882. EnvironmentHelper.prototype.updateOptions = function (options) {
  39883. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  39884. if (this._ground && !newOptions.createGround) {
  39885. this._ground.dispose();
  39886. this._ground = null;
  39887. }
  39888. if (this._groundMaterial && !newOptions.createGround) {
  39889. this._groundMaterial.dispose();
  39890. this._groundMaterial = null;
  39891. }
  39892. if (this._groundTexture) {
  39893. if (this._options.groundTexture != newOptions.groundTexture) {
  39894. this._groundTexture.dispose();
  39895. this._groundTexture = null;
  39896. }
  39897. }
  39898. if (this._skybox && !newOptions.createSkybox) {
  39899. this._skybox.dispose();
  39900. this._skybox = null;
  39901. }
  39902. if (this._skyboxMaterial && !newOptions.createSkybox) {
  39903. this._skyboxMaterial.dispose();
  39904. this._skyboxMaterial = null;
  39905. }
  39906. if (this._skyboxTexture) {
  39907. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  39908. this._skyboxTexture.dispose();
  39909. this._skyboxTexture = null;
  39910. }
  39911. }
  39912. if (this._groundMirror && !newOptions.enableGroundMirror) {
  39913. this._groundMirror.dispose();
  39914. this._groundMirror = null;
  39915. }
  39916. if (this._scene.environmentTexture) {
  39917. if (this._options.environmentTexture != newOptions.environmentTexture) {
  39918. this._scene.environmentTexture.dispose();
  39919. }
  39920. }
  39921. this._options = newOptions;
  39922. this._setupBackground();
  39923. this._setupImageProcessing();
  39924. };
  39925. /**
  39926. * Sets the primary color of all the available elements.
  39927. * @param color the main color to affect to the ground and the background
  39928. */
  39929. EnvironmentHelper.prototype.setMainColor = function (color) {
  39930. if (this.groundMaterial) {
  39931. this.groundMaterial.primaryColor = color;
  39932. }
  39933. if (this.skyboxMaterial) {
  39934. this.skyboxMaterial.primaryColor = color;
  39935. }
  39936. if (this.groundMirror) {
  39937. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  39938. }
  39939. };
  39940. /**
  39941. * Setup the image processing according to the specified options.
  39942. */
  39943. EnvironmentHelper.prototype._setupImageProcessing = function () {
  39944. if (this._options.setupImageProcessing) {
  39945. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  39946. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  39947. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  39948. this._setupEnvironmentTexture();
  39949. }
  39950. };
  39951. /**
  39952. * Setup the environment texture according to the specified options.
  39953. */
  39954. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  39955. if (this._scene.environmentTexture) {
  39956. return;
  39957. }
  39958. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39959. this._scene.environmentTexture = this._options.environmentTexture;
  39960. return;
  39961. }
  39962. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  39963. this._scene.environmentTexture = environmentTexture;
  39964. };
  39965. /**
  39966. * Setup the background according to the specified options.
  39967. */
  39968. EnvironmentHelper.prototype._setupBackground = function () {
  39969. if (!this._rootMesh) {
  39970. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  39971. }
  39972. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  39973. var sceneSize = this._getSceneSize();
  39974. if (this._options.createGround) {
  39975. this._setupGround(sceneSize);
  39976. this._setupGroundMaterial();
  39977. this._setupGroundDiffuseTexture();
  39978. if (this._options.enableGroundMirror) {
  39979. this._setupGroundMirrorTexture(sceneSize);
  39980. }
  39981. this._setupMirrorInGroundMaterial();
  39982. }
  39983. if (this._options.createSkybox) {
  39984. this._setupSkybox(sceneSize);
  39985. this._setupSkyboxMaterial();
  39986. this._setupSkyboxReflectionTexture();
  39987. }
  39988. this._rootMesh.position.x = sceneSize.rootPosition.x;
  39989. this._rootMesh.position.z = sceneSize.rootPosition.z;
  39990. this._rootMesh.position.y = sceneSize.rootPosition.y;
  39991. };
  39992. /**
  39993. * Get the scene sizes according to the setup.
  39994. */
  39995. EnvironmentHelper.prototype._getSceneSize = function () {
  39996. var _this = this;
  39997. var groundSize = this._options.groundSize;
  39998. var skyboxSize = this._options.skyboxSize;
  39999. var rootPosition = this._options.rootPosition;
  40000. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  40001. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40002. }
  40003. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  40004. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  40005. });
  40006. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  40007. if (this._options.sizeAuto) {
  40008. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  40009. this._scene.activeCamera.upperRadiusLimit) {
  40010. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  40011. skyboxSize = groundSize;
  40012. }
  40013. var sceneDiagonalLenght = sceneDiagonal.length();
  40014. if (sceneDiagonalLenght > groundSize) {
  40015. groundSize = sceneDiagonalLenght * 2;
  40016. skyboxSize = groundSize;
  40017. }
  40018. // 10 % bigger.
  40019. groundSize *= 1.1;
  40020. skyboxSize *= 1.5;
  40021. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  40022. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  40023. }
  40024. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40025. };
  40026. /**
  40027. * Setup the ground according to the specified options.
  40028. */
  40029. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  40030. var _this = this;
  40031. if (!this._ground || this._ground.isDisposed()) {
  40032. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  40033. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  40034. this._ground.parent = this._rootMesh;
  40035. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  40036. }
  40037. this._ground.receiveShadows = this._options.enableGroundShadow;
  40038. };
  40039. /**
  40040. * Setup the ground material according to the specified options.
  40041. */
  40042. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  40043. if (!this._groundMaterial) {
  40044. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  40045. }
  40046. this._groundMaterial.alpha = this._options.groundOpacity;
  40047. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  40048. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  40049. this._groundMaterial.primaryColor = this._options.groundColor;
  40050. this._groundMaterial.useRGBColor = false;
  40051. this._groundMaterial.enableNoise = true;
  40052. if (this._ground) {
  40053. this._ground.material = this._groundMaterial;
  40054. }
  40055. };
  40056. /**
  40057. * Setup the ground diffuse texture according to the specified options.
  40058. */
  40059. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  40060. if (!this._groundMaterial) {
  40061. return;
  40062. }
  40063. if (this._groundTexture) {
  40064. return;
  40065. }
  40066. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40067. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  40068. return;
  40069. }
  40070. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40071. diffuseTexture.gammaSpace = false;
  40072. diffuseTexture.hasAlpha = true;
  40073. this._groundMaterial.diffuseTexture = diffuseTexture;
  40074. };
  40075. /**
  40076. * Setup the ground mirror texture according to the specified options.
  40077. */
  40078. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  40079. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  40080. if (!this._groundMirror) {
  40081. 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);
  40082. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  40083. this._groundMirror.anisotropicFilteringLevel = 1;
  40084. this._groundMirror.wrapU = wrapping;
  40085. this._groundMirror.wrapV = wrapping;
  40086. this._groundMirror.gammaSpace = false;
  40087. if (this._groundMirror.renderList) {
  40088. for (var i = 0; i < this._scene.meshes.length; i++) {
  40089. var mesh = this._scene.meshes[i];
  40090. if (mesh !== this._ground &&
  40091. mesh !== this._skybox &&
  40092. mesh !== this._rootMesh) {
  40093. this._groundMirror.renderList.push(mesh);
  40094. }
  40095. }
  40096. }
  40097. }
  40098. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  40099. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  40100. };
  40101. /**
  40102. * Setup the ground to receive the mirror texture.
  40103. */
  40104. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  40105. if (this._groundMaterial) {
  40106. this._groundMaterial.reflectionTexture = this._groundMirror;
  40107. this._groundMaterial.reflectionFresnel = true;
  40108. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  40109. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  40110. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  40111. }
  40112. };
  40113. /**
  40114. * Setup the skybox according to the specified options.
  40115. */
  40116. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  40117. var _this = this;
  40118. if (!this._skybox || this._skybox.isDisposed()) {
  40119. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  40120. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  40121. }
  40122. this._skybox.parent = this._rootMesh;
  40123. };
  40124. /**
  40125. * Setup the skybox material according to the specified options.
  40126. */
  40127. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  40128. if (!this._skybox) {
  40129. return;
  40130. }
  40131. if (!this._skyboxMaterial) {
  40132. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  40133. }
  40134. this._skyboxMaterial.useRGBColor = false;
  40135. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  40136. this._skyboxMaterial.enableNoise = true;
  40137. this._skybox.material = this._skyboxMaterial;
  40138. };
  40139. /**
  40140. * Setup the skybox reflection texture according to the specified options.
  40141. */
  40142. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  40143. if (!this._skyboxMaterial) {
  40144. return;
  40145. }
  40146. if (this._skyboxTexture) {
  40147. return;
  40148. }
  40149. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40150. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  40151. return;
  40152. }
  40153. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40154. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  40155. this._skyboxTexture.gammaSpace = false;
  40156. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  40157. };
  40158. /**
  40159. * Dispose all the elements created by the Helper.
  40160. */
  40161. EnvironmentHelper.prototype.dispose = function () {
  40162. if (this._groundMaterial) {
  40163. this._groundMaterial.dispose(true, true);
  40164. }
  40165. if (this._skyboxMaterial) {
  40166. this._skyboxMaterial.dispose(true, true);
  40167. }
  40168. this._rootMesh.dispose(false);
  40169. };
  40170. /**
  40171. * Default ground texture URL.
  40172. */
  40173. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  40174. /**
  40175. * Default skybox texture URL.
  40176. */
  40177. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  40178. /**
  40179. * Default environment texture URL.
  40180. */
  40181. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  40182. return EnvironmentHelper;
  40183. }());
  40184. /***/ }),
  40185. /***/ "./Helpers/index.ts":
  40186. /*!**************************!*\
  40187. !*** ./Helpers/index.ts ***!
  40188. \**************************/
  40189. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  40190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40191. "use strict";
  40192. __webpack_require__.r(__webpack_exports__);
  40193. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  40195. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  40196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  40197. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  40198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  40199. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  40200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  40201. /***/ }),
  40202. /***/ "./Helpers/photoDome.ts":
  40203. /*!******************************!*\
  40204. !*** ./Helpers/photoDome.ts ***!
  40205. \******************************/
  40206. /*! exports provided: PhotoDome */
  40207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40208. "use strict";
  40209. __webpack_require__.r(__webpack_exports__);
  40210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  40211. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40212. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40213. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40214. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40215. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40216. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40217. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40218. /**
  40219. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  40220. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  40221. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  40222. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40223. */
  40224. var PhotoDome = /** @class */ (function (_super) {
  40225. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  40226. /**
  40227. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  40228. * @param name Element's name, child elements will append suffixes for their own names.
  40229. * @param urlsOfPhoto defines the url of the photo to display
  40230. * @param options defines an object containing optional or exposed sub element properties
  40231. * @param onError defines a callback called when an error occured while loading the texture
  40232. */
  40233. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  40234. if (onError === void 0) { onError = null; }
  40235. var _this = _super.call(this, name, scene) || this;
  40236. _this._useDirectMapping = false;
  40237. /**
  40238. * Observable raised when an error occured while loading the 360 image
  40239. */
  40240. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40241. // set defaults and manage values
  40242. name = name || "photoDome";
  40243. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40244. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40245. if (options.useDirectMapping === undefined) {
  40246. _this._useDirectMapping = true;
  40247. }
  40248. else {
  40249. _this._useDirectMapping = options.useDirectMapping;
  40250. }
  40251. _this._setReady(false);
  40252. // create
  40253. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40254. _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);
  40255. // configure material
  40256. material.opacityFresnel = false;
  40257. material.useEquirectangularFOV = true;
  40258. material.fovMultiplier = 1.0;
  40259. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  40260. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  40261. if (onError) {
  40262. onError(message, exception);
  40263. }
  40264. });
  40265. _this.photoTexture.onLoadObservable.addOnce(function () {
  40266. _this._setReady(true);
  40267. });
  40268. // configure mesh
  40269. _this._mesh.material = material;
  40270. _this._mesh.parent = _this;
  40271. return _this;
  40272. }
  40273. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  40274. /**
  40275. * Gets or sets the texture being displayed on the sphere
  40276. */
  40277. get: function () {
  40278. return this._photoTexture;
  40279. },
  40280. set: function (value) {
  40281. if (this._photoTexture === value) {
  40282. return;
  40283. }
  40284. this._photoTexture = value;
  40285. if (this._useDirectMapping) {
  40286. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40287. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40288. this._material.diffuseTexture = this._photoTexture;
  40289. }
  40290. else {
  40291. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40292. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40293. this._material.reflectionTexture = this._photoTexture;
  40294. }
  40295. },
  40296. enumerable: true,
  40297. configurable: true
  40298. });
  40299. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  40300. /**
  40301. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40302. * Also see the options.resolution property.
  40303. */
  40304. get: function () {
  40305. return this._material.fovMultiplier;
  40306. },
  40307. set: function (value) {
  40308. this._material.fovMultiplier = value;
  40309. },
  40310. enumerable: true,
  40311. configurable: true
  40312. });
  40313. /**
  40314. * Releases resources associated with this node.
  40315. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40316. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40317. */
  40318. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40319. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40320. this._photoTexture.dispose();
  40321. this._mesh.dispose();
  40322. this._material.dispose();
  40323. this.onLoadErrorObservable.clear();
  40324. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40325. };
  40326. return PhotoDome;
  40327. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  40328. /***/ }),
  40329. /***/ "./Helpers/sceneHelpers.ts":
  40330. /*!*********************************!*\
  40331. !*** ./Helpers/sceneHelpers.ts ***!
  40332. \*********************************/
  40333. /*! exports provided: _forceSceneHelpersToBundle */
  40334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40335. "use strict";
  40336. __webpack_require__.r(__webpack_exports__);
  40337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  40338. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40339. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  40340. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40341. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40342. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40343. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40344. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  40345. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  40346. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40347. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  40348. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40349. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  40350. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  40351. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  40352. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  40353. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  40354. /* harmony import */ var _Materials_Textures_Loaders_ddsTextureLoader__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  40355. /* harmony import */ var _Materials_Textures_Loaders_envTextureLoader__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/Loaders/envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  40356. /* harmony import */ var _Materials_Textures_Loaders_ktxTextureLoader__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  40357. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40358. /** @hidden */
  40359. var _forceSceneHelpersToBundle = true;
  40360. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  40361. if (replace === void 0) { replace = false; }
  40362. // Dispose existing light in replace mode.
  40363. if (replace) {
  40364. if (this.lights) {
  40365. for (var i = 0; i < this.lights.length; i++) {
  40366. this.lights[i].dispose();
  40367. }
  40368. }
  40369. }
  40370. // Light
  40371. if (this.lights.length === 0) {
  40372. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  40373. }
  40374. };
  40375. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  40376. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40377. if (replace === void 0) { replace = false; }
  40378. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40379. // Dispose existing camera in replace mode.
  40380. if (replace) {
  40381. if (this.activeCamera) {
  40382. this.activeCamera.dispose();
  40383. this.activeCamera = null;
  40384. }
  40385. }
  40386. // Camera
  40387. if (!this.activeCamera) {
  40388. var worldExtends = this.getWorldExtends();
  40389. var worldSize = worldExtends.max.subtract(worldExtends.min);
  40390. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  40391. var camera;
  40392. var radius = worldSize.length() * 1.5;
  40393. // empty scene scenario!
  40394. if (!isFinite(radius)) {
  40395. radius = 1;
  40396. worldCenter.copyFromFloats(0, 0, 0);
  40397. }
  40398. if (createArcRotateCamera) {
  40399. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  40400. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  40401. arcRotateCamera.wheelPrecision = 100 / radius;
  40402. camera = arcRotateCamera;
  40403. }
  40404. else {
  40405. 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);
  40406. freeCamera.setTarget(worldCenter);
  40407. camera = freeCamera;
  40408. }
  40409. camera.minZ = radius * 0.01;
  40410. camera.maxZ = radius * 1000;
  40411. camera.speed = radius * 0.2;
  40412. this.activeCamera = camera;
  40413. var canvas = this.getEngine().getRenderingCanvas();
  40414. if (attachCameraControls && canvas) {
  40415. camera.attachControl(canvas);
  40416. }
  40417. }
  40418. };
  40419. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  40420. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40421. if (replace === void 0) { replace = false; }
  40422. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40423. this.createDefaultLight(replace);
  40424. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  40425. };
  40426. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  40427. if (pbr === void 0) { pbr = false; }
  40428. if (scale === void 0) { scale = 1000; }
  40429. if (blur === void 0) { blur = 0; }
  40430. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  40431. if (!environmentTexture) {
  40432. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  40433. return null;
  40434. }
  40435. if (setGlobalEnvTexture) {
  40436. if (environmentTexture) {
  40437. this.environmentTexture = environmentTexture;
  40438. }
  40439. }
  40440. // Skybox
  40441. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  40442. if (pbr) {
  40443. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  40444. hdrSkyboxMaterial.backFaceCulling = false;
  40445. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  40446. if (hdrSkyboxMaterial.reflectionTexture) {
  40447. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40448. }
  40449. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  40450. hdrSkyboxMaterial.disableLighting = true;
  40451. hdrSkyboxMaterial.twoSidedLighting = true;
  40452. hdrSkybox.infiniteDistance = true;
  40453. hdrSkybox.material = hdrSkyboxMaterial;
  40454. }
  40455. else {
  40456. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  40457. skyboxMaterial.backFaceCulling = false;
  40458. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  40459. if (skyboxMaterial.reflectionTexture) {
  40460. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40461. }
  40462. skyboxMaterial.disableLighting = true;
  40463. hdrSkybox.infiniteDistance = true;
  40464. hdrSkybox.material = skyboxMaterial;
  40465. }
  40466. hdrSkybox.isPickable = false;
  40467. return hdrSkybox;
  40468. };
  40469. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  40470. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  40471. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  40472. }
  40473. return null;
  40474. };
  40475. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  40476. if (webVROptions === void 0) { webVROptions = {}; }
  40477. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  40478. };
  40479. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  40480. var _this = this;
  40481. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  40482. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  40483. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  40484. .then(function (ui) {
  40485. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  40486. return helper;
  40487. });
  40488. });
  40489. };
  40490. /***/ }),
  40491. /***/ "./Helpers/videoDome.ts":
  40492. /*!******************************!*\
  40493. !*** ./Helpers/videoDome.ts ***!
  40494. \******************************/
  40495. /*! exports provided: VideoDome */
  40496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40497. "use strict";
  40498. __webpack_require__.r(__webpack_exports__);
  40499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  40500. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40501. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40502. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40503. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40504. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  40505. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40506. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40507. /**
  40508. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  40509. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  40510. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  40511. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40512. */
  40513. var VideoDome = /** @class */ (function (_super) {
  40514. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  40515. /**
  40516. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  40517. * @param name Element's name, child elements will append suffixes for their own names.
  40518. * @param urlsOrVideo defines the url(s) or the video element to use
  40519. * @param options An object containing optional or exposed sub element properties
  40520. */
  40521. function VideoDome(name, urlsOrVideo, options, scene) {
  40522. var _this = _super.call(this, name, scene) || this;
  40523. _this._useDirectMapping = false;
  40524. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  40525. /**
  40526. * Oberserver used in Stereoscopic VR Mode.
  40527. */
  40528. _this._onBeforeCameraRenderObserver = null;
  40529. // set defaults and manage values
  40530. name = name || "videoDome";
  40531. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40532. options.clickToPlay = Boolean(options.clickToPlay);
  40533. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  40534. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  40535. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40536. if (options.useDirectMapping === undefined) {
  40537. _this._useDirectMapping = true;
  40538. }
  40539. else {
  40540. _this._useDirectMapping = options.useDirectMapping;
  40541. }
  40542. _this._setReady(false);
  40543. // create
  40544. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  40545. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40546. 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);
  40547. _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);
  40548. texture.onLoadObservable.addOnce(function () {
  40549. _this._setReady(true);
  40550. });
  40551. // configure material
  40552. material.useEquirectangularFOV = true;
  40553. material.fovMultiplier = 1.0;
  40554. material.opacityFresnel = false;
  40555. if (_this._useDirectMapping) {
  40556. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40557. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40558. material.diffuseTexture = texture;
  40559. }
  40560. else {
  40561. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40562. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40563. material.reflectionTexture = texture;
  40564. }
  40565. // configure mesh
  40566. _this._mesh.material = material;
  40567. _this._mesh.parent = _this;
  40568. // optional configuration
  40569. if (options.clickToPlay) {
  40570. scene.onPointerUp = function () {
  40571. _this._videoTexture.video.play();
  40572. };
  40573. }
  40574. return _this;
  40575. }
  40576. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  40577. /**
  40578. * Gets the video texture being displayed on the sphere
  40579. */
  40580. get: function () {
  40581. return this._videoTexture;
  40582. },
  40583. enumerable: true,
  40584. configurable: true
  40585. });
  40586. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  40587. /**
  40588. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40589. * Also see the options.resolution property.
  40590. */
  40591. get: function () {
  40592. return this._material.fovMultiplier;
  40593. },
  40594. set: function (value) {
  40595. this._material.fovMultiplier = value;
  40596. },
  40597. enumerable: true,
  40598. configurable: true
  40599. });
  40600. Object.defineProperty(VideoDome.prototype, "videoMode", {
  40601. /**
  40602. * Gets or set the current video mode for the video. It can be:
  40603. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  40604. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  40605. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  40606. */
  40607. get: function () {
  40608. return this._videoMode;
  40609. },
  40610. set: function (value) {
  40611. if (this._videoMode === value) {
  40612. return;
  40613. }
  40614. this._changeVideoMode(value);
  40615. },
  40616. enumerable: true,
  40617. configurable: true
  40618. });
  40619. VideoDome.prototype._changeVideoMode = function (value) {
  40620. var _this = this;
  40621. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40622. this._videoMode = value;
  40623. // Default Setup and Reset.
  40624. this._videoTexture.uScale = 1;
  40625. this._videoTexture.vScale = 1;
  40626. this._videoTexture.uOffset = 0;
  40627. this._videoTexture.vOffset = 0;
  40628. switch (value) {
  40629. case VideoDome.MODE_SIDEBYSIDE:
  40630. this._videoTexture.uScale = 0.5;
  40631. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  40632. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  40633. });
  40634. break;
  40635. case VideoDome.MODE_TOPBOTTOM:
  40636. this._videoTexture.vScale = 0.5;
  40637. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  40638. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  40639. });
  40640. break;
  40641. }
  40642. };
  40643. /**
  40644. * Releases resources associated with this node.
  40645. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40646. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40647. */
  40648. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40649. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40650. this._videoTexture.dispose();
  40651. this._mesh.dispose();
  40652. this._material.dispose();
  40653. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40654. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40655. };
  40656. /**
  40657. * Define the video source as a Monoscopic panoramic 360 video.
  40658. */
  40659. VideoDome.MODE_MONOSCOPIC = 0;
  40660. /**
  40661. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  40662. */
  40663. VideoDome.MODE_TOPBOTTOM = 1;
  40664. /**
  40665. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  40666. */
  40667. VideoDome.MODE_SIDEBYSIDE = 2;
  40668. return VideoDome;
  40669. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  40670. /***/ }),
  40671. /***/ "./Instrumentation/engineInstrumentation.ts":
  40672. /*!**************************************************!*\
  40673. !*** ./Instrumentation/engineInstrumentation.ts ***!
  40674. \**************************************************/
  40675. /*! exports provided: EngineInstrumentation */
  40676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40677. "use strict";
  40678. __webpack_require__.r(__webpack_exports__);
  40679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  40680. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40681. /**
  40682. * This class can be used to get instrumentation data from a Babylon engine
  40683. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40684. */
  40685. var EngineInstrumentation = /** @class */ (function () {
  40686. /**
  40687. * Instantiates a new engine instrumentation.
  40688. * This class can be used to get instrumentation data from a Babylon engine
  40689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40690. * @param engine Defines the engine to instrument
  40691. */
  40692. function EngineInstrumentation(
  40693. /**
  40694. * Define the instrumented engine.
  40695. */
  40696. engine) {
  40697. this.engine = engine;
  40698. this._captureGPUFrameTime = false;
  40699. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40700. this._captureShaderCompilationTime = false;
  40701. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40702. // Observers
  40703. this._onBeginFrameObserver = null;
  40704. this._onEndFrameObserver = null;
  40705. this._onBeforeShaderCompilationObserver = null;
  40706. this._onAfterShaderCompilationObserver = null;
  40707. }
  40708. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  40709. // Properties
  40710. /**
  40711. * Gets the perf counter used for GPU frame time
  40712. */
  40713. get: function () {
  40714. return this._gpuFrameTime;
  40715. },
  40716. enumerable: true,
  40717. configurable: true
  40718. });
  40719. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  40720. /**
  40721. * Gets the GPU frame time capture status
  40722. */
  40723. get: function () {
  40724. return this._captureGPUFrameTime;
  40725. },
  40726. /**
  40727. * Enable or disable the GPU frame time capture
  40728. */
  40729. set: function (value) {
  40730. var _this = this;
  40731. if (value === this._captureGPUFrameTime) {
  40732. return;
  40733. }
  40734. this._captureGPUFrameTime = value;
  40735. if (value) {
  40736. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  40737. if (!_this._gpuFrameTimeToken) {
  40738. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  40739. }
  40740. });
  40741. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  40742. if (!_this._gpuFrameTimeToken) {
  40743. return;
  40744. }
  40745. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  40746. if (time > -1) {
  40747. _this._gpuFrameTimeToken = null;
  40748. _this._gpuFrameTime.fetchNewFrame();
  40749. _this._gpuFrameTime.addCount(time, true);
  40750. }
  40751. });
  40752. }
  40753. else {
  40754. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40755. this._onBeginFrameObserver = null;
  40756. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40757. this._onEndFrameObserver = null;
  40758. }
  40759. },
  40760. enumerable: true,
  40761. configurable: true
  40762. });
  40763. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  40764. /**
  40765. * Gets the perf counter used for shader compilation time
  40766. */
  40767. get: function () {
  40768. return this._shaderCompilationTime;
  40769. },
  40770. enumerable: true,
  40771. configurable: true
  40772. });
  40773. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  40774. /**
  40775. * Gets the shader compilation time capture status
  40776. */
  40777. get: function () {
  40778. return this._captureShaderCompilationTime;
  40779. },
  40780. /**
  40781. * Enable or disable the shader compilation time capture
  40782. */
  40783. set: function (value) {
  40784. var _this = this;
  40785. if (value === this._captureShaderCompilationTime) {
  40786. return;
  40787. }
  40788. this._captureShaderCompilationTime = value;
  40789. if (value) {
  40790. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  40791. _this._shaderCompilationTime.fetchNewFrame();
  40792. _this._shaderCompilationTime.beginMonitoring();
  40793. });
  40794. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  40795. _this._shaderCompilationTime.endMonitoring();
  40796. });
  40797. }
  40798. else {
  40799. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40800. this._onBeforeShaderCompilationObserver = null;
  40801. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40802. this._onAfterShaderCompilationObserver = null;
  40803. }
  40804. },
  40805. enumerable: true,
  40806. configurable: true
  40807. });
  40808. /**
  40809. * Dispose and release associated resources.
  40810. */
  40811. EngineInstrumentation.prototype.dispose = function () {
  40812. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40813. this._onBeginFrameObserver = null;
  40814. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40815. this._onEndFrameObserver = null;
  40816. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40817. this._onBeforeShaderCompilationObserver = null;
  40818. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40819. this._onAfterShaderCompilationObserver = null;
  40820. this.engine = null;
  40821. };
  40822. return EngineInstrumentation;
  40823. }());
  40824. /***/ }),
  40825. /***/ "./Instrumentation/index.ts":
  40826. /*!**********************************!*\
  40827. !*** ./Instrumentation/index.ts ***!
  40828. \**********************************/
  40829. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  40830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40831. "use strict";
  40832. __webpack_require__.r(__webpack_exports__);
  40833. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  40834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  40835. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  40836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  40837. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  40838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  40839. /***/ }),
  40840. /***/ "./Instrumentation/sceneInstrumentation.ts":
  40841. /*!*************************************************!*\
  40842. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  40843. \*************************************************/
  40844. /*! exports provided: SceneInstrumentation */
  40845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40846. "use strict";
  40847. __webpack_require__.r(__webpack_exports__);
  40848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  40849. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40850. /**
  40851. * This class can be used to get instrumentation data from a Babylon engine
  40852. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40853. */
  40854. var SceneInstrumentation = /** @class */ (function () {
  40855. /**
  40856. * Instantiates a new scene instrumentation.
  40857. * This class can be used to get instrumentation data from a Babylon engine
  40858. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40859. * @param scene Defines the scene to instrument
  40860. */
  40861. function SceneInstrumentation(
  40862. /**
  40863. * Defines the scene to instrument
  40864. */
  40865. scene) {
  40866. var _this = this;
  40867. this.scene = scene;
  40868. this._captureActiveMeshesEvaluationTime = false;
  40869. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40870. this._captureRenderTargetsRenderTime = false;
  40871. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40872. this._captureFrameTime = false;
  40873. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40874. this._captureRenderTime = false;
  40875. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40876. this._captureInterFrameTime = false;
  40877. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40878. this._captureParticlesRenderTime = false;
  40879. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40880. this._captureSpritesRenderTime = false;
  40881. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40882. this._capturePhysicsTime = false;
  40883. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40884. this._captureAnimationsTime = false;
  40885. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40886. this._captureCameraRenderTime = false;
  40887. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40888. // Observers
  40889. this._onBeforeActiveMeshesEvaluationObserver = null;
  40890. this._onAfterActiveMeshesEvaluationObserver = null;
  40891. this._onBeforeRenderTargetsRenderObserver = null;
  40892. this._onAfterRenderTargetsRenderObserver = null;
  40893. this._onAfterRenderObserver = null;
  40894. this._onBeforeDrawPhaseObserver = null;
  40895. this._onAfterDrawPhaseObserver = null;
  40896. this._onBeforeAnimationsObserver = null;
  40897. this._onBeforeParticlesRenderingObserver = null;
  40898. this._onAfterParticlesRenderingObserver = null;
  40899. this._onBeforeSpritesRenderingObserver = null;
  40900. this._onAfterSpritesRenderingObserver = null;
  40901. this._onBeforePhysicsObserver = null;
  40902. this._onAfterPhysicsObserver = null;
  40903. this._onAfterAnimationsObserver = null;
  40904. this._onBeforeCameraRenderObserver = null;
  40905. this._onAfterCameraRenderObserver = null;
  40906. // Before render
  40907. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  40908. if (_this._captureActiveMeshesEvaluationTime) {
  40909. _this._activeMeshesEvaluationTime.fetchNewFrame();
  40910. }
  40911. if (_this._captureRenderTargetsRenderTime) {
  40912. _this._renderTargetsRenderTime.fetchNewFrame();
  40913. }
  40914. if (_this._captureFrameTime) {
  40915. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  40916. _this._frameTime.beginMonitoring();
  40917. }
  40918. if (_this._captureInterFrameTime) {
  40919. _this._interFrameTime.endMonitoring();
  40920. }
  40921. if (_this._captureParticlesRenderTime) {
  40922. _this._particlesRenderTime.fetchNewFrame();
  40923. }
  40924. if (_this._captureSpritesRenderTime) {
  40925. _this._spritesRenderTime.fetchNewFrame();
  40926. }
  40927. if (_this._captureAnimationsTime) {
  40928. _this._animationsTime.beginMonitoring();
  40929. }
  40930. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  40931. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  40932. });
  40933. // After render
  40934. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  40935. if (_this._captureFrameTime) {
  40936. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  40937. _this._frameTime.endMonitoring();
  40938. }
  40939. if (_this._captureRenderTime) {
  40940. _this._renderTime.endMonitoring(false);
  40941. }
  40942. if (_this._captureInterFrameTime) {
  40943. _this._interFrameTime.beginMonitoring();
  40944. }
  40945. });
  40946. }
  40947. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  40948. // Properties
  40949. /**
  40950. * Gets the perf counter used for active meshes evaluation time
  40951. */
  40952. get: function () {
  40953. return this._activeMeshesEvaluationTime;
  40954. },
  40955. enumerable: true,
  40956. configurable: true
  40957. });
  40958. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  40959. /**
  40960. * Gets the active meshes evaluation time capture status
  40961. */
  40962. get: function () {
  40963. return this._captureActiveMeshesEvaluationTime;
  40964. },
  40965. /**
  40966. * Enable or disable the active meshes evaluation time capture
  40967. */
  40968. set: function (value) {
  40969. var _this = this;
  40970. if (value === this._captureActiveMeshesEvaluationTime) {
  40971. return;
  40972. }
  40973. this._captureActiveMeshesEvaluationTime = value;
  40974. if (value) {
  40975. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  40976. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  40977. _this._activeMeshesEvaluationTime.beginMonitoring();
  40978. });
  40979. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  40980. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  40981. _this._activeMeshesEvaluationTime.endMonitoring();
  40982. });
  40983. }
  40984. else {
  40985. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40986. this._onBeforeActiveMeshesEvaluationObserver = null;
  40987. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40988. this._onAfterActiveMeshesEvaluationObserver = null;
  40989. }
  40990. },
  40991. enumerable: true,
  40992. configurable: true
  40993. });
  40994. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  40995. /**
  40996. * Gets the perf counter used for render targets render time
  40997. */
  40998. get: function () {
  40999. return this._renderTargetsRenderTime;
  41000. },
  41001. enumerable: true,
  41002. configurable: true
  41003. });
  41004. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  41005. /**
  41006. * Gets the render targets render time capture status
  41007. */
  41008. get: function () {
  41009. return this._captureRenderTargetsRenderTime;
  41010. },
  41011. /**
  41012. * Enable or disable the render targets render time capture
  41013. */
  41014. set: function (value) {
  41015. var _this = this;
  41016. if (value === this._captureRenderTargetsRenderTime) {
  41017. return;
  41018. }
  41019. this._captureRenderTargetsRenderTime = value;
  41020. if (value) {
  41021. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  41022. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  41023. _this._renderTargetsRenderTime.beginMonitoring();
  41024. });
  41025. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  41026. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  41027. _this._renderTargetsRenderTime.endMonitoring(false);
  41028. });
  41029. }
  41030. else {
  41031. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41032. this._onBeforeRenderTargetsRenderObserver = null;
  41033. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41034. this._onAfterRenderTargetsRenderObserver = null;
  41035. }
  41036. },
  41037. enumerable: true,
  41038. configurable: true
  41039. });
  41040. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  41041. /**
  41042. * Gets the perf counter used for particles render time
  41043. */
  41044. get: function () {
  41045. return this._particlesRenderTime;
  41046. },
  41047. enumerable: true,
  41048. configurable: true
  41049. });
  41050. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  41051. /**
  41052. * Gets the particles render time capture status
  41053. */
  41054. get: function () {
  41055. return this._captureParticlesRenderTime;
  41056. },
  41057. /**
  41058. * Enable or disable the particles render time capture
  41059. */
  41060. set: function (value) {
  41061. var _this = this;
  41062. if (value === this._captureParticlesRenderTime) {
  41063. return;
  41064. }
  41065. this._captureParticlesRenderTime = value;
  41066. if (value) {
  41067. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  41068. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  41069. _this._particlesRenderTime.beginMonitoring();
  41070. });
  41071. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  41072. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  41073. _this._particlesRenderTime.endMonitoring(false);
  41074. });
  41075. }
  41076. else {
  41077. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41078. this._onBeforeParticlesRenderingObserver = null;
  41079. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41080. this._onAfterParticlesRenderingObserver = null;
  41081. }
  41082. },
  41083. enumerable: true,
  41084. configurable: true
  41085. });
  41086. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  41087. /**
  41088. * Gets the perf counter used for sprites render time
  41089. */
  41090. get: function () {
  41091. return this._spritesRenderTime;
  41092. },
  41093. enumerable: true,
  41094. configurable: true
  41095. });
  41096. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  41097. /**
  41098. * Gets the sprites render time capture status
  41099. */
  41100. get: function () {
  41101. return this._captureSpritesRenderTime;
  41102. },
  41103. /**
  41104. * Enable or disable the sprites render time capture
  41105. */
  41106. set: function (value) {
  41107. var _this = this;
  41108. if (value === this._captureSpritesRenderTime) {
  41109. return;
  41110. }
  41111. this._captureSpritesRenderTime = value;
  41112. if (!this.scene.spriteManagers) {
  41113. return;
  41114. }
  41115. if (value) {
  41116. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  41117. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  41118. _this._spritesRenderTime.beginMonitoring();
  41119. });
  41120. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  41121. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  41122. _this._spritesRenderTime.endMonitoring(false);
  41123. });
  41124. }
  41125. else {
  41126. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41127. this._onBeforeSpritesRenderingObserver = null;
  41128. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41129. this._onAfterSpritesRenderingObserver = null;
  41130. }
  41131. },
  41132. enumerable: true,
  41133. configurable: true
  41134. });
  41135. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  41136. /**
  41137. * Gets the perf counter used for physics time
  41138. */
  41139. get: function () {
  41140. return this._physicsTime;
  41141. },
  41142. enumerable: true,
  41143. configurable: true
  41144. });
  41145. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  41146. /**
  41147. * Gets the physics time capture status
  41148. */
  41149. get: function () {
  41150. return this._capturePhysicsTime;
  41151. },
  41152. /**
  41153. * Enable or disable the physics time capture
  41154. */
  41155. set: function (value) {
  41156. var _this = this;
  41157. if (value === this._capturePhysicsTime) {
  41158. return;
  41159. }
  41160. if (!this.scene.onBeforePhysicsObservable) {
  41161. return;
  41162. }
  41163. this._capturePhysicsTime = value;
  41164. if (value) {
  41165. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  41166. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  41167. _this._physicsTime.beginMonitoring();
  41168. });
  41169. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  41170. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  41171. _this._physicsTime.endMonitoring();
  41172. });
  41173. }
  41174. else {
  41175. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41176. this._onBeforePhysicsObserver = null;
  41177. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41178. this._onAfterPhysicsObserver = null;
  41179. }
  41180. },
  41181. enumerable: true,
  41182. configurable: true
  41183. });
  41184. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  41185. /**
  41186. * Gets the perf counter used for animations time
  41187. */
  41188. get: function () {
  41189. return this._animationsTime;
  41190. },
  41191. enumerable: true,
  41192. configurable: true
  41193. });
  41194. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  41195. /**
  41196. * Gets the animations time capture status
  41197. */
  41198. get: function () {
  41199. return this._captureAnimationsTime;
  41200. },
  41201. /**
  41202. * Enable or disable the animations time capture
  41203. */
  41204. set: function (value) {
  41205. var _this = this;
  41206. if (value === this._captureAnimationsTime) {
  41207. return;
  41208. }
  41209. this._captureAnimationsTime = value;
  41210. if (value) {
  41211. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  41212. _this._animationsTime.endMonitoring();
  41213. });
  41214. }
  41215. else {
  41216. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41217. this._onAfterAnimationsObserver = null;
  41218. }
  41219. },
  41220. enumerable: true,
  41221. configurable: true
  41222. });
  41223. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  41224. /**
  41225. * Gets the perf counter used for frame time capture
  41226. */
  41227. get: function () {
  41228. return this._frameTime;
  41229. },
  41230. enumerable: true,
  41231. configurable: true
  41232. });
  41233. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  41234. /**
  41235. * Gets the frame time capture status
  41236. */
  41237. get: function () {
  41238. return this._captureFrameTime;
  41239. },
  41240. /**
  41241. * Enable or disable the frame time capture
  41242. */
  41243. set: function (value) {
  41244. this._captureFrameTime = value;
  41245. },
  41246. enumerable: true,
  41247. configurable: true
  41248. });
  41249. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  41250. /**
  41251. * Gets the perf counter used for inter-frames time capture
  41252. */
  41253. get: function () {
  41254. return this._interFrameTime;
  41255. },
  41256. enumerable: true,
  41257. configurable: true
  41258. });
  41259. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  41260. /**
  41261. * Gets the inter-frames time capture status
  41262. */
  41263. get: function () {
  41264. return this._captureInterFrameTime;
  41265. },
  41266. /**
  41267. * Enable or disable the inter-frames time capture
  41268. */
  41269. set: function (value) {
  41270. this._captureInterFrameTime = value;
  41271. },
  41272. enumerable: true,
  41273. configurable: true
  41274. });
  41275. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  41276. /**
  41277. * Gets the perf counter used for render time capture
  41278. */
  41279. get: function () {
  41280. return this._renderTime;
  41281. },
  41282. enumerable: true,
  41283. configurable: true
  41284. });
  41285. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  41286. /**
  41287. * Gets the render time capture status
  41288. */
  41289. get: function () {
  41290. return this._captureRenderTime;
  41291. },
  41292. /**
  41293. * Enable or disable the render time capture
  41294. */
  41295. set: function (value) {
  41296. var _this = this;
  41297. if (value === this._captureRenderTime) {
  41298. return;
  41299. }
  41300. this._captureRenderTime = value;
  41301. if (value) {
  41302. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  41303. _this._renderTime.beginMonitoring();
  41304. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  41305. });
  41306. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  41307. _this._renderTime.endMonitoring(false);
  41308. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  41309. });
  41310. }
  41311. else {
  41312. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41313. this._onBeforeDrawPhaseObserver = null;
  41314. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41315. this._onAfterDrawPhaseObserver = null;
  41316. }
  41317. },
  41318. enumerable: true,
  41319. configurable: true
  41320. });
  41321. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  41322. /**
  41323. * Gets the perf counter used for camera render time capture
  41324. */
  41325. get: function () {
  41326. return this._cameraRenderTime;
  41327. },
  41328. enumerable: true,
  41329. configurable: true
  41330. });
  41331. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  41332. /**
  41333. * Gets the camera render time capture status
  41334. */
  41335. get: function () {
  41336. return this._captureCameraRenderTime;
  41337. },
  41338. /**
  41339. * Enable or disable the camera render time capture
  41340. */
  41341. set: function (value) {
  41342. var _this = this;
  41343. if (value === this._captureCameraRenderTime) {
  41344. return;
  41345. }
  41346. this._captureCameraRenderTime = value;
  41347. if (value) {
  41348. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  41349. _this._cameraRenderTime.beginMonitoring();
  41350. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  41351. });
  41352. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  41353. _this._cameraRenderTime.endMonitoring(false);
  41354. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  41355. });
  41356. }
  41357. else {
  41358. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41359. this._onBeforeCameraRenderObserver = null;
  41360. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41361. this._onAfterCameraRenderObserver = null;
  41362. }
  41363. },
  41364. enumerable: true,
  41365. configurable: true
  41366. });
  41367. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  41368. /**
  41369. * Gets the perf counter used for draw calls
  41370. */
  41371. get: function () {
  41372. return this.scene.getEngine()._drawCalls;
  41373. },
  41374. enumerable: true,
  41375. configurable: true
  41376. });
  41377. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  41378. /**
  41379. * Gets the perf counter used for texture collisions
  41380. */
  41381. get: function () {
  41382. return this.scene.getEngine()._textureCollisions;
  41383. },
  41384. enumerable: true,
  41385. configurable: true
  41386. });
  41387. /**
  41388. * Dispose and release associated resources.
  41389. */
  41390. SceneInstrumentation.prototype.dispose = function () {
  41391. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41392. this._onAfterRenderObserver = null;
  41393. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41394. this._onBeforeActiveMeshesEvaluationObserver = null;
  41395. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41396. this._onAfterActiveMeshesEvaluationObserver = null;
  41397. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41398. this._onBeforeRenderTargetsRenderObserver = null;
  41399. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41400. this._onAfterRenderTargetsRenderObserver = null;
  41401. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  41402. this._onBeforeAnimationsObserver = null;
  41403. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41404. this._onBeforeParticlesRenderingObserver = null;
  41405. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41406. this._onAfterParticlesRenderingObserver = null;
  41407. if (this._onBeforeSpritesRenderingObserver) {
  41408. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41409. this._onBeforeSpritesRenderingObserver = null;
  41410. }
  41411. if (this._onAfterSpritesRenderingObserver) {
  41412. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41413. this._onAfterSpritesRenderingObserver = null;
  41414. }
  41415. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41416. this._onBeforeDrawPhaseObserver = null;
  41417. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41418. this._onAfterDrawPhaseObserver = null;
  41419. if (this._onBeforePhysicsObserver) {
  41420. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41421. this._onBeforePhysicsObserver = null;
  41422. }
  41423. if (this._onAfterPhysicsObserver) {
  41424. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41425. this._onAfterPhysicsObserver = null;
  41426. }
  41427. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41428. this._onAfterAnimationsObserver = null;
  41429. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41430. this._onBeforeCameraRenderObserver = null;
  41431. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41432. this._onAfterCameraRenderObserver = null;
  41433. this.scene = null;
  41434. };
  41435. return SceneInstrumentation;
  41436. }());
  41437. /***/ }),
  41438. /***/ "./Instrumentation/timeToken.ts":
  41439. /*!**************************************!*\
  41440. !*** ./Instrumentation/timeToken.ts ***!
  41441. \**************************************/
  41442. /*! exports provided: _TimeToken */
  41443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41444. "use strict";
  41445. __webpack_require__.r(__webpack_exports__);
  41446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  41447. /**
  41448. * @hidden
  41449. **/
  41450. var _TimeToken = /** @class */ (function () {
  41451. function _TimeToken() {
  41452. this._timeElapsedQueryEnded = false;
  41453. }
  41454. return _TimeToken;
  41455. }());
  41456. /***/ }),
  41457. /***/ "./Layers/effectLayer.ts":
  41458. /*!*******************************!*\
  41459. !*** ./Layers/effectLayer.ts ***!
  41460. \*******************************/
  41461. /*! exports provided: EffectLayer */
  41462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41463. "use strict";
  41464. __webpack_require__.r(__webpack_exports__);
  41465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  41466. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41467. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41468. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41469. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41470. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41471. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  41472. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41473. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41474. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41475. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41476. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  41477. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41478. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  41479. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  41480. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  41481. /**
  41482. * The effect layer Helps adding post process effect blended with the main pass.
  41483. *
  41484. * This can be for instance use to generate glow or higlight effects on the scene.
  41485. *
  41486. * The effect layer class can not be used directly and is intented to inherited from to be
  41487. * customized per effects.
  41488. */
  41489. var EffectLayer = /** @class */ (function () {
  41490. /**
  41491. * Instantiates a new effect Layer and references it in the scene.
  41492. * @param name The name of the layer
  41493. * @param scene The scene to use the layer in
  41494. */
  41495. function EffectLayer(
  41496. /** The Friendly of the effect in the scene */
  41497. name, scene) {
  41498. this._vertexBuffers = {};
  41499. this._maxSize = 0;
  41500. this._mainTextureDesiredSize = { width: 0, height: 0 };
  41501. this._shouldRender = true;
  41502. this._postProcesses = [];
  41503. this._textures = [];
  41504. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  41505. /**
  41506. * The clear color of the texture used to generate the glow map.
  41507. */
  41508. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  41509. /**
  41510. * Specifies wether the highlight layer is enabled or not.
  41511. */
  41512. this.isEnabled = true;
  41513. /**
  41514. * An event triggered when the effect layer has been disposed.
  41515. */
  41516. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41517. /**
  41518. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  41519. */
  41520. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41521. /**
  41522. * An event triggered when the generated texture is being merged in the scene.
  41523. */
  41524. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41525. /**
  41526. * An event triggered when the generated texture has been merged in the scene.
  41527. */
  41528. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41529. /**
  41530. * An event triggered when the efffect layer changes its size.
  41531. */
  41532. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41533. this.name = name;
  41534. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  41535. EffectLayer._SceneComponentInitialization(this._scene);
  41536. this._engine = this._scene.getEngine();
  41537. this._maxSize = this._engine.getCaps().maxTextureSize;
  41538. this._scene.effectLayers.push(this);
  41539. // Generate Buffers
  41540. this._generateIndexBuffer();
  41541. this._genrateVertexBuffer();
  41542. }
  41543. Object.defineProperty(EffectLayer.prototype, "camera", {
  41544. /**
  41545. * Gets the camera attached to the layer.
  41546. */
  41547. get: function () {
  41548. return this._effectLayerOptions.camera;
  41549. },
  41550. enumerable: true,
  41551. configurable: true
  41552. });
  41553. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  41554. /**
  41555. * Gets the rendering group id the layer should render in.
  41556. */
  41557. get: function () {
  41558. return this._effectLayerOptions.renderingGroupId;
  41559. },
  41560. enumerable: true,
  41561. configurable: true
  41562. });
  41563. /**
  41564. * Initializes the effect layer with the required options.
  41565. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  41566. */
  41567. EffectLayer.prototype._init = function (options) {
  41568. // Adapt options
  41569. 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);
  41570. this._setMainTextureSize();
  41571. this._createMainTexture();
  41572. this._createTextureAndPostProcesses();
  41573. this._mergeEffect = this._createMergeEffect();
  41574. };
  41575. /**
  41576. * Generates the index buffer of the full screen quad blending to the main canvas.
  41577. */
  41578. EffectLayer.prototype._generateIndexBuffer = function () {
  41579. // Indices
  41580. var indices = [];
  41581. indices.push(0);
  41582. indices.push(1);
  41583. indices.push(2);
  41584. indices.push(0);
  41585. indices.push(2);
  41586. indices.push(3);
  41587. this._indexBuffer = this._engine.createIndexBuffer(indices);
  41588. };
  41589. /**
  41590. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  41591. */
  41592. EffectLayer.prototype._genrateVertexBuffer = function () {
  41593. // VBO
  41594. var vertices = [];
  41595. vertices.push(1, 1);
  41596. vertices.push(-1, 1);
  41597. vertices.push(-1, -1);
  41598. vertices.push(1, -1);
  41599. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  41600. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  41601. };
  41602. /**
  41603. * Sets the main texture desired size which is the closest power of two
  41604. * of the engine canvas size.
  41605. */
  41606. EffectLayer.prototype._setMainTextureSize = function () {
  41607. if (this._effectLayerOptions.mainTextureFixedSize) {
  41608. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  41609. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  41610. }
  41611. else {
  41612. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  41613. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  41614. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  41615. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  41616. }
  41617. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  41618. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  41619. };
  41620. /**
  41621. * Creates the main texture for the effect layer.
  41622. */
  41623. EffectLayer.prototype._createMainTexture = function () {
  41624. var _this = this;
  41625. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  41626. width: this._mainTextureDesiredSize.width,
  41627. height: this._mainTextureDesiredSize.height
  41628. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  41629. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  41630. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41631. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41632. this._mainTexture.anisotropicFilteringLevel = 1;
  41633. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  41634. this._mainTexture.renderParticles = false;
  41635. this._mainTexture.renderList = null;
  41636. this._mainTexture.ignoreCameraViewport = true;
  41637. // Custom render function
  41638. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  41639. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  41640. var index;
  41641. var engine = _this._scene.getEngine();
  41642. if (depthOnlySubMeshes.length) {
  41643. engine.setColorWrite(false);
  41644. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  41645. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  41646. }
  41647. engine.setColorWrite(true);
  41648. }
  41649. for (index = 0; index < opaqueSubMeshes.length; index++) {
  41650. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  41651. }
  41652. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  41653. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  41654. }
  41655. for (index = 0; index < transparentSubMeshes.length; index++) {
  41656. _this._renderSubMesh(transparentSubMeshes.data[index]);
  41657. }
  41658. };
  41659. this._mainTexture.onClearObservable.add(function (engine) {
  41660. engine.clear(_this.neutralColor, true, true, true);
  41661. });
  41662. };
  41663. /**
  41664. * Adds specific effects defines.
  41665. * @param defines The defines to add specifics to.
  41666. */
  41667. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  41668. // Nothing to add by default.
  41669. };
  41670. /**
  41671. * Checks for the readiness of the element composing the layer.
  41672. * @param subMesh the mesh to check for
  41673. * @param useInstances specify wether or not to use instances to render the mesh
  41674. * @param emissiveTexture the associated emissive texture used to generate the glow
  41675. * @return true if ready otherwise, false
  41676. */
  41677. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  41678. var material = subMesh.getMaterial();
  41679. if (!material) {
  41680. return false;
  41681. }
  41682. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  41683. return false;
  41684. }
  41685. var defines = [];
  41686. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41687. var mesh = subMesh.getMesh();
  41688. var uv1 = false;
  41689. var uv2 = false;
  41690. // Diffuse
  41691. if (material) {
  41692. var needAlphaTest = material.needAlphaTesting();
  41693. var diffuseTexture = material.getAlphaTestTexture();
  41694. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41695. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41696. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41697. defines.push("#define DIFFUSE");
  41698. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41699. diffuseTexture.coordinatesIndex === 1) {
  41700. defines.push("#define DIFFUSEUV2");
  41701. uv2 = true;
  41702. }
  41703. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41704. defines.push("#define DIFFUSEUV1");
  41705. uv1 = true;
  41706. }
  41707. if (needAlphaTest) {
  41708. defines.push("#define ALPHATEST");
  41709. defines.push("#define ALPHATESTVALUE 0.4");
  41710. }
  41711. }
  41712. var opacityTexture = material.opacityTexture;
  41713. if (opacityTexture) {
  41714. defines.push("#define OPACITY");
  41715. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41716. opacityTexture.coordinatesIndex === 1) {
  41717. defines.push("#define OPACITYUV2");
  41718. uv2 = true;
  41719. }
  41720. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41721. defines.push("#define OPACITYUV1");
  41722. uv1 = true;
  41723. }
  41724. }
  41725. }
  41726. // Emissive
  41727. if (emissiveTexture) {
  41728. defines.push("#define EMISSIVE");
  41729. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41730. emissiveTexture.coordinatesIndex === 1) {
  41731. defines.push("#define EMISSIVEUV2");
  41732. uv2 = true;
  41733. }
  41734. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41735. defines.push("#define EMISSIVEUV1");
  41736. uv1 = true;
  41737. }
  41738. }
  41739. // Vertex
  41740. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  41741. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  41742. defines.push("#define VERTEXALPHA");
  41743. }
  41744. if (uv1) {
  41745. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  41746. defines.push("#define UV1");
  41747. }
  41748. if (uv2) {
  41749. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  41750. defines.push("#define UV2");
  41751. }
  41752. // Bones
  41753. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  41754. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  41755. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  41756. if (mesh.numBoneInfluencers > 4) {
  41757. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  41758. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  41759. }
  41760. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  41761. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  41762. }
  41763. else {
  41764. defines.push("#define NUM_BONE_INFLUENCERS 0");
  41765. }
  41766. // Morph targets
  41767. var manager = mesh.morphTargetManager;
  41768. var morphInfluencers = 0;
  41769. if (manager) {
  41770. if (manager.numInfluencers > 0) {
  41771. defines.push("#define MORPHTARGETS");
  41772. morphInfluencers = manager.numInfluencers;
  41773. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  41774. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  41775. }
  41776. }
  41777. // Instances
  41778. if (useInstances) {
  41779. defines.push("#define INSTANCES");
  41780. attribs.push("world0");
  41781. attribs.push("world1");
  41782. attribs.push("world2");
  41783. attribs.push("world3");
  41784. }
  41785. this._addCustomEffectDefines(defines);
  41786. // Get correct effect
  41787. var join = defines.join("\n");
  41788. if (this._cachedDefines !== join) {
  41789. this._cachedDefines = join;
  41790. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  41791. "color", "morphTargetInfluences",
  41792. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  41793. }
  41794. return this._effectLayerMapGenerationEffect.isReady();
  41795. };
  41796. /**
  41797. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  41798. */
  41799. EffectLayer.prototype.render = function () {
  41800. var currentEffect = this._mergeEffect;
  41801. // Check
  41802. if (!currentEffect.isReady()) {
  41803. return;
  41804. }
  41805. for (var i = 0; i < this._postProcesses.length; i++) {
  41806. if (!this._postProcesses[i].isReady()) {
  41807. return;
  41808. }
  41809. }
  41810. var engine = this._scene.getEngine();
  41811. this.onBeforeComposeObservable.notifyObservers(this);
  41812. // Render
  41813. engine.enableEffect(currentEffect);
  41814. engine.setState(false);
  41815. // VBOs
  41816. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  41817. // Cache
  41818. var previousAlphaMode = engine.getAlphaMode();
  41819. // Go Blend.
  41820. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  41821. // Blends the map on the main canvas.
  41822. this._internalRender(currentEffect);
  41823. // Restore Alpha
  41824. engine.setAlphaMode(previousAlphaMode);
  41825. this.onAfterComposeObservable.notifyObservers(this);
  41826. // Handle size changes.
  41827. var size = this._mainTexture.getSize();
  41828. this._setMainTextureSize();
  41829. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  41830. // Recreate RTT and post processes on size change.
  41831. this.onSizeChangedObservable.notifyObservers(this);
  41832. this._disposeTextureAndPostProcesses();
  41833. this._createMainTexture();
  41834. this._createTextureAndPostProcesses();
  41835. }
  41836. };
  41837. /**
  41838. * Determine if a given mesh will be used in the current effect.
  41839. * @param mesh mesh to test
  41840. * @returns true if the mesh will be used
  41841. */
  41842. EffectLayer.prototype.hasMesh = function (mesh) {
  41843. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  41844. return true;
  41845. }
  41846. return false;
  41847. };
  41848. /**
  41849. * Returns true if the layer contains information to display, otherwise false.
  41850. * @returns true if the glow layer should be rendered
  41851. */
  41852. EffectLayer.prototype.shouldRender = function () {
  41853. return this.isEnabled && this._shouldRender;
  41854. };
  41855. /**
  41856. * Returns true if the mesh should render, otherwise false.
  41857. * @param mesh The mesh to render
  41858. * @returns true if it should render otherwise false
  41859. */
  41860. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  41861. return true;
  41862. };
  41863. /**
  41864. * Returns true if the mesh can be rendered, otherwise false.
  41865. * @param mesh The mesh to render
  41866. * @param material The material used on the mesh
  41867. * @returns true if it can be rendered otherwise false
  41868. */
  41869. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  41870. return !material.needAlphaBlendingForMesh(mesh);
  41871. };
  41872. /**
  41873. * Returns true if the mesh should render, otherwise false.
  41874. * @param mesh The mesh to render
  41875. * @returns true if it should render otherwise false
  41876. */
  41877. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  41878. return true;
  41879. };
  41880. /**
  41881. * Renders the submesh passed in parameter to the generation map.
  41882. */
  41883. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  41884. var _this = this;
  41885. if (!this.shouldRender()) {
  41886. return;
  41887. }
  41888. var material = subMesh.getMaterial();
  41889. var mesh = subMesh.getRenderingMesh();
  41890. var scene = this._scene;
  41891. var engine = scene.getEngine();
  41892. if (!material) {
  41893. return;
  41894. }
  41895. // Do not block in blend mode.
  41896. if (!this._canRenderMesh(mesh, material)) {
  41897. return;
  41898. }
  41899. // Culling
  41900. engine.setState(material.backFaceCulling);
  41901. // Managing instances
  41902. var batch = mesh._getInstancesRenderList(subMesh._id);
  41903. if (batch.mustReturn) {
  41904. return;
  41905. }
  41906. // Early Exit per mesh
  41907. if (!this._shouldRenderMesh(mesh)) {
  41908. return;
  41909. }
  41910. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  41911. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  41912. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  41913. engine.enableEffect(this._effectLayerMapGenerationEffect);
  41914. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  41915. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  41916. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  41917. var needAlphaTest = material.needAlphaTesting();
  41918. var diffuseTexture = material.getAlphaTestTexture();
  41919. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41920. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41921. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41922. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  41923. var textureMatrix = diffuseTexture.getTextureMatrix();
  41924. if (textureMatrix) {
  41925. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  41926. }
  41927. }
  41928. var opacityTexture = material.opacityTexture;
  41929. if (opacityTexture) {
  41930. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  41931. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  41932. var textureMatrix = opacityTexture.getTextureMatrix();
  41933. if (textureMatrix) {
  41934. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  41935. }
  41936. }
  41937. // Glow emissive only
  41938. if (this._emissiveTextureAndColor.texture) {
  41939. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  41940. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  41941. }
  41942. // Bones
  41943. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  41944. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  41945. }
  41946. // Morph targets
  41947. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  41948. // Draw
  41949. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  41950. }
  41951. else {
  41952. // Need to reset refresh rate of the main map
  41953. this._mainTexture.resetRefreshCounter();
  41954. }
  41955. };
  41956. /**
  41957. * Rebuild the required buffers.
  41958. * @hidden Internal use only.
  41959. */
  41960. EffectLayer.prototype._rebuild = function () {
  41961. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41962. if (vb) {
  41963. vb._rebuild();
  41964. }
  41965. this._generateIndexBuffer();
  41966. };
  41967. /**
  41968. * Dispose only the render target textures and post process.
  41969. */
  41970. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  41971. this._mainTexture.dispose();
  41972. for (var i = 0; i < this._postProcesses.length; i++) {
  41973. if (this._postProcesses[i]) {
  41974. this._postProcesses[i].dispose();
  41975. }
  41976. }
  41977. this._postProcesses = [];
  41978. for (var i = 0; i < this._textures.length; i++) {
  41979. if (this._textures[i]) {
  41980. this._textures[i].dispose();
  41981. }
  41982. }
  41983. this._textures = [];
  41984. };
  41985. /**
  41986. * Dispose the highlight layer and free resources.
  41987. */
  41988. EffectLayer.prototype.dispose = function () {
  41989. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41990. if (vertexBuffer) {
  41991. vertexBuffer.dispose();
  41992. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  41993. }
  41994. if (this._indexBuffer) {
  41995. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  41996. this._indexBuffer = null;
  41997. }
  41998. // Clean textures and post processes
  41999. this._disposeTextureAndPostProcesses();
  42000. // Remove from scene
  42001. var index = this._scene.effectLayers.indexOf(this, 0);
  42002. if (index > -1) {
  42003. this._scene.effectLayers.splice(index, 1);
  42004. }
  42005. // Callback
  42006. this.onDisposeObservable.notifyObservers(this);
  42007. this.onDisposeObservable.clear();
  42008. this.onBeforeRenderMainTextureObservable.clear();
  42009. this.onBeforeComposeObservable.clear();
  42010. this.onAfterComposeObservable.clear();
  42011. this.onSizeChangedObservable.clear();
  42012. };
  42013. /**
  42014. * Gets the class name of the effect layer
  42015. * @returns the string with the class name of the effect layer
  42016. */
  42017. EffectLayer.prototype.getClassName = function () {
  42018. return "EffectLayer";
  42019. };
  42020. /**
  42021. * Creates an effect layer from parsed effect layer data
  42022. * @param parsedEffectLayer defines effect layer data
  42023. * @param scene defines the current scene
  42024. * @param rootUrl defines the root URL containing the effect layer information
  42025. * @returns a parsed effect Layer
  42026. */
  42027. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  42028. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  42029. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  42030. };
  42031. /** @hidden */
  42032. EffectLayer._SceneComponentInitialization = function (_) {
  42033. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  42034. };
  42035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42037. ], EffectLayer.prototype, "name", void 0);
  42038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  42040. ], EffectLayer.prototype, "neutralColor", void 0);
  42041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42043. ], EffectLayer.prototype, "isEnabled", void 0);
  42044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  42046. ], EffectLayer.prototype, "camera", null);
  42047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42049. ], EffectLayer.prototype, "renderingGroupId", null);
  42050. return EffectLayer;
  42051. }());
  42052. /***/ }),
  42053. /***/ "./Layers/effectLayerSceneComponent.ts":
  42054. /*!*********************************************!*\
  42055. !*** ./Layers/effectLayerSceneComponent.ts ***!
  42056. \*********************************************/
  42057. /*! exports provided: EffectLayerSceneComponent */
  42058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42059. "use strict";
  42060. __webpack_require__.r(__webpack_exports__);
  42061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  42062. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  42063. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42064. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42065. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42066. // Adds the parser to the scene parsers.
  42067. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  42068. if (parsedData.effectLayers) {
  42069. if (!container.effectLayers) {
  42070. container.effectLayers = new Array();
  42071. }
  42072. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  42073. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  42074. container.effectLayers.push(effectLayer);
  42075. }
  42076. }
  42077. });
  42078. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  42079. var index = this.effectLayers.indexOf(toRemove);
  42080. if (index !== -1) {
  42081. this.effectLayers.splice(index, 1);
  42082. }
  42083. return index;
  42084. };
  42085. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  42086. this.effectLayers.push(newEffectLayer);
  42087. };
  42088. /**
  42089. * Defines the layer scene component responsible to manage any effect layers
  42090. * in a given scene.
  42091. */
  42092. var EffectLayerSceneComponent = /** @class */ (function () {
  42093. /**
  42094. * Creates a new instance of the component for the given scene
  42095. * @param scene Defines the scene to register the component in
  42096. */
  42097. function EffectLayerSceneComponent(scene) {
  42098. /**
  42099. * The component name helpfull to identify the component in the list of scene components.
  42100. */
  42101. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  42102. this._renderEffects = false;
  42103. this._needStencil = false;
  42104. this._previousStencilState = false;
  42105. this.scene = scene;
  42106. this._engine = scene.getEngine();
  42107. scene.effectLayers = new Array();
  42108. }
  42109. /**
  42110. * Registers the component in a given scene
  42111. */
  42112. EffectLayerSceneComponent.prototype.register = function () {
  42113. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  42114. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  42115. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  42116. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  42117. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  42118. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  42119. };
  42120. /**
  42121. * Rebuilds the elements related to this component in case of
  42122. * context lost for instance.
  42123. */
  42124. EffectLayerSceneComponent.prototype.rebuild = function () {
  42125. var layers = this.scene.effectLayers;
  42126. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42127. var effectLayer = layers_1[_i];
  42128. effectLayer._rebuild();
  42129. }
  42130. };
  42131. /**
  42132. * Serializes the component data to the specified json object
  42133. * @param serializationObject The object to serialize to
  42134. */
  42135. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  42136. // Effect layers
  42137. serializationObject.effectLayers = [];
  42138. var layers = this.scene.effectLayers;
  42139. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42140. var effectLayer = layers_2[_i];
  42141. if (effectLayer.serialize) {
  42142. serializationObject.effectLayers.push(effectLayer.serialize());
  42143. }
  42144. }
  42145. };
  42146. /**
  42147. * Adds all the element from the container to the scene
  42148. * @param container the container holding the elements
  42149. */
  42150. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  42151. var _this = this;
  42152. if (!container.effectLayers) {
  42153. return;
  42154. }
  42155. container.effectLayers.forEach(function (o) {
  42156. _this.scene.addEffectLayer(o);
  42157. });
  42158. };
  42159. /**
  42160. * Removes all the elements in the container from the scene
  42161. * @param container contains the elements to remove
  42162. */
  42163. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  42164. var _this = this;
  42165. if (!container.effectLayers) {
  42166. return;
  42167. }
  42168. container.effectLayers.forEach(function (o) {
  42169. _this.scene.removeEffectLayer(o);
  42170. });
  42171. };
  42172. /**
  42173. * Disposes the component and the associated ressources.
  42174. */
  42175. EffectLayerSceneComponent.prototype.dispose = function () {
  42176. var layers = this.scene.effectLayers;
  42177. while (layers.length) {
  42178. layers[0].dispose();
  42179. }
  42180. };
  42181. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  42182. var layers = this.scene.effectLayers;
  42183. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  42184. var layer = layers_3[_i];
  42185. if (!layer.hasMesh(mesh)) {
  42186. continue;
  42187. }
  42188. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  42189. var subMesh = _b[_a];
  42190. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  42191. return false;
  42192. }
  42193. }
  42194. }
  42195. return true;
  42196. };
  42197. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  42198. this._renderEffects = false;
  42199. this._needStencil = false;
  42200. var layers = this.scene.effectLayers;
  42201. if (layers && layers.length > 0) {
  42202. this._previousStencilState = this._engine.getStencilBuffer();
  42203. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  42204. var effectLayer = layers_4[_i];
  42205. if (effectLayer.shouldRender() &&
  42206. (!effectLayer.camera ||
  42207. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  42208. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  42209. this._renderEffects = true;
  42210. this._needStencil = this._needStencil || effectLayer.needStencil();
  42211. var renderTarget = effectLayer._mainTexture;
  42212. if (renderTarget._shouldRender()) {
  42213. this.scene.incrementRenderId();
  42214. renderTarget.render(false, false);
  42215. }
  42216. }
  42217. }
  42218. this.scene.incrementRenderId();
  42219. }
  42220. };
  42221. EffectLayerSceneComponent.prototype._setStencil = function () {
  42222. // Activate effect Layer stencil
  42223. if (this._needStencil) {
  42224. this._engine.setStencilBuffer(true);
  42225. }
  42226. };
  42227. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  42228. // Restore effect Layer stencil
  42229. if (this._needStencil) {
  42230. this._engine.setStencilBuffer(this._previousStencilState);
  42231. }
  42232. };
  42233. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  42234. if (this._renderEffects) {
  42235. this._engine.setDepthBuffer(false);
  42236. var layers = this.scene.effectLayers;
  42237. for (var i = 0; i < layers.length; i++) {
  42238. var effectLayer = layers[i];
  42239. if (effectLayer.renderingGroupId === renderingGroupId) {
  42240. if (effectLayer.shouldRender()) {
  42241. effectLayer.render();
  42242. }
  42243. }
  42244. }
  42245. this._engine.setDepthBuffer(true);
  42246. }
  42247. };
  42248. EffectLayerSceneComponent.prototype._drawCamera = function () {
  42249. if (this._renderEffects) {
  42250. this._draw(-1);
  42251. }
  42252. };
  42253. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  42254. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  42255. this._draw(index);
  42256. }
  42257. };
  42258. return EffectLayerSceneComponent;
  42259. }());
  42260. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  42261. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  42262. if (!component) {
  42263. component = new EffectLayerSceneComponent(scene);
  42264. scene._addComponent(component);
  42265. }
  42266. };
  42267. /***/ }),
  42268. /***/ "./Layers/glowLayer.ts":
  42269. /*!*****************************!*\
  42270. !*** ./Layers/glowLayer.ts ***!
  42271. \*****************************/
  42272. /*! exports provided: GlowLayer */
  42273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42274. "use strict";
  42275. __webpack_require__.r(__webpack_exports__);
  42276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  42277. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42278. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42279. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42280. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42281. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42282. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42283. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42284. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42285. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42286. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42287. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42288. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42289. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42290. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42291. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42292. /* harmony import */ var _Layers_effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Layers/effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42293. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  42294. for (var index = 0; index < this.effectLayers.length; index++) {
  42295. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  42296. return this.effectLayers[index];
  42297. }
  42298. }
  42299. return null;
  42300. };
  42301. /**
  42302. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  42303. *
  42304. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42305. * glowy meshes to your scene.
  42306. *
  42307. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  42308. */
  42309. var GlowLayer = /** @class */ (function (_super) {
  42310. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  42311. /**
  42312. * Instantiates a new glow Layer and references it to the scene.
  42313. * @param name The name of the layer
  42314. * @param scene The scene to use the layer in
  42315. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  42316. */
  42317. function GlowLayer(name, scene, options) {
  42318. var _this = _super.call(this, name, scene) || this;
  42319. _this._intensity = 1.0;
  42320. _this._includedOnlyMeshes = [];
  42321. _this._excludedMeshes = [];
  42322. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  42323. // Adapt options
  42324. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  42325. // Initialize the layer
  42326. _this._init({
  42327. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  42328. camera: _this._options.camera,
  42329. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42330. mainTextureRatio: _this._options.mainTextureRatio,
  42331. renderingGroupId: _this._options.renderingGroupId
  42332. });
  42333. return _this;
  42334. }
  42335. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  42336. /**
  42337. * Gets the kernel size of the blur.
  42338. */
  42339. get: function () {
  42340. return this._horizontalBlurPostprocess1.kernel;
  42341. },
  42342. /**
  42343. * Sets the kernel size of the blur.
  42344. */
  42345. set: function (value) {
  42346. this._horizontalBlurPostprocess1.kernel = value;
  42347. this._verticalBlurPostprocess1.kernel = value;
  42348. this._horizontalBlurPostprocess2.kernel = value;
  42349. this._verticalBlurPostprocess2.kernel = value;
  42350. },
  42351. enumerable: true,
  42352. configurable: true
  42353. });
  42354. Object.defineProperty(GlowLayer.prototype, "intensity", {
  42355. /**
  42356. * Gets the glow intensity.
  42357. */
  42358. get: function () {
  42359. return this._intensity;
  42360. },
  42361. /**
  42362. * Sets the glow intensity.
  42363. */
  42364. set: function (value) {
  42365. this._intensity = value;
  42366. },
  42367. enumerable: true,
  42368. configurable: true
  42369. });
  42370. /**
  42371. * Get the effect name of the layer.
  42372. * @return The effect name
  42373. */
  42374. GlowLayer.prototype.getEffectName = function () {
  42375. return GlowLayer.EffectName;
  42376. };
  42377. /**
  42378. * Create the merge effect. This is the shader use to blit the information back
  42379. * to the main canvas at the end of the scene rendering.
  42380. */
  42381. GlowLayer.prototype._createMergeEffect = function () {
  42382. // Effect
  42383. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  42384. };
  42385. /**
  42386. * Creates the render target textures and post processes used in the glow layer.
  42387. */
  42388. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  42389. var _this = this;
  42390. var blurTextureWidth = this._mainTextureDesiredSize.width;
  42391. var blurTextureHeight = this._mainTextureDesiredSize.height;
  42392. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42393. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42394. var textureType = 0;
  42395. if (this._engine.getCaps().textureHalfFloatRender) {
  42396. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42397. }
  42398. else {
  42399. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42400. }
  42401. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  42402. width: blurTextureWidth,
  42403. height: blurTextureHeight
  42404. }, this._scene, false, true, textureType);
  42405. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42406. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42407. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42408. this._blurTexture1.renderParticles = false;
  42409. this._blurTexture1.ignoreCameraViewport = true;
  42410. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  42411. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  42412. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  42413. width: blurTextureWidth2,
  42414. height: blurTextureHeight2
  42415. }, this._scene, false, true, textureType);
  42416. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42417. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42418. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42419. this._blurTexture2.renderParticles = false;
  42420. this._blurTexture2.ignoreCameraViewport = true;
  42421. this._textures = [this._blurTexture1, this._blurTexture2];
  42422. 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, {
  42423. width: blurTextureWidth,
  42424. height: blurTextureHeight
  42425. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42426. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  42427. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  42428. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  42429. effect.setTexture("textureSampler", _this._mainTexture);
  42430. });
  42431. 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, {
  42432. width: blurTextureWidth,
  42433. height: blurTextureHeight
  42434. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42435. 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, {
  42436. width: blurTextureWidth2,
  42437. height: blurTextureHeight2
  42438. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42439. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  42440. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  42441. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  42442. effect.setTexture("textureSampler", _this._blurTexture1);
  42443. });
  42444. 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, {
  42445. width: blurTextureWidth2,
  42446. height: blurTextureHeight2
  42447. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42448. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  42449. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  42450. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  42451. this._mainTexture.samples = this._options.mainTextureSamples;
  42452. this._mainTexture.onAfterUnbindObservable.add(function () {
  42453. var internalTexture = _this._blurTexture1.getInternalTexture();
  42454. if (internalTexture) {
  42455. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  42456. internalTexture = _this._blurTexture2.getInternalTexture();
  42457. if (internalTexture) {
  42458. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  42459. }
  42460. }
  42461. });
  42462. // Prevent autoClear.
  42463. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42464. };
  42465. /**
  42466. * Checks for the readiness of the element composing the layer.
  42467. * @param subMesh the mesh to check for
  42468. * @param useInstances specify wether or not to use instances to render the mesh
  42469. * @param emissiveTexture the associated emissive texture used to generate the glow
  42470. * @return true if ready otherwise, false
  42471. */
  42472. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  42473. var material = subMesh.getMaterial();
  42474. var mesh = subMesh.getRenderingMesh();
  42475. if (!material || !mesh) {
  42476. return false;
  42477. }
  42478. var emissiveTexture = material.emissiveTexture;
  42479. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42480. };
  42481. /**
  42482. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42483. */
  42484. GlowLayer.prototype.needStencil = function () {
  42485. return false;
  42486. };
  42487. /**
  42488. * Returns true if the mesh can be rendered, otherwise false.
  42489. * @param mesh The mesh to render
  42490. * @param material The material used on the mesh
  42491. * @returns true if it can be rendered otherwise false
  42492. */
  42493. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  42494. return true;
  42495. };
  42496. /**
  42497. * Implementation specific of rendering the generating effect on the main canvas.
  42498. * @param effect The effect used to render through
  42499. */
  42500. GlowLayer.prototype._internalRender = function (effect) {
  42501. // Texture
  42502. effect.setTexture("textureSampler", this._blurTexture1);
  42503. effect.setTexture("textureSampler2", this._blurTexture2);
  42504. effect.setFloat("offset", this._intensity);
  42505. // Cache
  42506. var engine = this._engine;
  42507. var previousStencilBuffer = engine.getStencilBuffer();
  42508. // Draw order
  42509. engine.setStencilBuffer(false);
  42510. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  42511. // Draw order
  42512. engine.setStencilBuffer(previousStencilBuffer);
  42513. };
  42514. /**
  42515. * Sets the required values for both the emissive texture and and the main color.
  42516. */
  42517. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42518. var textureLevel = 1.0;
  42519. if (this.customEmissiveTextureSelector) {
  42520. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  42521. }
  42522. else {
  42523. if (material) {
  42524. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42525. if (this._emissiveTextureAndColor.texture) {
  42526. textureLevel = this._emissiveTextureAndColor.texture.level;
  42527. }
  42528. }
  42529. else {
  42530. this._emissiveTextureAndColor.texture = null;
  42531. }
  42532. }
  42533. if (this.customEmissiveColorSelector) {
  42534. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  42535. }
  42536. else {
  42537. if (material.emissiveColor) {
  42538. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  42539. }
  42540. else {
  42541. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42542. }
  42543. }
  42544. };
  42545. /**
  42546. * Returns true if the mesh should render, otherwise false.
  42547. * @param mesh The mesh to render
  42548. * @returns true if it should render otherwise false
  42549. */
  42550. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  42551. return this.hasMesh(mesh);
  42552. };
  42553. /**
  42554. * Adds specific effects defines.
  42555. * @param defines The defines to add specifics to.
  42556. */
  42557. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  42558. defines.push("#define GLOW");
  42559. };
  42560. /**
  42561. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  42562. * @param mesh The mesh to exclude from the glow layer
  42563. */
  42564. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  42565. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  42566. this._excludedMeshes.push(mesh.uniqueId);
  42567. }
  42568. };
  42569. /**
  42570. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  42571. * @param mesh The mesh to remove
  42572. */
  42573. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  42574. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  42575. if (index !== -1) {
  42576. this._excludedMeshes.splice(index, 1);
  42577. }
  42578. };
  42579. /**
  42580. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  42581. * @param mesh The mesh to include in the glow layer
  42582. */
  42583. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  42584. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  42585. this._includedOnlyMeshes.push(mesh.uniqueId);
  42586. }
  42587. };
  42588. /**
  42589. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  42590. * @param mesh The mesh to remove
  42591. */
  42592. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  42593. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  42594. if (index !== -1) {
  42595. this._includedOnlyMeshes.splice(index, 1);
  42596. }
  42597. };
  42598. /**
  42599. * Determine if a given mesh will be used in the glow layer
  42600. * @param mesh The mesh to test
  42601. * @returns true if the mesh will be highlighted by the current glow layer
  42602. */
  42603. GlowLayer.prototype.hasMesh = function (mesh) {
  42604. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42605. return false;
  42606. }
  42607. // Included Mesh
  42608. if (this._includedOnlyMeshes.length) {
  42609. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  42610. }
  42611. // Excluded Mesh
  42612. if (this._excludedMeshes.length) {
  42613. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  42614. }
  42615. return true;
  42616. };
  42617. /**
  42618. * Free any resources and references associated to a mesh.
  42619. * Internal use
  42620. * @param mesh The mesh to free.
  42621. * @hidden
  42622. */
  42623. GlowLayer.prototype._disposeMesh = function (mesh) {
  42624. this.removeIncludedOnlyMesh(mesh);
  42625. this.removeExcludedMesh(mesh);
  42626. };
  42627. /**
  42628. * Gets the class name of the effect layer
  42629. * @returns the string with the class name of the effect layer
  42630. */
  42631. GlowLayer.prototype.getClassName = function () {
  42632. return "GlowLayer";
  42633. };
  42634. /**
  42635. * Serializes this glow layer
  42636. * @returns a serialized glow layer object
  42637. */
  42638. GlowLayer.prototype.serialize = function () {
  42639. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42640. serializationObject.customType = "BABYLON.GlowLayer";
  42641. var index;
  42642. // Included meshes
  42643. serializationObject.includedMeshes = [];
  42644. if (this._includedOnlyMeshes.length) {
  42645. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  42646. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  42647. if (mesh) {
  42648. serializationObject.includedMeshes.push(mesh.id);
  42649. }
  42650. }
  42651. }
  42652. // Excluded meshes
  42653. serializationObject.excludedMeshes = [];
  42654. if (this._excludedMeshes.length) {
  42655. for (index = 0; index < this._excludedMeshes.length; index++) {
  42656. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  42657. if (mesh) {
  42658. serializationObject.excludedMeshes.push(mesh.id);
  42659. }
  42660. }
  42661. }
  42662. return serializationObject;
  42663. };
  42664. /**
  42665. * Creates a Glow Layer from parsed glow layer data
  42666. * @param parsedGlowLayer defines glow layer data
  42667. * @param scene defines the current scene
  42668. * @param rootUrl defines the root URL containing the glow layer information
  42669. * @returns a parsed Glow Layer
  42670. */
  42671. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  42672. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  42673. var index;
  42674. // Excluded meshes
  42675. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  42676. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  42677. if (mesh) {
  42678. gl.addExcludedMesh(mesh);
  42679. }
  42680. }
  42681. // Included meshes
  42682. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  42683. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  42684. if (mesh) {
  42685. gl.addIncludedOnlyMesh(mesh);
  42686. }
  42687. }
  42688. return gl;
  42689. };
  42690. /**
  42691. * Effect Name of the layer.
  42692. */
  42693. GlowLayer.EffectName = "GlowLayer";
  42694. /**
  42695. * The default blur kernel size used for the glow.
  42696. */
  42697. GlowLayer.DefaultBlurKernelSize = 32;
  42698. /**
  42699. * The default texture size ratio used for the glow.
  42700. */
  42701. GlowLayer.DefaultTextureRatio = 0.5;
  42702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42704. ], GlowLayer.prototype, "blurKernelSize", null);
  42705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42707. ], GlowLayer.prototype, "intensity", null);
  42708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42710. ], GlowLayer.prototype, "_options", void 0);
  42711. return GlowLayer;
  42712. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  42713. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  42714. /***/ }),
  42715. /***/ "./Layers/highlightLayer.ts":
  42716. /*!**********************************!*\
  42717. !*** ./Layers/highlightLayer.ts ***!
  42718. \**********************************/
  42719. /*! exports provided: HighlightLayer */
  42720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42721. "use strict";
  42722. __webpack_require__.r(__webpack_exports__);
  42723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  42724. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42725. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42726. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42727. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42728. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42729. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42730. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42731. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42732. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42733. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  42734. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  42735. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42736. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42737. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42738. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42739. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42740. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42741. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42742. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42743. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  42744. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  42745. for (var index = 0; index < this.effectLayers.length; index++) {
  42746. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  42747. return this.effectLayers[index];
  42748. }
  42749. }
  42750. return null;
  42751. };
  42752. /**
  42753. * Special Glow Blur post process only blurring the alpha channel
  42754. * It enforces keeping the most luminous color in the color channel.
  42755. */
  42756. var GlowBlurPostProcess = /** @class */ (function (_super) {
  42757. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  42758. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  42759. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  42760. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  42761. _this.direction = direction;
  42762. _this.kernel = kernel;
  42763. _this.onApplyObservable.add(function (effect) {
  42764. effect.setFloat2("screenSize", _this.width, _this.height);
  42765. effect.setVector2("direction", _this.direction);
  42766. effect.setFloat("blurWidth", _this.kernel);
  42767. });
  42768. return _this;
  42769. }
  42770. return GlowBlurPostProcess;
  42771. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  42772. /**
  42773. * The highlight layer Helps adding a glow effect around a mesh.
  42774. *
  42775. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42776. * glowy meshes to your scene.
  42777. *
  42778. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  42779. */
  42780. var HighlightLayer = /** @class */ (function (_super) {
  42781. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  42782. /**
  42783. * Instantiates a new highlight Layer and references it to the scene..
  42784. * @param name The name of the layer
  42785. * @param scene The scene to use the layer in
  42786. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  42787. */
  42788. function HighlightLayer(name, scene, options) {
  42789. var _this = _super.call(this, name, scene) || this;
  42790. _this.name = name;
  42791. /**
  42792. * Specifies whether or not the inner glow is ACTIVE in the layer.
  42793. */
  42794. _this.innerGlow = true;
  42795. /**
  42796. * Specifies whether or not the outer glow is ACTIVE in the layer.
  42797. */
  42798. _this.outerGlow = true;
  42799. /**
  42800. * An event triggered when the highlight layer is being blurred.
  42801. */
  42802. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42803. /**
  42804. * An event triggered when the highlight layer has been blurred.
  42805. */
  42806. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42807. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  42808. _this._meshes = {};
  42809. _this._excludedMeshes = {};
  42810. _this.neutralColor = HighlightLayer.NeutralColor;
  42811. // Warn on stencil
  42812. if (!_this._engine.isStencilEnable) {
  42813. _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 }");
  42814. }
  42815. // Adapt options
  42816. _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);
  42817. // Initialize the layer
  42818. _this._init({
  42819. alphaBlendingMode: _this._options.alphaBlendingMode,
  42820. camera: _this._options.camera,
  42821. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42822. mainTextureRatio: _this._options.mainTextureRatio,
  42823. renderingGroupId: _this._options.renderingGroupId
  42824. });
  42825. // Do not render as long as no meshes have been added
  42826. _this._shouldRender = false;
  42827. return _this;
  42828. }
  42829. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  42830. /**
  42831. * Gets the horizontal size of the blur.
  42832. */
  42833. get: function () {
  42834. return this._horizontalBlurPostprocess.kernel;
  42835. },
  42836. /**
  42837. * Specifies the horizontal size of the blur.
  42838. */
  42839. set: function (value) {
  42840. this._horizontalBlurPostprocess.kernel = value;
  42841. },
  42842. enumerable: true,
  42843. configurable: true
  42844. });
  42845. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  42846. /**
  42847. * Gets the vertical size of the blur.
  42848. */
  42849. get: function () {
  42850. return this._verticalBlurPostprocess.kernel;
  42851. },
  42852. /**
  42853. * Specifies the vertical size of the blur.
  42854. */
  42855. set: function (value) {
  42856. this._verticalBlurPostprocess.kernel = value;
  42857. },
  42858. enumerable: true,
  42859. configurable: true
  42860. });
  42861. /**
  42862. * Get the effect name of the layer.
  42863. * @return The effect name
  42864. */
  42865. HighlightLayer.prototype.getEffectName = function () {
  42866. return HighlightLayer.EffectName;
  42867. };
  42868. /**
  42869. * Create the merge effect. This is the shader use to blit the information back
  42870. * to the main canvas at the end of the scene rendering.
  42871. */
  42872. HighlightLayer.prototype._createMergeEffect = function () {
  42873. // Effect
  42874. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  42875. };
  42876. /**
  42877. * Creates the render target textures and post processes used in the highlight layer.
  42878. */
  42879. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  42880. var _this = this;
  42881. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  42882. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  42883. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42884. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42885. var textureType = 0;
  42886. if (this._engine.getCaps().textureHalfFloatRender) {
  42887. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42888. }
  42889. else {
  42890. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42891. }
  42892. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  42893. width: blurTextureWidth,
  42894. height: blurTextureHeight
  42895. }, this._scene, false, true, textureType);
  42896. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42897. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42898. this._blurTexture.anisotropicFilteringLevel = 16;
  42899. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  42900. this._blurTexture.renderParticles = false;
  42901. this._blurTexture.ignoreCameraViewport = true;
  42902. this._textures = [this._blurTexture];
  42903. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  42904. 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());
  42905. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  42906. effect.setTexture("textureSampler", _this._mainTexture);
  42907. });
  42908. 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());
  42909. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42910. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42911. });
  42912. 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());
  42913. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  42914. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42915. });
  42916. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42917. }
  42918. else {
  42919. 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, {
  42920. width: blurTextureWidth,
  42921. height: blurTextureHeight
  42922. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42923. this._horizontalBlurPostprocess.width = blurTextureWidth;
  42924. this._horizontalBlurPostprocess.height = blurTextureHeight;
  42925. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42926. effect.setTexture("textureSampler", _this._mainTexture);
  42927. });
  42928. 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, {
  42929. width: blurTextureWidth,
  42930. height: blurTextureHeight
  42931. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42932. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42933. }
  42934. this._mainTexture.onAfterUnbindObservable.add(function () {
  42935. _this.onBeforeBlurObservable.notifyObservers(_this);
  42936. var internalTexture = _this._blurTexture.getInternalTexture();
  42937. if (internalTexture) {
  42938. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  42939. }
  42940. _this.onAfterBlurObservable.notifyObservers(_this);
  42941. });
  42942. // Prevent autoClear.
  42943. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42944. };
  42945. /**
  42946. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42947. */
  42948. HighlightLayer.prototype.needStencil = function () {
  42949. return true;
  42950. };
  42951. /**
  42952. * Checks for the readiness of the element composing the layer.
  42953. * @param subMesh the mesh to check for
  42954. * @param useInstances specify wether or not to use instances to render the mesh
  42955. * @param emissiveTexture the associated emissive texture used to generate the glow
  42956. * @return true if ready otherwise, false
  42957. */
  42958. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  42959. var material = subMesh.getMaterial();
  42960. var mesh = subMesh.getRenderingMesh();
  42961. if (!material || !mesh || !this._meshes) {
  42962. return false;
  42963. }
  42964. var emissiveTexture = null;
  42965. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42966. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42967. emissiveTexture = material.emissiveTexture;
  42968. }
  42969. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42970. };
  42971. /**
  42972. * Implementation specific of rendering the generating effect on the main canvas.
  42973. * @param effect The effect used to render through
  42974. */
  42975. HighlightLayer.prototype._internalRender = function (effect) {
  42976. // Texture
  42977. effect.setTexture("textureSampler", this._blurTexture);
  42978. // Cache
  42979. var engine = this._engine;
  42980. var previousStencilBuffer = engine.getStencilBuffer();
  42981. var previousStencilFunction = engine.getStencilFunction();
  42982. var previousStencilMask = engine.getStencilMask();
  42983. var previousStencilOperationPass = engine.getStencilOperationPass();
  42984. var previousStencilOperationFail = engine.getStencilOperationFail();
  42985. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  42986. var previousStencilReference = engine.getStencilFunctionReference();
  42987. // Stencil operations
  42988. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  42989. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42990. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42991. // Draw order
  42992. engine.setStencilMask(0x00);
  42993. engine.setStencilBuffer(true);
  42994. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  42995. // 2 passes inner outer
  42996. if (this.outerGlow) {
  42997. effect.setFloat("offset", 0);
  42998. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  42999. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43000. }
  43001. if (this.innerGlow) {
  43002. effect.setFloat("offset", 1);
  43003. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  43004. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43005. }
  43006. // Restore Cache
  43007. engine.setStencilFunction(previousStencilFunction);
  43008. engine.setStencilMask(previousStencilMask);
  43009. engine.setStencilBuffer(previousStencilBuffer);
  43010. engine.setStencilOperationPass(previousStencilOperationPass);
  43011. engine.setStencilOperationFail(previousStencilOperationFail);
  43012. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  43013. engine.setStencilFunctionReference(previousStencilReference);
  43014. };
  43015. /**
  43016. * Returns true if the layer contains information to display, otherwise false.
  43017. */
  43018. HighlightLayer.prototype.shouldRender = function () {
  43019. if (_super.prototype.shouldRender.call(this)) {
  43020. return this._meshes ? true : false;
  43021. }
  43022. return false;
  43023. };
  43024. /**
  43025. * Returns true if the mesh should render, otherwise false.
  43026. * @param mesh The mesh to render
  43027. * @returns true if it should render otherwise false
  43028. */
  43029. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  43030. // Excluded Mesh
  43031. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  43032. return false;
  43033. }
  43034. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43035. return false;
  43036. }
  43037. return true;
  43038. };
  43039. /**
  43040. * Sets the required values for both the emissive texture and and the main color.
  43041. */
  43042. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43043. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43044. if (highlightLayerMesh) {
  43045. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  43046. }
  43047. else {
  43048. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43049. }
  43050. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43051. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43052. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  43053. }
  43054. else {
  43055. this._emissiveTextureAndColor.texture = null;
  43056. }
  43057. };
  43058. /**
  43059. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43060. * @param mesh The mesh to exclude from the highlight layer
  43061. */
  43062. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  43063. if (!this._excludedMeshes) {
  43064. return;
  43065. }
  43066. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43067. if (!meshExcluded) {
  43068. this._excludedMeshes[mesh.uniqueId] = {
  43069. mesh: mesh,
  43070. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  43071. mesh.getEngine().setStencilBuffer(false);
  43072. }),
  43073. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  43074. mesh.getEngine().setStencilBuffer(true);
  43075. }),
  43076. };
  43077. }
  43078. };
  43079. /**
  43080. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43081. * @param mesh The mesh to highlight
  43082. */
  43083. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  43084. if (!this._excludedMeshes) {
  43085. return;
  43086. }
  43087. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43088. if (meshExcluded) {
  43089. if (meshExcluded.beforeBind) {
  43090. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  43091. }
  43092. if (meshExcluded.afterRender) {
  43093. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  43094. }
  43095. }
  43096. this._excludedMeshes[mesh.uniqueId] = null;
  43097. };
  43098. /**
  43099. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43100. * @param mesh mesh to test
  43101. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43102. */
  43103. HighlightLayer.prototype.hasMesh = function (mesh) {
  43104. if (!this._meshes) {
  43105. return false;
  43106. }
  43107. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43108. return false;
  43109. }
  43110. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  43111. };
  43112. /**
  43113. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43114. * @param mesh The mesh to highlight
  43115. * @param color The color of the highlight
  43116. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43117. */
  43118. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  43119. var _this = this;
  43120. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  43121. if (!this._meshes) {
  43122. return;
  43123. }
  43124. var meshHighlight = this._meshes[mesh.uniqueId];
  43125. if (meshHighlight) {
  43126. meshHighlight.color = color;
  43127. }
  43128. else {
  43129. this._meshes[mesh.uniqueId] = {
  43130. mesh: mesh,
  43131. color: color,
  43132. // Lambda required for capture due to Observable this context
  43133. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  43134. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  43135. _this._defaultStencilReference(mesh);
  43136. }
  43137. else {
  43138. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  43139. }
  43140. }),
  43141. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  43142. glowEmissiveOnly: glowEmissiveOnly
  43143. };
  43144. mesh.onDisposeObservable.add(function () {
  43145. _this._disposeMesh(mesh);
  43146. });
  43147. }
  43148. this._shouldRender = true;
  43149. };
  43150. /**
  43151. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43152. * @param mesh The mesh to highlight
  43153. */
  43154. HighlightLayer.prototype.removeMesh = function (mesh) {
  43155. if (!this._meshes) {
  43156. return;
  43157. }
  43158. var meshHighlight = this._meshes[mesh.uniqueId];
  43159. if (meshHighlight) {
  43160. if (meshHighlight.observerHighlight) {
  43161. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43162. }
  43163. if (meshHighlight.observerDefault) {
  43164. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43165. }
  43166. delete this._meshes[mesh.uniqueId];
  43167. }
  43168. this._shouldRender = false;
  43169. for (var meshHighlightToCheck in this._meshes) {
  43170. if (this._meshes[meshHighlightToCheck]) {
  43171. this._shouldRender = true;
  43172. break;
  43173. }
  43174. }
  43175. };
  43176. /**
  43177. * Force the stencil to the normal expected value for none glowing parts
  43178. */
  43179. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  43180. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  43181. };
  43182. /**
  43183. * Free any resources and references associated to a mesh.
  43184. * Internal use
  43185. * @param mesh The mesh to free.
  43186. * @hidden
  43187. */
  43188. HighlightLayer.prototype._disposeMesh = function (mesh) {
  43189. this.removeMesh(mesh);
  43190. this.removeExcludedMesh(mesh);
  43191. };
  43192. /**
  43193. * Dispose the highlight layer and free resources.
  43194. */
  43195. HighlightLayer.prototype.dispose = function () {
  43196. if (this._meshes) {
  43197. // Clean mesh references
  43198. for (var id in this._meshes) {
  43199. var meshHighlight = this._meshes[id];
  43200. if (meshHighlight && meshHighlight.mesh) {
  43201. if (meshHighlight.observerHighlight) {
  43202. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43203. }
  43204. if (meshHighlight.observerDefault) {
  43205. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43206. }
  43207. }
  43208. }
  43209. this._meshes = null;
  43210. }
  43211. if (this._excludedMeshes) {
  43212. for (var id in this._excludedMeshes) {
  43213. var meshHighlight = this._excludedMeshes[id];
  43214. if (meshHighlight) {
  43215. if (meshHighlight.beforeBind) {
  43216. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  43217. }
  43218. if (meshHighlight.afterRender) {
  43219. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  43220. }
  43221. }
  43222. }
  43223. this._excludedMeshes = null;
  43224. }
  43225. _super.prototype.dispose.call(this);
  43226. };
  43227. /**
  43228. * Gets the class name of the effect layer
  43229. * @returns the string with the class name of the effect layer
  43230. */
  43231. HighlightLayer.prototype.getClassName = function () {
  43232. return "HighlightLayer";
  43233. };
  43234. /**
  43235. * Serializes this Highlight layer
  43236. * @returns a serialized Highlight layer object
  43237. */
  43238. HighlightLayer.prototype.serialize = function () {
  43239. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43240. serializationObject.customType = "BABYLON.HighlightLayer";
  43241. // Highlighted meshes
  43242. serializationObject.meshes = [];
  43243. if (this._meshes) {
  43244. for (var m in this._meshes) {
  43245. var mesh = this._meshes[m];
  43246. if (mesh) {
  43247. serializationObject.meshes.push({
  43248. glowEmissiveOnly: mesh.glowEmissiveOnly,
  43249. color: mesh.color.asArray(),
  43250. meshId: mesh.mesh.id
  43251. });
  43252. }
  43253. }
  43254. }
  43255. // Excluded meshes
  43256. serializationObject.excludedMeshes = [];
  43257. if (this._excludedMeshes) {
  43258. for (var e in this._excludedMeshes) {
  43259. var excludedMesh = this._excludedMeshes[e];
  43260. if (excludedMesh) {
  43261. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  43262. }
  43263. }
  43264. }
  43265. return serializationObject;
  43266. };
  43267. /**
  43268. * Creates a Highlight layer from parsed Highlight layer data
  43269. * @param parsedHightlightLayer defines the Highlight layer data
  43270. * @param scene defines the current scene
  43271. * @param rootUrl defines the root URL containing the Highlight layer information
  43272. * @returns a parsed Highlight layer
  43273. */
  43274. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  43275. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  43276. var index;
  43277. // Excluded meshes
  43278. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  43279. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  43280. if (mesh) {
  43281. hl.addExcludedMesh(mesh);
  43282. }
  43283. }
  43284. // Included meshes
  43285. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  43286. var highlightedMesh = parsedHightlightLayer.meshes[index];
  43287. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  43288. if (mesh) {
  43289. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  43290. }
  43291. }
  43292. return hl;
  43293. };
  43294. /**
  43295. * Effect Name of the highlight layer.
  43296. */
  43297. HighlightLayer.EffectName = "HighlightLayer";
  43298. /**
  43299. * The neutral color used during the preparation of the glow effect.
  43300. * This is black by default as the blend operation is a blend operation.
  43301. */
  43302. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  43303. /**
  43304. * Stencil value used for glowing meshes.
  43305. */
  43306. HighlightLayer.GlowingMeshStencilReference = 0x02;
  43307. /**
  43308. * Stencil value used for the other meshes in the scene.
  43309. */
  43310. HighlightLayer.NormalMeshStencilReference = 0x01;
  43311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43313. ], HighlightLayer.prototype, "innerGlow", void 0);
  43314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43316. ], HighlightLayer.prototype, "outerGlow", void 0);
  43317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43319. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  43320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43322. ], HighlightLayer.prototype, "blurVerticalSize", null);
  43323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43325. ], HighlightLayer.prototype, "_options", void 0);
  43326. return HighlightLayer;
  43327. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  43328. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  43329. /***/ }),
  43330. /***/ "./Layers/index.ts":
  43331. /*!*************************!*\
  43332. !*** ./Layers/index.ts ***!
  43333. \*************************/
  43334. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  43335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43336. "use strict";
  43337. __webpack_require__.r(__webpack_exports__);
  43338. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43340. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  43341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  43342. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  43343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  43344. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  43345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  43346. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  43347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  43348. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  43350. /***/ }),
  43351. /***/ "./Layers/layer.ts":
  43352. /*!*************************!*\
  43353. !*** ./Layers/layer.ts ***!
  43354. \*************************/
  43355. /*! exports provided: Layer */
  43356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43357. "use strict";
  43358. __webpack_require__.r(__webpack_exports__);
  43359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  43360. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43361. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43362. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43363. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43364. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43365. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43366. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43367. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43368. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43369. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  43370. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  43371. /**
  43372. * This represents a full screen 2d layer.
  43373. * This can be useful to display a picture in the background of your scene for instance.
  43374. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43375. */
  43376. var Layer = /** @class */ (function () {
  43377. /**
  43378. * Instantiates a new layer.
  43379. * This represents a full screen 2d layer.
  43380. * This can be useful to display a picture in the background of your scene for instance.
  43381. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43382. * @param name Define the name of the layer in the scene
  43383. * @param imgUrl Define the url of the texture to display in the layer
  43384. * @param scene Define the scene the layer belongs to
  43385. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  43386. * @param color Defines a color for the layer
  43387. */
  43388. function Layer(
  43389. /**
  43390. * Define the name of the layer.
  43391. */
  43392. name, imgUrl, scene, isBackground, color) {
  43393. this.name = name;
  43394. /**
  43395. * Define the scale of the layer in order to zoom in out of the texture.
  43396. */
  43397. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  43398. /**
  43399. * Define an offset for the layer in order to shift the texture.
  43400. */
  43401. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  43402. /**
  43403. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  43404. */
  43405. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  43406. /**
  43407. * Define a mask to restrict the layer to only some of the scene cameras.
  43408. */
  43409. this.layerMask = 0x0FFFFFFF;
  43410. /**
  43411. * Define the list of render target the layer is visible into.
  43412. */
  43413. this.renderTargetTextures = [];
  43414. /**
  43415. * Define if the layer is only used in renderTarget or if it also
  43416. * renders in the main frame buffer of the canvas.
  43417. */
  43418. this.renderOnlyInRenderTargetTextures = false;
  43419. this._vertexBuffers = {};
  43420. /**
  43421. * An event triggered when the layer is disposed.
  43422. */
  43423. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43424. /**
  43425. * An event triggered before rendering the scene
  43426. */
  43427. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43428. /**
  43429. * An event triggered after rendering the scene
  43430. */
  43431. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43432. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  43433. this.isBackground = isBackground === undefined ? true : isBackground;
  43434. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  43435. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  43436. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  43437. if (!layerComponent) {
  43438. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  43439. this._scene._addComponent(layerComponent);
  43440. }
  43441. this._scene.layers.push(this);
  43442. var engine = this._scene.getEngine();
  43443. // VBO
  43444. var vertices = [];
  43445. vertices.push(1, 1);
  43446. vertices.push(-1, 1);
  43447. vertices.push(-1, -1);
  43448. vertices.push(1, -1);
  43449. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  43450. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  43451. this._createIndexBuffer();
  43452. // Effects
  43453. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  43454. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  43455. }
  43456. Object.defineProperty(Layer.prototype, "onDispose", {
  43457. /**
  43458. * Back compatibility with callback before the onDisposeObservable existed.
  43459. * The set callback will be triggered when the layer has been disposed.
  43460. */
  43461. set: function (callback) {
  43462. if (this._onDisposeObserver) {
  43463. this.onDisposeObservable.remove(this._onDisposeObserver);
  43464. }
  43465. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  43466. },
  43467. enumerable: true,
  43468. configurable: true
  43469. });
  43470. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  43471. /**
  43472. * Back compatibility with callback before the onBeforeRenderObservable existed.
  43473. * The set callback will be triggered just before rendering the layer.
  43474. */
  43475. set: function (callback) {
  43476. if (this._onBeforeRenderObserver) {
  43477. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  43478. }
  43479. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  43480. },
  43481. enumerable: true,
  43482. configurable: true
  43483. });
  43484. Object.defineProperty(Layer.prototype, "onAfterRender", {
  43485. /**
  43486. * Back compatibility with callback before the onAfterRenderObservable existed.
  43487. * The set callback will be triggered just after rendering the layer.
  43488. */
  43489. set: function (callback) {
  43490. if (this._onAfterRenderObserver) {
  43491. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  43492. }
  43493. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  43494. },
  43495. enumerable: true,
  43496. configurable: true
  43497. });
  43498. Layer.prototype._createIndexBuffer = function () {
  43499. var engine = this._scene.getEngine();
  43500. // Indices
  43501. var indices = [];
  43502. indices.push(0);
  43503. indices.push(1);
  43504. indices.push(2);
  43505. indices.push(0);
  43506. indices.push(2);
  43507. indices.push(3);
  43508. this._indexBuffer = engine.createIndexBuffer(indices);
  43509. };
  43510. /** @hidden */
  43511. Layer.prototype._rebuild = function () {
  43512. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  43513. if (vb) {
  43514. vb._rebuild();
  43515. }
  43516. this._createIndexBuffer();
  43517. };
  43518. /**
  43519. * Renders the layer in the scene.
  43520. */
  43521. Layer.prototype.render = function () {
  43522. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  43523. // Check
  43524. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  43525. return;
  43526. }
  43527. var engine = this._scene.getEngine();
  43528. this.onBeforeRenderObservable.notifyObservers(this);
  43529. // Render
  43530. engine.enableEffect(currentEffect);
  43531. engine.setState(false);
  43532. // Texture
  43533. currentEffect.setTexture("textureSampler", this.texture);
  43534. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  43535. // Color
  43536. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  43537. // Scale / offset
  43538. currentEffect.setVector2("offset", this.offset);
  43539. currentEffect.setVector2("scale", this.scale);
  43540. // VBOs
  43541. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  43542. // Draw order
  43543. if (!this.alphaTest) {
  43544. engine.setAlphaMode(this.alphaBlendingMode);
  43545. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  43546. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  43547. }
  43548. else {
  43549. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  43550. }
  43551. this.onAfterRenderObservable.notifyObservers(this);
  43552. };
  43553. /**
  43554. * Disposes and releases the associated ressources.
  43555. */
  43556. Layer.prototype.dispose = function () {
  43557. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  43558. if (vertexBuffer) {
  43559. vertexBuffer.dispose();
  43560. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  43561. }
  43562. if (this._indexBuffer) {
  43563. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43564. this._indexBuffer = null;
  43565. }
  43566. if (this.texture) {
  43567. this.texture.dispose();
  43568. this.texture = null;
  43569. }
  43570. // Clean RTT list
  43571. this.renderTargetTextures = [];
  43572. // Remove from scene
  43573. var index = this._scene.layers.indexOf(this);
  43574. this._scene.layers.splice(index, 1);
  43575. // Callback
  43576. this.onDisposeObservable.notifyObservers(this);
  43577. this.onDisposeObservable.clear();
  43578. this.onAfterRenderObservable.clear();
  43579. this.onBeforeRenderObservable.clear();
  43580. };
  43581. return Layer;
  43582. }());
  43583. /***/ }),
  43584. /***/ "./Layers/layerSceneComponent.ts":
  43585. /*!***************************************!*\
  43586. !*** ./Layers/layerSceneComponent.ts ***!
  43587. \***************************************/
  43588. /*! exports provided: LayerSceneComponent */
  43589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43590. "use strict";
  43591. __webpack_require__.r(__webpack_exports__);
  43592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  43593. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43594. /**
  43595. * Defines the layer scene component responsible to manage any layers
  43596. * in a given scene.
  43597. */
  43598. var LayerSceneComponent = /** @class */ (function () {
  43599. /**
  43600. * Creates a new instance of the component for the given scene
  43601. * @param scene Defines the scene to register the component in
  43602. */
  43603. function LayerSceneComponent(scene) {
  43604. /**
  43605. * The component name helpfull to identify the component in the list of scene components.
  43606. */
  43607. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  43608. this.scene = scene;
  43609. this._engine = scene.getEngine();
  43610. scene.layers = new Array();
  43611. }
  43612. /**
  43613. * Registers the component in a given scene
  43614. */
  43615. LayerSceneComponent.prototype.register = function () {
  43616. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  43617. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  43618. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  43619. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  43620. };
  43621. /**
  43622. * Rebuilds the elements related to this component in case of
  43623. * context lost for instance.
  43624. */
  43625. LayerSceneComponent.prototype.rebuild = function () {
  43626. var layers = this.scene.layers;
  43627. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  43628. var layer = layers_1[_i];
  43629. layer._rebuild();
  43630. }
  43631. };
  43632. /**
  43633. * Disposes the component and the associated ressources.
  43634. */
  43635. LayerSceneComponent.prototype.dispose = function () {
  43636. var layers = this.scene.layers;
  43637. while (layers.length) {
  43638. layers[0].dispose();
  43639. }
  43640. };
  43641. LayerSceneComponent.prototype._draw = function (predicate) {
  43642. var layers = this.scene.layers;
  43643. if (layers.length) {
  43644. this._engine.setDepthBuffer(false);
  43645. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  43646. var layer = layers_2[_i];
  43647. if (predicate(layer)) {
  43648. layer.render();
  43649. }
  43650. }
  43651. this._engine.setDepthBuffer(true);
  43652. }
  43653. };
  43654. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  43655. return !layer.renderOnlyInRenderTargetTextures &&
  43656. layer.isBackground === isBackground &&
  43657. ((layer.layerMask & cameraLayerMask) !== 0);
  43658. };
  43659. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  43660. var _this = this;
  43661. this._draw(function (layer) {
  43662. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  43663. });
  43664. };
  43665. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  43666. var _this = this;
  43667. this._draw(function (layer) {
  43668. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  43669. });
  43670. };
  43671. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  43672. return (layer.renderTargetTextures.length > 0) &&
  43673. layer.isBackground === isBackground &&
  43674. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  43675. ((layer.layerMask & cameraLayerMask) !== 0);
  43676. };
  43677. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  43678. var _this = this;
  43679. this._draw(function (layer) {
  43680. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  43681. });
  43682. };
  43683. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  43684. var _this = this;
  43685. this._draw(function (layer) {
  43686. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  43687. });
  43688. };
  43689. return LayerSceneComponent;
  43690. }());
  43691. /***/ }),
  43692. /***/ "./Legacy/legacy.ts":
  43693. /*!**************************!*\
  43694. !*** ./Legacy/legacy.ts ***!
  43695. \**************************/
  43696. /*! exports provided: Debug, AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, 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, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  43697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43698. "use strict";
  43699. __webpack_require__.r(__webpack_exports__);
  43700. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  43701. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  43702. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  43703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  43704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  43705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  43706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  43707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  43708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  43709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  43710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  43711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  43712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  43713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  43714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  43715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  43716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  43717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  43718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  43719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  43720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  43721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  43722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  43723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  43724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  43725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  43726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  43727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  43728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  43729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  43730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  43731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  43732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  43733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  43734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  43735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  43736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  43737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  43738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  43739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  43740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  43741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  43742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  43743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  43744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  43745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  43746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  43747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  43748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  43749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  43750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  43751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  43752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  43753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  43754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  43755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  43756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  43757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  43758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  43759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  43760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  43761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  43762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  43763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  43764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  43765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  43766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  43767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  43768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  43769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  43770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  43771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  43772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  43773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  43774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  43775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  43776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  43777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  43778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  43779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  43780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  43781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  43782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  43783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  43784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  43785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  43786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  43787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  43788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  43789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  43790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  43791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  43792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  43793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  43794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  43795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  43796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  43797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  43798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  43799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  43800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  43801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  43802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  43803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  43804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  43805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  43806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  43807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  43808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  43809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  43810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  43811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  43812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  43813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  43814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  43815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  43816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  43817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  43818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  43819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  43820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  43821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  43822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  43823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  43824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  43825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  43826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  43827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  43828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  43829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  43830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  43831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  43832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  43833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  43834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  43835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  43836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  43837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  43838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  43839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  43840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  43841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  43842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  43843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  43844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  43845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  43846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  43847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  43848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  43849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  43851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  43852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  43853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  43854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  43855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  43857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  43858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  43859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  43860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  43861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  43862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  43863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  43864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  43865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  43866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  43867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  43868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  43869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  43870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  43871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  43872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  43873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  43874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  43875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  43876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  43877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  43878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  43879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  43880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  43881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  43882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  43883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  43884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  43885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  43886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  43887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  43888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  43889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  43890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  43891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  43892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  43893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  43894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  43895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  43896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  43897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  43898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  43899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  43900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  43901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  43902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  43903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  43904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  43905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  43906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  43907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  43908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  43909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  43910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  43911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  43912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  43913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  43914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  43915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  43916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  43917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  43918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  43919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  43920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  43921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  43922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  43923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  43924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  43925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  43926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  43927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  43928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  43929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  43930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  43931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  43932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  43933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  43934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  43935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  43936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  43937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  43938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  43939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  43940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  43941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  43942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  43943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  43944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  43945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  43946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  43947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  43948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  43949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  43950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  43951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  43952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  43953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  43954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  43955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  43956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  43957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  43958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  43959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  43960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  43961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  43962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  43963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  43964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  43965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  43966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  43967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  43968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  43969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  43970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  43971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  43972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  43973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  43974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  43975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  43976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  43977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  43978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  43979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  43980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  43981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  43982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  43983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  43984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  43985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  43986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  43987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  43988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  43989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  43990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  43991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  43992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  43993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  43994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  43995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  43996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  43997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  43998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  43999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  44000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  44001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  44002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  44003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  44004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  44005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  44006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  44007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  44008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  44009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  44010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  44011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  44012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  44013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  44014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  44015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  44016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  44017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  44018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  44019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  44020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  44021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  44022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  44023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  44024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  44025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  44026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  44027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  44028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  44029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  44030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  44031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  44032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  44033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  44034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  44035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  44036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  44037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  44038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  44039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  44040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  44041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  44042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  44043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  44044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  44045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  44046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  44047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  44048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  44049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  44050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  44051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  44052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  44053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  44054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  44055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  44056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  44057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  44058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  44059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  44060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  44061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  44062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  44063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  44064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  44065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  44066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  44067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  44068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  44069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  44070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  44071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  44072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  44073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  44074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  44075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  44076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  44077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  44078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  44079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  44080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  44081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  44082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  44083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  44084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  44085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  44086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  44087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  44088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  44089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  44090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  44091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  44092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  44093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  44094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  44095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  44096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  44097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  44098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  44099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  44100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  44101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  44102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  44103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  44104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  44105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  44106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  44107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  44108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  44109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  44110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  44111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  44112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  44113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  44114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  44115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  44116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  44117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  44118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  44119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  44120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  44121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  44122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  44123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  44124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  44125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  44126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  44127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  44128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  44129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  44130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  44131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  44132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  44133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  44134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  44135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  44136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  44137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  44138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  44139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  44140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  44141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  44142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  44143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  44144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  44145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  44146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  44147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  44148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  44149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  44150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  44151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  44152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  44153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  44154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  44155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  44156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  44157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  44158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  44159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  44160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  44161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  44162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  44163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  44165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  44166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  44167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  44168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  44169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  44170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  44171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  44172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  44173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  44174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  44175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  44176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  44177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  44178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  44179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  44180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  44181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  44182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  44183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  44184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  44185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  44186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  44187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  44188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  44189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  44190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  44191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  44192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  44193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  44194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  44195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  44196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  44197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  44198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  44199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  44200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  44201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  44202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  44203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  44204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  44205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  44206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  44207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  44208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  44209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  44210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  44211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  44212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  44213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  44214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  44215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  44216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  44217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  44218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  44219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  44220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  44221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  44222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  44223. /**
  44224. * Legacy support, defining window.BABYLON (global variable).
  44225. *
  44226. * This is the entry point for the UMD module.
  44227. * The entry point for a future ESM package should be index.ts
  44228. */
  44229. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  44230. if (typeof globalObject !== "undefined") {
  44231. globalObject.BABYLON = BABYLON;
  44232. globalObject.BABYLON = globalObject.BABYLON || {};
  44233. var BABYLON = globalObject.BABYLON;
  44234. BABYLON.Debug = BABYLON.Debug || {};
  44235. var keys = [];
  44236. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  44237. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  44238. keys.push(key);
  44239. }
  44240. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  44241. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  44242. }
  44243. }
  44244. var Debug = {
  44245. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  44246. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  44247. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  44248. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  44249. };
  44250. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  44251. /***/ }),
  44252. /***/ "./LensFlares/index.ts":
  44253. /*!*****************************!*\
  44254. !*** ./LensFlares/index.ts ***!
  44255. \*****************************/
  44256. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  44257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44258. "use strict";
  44259. __webpack_require__.r(__webpack_exports__);
  44260. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44262. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  44264. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  44265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  44266. /***/ }),
  44267. /***/ "./LensFlares/lensFlare.ts":
  44268. /*!*********************************!*\
  44269. !*** ./LensFlares/lensFlare.ts ***!
  44270. \*********************************/
  44271. /*! exports provided: LensFlare */
  44272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44273. "use strict";
  44274. __webpack_require__.r(__webpack_exports__);
  44275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  44276. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44277. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44278. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44279. /**
  44280. * This represents one of the lens effect in a `lensFlareSystem`.
  44281. * It controls one of the indiviual texture used in the effect.
  44282. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44283. */
  44284. var LensFlare = /** @class */ (function () {
  44285. /**
  44286. * Instantiates a new Lens Flare.
  44287. * This represents one of the lens effect in a `lensFlareSystem`.
  44288. * It controls one of the indiviual texture used in the effect.
  44289. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44290. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44291. * @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.
  44292. * @param color Define the lens color
  44293. * @param imgUrl Define the lens texture url
  44294. * @param system Define the `lensFlareSystem` this flare is part of
  44295. */
  44296. function LensFlare(
  44297. /**
  44298. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44299. */
  44300. size,
  44301. /**
  44302. * 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.
  44303. */
  44304. position, color, imgUrl, system) {
  44305. this.size = size;
  44306. this.position = position;
  44307. /**
  44308. * Define the alpha mode to render this particular lens.
  44309. */
  44310. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  44311. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  44312. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  44313. this._system = system;
  44314. system.lensFlares.push(this);
  44315. }
  44316. /**
  44317. * Creates a new Lens Flare.
  44318. * This represents one of the lens effect in a `lensFlareSystem`.
  44319. * It controls one of the indiviual texture used in the effect.
  44320. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44321. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44322. * @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.
  44323. * @param color Define the lens color
  44324. * @param imgUrl Define the lens texture url
  44325. * @param system Define the `lensFlareSystem` this flare is part of
  44326. * @returns The newly created Lens Flare
  44327. */
  44328. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  44329. return new LensFlare(size, position, color, imgUrl, system);
  44330. };
  44331. /**
  44332. * Dispose and release the lens flare with its associated resources.
  44333. */
  44334. LensFlare.prototype.dispose = function () {
  44335. if (this.texture) {
  44336. this.texture.dispose();
  44337. }
  44338. // Remove from scene
  44339. var index = this._system.lensFlares.indexOf(this);
  44340. this._system.lensFlares.splice(index, 1);
  44341. };
  44342. return LensFlare;
  44343. }());
  44344. /***/ }),
  44345. /***/ "./LensFlares/lensFlareSystem.ts":
  44346. /*!***************************************!*\
  44347. !*** ./LensFlares/lensFlareSystem.ts ***!
  44348. \***************************************/
  44349. /*! exports provided: LensFlareSystem */
  44350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44351. "use strict";
  44352. __webpack_require__.r(__webpack_exports__);
  44353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  44354. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44355. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44356. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  44357. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  44358. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44359. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  44360. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44361. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44362. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44363. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  44364. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  44365. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  44366. /**
  44367. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44368. * It is usually composed of several `lensFlare`.
  44369. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44370. */
  44371. var LensFlareSystem = /** @class */ (function () {
  44372. /**
  44373. * Instantiates a lens flare system.
  44374. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44375. * It is usually composed of several `lensFlare`.
  44376. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44377. * @param name Define the name of the lens flare system in the scene
  44378. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44379. * @param scene Define the scene the lens flare system belongs to
  44380. */
  44381. function LensFlareSystem(
  44382. /**
  44383. * Define the name of the lens flare system
  44384. */
  44385. name, emitter, scene) {
  44386. this.name = name;
  44387. /**
  44388. * List of lens flares used in this system.
  44389. */
  44390. this.lensFlares = new Array();
  44391. /**
  44392. * Define a limit from the border the lens flare can be visible.
  44393. */
  44394. this.borderLimit = 300;
  44395. /**
  44396. * Define a viewport border we do not want to see the lens flare in.
  44397. */
  44398. this.viewportBorder = 0;
  44399. /**
  44400. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44401. */
  44402. this.layerMask = 0x0FFFFFFF;
  44403. this._vertexBuffers = {};
  44404. this._isEnabled = true;
  44405. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  44406. LensFlareSystem._SceneComponentInitialization(this._scene);
  44407. this._emitter = emitter;
  44408. this.id = name;
  44409. scene.lensFlareSystems.push(this);
  44410. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  44411. var engine = scene.getEngine();
  44412. // VBO
  44413. var vertices = [];
  44414. vertices.push(1, 1);
  44415. vertices.push(-1, 1);
  44416. vertices.push(-1, -1);
  44417. vertices.push(1, -1);
  44418. 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);
  44419. // Indices
  44420. var indices = [];
  44421. indices.push(0);
  44422. indices.push(1);
  44423. indices.push(2);
  44424. indices.push(0);
  44425. indices.push(2);
  44426. indices.push(3);
  44427. this._indexBuffer = engine.createIndexBuffer(indices);
  44428. // Effects
  44429. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  44430. }
  44431. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  44432. /**
  44433. * Define if the lens flare system is enabled.
  44434. */
  44435. get: function () {
  44436. return this._isEnabled;
  44437. },
  44438. set: function (value) {
  44439. this._isEnabled = value;
  44440. },
  44441. enumerable: true,
  44442. configurable: true
  44443. });
  44444. /**
  44445. * Get the scene the effects belongs to.
  44446. * @returns the scene holding the lens flare system
  44447. */
  44448. LensFlareSystem.prototype.getScene = function () {
  44449. return this._scene;
  44450. };
  44451. /**
  44452. * Get the emitter of the lens flare system.
  44453. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44454. * @returns the emitter of the lens flare system
  44455. */
  44456. LensFlareSystem.prototype.getEmitter = function () {
  44457. return this._emitter;
  44458. };
  44459. /**
  44460. * Set the emitter of the lens flare system.
  44461. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44462. * @param newEmitter Define the new emitter of the system
  44463. */
  44464. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  44465. this._emitter = newEmitter;
  44466. };
  44467. /**
  44468. * Get the lens flare system emitter position.
  44469. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  44470. * @returns the position
  44471. */
  44472. LensFlareSystem.prototype.getEmitterPosition = function () {
  44473. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  44474. };
  44475. /**
  44476. * @hidden
  44477. */
  44478. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  44479. var position = this.getEmitterPosition();
  44480. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  44481. this._positionX = position.x;
  44482. this._positionY = position.y;
  44483. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  44484. if (this.viewportBorder > 0) {
  44485. globalViewport.x -= this.viewportBorder;
  44486. globalViewport.y -= this.viewportBorder;
  44487. globalViewport.width += this.viewportBorder * 2;
  44488. globalViewport.height += this.viewportBorder * 2;
  44489. position.x += this.viewportBorder;
  44490. position.y += this.viewportBorder;
  44491. this._positionX += this.viewportBorder;
  44492. this._positionY += this.viewportBorder;
  44493. }
  44494. if (position.z > 0) {
  44495. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  44496. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  44497. return true;
  44498. }
  44499. }
  44500. return true;
  44501. }
  44502. return false;
  44503. };
  44504. /** @hidden */
  44505. LensFlareSystem.prototype._isVisible = function () {
  44506. if (!this._isEnabled || !this._scene.activeCamera) {
  44507. return false;
  44508. }
  44509. var emitterPosition = this.getEmitterPosition();
  44510. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  44511. var distance = direction.length();
  44512. direction.normalize();
  44513. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  44514. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  44515. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  44516. };
  44517. /**
  44518. * @hidden
  44519. */
  44520. LensFlareSystem.prototype.render = function () {
  44521. if (!this._effect.isReady() || !this._scene.activeCamera) {
  44522. return false;
  44523. }
  44524. var engine = this._scene.getEngine();
  44525. var viewport = this._scene.activeCamera.viewport;
  44526. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  44527. // Position
  44528. if (!this.computeEffectivePosition(globalViewport)) {
  44529. return false;
  44530. }
  44531. // Visibility
  44532. if (!this._isVisible()) {
  44533. return false;
  44534. }
  44535. // Intensity
  44536. var awayX;
  44537. var awayY;
  44538. if (this._positionX < this.borderLimit + globalViewport.x) {
  44539. awayX = this.borderLimit + globalViewport.x - this._positionX;
  44540. }
  44541. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  44542. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  44543. }
  44544. else {
  44545. awayX = 0;
  44546. }
  44547. if (this._positionY < this.borderLimit + globalViewport.y) {
  44548. awayY = this.borderLimit + globalViewport.y - this._positionY;
  44549. }
  44550. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  44551. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  44552. }
  44553. else {
  44554. awayY = 0;
  44555. }
  44556. var away = (awayX > awayY) ? awayX : awayY;
  44557. away -= this.viewportBorder;
  44558. if (away > this.borderLimit) {
  44559. away = this.borderLimit;
  44560. }
  44561. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  44562. if (intensity < 0) {
  44563. return false;
  44564. }
  44565. if (intensity > 1.0) {
  44566. intensity = 1.0;
  44567. }
  44568. if (this.viewportBorder > 0) {
  44569. globalViewport.x += this.viewportBorder;
  44570. globalViewport.y += this.viewportBorder;
  44571. globalViewport.width -= this.viewportBorder * 2;
  44572. globalViewport.height -= this.viewportBorder * 2;
  44573. this._positionX -= this.viewportBorder;
  44574. this._positionY -= this.viewportBorder;
  44575. }
  44576. // Position
  44577. var centerX = globalViewport.x + globalViewport.width / 2;
  44578. var centerY = globalViewport.y + globalViewport.height / 2;
  44579. var distX = centerX - this._positionX;
  44580. var distY = centerY - this._positionY;
  44581. // Effects
  44582. engine.enableEffect(this._effect);
  44583. engine.setState(false);
  44584. engine.setDepthBuffer(false);
  44585. // VBOs
  44586. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  44587. // Flares
  44588. for (var index = 0; index < this.lensFlares.length; index++) {
  44589. var flare = this.lensFlares[index];
  44590. engine.setAlphaMode(flare.alphaMode);
  44591. var x = centerX - (distX * flare.position);
  44592. var y = centerY - (distY * flare.position);
  44593. var cw = flare.size;
  44594. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  44595. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  44596. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  44597. 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);
  44598. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  44599. // Texture
  44600. this._effect.setTexture("textureSampler", flare.texture);
  44601. // Color
  44602. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  44603. // Draw order
  44604. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44605. }
  44606. engine.setDepthBuffer(true);
  44607. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44608. return true;
  44609. };
  44610. /**
  44611. * Dispose and release the lens flare with its associated resources.
  44612. */
  44613. LensFlareSystem.prototype.dispose = function () {
  44614. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  44615. if (vertexBuffer) {
  44616. vertexBuffer.dispose();
  44617. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  44618. }
  44619. if (this._indexBuffer) {
  44620. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44621. this._indexBuffer = null;
  44622. }
  44623. while (this.lensFlares.length) {
  44624. this.lensFlares[0].dispose();
  44625. }
  44626. // Remove from scene
  44627. var index = this._scene.lensFlareSystems.indexOf(this);
  44628. this._scene.lensFlareSystems.splice(index, 1);
  44629. };
  44630. /**
  44631. * Parse a lens flare system from a JSON repressentation
  44632. * @param parsedLensFlareSystem Define the JSON to parse
  44633. * @param scene Define the scene the parsed system should be instantiated in
  44634. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44635. * @returns the parsed system
  44636. */
  44637. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  44638. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  44639. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  44640. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  44641. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  44642. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  44643. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  44644. var parsedFlare = parsedLensFlareSystem.flares[index];
  44645. _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);
  44646. }
  44647. return lensFlareSystem;
  44648. };
  44649. /**
  44650. * Serialize the current Lens Flare System into a JSON representation.
  44651. * @returns the serialized JSON
  44652. */
  44653. LensFlareSystem.prototype.serialize = function () {
  44654. var serializationObject = {};
  44655. serializationObject.id = this.id;
  44656. serializationObject.name = this.name;
  44657. serializationObject.emitterId = this.getEmitter().id;
  44658. serializationObject.borderLimit = this.borderLimit;
  44659. serializationObject.flares = [];
  44660. for (var index = 0; index < this.lensFlares.length; index++) {
  44661. var flare = this.lensFlares[index];
  44662. serializationObject.flares.push({
  44663. size: flare.size,
  44664. position: flare.position,
  44665. color: flare.color.asArray(),
  44666. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  44667. });
  44668. }
  44669. return serializationObject;
  44670. };
  44671. /** @hidden */
  44672. LensFlareSystem._SceneComponentInitialization = function (_) {
  44673. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  44674. };
  44675. return LensFlareSystem;
  44676. }());
  44677. /***/ }),
  44678. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  44679. /*!*****************************************************!*\
  44680. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  44681. \*****************************************************/
  44682. /*! exports provided: LensFlareSystemSceneComponent */
  44683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44684. "use strict";
  44685. __webpack_require__.r(__webpack_exports__);
  44686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  44687. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44688. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44689. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  44690. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44691. // Adds the parser to the scene parsers.
  44692. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  44693. // Lens flares
  44694. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  44695. if (!container.lensFlareSystems) {
  44696. container.lensFlareSystems = new Array();
  44697. }
  44698. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  44699. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  44700. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  44701. container.lensFlareSystems.push(lf);
  44702. }
  44703. }
  44704. });
  44705. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  44706. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44707. if (this.lensFlareSystems[index].name === name) {
  44708. return this.lensFlareSystems[index];
  44709. }
  44710. }
  44711. return null;
  44712. };
  44713. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  44714. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44715. if (this.lensFlareSystems[index].id === id) {
  44716. return this.lensFlareSystems[index];
  44717. }
  44718. }
  44719. return null;
  44720. };
  44721. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  44722. var index = this.lensFlareSystems.indexOf(toRemove);
  44723. if (index !== -1) {
  44724. this.lensFlareSystems.splice(index, 1);
  44725. }
  44726. return index;
  44727. };
  44728. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  44729. this.lensFlareSystems.push(newLensFlareSystem);
  44730. };
  44731. /**
  44732. * Defines the lens flare scene component responsible to manage any lens flares
  44733. * in a given scene.
  44734. */
  44735. var LensFlareSystemSceneComponent = /** @class */ (function () {
  44736. /**
  44737. * Creates a new instance of the component for the given scene
  44738. * @param scene Defines the scene to register the component in
  44739. */
  44740. function LensFlareSystemSceneComponent(scene) {
  44741. /**
  44742. * The component name helpfull to identify the component in the list of scene components.
  44743. */
  44744. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  44745. this.scene = scene;
  44746. scene.lensFlareSystems = new Array();
  44747. }
  44748. /**
  44749. * Registers the component in a given scene
  44750. */
  44751. LensFlareSystemSceneComponent.prototype.register = function () {
  44752. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  44753. };
  44754. /**
  44755. * Rebuilds the elements related to this component in case of
  44756. * context lost for instance.
  44757. */
  44758. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  44759. // Nothing to do for lens flare
  44760. };
  44761. /**
  44762. * Adds all the element from the container to the scene
  44763. * @param container the container holding the elements
  44764. */
  44765. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  44766. var _this = this;
  44767. if (!container.lensFlareSystems) {
  44768. return;
  44769. }
  44770. container.lensFlareSystems.forEach(function (o) {
  44771. _this.scene.addLensFlareSystem(o);
  44772. });
  44773. };
  44774. /**
  44775. * Removes all the elements in the container from the scene
  44776. * @param container contains the elements to remove
  44777. */
  44778. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  44779. var _this = this;
  44780. if (!container.lensFlareSystems) {
  44781. return;
  44782. }
  44783. container.lensFlareSystems.forEach(function (o) {
  44784. _this.scene.removeLensFlareSystem(o);
  44785. });
  44786. };
  44787. /**
  44788. * Serializes the component data to the specified json object
  44789. * @param serializationObject The object to serialize to
  44790. */
  44791. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  44792. // Lens flares
  44793. serializationObject.lensFlareSystems = [];
  44794. var lensFlareSystems = this.scene.lensFlareSystems;
  44795. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  44796. var lensFlareSystem = lensFlareSystems_1[_i];
  44797. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  44798. }
  44799. };
  44800. /**
  44801. * Disposes the component and the associated ressources.
  44802. */
  44803. LensFlareSystemSceneComponent.prototype.dispose = function () {
  44804. var lensFlareSystems = this.scene.lensFlareSystems;
  44805. while (lensFlareSystems.length) {
  44806. lensFlareSystems[0].dispose();
  44807. }
  44808. };
  44809. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  44810. // Lens flares
  44811. if (this.scene.lensFlaresEnabled) {
  44812. var lensFlareSystems = this.scene.lensFlareSystems;
  44813. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44814. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  44815. var lensFlareSystem = lensFlareSystems_2[_i];
  44816. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  44817. lensFlareSystem.render();
  44818. }
  44819. }
  44820. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44821. }
  44822. };
  44823. return LensFlareSystemSceneComponent;
  44824. }());
  44825. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  44826. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  44827. if (!component) {
  44828. component = new LensFlareSystemSceneComponent(scene);
  44829. scene._addComponent(component);
  44830. }
  44831. };
  44832. /***/ }),
  44833. /***/ "./Lights/Shadows/index.ts":
  44834. /*!*********************************!*\
  44835. !*** ./Lights/Shadows/index.ts ***!
  44836. \*********************************/
  44837. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  44838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44839. "use strict";
  44840. __webpack_require__.r(__webpack_exports__);
  44841. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44843. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  44844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  44845. /***/ }),
  44846. /***/ "./Lights/Shadows/shadowGenerator.ts":
  44847. /*!*******************************************!*\
  44848. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  44849. \*******************************************/
  44850. /*! exports provided: ShadowGenerator */
  44851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44852. "use strict";
  44853. __webpack_require__.r(__webpack_exports__);
  44854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  44855. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44856. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  44857. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  44858. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  44859. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  44860. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  44861. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44862. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  44863. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  44864. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  44865. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  44866. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  44867. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  44868. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  44869. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  44870. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  44871. /**
  44872. * Default implementation IShadowGenerator.
  44873. * This is the main object responsible of generating shadows in the framework.
  44874. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44875. */
  44876. var ShadowGenerator = /** @class */ (function () {
  44877. /**
  44878. * Creates a ShadowGenerator object.
  44879. * A ShadowGenerator is the required tool to use the shadows.
  44880. * Each light casting shadows needs to use its own ShadowGenerator.
  44881. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44882. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44883. * @param light The light object generating the shadows.
  44884. * @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.
  44885. */
  44886. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  44887. /**
  44888. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  44889. */
  44890. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44891. /**
  44892. * Observable triggered before a mesh is rendered in the shadow map.
  44893. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  44894. */
  44895. this.onBeforeShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44896. this._bias = 0.00005;
  44897. this._normalBias = 0;
  44898. this._blurBoxOffset = 1;
  44899. this._blurScale = 2;
  44900. this._blurKernel = 1;
  44901. this._useKernelBlur = false;
  44902. this._filter = ShadowGenerator.FILTER_NONE;
  44903. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  44904. this._contactHardeningLightSizeUVRatio = 0.1;
  44905. this._darkness = 0;
  44906. this._transparencyShadow = false;
  44907. /**
  44908. * Controls the extent to which the shadows fade out at the edge of the frustum
  44909. * Used only by directionals and spots
  44910. */
  44911. this.frustumEdgeFalloff = 0;
  44912. /**
  44913. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44914. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44915. * It might on the other hand introduce peter panning.
  44916. */
  44917. this.forceBackFacesOnly = false;
  44918. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  44919. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44920. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44921. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44922. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44923. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44924. this._currentFaceIndex = 0;
  44925. this._currentFaceIndexCache = 0;
  44926. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  44927. this._mapSize = mapSize;
  44928. this._light = light;
  44929. this._scene = light.getScene();
  44930. light._shadowGenerator = this;
  44931. ShadowGenerator._SceneComponentInitialization(this._scene);
  44932. // Texture type fallback from float to int if not supported.
  44933. var caps = this._scene.getEngine().getCaps();
  44934. if (!usefulFloatFirst) {
  44935. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44936. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44937. }
  44938. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44939. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44940. }
  44941. else {
  44942. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44943. }
  44944. }
  44945. else {
  44946. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44947. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44948. }
  44949. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44950. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44951. }
  44952. else {
  44953. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44954. }
  44955. }
  44956. this._initializeGenerator();
  44957. this._applyFilterValues();
  44958. }
  44959. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  44960. /**
  44961. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44962. */
  44963. get: function () {
  44964. return this._bias;
  44965. },
  44966. /**
  44967. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44968. */
  44969. set: function (bias) {
  44970. this._bias = bias;
  44971. },
  44972. enumerable: true,
  44973. configurable: true
  44974. });
  44975. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  44976. /**
  44977. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44978. */
  44979. get: function () {
  44980. return this._normalBias;
  44981. },
  44982. /**
  44983. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44984. */
  44985. set: function (normalBias) {
  44986. this._normalBias = normalBias;
  44987. },
  44988. enumerable: true,
  44989. configurable: true
  44990. });
  44991. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  44992. /**
  44993. * Gets the blur box offset: offset applied during the blur pass.
  44994. * Only useful if useKernelBlur = false
  44995. */
  44996. get: function () {
  44997. return this._blurBoxOffset;
  44998. },
  44999. /**
  45000. * Sets the blur box offset: offset applied during the blur pass.
  45001. * Only useful if useKernelBlur = false
  45002. */
  45003. set: function (value) {
  45004. if (this._blurBoxOffset === value) {
  45005. return;
  45006. }
  45007. this._blurBoxOffset = value;
  45008. this._disposeBlurPostProcesses();
  45009. },
  45010. enumerable: true,
  45011. configurable: true
  45012. });
  45013. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  45014. /**
  45015. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  45016. * 2 means half of the size.
  45017. */
  45018. get: function () {
  45019. return this._blurScale;
  45020. },
  45021. /**
  45022. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  45023. * 2 means half of the size.
  45024. */
  45025. set: function (value) {
  45026. if (this._blurScale === value) {
  45027. return;
  45028. }
  45029. this._blurScale = value;
  45030. this._disposeBlurPostProcesses();
  45031. },
  45032. enumerable: true,
  45033. configurable: true
  45034. });
  45035. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  45036. /**
  45037. * Gets the blur kernel: kernel size of the blur pass.
  45038. * Only useful if useKernelBlur = true
  45039. */
  45040. get: function () {
  45041. return this._blurKernel;
  45042. },
  45043. /**
  45044. * Sets the blur kernel: kernel size of the blur pass.
  45045. * Only useful if useKernelBlur = true
  45046. */
  45047. set: function (value) {
  45048. if (this._blurKernel === value) {
  45049. return;
  45050. }
  45051. this._blurKernel = value;
  45052. this._disposeBlurPostProcesses();
  45053. },
  45054. enumerable: true,
  45055. configurable: true
  45056. });
  45057. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  45058. /**
  45059. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  45060. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45061. */
  45062. get: function () {
  45063. return this._useKernelBlur;
  45064. },
  45065. /**
  45066. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  45067. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45068. */
  45069. set: function (value) {
  45070. if (this._useKernelBlur === value) {
  45071. return;
  45072. }
  45073. this._useKernelBlur = value;
  45074. this._disposeBlurPostProcesses();
  45075. },
  45076. enumerable: true,
  45077. configurable: true
  45078. });
  45079. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  45080. /**
  45081. * Gets the depth scale used in ESM mode.
  45082. */
  45083. get: function () {
  45084. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  45085. },
  45086. /**
  45087. * Sets the depth scale used in ESM mode.
  45088. * This can override the scale stored on the light.
  45089. */
  45090. set: function (value) {
  45091. this._depthScale = value;
  45092. },
  45093. enumerable: true,
  45094. configurable: true
  45095. });
  45096. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  45097. /**
  45098. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  45099. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45100. */
  45101. get: function () {
  45102. return this._filter;
  45103. },
  45104. /**
  45105. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  45106. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45107. */
  45108. set: function (value) {
  45109. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  45110. if (this._light.needCube()) {
  45111. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45112. this.useExponentialShadowMap = true;
  45113. return;
  45114. }
  45115. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45116. this.useCloseExponentialShadowMap = true;
  45117. return;
  45118. }
  45119. // PCF on cubemap would also be expensive
  45120. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45121. this.usePoissonSampling = true;
  45122. return;
  45123. }
  45124. }
  45125. // Weblg1 fallback for PCF.
  45126. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45127. if (this._scene.getEngine().webGLVersion === 1) {
  45128. this.usePoissonSampling = true;
  45129. return;
  45130. }
  45131. }
  45132. if (this._filter === value) {
  45133. return;
  45134. }
  45135. this._filter = value;
  45136. this._disposeBlurPostProcesses();
  45137. this._applyFilterValues();
  45138. this._light._markMeshesAsLightDirty();
  45139. },
  45140. enumerable: true,
  45141. configurable: true
  45142. });
  45143. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  45144. /**
  45145. * Gets if the current filter is set to Poisson Sampling.
  45146. */
  45147. get: function () {
  45148. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  45149. },
  45150. /**
  45151. * Sets the current filter to Poisson Sampling.
  45152. */
  45153. set: function (value) {
  45154. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  45155. return;
  45156. }
  45157. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  45158. },
  45159. enumerable: true,
  45160. configurable: true
  45161. });
  45162. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  45163. /**
  45164. * Gets if the current filter is set to ESM.
  45165. */
  45166. get: function () {
  45167. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  45168. },
  45169. /**
  45170. * Sets the current filter is to ESM.
  45171. */
  45172. set: function (value) {
  45173. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  45174. return;
  45175. }
  45176. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45177. },
  45178. enumerable: true,
  45179. configurable: true
  45180. });
  45181. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  45182. /**
  45183. * Gets if the current filter is set to filtered ESM.
  45184. */
  45185. get: function () {
  45186. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  45187. },
  45188. /**
  45189. * Gets if the current filter is set to filtered ESM.
  45190. */
  45191. set: function (value) {
  45192. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45193. return;
  45194. }
  45195. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45196. },
  45197. enumerable: true,
  45198. configurable: true
  45199. });
  45200. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  45201. /**
  45202. * Gets if the current filter is set to "close ESM" (using the inverse of the
  45203. * exponential to prevent steep falloff artifacts).
  45204. */
  45205. get: function () {
  45206. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  45207. },
  45208. /**
  45209. * Sets the current filter to "close ESM" (using the inverse of the
  45210. * exponential to prevent steep falloff artifacts).
  45211. */
  45212. set: function (value) {
  45213. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  45214. return;
  45215. }
  45216. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45217. },
  45218. enumerable: true,
  45219. configurable: true
  45220. });
  45221. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  45222. /**
  45223. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  45224. * exponential to prevent steep falloff artifacts).
  45225. */
  45226. get: function () {
  45227. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  45228. },
  45229. /**
  45230. * Sets the current filter to filtered "close ESM" (using the inverse of the
  45231. * exponential to prevent steep falloff artifacts).
  45232. */
  45233. set: function (value) {
  45234. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45235. return;
  45236. }
  45237. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45238. },
  45239. enumerable: true,
  45240. configurable: true
  45241. });
  45242. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  45243. /**
  45244. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  45245. */
  45246. get: function () {
  45247. return this.filter === ShadowGenerator.FILTER_PCF;
  45248. },
  45249. /**
  45250. * Sets the current filter to "PCF" (percentage closer filtering).
  45251. */
  45252. set: function (value) {
  45253. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  45254. return;
  45255. }
  45256. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  45257. },
  45258. enumerable: true,
  45259. configurable: true
  45260. });
  45261. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  45262. /**
  45263. * Gets the PCF or PCSS Quality.
  45264. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45265. */
  45266. get: function () {
  45267. return this._filteringQuality;
  45268. },
  45269. /**
  45270. * Sets the PCF or PCSS Quality.
  45271. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45272. */
  45273. set: function (filteringQuality) {
  45274. this._filteringQuality = filteringQuality;
  45275. },
  45276. enumerable: true,
  45277. configurable: true
  45278. });
  45279. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  45280. /**
  45281. * Gets if the current filter is set to "PCSS" (contact hardening).
  45282. */
  45283. get: function () {
  45284. return this.filter === ShadowGenerator.FILTER_PCSS;
  45285. },
  45286. /**
  45287. * Sets the current filter to "PCSS" (contact hardening).
  45288. */
  45289. set: function (value) {
  45290. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  45291. return;
  45292. }
  45293. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  45294. },
  45295. enumerable: true,
  45296. configurable: true
  45297. });
  45298. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  45299. /**
  45300. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45301. * Using a ratio helps keeping shape stability independently of the map size.
  45302. *
  45303. * It does not account for the light projection as it was having too much
  45304. * instability during the light setup or during light position changes.
  45305. *
  45306. * Only valid if useContactHardeningShadow is true.
  45307. */
  45308. get: function () {
  45309. return this._contactHardeningLightSizeUVRatio;
  45310. },
  45311. /**
  45312. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45313. * Using a ratio helps keeping shape stability independently of the map size.
  45314. *
  45315. * It does not account for the light projection as it was having too much
  45316. * instability during the light setup or during light position changes.
  45317. *
  45318. * Only valid if useContactHardeningShadow is true.
  45319. */
  45320. set: function (contactHardeningLightSizeUVRatio) {
  45321. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  45322. },
  45323. enumerable: true,
  45324. configurable: true
  45325. });
  45326. /**
  45327. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  45328. * 0 means strongest and 1 would means no shadow.
  45329. * @returns the darkness.
  45330. */
  45331. ShadowGenerator.prototype.getDarkness = function () {
  45332. return this._darkness;
  45333. };
  45334. /**
  45335. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  45336. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  45337. * @returns the shadow generator allowing fluent coding.
  45338. */
  45339. ShadowGenerator.prototype.setDarkness = function (darkness) {
  45340. if (darkness >= 1.0) {
  45341. this._darkness = 1.0;
  45342. }
  45343. else if (darkness <= 0.0) {
  45344. this._darkness = 0.0;
  45345. }
  45346. else {
  45347. this._darkness = darkness;
  45348. }
  45349. return this;
  45350. };
  45351. /**
  45352. * Sets the ability to have transparent shadow (boolean).
  45353. * @param transparent True if transparent else False
  45354. * @returns the shadow generator allowing fluent coding
  45355. */
  45356. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  45357. this._transparencyShadow = transparent;
  45358. return this;
  45359. };
  45360. /**
  45361. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  45362. * @returns The render target texture if present otherwise, null
  45363. */
  45364. ShadowGenerator.prototype.getShadowMap = function () {
  45365. return this._shadowMap;
  45366. };
  45367. /**
  45368. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  45369. * @returns The render target texture if the shadow map is present otherwise, null
  45370. */
  45371. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  45372. if (this._shadowMap2) {
  45373. return this._shadowMap2;
  45374. }
  45375. return this._shadowMap;
  45376. };
  45377. /**
  45378. * Helper function to add a mesh and its descendants to the list of shadow casters.
  45379. * @param mesh Mesh to add
  45380. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  45381. * @returns the Shadow Generator itself
  45382. */
  45383. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  45384. if (includeDescendants === void 0) { includeDescendants = true; }
  45385. var _a;
  45386. if (!this._shadowMap) {
  45387. return this;
  45388. }
  45389. if (!this._shadowMap.renderList) {
  45390. this._shadowMap.renderList = [];
  45391. }
  45392. this._shadowMap.renderList.push(mesh);
  45393. if (includeDescendants) {
  45394. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  45395. }
  45396. return this;
  45397. };
  45398. /**
  45399. * Helper function to remove a mesh and its descendants from the list of shadow casters
  45400. * @param mesh Mesh to remove
  45401. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  45402. * @returns the Shadow Generator itself
  45403. */
  45404. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  45405. if (includeDescendants === void 0) { includeDescendants = true; }
  45406. if (!this._shadowMap || !this._shadowMap.renderList) {
  45407. return this;
  45408. }
  45409. var index = this._shadowMap.renderList.indexOf(mesh);
  45410. if (index !== -1) {
  45411. this._shadowMap.renderList.splice(index, 1);
  45412. }
  45413. if (includeDescendants) {
  45414. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  45415. var child = _a[_i];
  45416. this.removeShadowCaster(child);
  45417. }
  45418. }
  45419. return this;
  45420. };
  45421. /**
  45422. * Returns the associated light object.
  45423. * @returns the light generating the shadow
  45424. */
  45425. ShadowGenerator.prototype.getLight = function () {
  45426. return this._light;
  45427. };
  45428. ShadowGenerator.prototype._initializeGenerator = function () {
  45429. this._light._markMeshesAsLightDirty();
  45430. this._initializeShadowMap();
  45431. };
  45432. ShadowGenerator.prototype._initializeShadowMap = function () {
  45433. var _this = this;
  45434. // Render target
  45435. var engine = this._scene.getEngine();
  45436. if (engine.webGLVersion > 1) {
  45437. 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);
  45438. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  45439. }
  45440. else {
  45441. 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());
  45442. }
  45443. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45444. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45445. this._shadowMap.anisotropicFilteringLevel = 1;
  45446. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45447. this._shadowMap.renderParticles = false;
  45448. this._shadowMap.ignoreCameraViewport = true;
  45449. // Record Face Index before render.
  45450. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  45451. _this._currentFaceIndex = faceIndex;
  45452. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45453. engine.setColorWrite(false);
  45454. }
  45455. });
  45456. // Custom render function.
  45457. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  45458. // Blur if required afer render.
  45459. this._shadowMap.onAfterUnbindObservable.add(function () {
  45460. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45461. engine.setColorWrite(true);
  45462. }
  45463. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  45464. return;
  45465. }
  45466. var shadowMap = _this.getShadowMapForRendering();
  45467. if (shadowMap) {
  45468. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  45469. }
  45470. });
  45471. // Clear according to the chosen filter.
  45472. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  45473. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  45474. this._shadowMap.onClearObservable.add(function (engine) {
  45475. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45476. engine.clear(clearOne, false, true, false);
  45477. }
  45478. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  45479. engine.clear(clearZero, true, true, false);
  45480. }
  45481. else {
  45482. engine.clear(clearOne, true, true, false);
  45483. }
  45484. });
  45485. };
  45486. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  45487. var _this = this;
  45488. var engine = this._scene.getEngine();
  45489. var targetSize = this._mapSize / this.blurScale;
  45490. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  45491. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  45492. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45493. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45494. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45495. }
  45496. if (this.useKernelBlur) {
  45497. 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);
  45498. this._kernelBlurXPostprocess.width = targetSize;
  45499. this._kernelBlurXPostprocess.height = targetSize;
  45500. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  45501. effect.setTexture("textureSampler", _this._shadowMap);
  45502. });
  45503. 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);
  45504. this._kernelBlurXPostprocess.autoClear = false;
  45505. this._kernelBlurYPostprocess.autoClear = false;
  45506. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45507. this._kernelBlurXPostprocess.packedFloat = true;
  45508. this._kernelBlurYPostprocess.packedFloat = true;
  45509. }
  45510. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  45511. }
  45512. else {
  45513. 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);
  45514. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  45515. effect.setFloat2("screenSize", targetSize, targetSize);
  45516. effect.setTexture("textureSampler", _this._shadowMap);
  45517. });
  45518. this._boxBlurPostprocess.autoClear = false;
  45519. this._blurPostProcesses = [this._boxBlurPostprocess];
  45520. }
  45521. };
  45522. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  45523. var index;
  45524. var engine = this._scene.getEngine();
  45525. if (depthOnlySubMeshes.length) {
  45526. engine.setColorWrite(false);
  45527. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  45528. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  45529. }
  45530. engine.setColorWrite(true);
  45531. }
  45532. for (index = 0; index < opaqueSubMeshes.length; index++) {
  45533. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  45534. }
  45535. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  45536. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  45537. }
  45538. if (this._transparencyShadow) {
  45539. for (index = 0; index < transparentSubMeshes.length; index++) {
  45540. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  45541. }
  45542. }
  45543. };
  45544. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  45545. var _this = this;
  45546. var mesh = subMesh.getRenderingMesh();
  45547. var scene = this._scene;
  45548. var engine = scene.getEngine();
  45549. var material = subMesh.getMaterial();
  45550. if (!material || subMesh.verticesCount === 0) {
  45551. return;
  45552. }
  45553. // Culling
  45554. engine.setState(material.backFaceCulling);
  45555. // Managing instances
  45556. var batch = mesh._getInstancesRenderList(subMesh._id);
  45557. if (batch.mustReturn) {
  45558. return;
  45559. }
  45560. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  45561. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  45562. engine.enableEffect(this._effect);
  45563. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  45564. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  45565. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  45566. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45567. this._effect.setVector3("lightData", this._cachedDirection);
  45568. }
  45569. else {
  45570. this._effect.setVector3("lightData", this._cachedPosition);
  45571. }
  45572. if (scene.activeCamera) {
  45573. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  45574. }
  45575. // Alpha test
  45576. if (material && material.needAlphaTesting()) {
  45577. var alphaTexture = material.getAlphaTestTexture();
  45578. if (alphaTexture) {
  45579. this._effect.setTexture("diffuseSampler", alphaTexture);
  45580. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  45581. }
  45582. }
  45583. // Bones
  45584. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45585. var skeleton = mesh.skeleton;
  45586. if (skeleton.isUsingTextureForMatrices) {
  45587. var boneTexture = skeleton.getTransformMatrixTexture();
  45588. if (!boneTexture) {
  45589. return;
  45590. }
  45591. this._effect.setTexture("boneSampler", boneTexture);
  45592. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  45593. }
  45594. else {
  45595. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  45596. }
  45597. }
  45598. // Morph targets
  45599. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  45600. if (this.forceBackFacesOnly) {
  45601. engine.setState(true, 0, false, true);
  45602. }
  45603. // Observables
  45604. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(mesh);
  45605. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  45606. // Draw
  45607. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  45608. if (this.forceBackFacesOnly) {
  45609. engine.setState(true, 0, false, false);
  45610. }
  45611. }
  45612. else {
  45613. // Need to reset refresh rate of the shadowMap
  45614. if (this._shadowMap) {
  45615. this._shadowMap.resetRefreshCounter();
  45616. }
  45617. }
  45618. };
  45619. ShadowGenerator.prototype._applyFilterValues = function () {
  45620. if (!this._shadowMap) {
  45621. return;
  45622. }
  45623. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  45624. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  45625. }
  45626. else {
  45627. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45628. }
  45629. };
  45630. /**
  45631. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45632. * @param onCompiled Callback triggered at the and of the effects compilation
  45633. * @param options Sets of optional options forcing the compilation with different modes
  45634. */
  45635. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  45636. var _this = this;
  45637. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  45638. var shadowMap = this.getShadowMap();
  45639. if (!shadowMap) {
  45640. if (onCompiled) {
  45641. onCompiled(this);
  45642. }
  45643. return;
  45644. }
  45645. var renderList = shadowMap.renderList;
  45646. if (!renderList) {
  45647. if (onCompiled) {
  45648. onCompiled(this);
  45649. }
  45650. return;
  45651. }
  45652. var subMeshes = new Array();
  45653. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  45654. var mesh = renderList_1[_i];
  45655. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  45656. }
  45657. if (subMeshes.length === 0) {
  45658. if (onCompiled) {
  45659. onCompiled(this);
  45660. }
  45661. return;
  45662. }
  45663. var currentIndex = 0;
  45664. var checkReady = function () {
  45665. if (!_this._scene || !_this._scene.getEngine()) {
  45666. return;
  45667. }
  45668. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  45669. currentIndex++;
  45670. if (currentIndex >= subMeshes.length) {
  45671. if (onCompiled) {
  45672. onCompiled(_this);
  45673. }
  45674. return;
  45675. }
  45676. }
  45677. setTimeout(checkReady, 16);
  45678. };
  45679. checkReady();
  45680. };
  45681. /**
  45682. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45683. * @param options Sets of optional options forcing the compilation with different modes
  45684. * @returns A promise that resolves when the compilation completes
  45685. */
  45686. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  45687. var _this = this;
  45688. return new Promise(function (resolve) {
  45689. _this.forceCompilation(function () {
  45690. resolve();
  45691. }, options);
  45692. });
  45693. };
  45694. /**
  45695. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  45696. * @param subMesh The submesh we want to render in the shadow map
  45697. * @param useInstances Defines wether will draw in the map using instances
  45698. * @returns true if ready otherwise, false
  45699. */
  45700. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  45701. var defines = [];
  45702. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45703. defines.push("#define FLOAT");
  45704. }
  45705. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45706. defines.push("#define ESM");
  45707. }
  45708. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  45709. defines.push("#define DEPTHTEXTURE");
  45710. }
  45711. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  45712. var mesh = subMesh.getMesh();
  45713. var material = subMesh.getMaterial();
  45714. // Normal bias.
  45715. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  45716. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  45717. defines.push("#define NORMAL");
  45718. if (mesh.nonUniformScaling) {
  45719. defines.push("#define NONUNIFORMSCALING");
  45720. }
  45721. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45722. defines.push("#define DIRECTIONINLIGHTDATA");
  45723. }
  45724. }
  45725. // Alpha test
  45726. if (material && material.needAlphaTesting()) {
  45727. var alphaTexture = material.getAlphaTestTexture();
  45728. if (alphaTexture) {
  45729. defines.push("#define ALPHATEST");
  45730. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  45731. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  45732. defines.push("#define UV1");
  45733. }
  45734. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  45735. if (alphaTexture.coordinatesIndex === 1) {
  45736. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  45737. defines.push("#define UV2");
  45738. }
  45739. }
  45740. }
  45741. }
  45742. // Bones
  45743. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45744. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  45745. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  45746. if (mesh.numBoneInfluencers > 4) {
  45747. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  45748. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  45749. }
  45750. var skeleton = mesh.skeleton;
  45751. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45752. if (skeleton.isUsingTextureForMatrices) {
  45753. defines.push("#define BONETEXTURE");
  45754. }
  45755. else {
  45756. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  45757. }
  45758. }
  45759. else {
  45760. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45761. }
  45762. // Morph targets
  45763. var manager = mesh.morphTargetManager;
  45764. var morphInfluencers = 0;
  45765. if (manager) {
  45766. if (manager.numInfluencers > 0) {
  45767. defines.push("#define MORPHTARGETS");
  45768. morphInfluencers = manager.numInfluencers;
  45769. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  45770. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  45771. }
  45772. }
  45773. // Instances
  45774. if (useInstances) {
  45775. defines.push("#define INSTANCES");
  45776. attribs.push("world0");
  45777. attribs.push("world1");
  45778. attribs.push("world2");
  45779. attribs.push("world3");
  45780. }
  45781. if (this.customShaderOptions) {
  45782. if (this.customShaderOptions.defines) {
  45783. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  45784. var define = _a[_i];
  45785. if (defines.indexOf(define) === -1) {
  45786. defines.push(define);
  45787. }
  45788. }
  45789. }
  45790. }
  45791. // Get correct effect
  45792. var join = defines.join("\n");
  45793. if (this._cachedDefines !== join) {
  45794. this._cachedDefines = join;
  45795. var shaderName = "shadowMap";
  45796. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  45797. var samplers = ["diffuseSampler", "boneSampler"];
  45798. // Custom shader?
  45799. if (this.customShaderOptions) {
  45800. shaderName = this.customShaderOptions.shaderName;
  45801. if (this.customShaderOptions.attributes) {
  45802. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  45803. var attrib = _c[_b];
  45804. if (attribs.indexOf(attrib) === -1) {
  45805. attribs.push(attrib);
  45806. }
  45807. }
  45808. }
  45809. if (this.customShaderOptions.uniforms) {
  45810. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  45811. var uniform = _e[_d];
  45812. if (uniforms.indexOf(uniform) === -1) {
  45813. uniforms.push(uniform);
  45814. }
  45815. }
  45816. }
  45817. if (this.customShaderOptions.samplers) {
  45818. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  45819. var sampler = _g[_f];
  45820. if (samplers.indexOf(sampler) === -1) {
  45821. samplers.push(sampler);
  45822. }
  45823. }
  45824. }
  45825. }
  45826. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  45827. }
  45828. if (!this._effect.isReady()) {
  45829. return false;
  45830. }
  45831. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45832. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  45833. this._initializeBlurRTTAndPostProcesses();
  45834. }
  45835. }
  45836. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  45837. return false;
  45838. }
  45839. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  45840. return false;
  45841. }
  45842. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  45843. return false;
  45844. }
  45845. return true;
  45846. };
  45847. /**
  45848. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  45849. * @param defines Defines of the material we want to update
  45850. * @param lightIndex Index of the light in the enabled light list of the material
  45851. */
  45852. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  45853. var scene = this._scene;
  45854. var light = this._light;
  45855. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45856. return;
  45857. }
  45858. defines["SHADOW" + lightIndex] = true;
  45859. if (this.useContactHardeningShadow) {
  45860. defines["SHADOWPCSS" + lightIndex] = true;
  45861. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45862. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45863. }
  45864. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45865. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45866. }
  45867. // else default to high.
  45868. }
  45869. if (this.usePercentageCloserFiltering) {
  45870. defines["SHADOWPCF" + lightIndex] = true;
  45871. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45872. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45873. }
  45874. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45875. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45876. }
  45877. // else default to high.
  45878. }
  45879. else if (this.usePoissonSampling) {
  45880. defines["SHADOWPOISSON" + lightIndex] = true;
  45881. }
  45882. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45883. defines["SHADOWESM" + lightIndex] = true;
  45884. }
  45885. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45886. defines["SHADOWCLOSEESM" + lightIndex] = true;
  45887. }
  45888. if (light.needCube()) {
  45889. defines["SHADOWCUBE" + lightIndex] = true;
  45890. }
  45891. };
  45892. /**
  45893. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  45894. * defined in the generator but impacting the effect).
  45895. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  45896. * @param effect The effect we are binfing the information for
  45897. */
  45898. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  45899. var light = this._light;
  45900. var scene = this._scene;
  45901. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45902. return;
  45903. }
  45904. var camera = scene.activeCamera;
  45905. if (!camera) {
  45906. return;
  45907. }
  45908. var shadowMap = this.getShadowMap();
  45909. if (!shadowMap) {
  45910. return;
  45911. }
  45912. if (!light.needCube()) {
  45913. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  45914. }
  45915. // Only PCF uses depth stencil texture.
  45916. if (this._filter === ShadowGenerator.FILTER_PCF) {
  45917. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45918. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45919. }
  45920. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  45921. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45922. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  45923. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45924. }
  45925. else {
  45926. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45927. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  45928. }
  45929. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  45930. };
  45931. /**
  45932. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  45933. * (eq to shadow prjection matrix * light transform matrix)
  45934. * @returns The transform matrix used to create the shadow map
  45935. */
  45936. ShadowGenerator.prototype.getTransformMatrix = function () {
  45937. var scene = this._scene;
  45938. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  45939. return this._transformMatrix;
  45940. }
  45941. this._currentRenderID = scene.getRenderId();
  45942. this._currentFaceIndexCache = this._currentFaceIndex;
  45943. var lightPosition = this._light.position;
  45944. if (this._light.computeTransformedInformation()) {
  45945. lightPosition = this._light.transformedPosition;
  45946. }
  45947. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  45948. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  45949. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  45950. }
  45951. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  45952. this._cachedPosition.copyFrom(lightPosition);
  45953. this._cachedDirection.copyFrom(this._lightDirection);
  45954. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  45955. var shadowMap = this.getShadowMap();
  45956. if (shadowMap) {
  45957. var renderList = shadowMap.renderList;
  45958. if (renderList) {
  45959. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  45960. }
  45961. }
  45962. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  45963. }
  45964. return this._transformMatrix;
  45965. };
  45966. /**
  45967. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  45968. * Cube and 2D textures for instance.
  45969. */
  45970. ShadowGenerator.prototype.recreateShadowMap = function () {
  45971. var shadowMap = this._shadowMap;
  45972. if (!shadowMap) {
  45973. return;
  45974. }
  45975. // Track render list.
  45976. var renderList = shadowMap.renderList;
  45977. // Clean up existing data.
  45978. this._disposeRTTandPostProcesses();
  45979. // Reinitializes.
  45980. this._initializeGenerator();
  45981. // Reaffect the filter to ensure a correct fallback if necessary.
  45982. this.filter = this.filter;
  45983. // Reaffect the filter.
  45984. this._applyFilterValues();
  45985. // Reaffect Render List.
  45986. this._shadowMap.renderList = renderList;
  45987. };
  45988. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  45989. if (this._shadowMap2) {
  45990. this._shadowMap2.dispose();
  45991. this._shadowMap2 = null;
  45992. }
  45993. if (this._boxBlurPostprocess) {
  45994. this._boxBlurPostprocess.dispose();
  45995. this._boxBlurPostprocess = null;
  45996. }
  45997. if (this._kernelBlurXPostprocess) {
  45998. this._kernelBlurXPostprocess.dispose();
  45999. this._kernelBlurXPostprocess = null;
  46000. }
  46001. if (this._kernelBlurYPostprocess) {
  46002. this._kernelBlurYPostprocess.dispose();
  46003. this._kernelBlurYPostprocess = null;
  46004. }
  46005. this._blurPostProcesses = [];
  46006. };
  46007. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  46008. if (this._shadowMap) {
  46009. this._shadowMap.dispose();
  46010. this._shadowMap = null;
  46011. }
  46012. this._disposeBlurPostProcesses();
  46013. };
  46014. /**
  46015. * Disposes the ShadowGenerator.
  46016. * Returns nothing.
  46017. */
  46018. ShadowGenerator.prototype.dispose = function () {
  46019. this._disposeRTTandPostProcesses();
  46020. if (this._light) {
  46021. this._light._shadowGenerator = null;
  46022. this._light._markMeshesAsLightDirty();
  46023. }
  46024. };
  46025. /**
  46026. * Serializes the shadow generator setup to a json object.
  46027. * @returns The serialized JSON object
  46028. */
  46029. ShadowGenerator.prototype.serialize = function () {
  46030. var serializationObject = {};
  46031. var shadowMap = this.getShadowMap();
  46032. if (!shadowMap) {
  46033. return serializationObject;
  46034. }
  46035. serializationObject.lightId = this._light.id;
  46036. serializationObject.mapSize = shadowMap.getRenderSize();
  46037. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  46038. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  46039. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46040. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46041. serializationObject.usePoissonSampling = this.usePoissonSampling;
  46042. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  46043. serializationObject.depthScale = this.depthScale;
  46044. serializationObject.darkness = this.getDarkness();
  46045. serializationObject.blurBoxOffset = this.blurBoxOffset;
  46046. serializationObject.blurKernel = this.blurKernel;
  46047. serializationObject.blurScale = this.blurScale;
  46048. serializationObject.useKernelBlur = this.useKernelBlur;
  46049. serializationObject.transparencyShadow = this._transparencyShadow;
  46050. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  46051. serializationObject.bias = this.bias;
  46052. serializationObject.normalBias = this.normalBias;
  46053. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  46054. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  46055. serializationObject.filteringQuality = this.filteringQuality;
  46056. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  46057. serializationObject.renderList = [];
  46058. if (shadowMap.renderList) {
  46059. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  46060. var mesh = shadowMap.renderList[meshIndex];
  46061. serializationObject.renderList.push(mesh.id);
  46062. }
  46063. }
  46064. return serializationObject;
  46065. };
  46066. /**
  46067. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  46068. * @param parsedShadowGenerator The JSON object to parse
  46069. * @param scene The scene to create the shadow map for
  46070. * @returns The parsed shadow generator
  46071. */
  46072. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  46073. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  46074. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  46075. var shadowMap = shadowGenerator.getShadowMap();
  46076. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  46077. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  46078. meshes.forEach(function (mesh) {
  46079. if (!shadowMap) {
  46080. return;
  46081. }
  46082. if (!shadowMap.renderList) {
  46083. shadowMap.renderList = [];
  46084. }
  46085. shadowMap.renderList.push(mesh);
  46086. });
  46087. }
  46088. if (parsedShadowGenerator.usePoissonSampling) {
  46089. shadowGenerator.usePoissonSampling = true;
  46090. }
  46091. else if (parsedShadowGenerator.useExponentialShadowMap) {
  46092. shadowGenerator.useExponentialShadowMap = true;
  46093. }
  46094. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  46095. shadowGenerator.useBlurExponentialShadowMap = true;
  46096. }
  46097. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  46098. shadowGenerator.useCloseExponentialShadowMap = true;
  46099. }
  46100. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  46101. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  46102. }
  46103. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  46104. shadowGenerator.usePercentageCloserFiltering = true;
  46105. }
  46106. else if (parsedShadowGenerator.useContactHardeningShadow) {
  46107. shadowGenerator.useContactHardeningShadow = true;
  46108. }
  46109. if (parsedShadowGenerator.filteringQuality) {
  46110. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  46111. }
  46112. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  46113. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  46114. }
  46115. // Backward compat
  46116. else if (parsedShadowGenerator.useVarianceShadowMap) {
  46117. shadowGenerator.useExponentialShadowMap = true;
  46118. }
  46119. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  46120. shadowGenerator.useBlurExponentialShadowMap = true;
  46121. }
  46122. if (parsedShadowGenerator.depthScale) {
  46123. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  46124. }
  46125. if (parsedShadowGenerator.blurScale) {
  46126. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  46127. }
  46128. if (parsedShadowGenerator.blurBoxOffset) {
  46129. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  46130. }
  46131. if (parsedShadowGenerator.useKernelBlur) {
  46132. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  46133. }
  46134. if (parsedShadowGenerator.blurKernel) {
  46135. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  46136. }
  46137. if (parsedShadowGenerator.bias !== undefined) {
  46138. shadowGenerator.bias = parsedShadowGenerator.bias;
  46139. }
  46140. if (parsedShadowGenerator.normalBias !== undefined) {
  46141. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  46142. }
  46143. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  46144. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  46145. }
  46146. if (parsedShadowGenerator.darkness) {
  46147. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  46148. }
  46149. if (parsedShadowGenerator.transparencyShadow) {
  46150. shadowGenerator.setTransparencyShadow(true);
  46151. }
  46152. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  46153. return shadowGenerator;
  46154. };
  46155. /**
  46156. * Shadow generator mode None: no filtering applied.
  46157. */
  46158. ShadowGenerator.FILTER_NONE = 0;
  46159. /**
  46160. * Shadow generator mode ESM: Exponential Shadow Mapping.
  46161. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46162. */
  46163. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  46164. /**
  46165. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  46166. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  46167. */
  46168. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  46169. /**
  46170. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  46171. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46172. */
  46173. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  46174. /**
  46175. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  46176. * edge artifacts on steep falloff.
  46177. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46178. */
  46179. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  46180. /**
  46181. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  46182. * edge artifacts on steep falloff.
  46183. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46184. */
  46185. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  46186. /**
  46187. * Shadow generator mode PCF: Percentage Closer Filtering
  46188. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46189. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  46190. */
  46191. ShadowGenerator.FILTER_PCF = 6;
  46192. /**
  46193. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  46194. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46195. * Contact Hardening
  46196. */
  46197. ShadowGenerator.FILTER_PCSS = 7;
  46198. /**
  46199. * Reserved for PCF and PCSS
  46200. * Highest Quality.
  46201. *
  46202. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  46203. *
  46204. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  46205. */
  46206. ShadowGenerator.QUALITY_HIGH = 0;
  46207. /**
  46208. * Reserved for PCF and PCSS
  46209. * Good tradeoff for quality/perf cross devices
  46210. *
  46211. * Execute PCF on a 3*3 kernel.
  46212. *
  46213. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  46214. */
  46215. ShadowGenerator.QUALITY_MEDIUM = 1;
  46216. /**
  46217. * Reserved for PCF and PCSS
  46218. * The lowest quality but the fastest.
  46219. *
  46220. * Execute PCF on a 1*1 kernel.
  46221. *
  46222. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  46223. */
  46224. ShadowGenerator.QUALITY_LOW = 2;
  46225. /** @hidden */
  46226. ShadowGenerator._SceneComponentInitialization = function (_) {
  46227. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  46228. };
  46229. return ShadowGenerator;
  46230. }());
  46231. /***/ }),
  46232. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  46233. /*!*********************************************************!*\
  46234. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  46235. \*********************************************************/
  46236. /*! exports provided: ShadowGeneratorSceneComponent */
  46237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46238. "use strict";
  46239. __webpack_require__.r(__webpack_exports__);
  46240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  46241. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  46242. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46243. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46244. // Adds the parser to the scene parsers.
  46245. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  46246. // Shadows
  46247. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  46248. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  46249. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  46250. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  46251. // SG would be available on their associated lights
  46252. }
  46253. }
  46254. });
  46255. /**
  46256. * Defines the shadow generator component responsible to manage any shadow generators
  46257. * in a given scene.
  46258. */
  46259. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  46260. /**
  46261. * Creates a new instance of the component for the given scene
  46262. * @param scene Defines the scene to register the component in
  46263. */
  46264. function ShadowGeneratorSceneComponent(scene) {
  46265. /**
  46266. * The component name helpfull to identify the component in the list of scene components.
  46267. */
  46268. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  46269. this.scene = scene;
  46270. }
  46271. /**
  46272. * Registers the component in a given scene
  46273. */
  46274. ShadowGeneratorSceneComponent.prototype.register = function () {
  46275. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  46276. };
  46277. /**
  46278. * Rebuilds the elements related to this component in case of
  46279. * context lost for instance.
  46280. */
  46281. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  46282. // Nothing To Do Here.
  46283. };
  46284. /**
  46285. * Serializes the component data to the specified json object
  46286. * @param serializationObject The object to serialize to
  46287. */
  46288. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  46289. // Shadows
  46290. serializationObject.shadowGenerators = [];
  46291. var lights = this.scene.lights;
  46292. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  46293. var light = lights_1[_i];
  46294. var shadowGenerator = light.getShadowGenerator();
  46295. if (shadowGenerator) {
  46296. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  46297. }
  46298. }
  46299. };
  46300. /**
  46301. * Adds all the element from the container to the scene
  46302. * @param container the container holding the elements
  46303. */
  46304. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  46305. // Nothing To Do Here. (directly attached to a light)
  46306. };
  46307. /**
  46308. * Removes all the elements in the container from the scene
  46309. * @param container contains the elements to remove
  46310. */
  46311. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  46312. // Nothing To Do Here. (directly attached to a light)
  46313. };
  46314. /**
  46315. * Rebuilds the elements related to this component in case of
  46316. * context lost for instance.
  46317. */
  46318. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  46319. // Nothing To Do Here.
  46320. };
  46321. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  46322. // Shadows
  46323. var scene = this.scene;
  46324. if (this.scene.shadowsEnabled) {
  46325. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  46326. var light = scene.lights[lightIndex];
  46327. var shadowGenerator = light.getShadowGenerator();
  46328. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  46329. var shadowMap = (shadowGenerator.getShadowMap());
  46330. if (scene.textures.indexOf(shadowMap) !== -1) {
  46331. renderTargets.push(shadowMap);
  46332. }
  46333. }
  46334. }
  46335. }
  46336. };
  46337. return ShadowGeneratorSceneComponent;
  46338. }());
  46339. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  46340. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  46341. if (!component) {
  46342. component = new ShadowGeneratorSceneComponent(scene);
  46343. scene._addComponent(component);
  46344. }
  46345. };
  46346. /***/ }),
  46347. /***/ "./Lights/directionalLight.ts":
  46348. /*!************************************!*\
  46349. !*** ./Lights/directionalLight.ts ***!
  46350. \************************************/
  46351. /*! exports provided: DirectionalLight */
  46352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46353. "use strict";
  46354. __webpack_require__.r(__webpack_exports__);
  46355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  46356. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46357. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46358. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46359. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46360. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46361. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46362. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  46363. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46364. });
  46365. /**
  46366. * A directional light is defined by a direction (what a surprise!).
  46367. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46368. * 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.
  46369. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46370. */
  46371. var DirectionalLight = /** @class */ (function (_super) {
  46372. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  46373. /**
  46374. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46375. * The directional light is emitted from everywhere in the given direction.
  46376. * It can cast shadows.
  46377. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46378. * @param name The friendly name of the light
  46379. * @param direction The direction of the light
  46380. * @param scene The scene the light belongs to
  46381. */
  46382. function DirectionalLight(name, direction, scene) {
  46383. var _this = _super.call(this, name, scene) || this;
  46384. _this._shadowFrustumSize = 0;
  46385. _this._shadowOrthoScale = 0.1;
  46386. /**
  46387. * Automatically compute the projection matrix to best fit (including all the casters)
  46388. * on each frame.
  46389. */
  46390. _this.autoUpdateExtends = true;
  46391. // Cache
  46392. _this._orthoLeft = Number.MAX_VALUE;
  46393. _this._orthoRight = Number.MIN_VALUE;
  46394. _this._orthoTop = Number.MIN_VALUE;
  46395. _this._orthoBottom = Number.MAX_VALUE;
  46396. _this.position = direction.scale(-1.0);
  46397. _this.direction = direction;
  46398. return _this;
  46399. }
  46400. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  46401. /**
  46402. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46403. */
  46404. get: function () {
  46405. return this._shadowFrustumSize;
  46406. },
  46407. /**
  46408. * Specifies a fix frustum size for the shadow generation.
  46409. */
  46410. set: function (value) {
  46411. this._shadowFrustumSize = value;
  46412. this.forceProjectionMatrixCompute();
  46413. },
  46414. enumerable: true,
  46415. configurable: true
  46416. });
  46417. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  46418. /**
  46419. * Gets the shadow projection scale against the optimal computed one.
  46420. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46421. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46422. */
  46423. get: function () {
  46424. return this._shadowOrthoScale;
  46425. },
  46426. /**
  46427. * Sets the shadow projection scale against the optimal computed one.
  46428. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46429. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46430. */
  46431. set: function (value) {
  46432. this._shadowOrthoScale = value;
  46433. this.forceProjectionMatrixCompute();
  46434. },
  46435. enumerable: true,
  46436. configurable: true
  46437. });
  46438. /**
  46439. * Returns the string "DirectionalLight".
  46440. * @return The class name
  46441. */
  46442. DirectionalLight.prototype.getClassName = function () {
  46443. return "DirectionalLight";
  46444. };
  46445. /**
  46446. * Returns the integer 1.
  46447. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46448. */
  46449. DirectionalLight.prototype.getTypeID = function () {
  46450. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  46451. };
  46452. /**
  46453. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46454. * Returns the DirectionalLight Shadow projection matrix.
  46455. */
  46456. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46457. if (this.shadowFrustumSize > 0) {
  46458. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  46459. }
  46460. else {
  46461. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  46462. }
  46463. };
  46464. /**
  46465. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46466. * Returns the DirectionalLight Shadow projection matrix.
  46467. */
  46468. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  46469. var activeCamera = this.getScene().activeCamera;
  46470. if (!activeCamera) {
  46471. return;
  46472. }
  46473. _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);
  46474. };
  46475. /**
  46476. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46477. * Returns the DirectionalLight Shadow projection matrix.
  46478. */
  46479. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46480. var activeCamera = this.getScene().activeCamera;
  46481. if (!activeCamera) {
  46482. return;
  46483. }
  46484. // Check extends
  46485. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  46486. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46487. this._orthoLeft = Number.MAX_VALUE;
  46488. this._orthoRight = Number.MIN_VALUE;
  46489. this._orthoTop = Number.MIN_VALUE;
  46490. this._orthoBottom = Number.MAX_VALUE;
  46491. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  46492. var mesh = renderList[meshIndex];
  46493. if (!mesh) {
  46494. continue;
  46495. }
  46496. var boundingInfo = mesh.getBoundingInfo();
  46497. var boundingBox = boundingInfo.boundingBox;
  46498. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  46499. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  46500. if (tempVector3.x < this._orthoLeft) {
  46501. this._orthoLeft = tempVector3.x;
  46502. }
  46503. if (tempVector3.y < this._orthoBottom) {
  46504. this._orthoBottom = tempVector3.y;
  46505. }
  46506. if (tempVector3.x > this._orthoRight) {
  46507. this._orthoRight = tempVector3.x;
  46508. }
  46509. if (tempVector3.y > this._orthoTop) {
  46510. this._orthoTop = tempVector3.y;
  46511. }
  46512. }
  46513. }
  46514. }
  46515. var xOffset = this._orthoRight - this._orthoLeft;
  46516. var yOffset = this._orthoTop - this._orthoBottom;
  46517. _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);
  46518. };
  46519. DirectionalLight.prototype._buildUniformLayout = function () {
  46520. this._uniformBuffer.addUniform("vLightData", 4);
  46521. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46522. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46523. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46524. this._uniformBuffer.addUniform("depthValues", 2);
  46525. this._uniformBuffer.create();
  46526. };
  46527. /**
  46528. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46529. * @param effect The effect to update
  46530. * @param lightIndex The index of the light in the effect to update
  46531. * @returns The directional light
  46532. */
  46533. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  46534. if (this.computeTransformedInformation()) {
  46535. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  46536. return this;
  46537. }
  46538. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  46539. return this;
  46540. };
  46541. /**
  46542. * Gets the minZ used for shadow according to both the scene and the light.
  46543. *
  46544. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46545. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46546. * @param activeCamera The camera we are returning the min for
  46547. * @returns the depth min z
  46548. */
  46549. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  46550. return 1;
  46551. };
  46552. /**
  46553. * Gets the maxZ used for shadow according to both the scene and the light.
  46554. *
  46555. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46556. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46557. * @param activeCamera The camera we are returning the max for
  46558. * @returns the depth max z
  46559. */
  46560. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  46561. return 1;
  46562. };
  46563. /**
  46564. * Prepares the list of defines specific to the light type.
  46565. * @param defines the list of defines
  46566. * @param lightIndex defines the index of the light for the effect
  46567. */
  46568. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46569. defines["DIRLIGHT" + lightIndex] = true;
  46570. };
  46571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46573. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  46574. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46576. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  46577. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46578. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46579. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  46580. return DirectionalLight;
  46581. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46582. /***/ }),
  46583. /***/ "./Lights/hemisphericLight.ts":
  46584. /*!************************************!*\
  46585. !*** ./Lights/hemisphericLight.ts ***!
  46586. \************************************/
  46587. /*! exports provided: HemisphericLight */
  46588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46589. "use strict";
  46590. __webpack_require__.r(__webpack_exports__);
  46591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  46592. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46593. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46594. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46595. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46596. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46597. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  46598. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46599. });
  46600. /**
  46601. * The HemisphericLight simulates the ambient environment light,
  46602. * so the passed direction is the light reflection direction, not the incoming direction.
  46603. */
  46604. var HemisphericLight = /** @class */ (function (_super) {
  46605. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  46606. /**
  46607. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  46608. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  46609. * The HemisphericLight can't cast shadows.
  46610. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46611. * @param name The friendly name of the light
  46612. * @param direction The direction of the light reflection
  46613. * @param scene The scene the light belongs to
  46614. */
  46615. function HemisphericLight(name, direction, scene) {
  46616. var _this = _super.call(this, name, scene) || this;
  46617. /**
  46618. * The groundColor is the light in the opposite direction to the one specified during creation.
  46619. * 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.
  46620. */
  46621. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  46622. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46623. return _this;
  46624. }
  46625. HemisphericLight.prototype._buildUniformLayout = function () {
  46626. this._uniformBuffer.addUniform("vLightData", 4);
  46627. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46628. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46629. this._uniformBuffer.addUniform("vLightGround", 3);
  46630. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46631. this._uniformBuffer.addUniform("depthValues", 2);
  46632. this._uniformBuffer.create();
  46633. };
  46634. /**
  46635. * Returns the string "HemisphericLight".
  46636. * @return The class name
  46637. */
  46638. HemisphericLight.prototype.getClassName = function () {
  46639. return "HemisphericLight";
  46640. };
  46641. /**
  46642. * Sets the HemisphericLight direction towards the passed target (Vector3).
  46643. * Returns the updated direction.
  46644. * @param target The target the direction should point to
  46645. * @return The computed direction
  46646. */
  46647. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  46648. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  46649. return this.direction;
  46650. };
  46651. /**
  46652. * Returns the shadow generator associated to the light.
  46653. * @returns Always null for hemispheric lights because it does not support shadows.
  46654. */
  46655. HemisphericLight.prototype.getShadowGenerator = function () {
  46656. return null;
  46657. };
  46658. /**
  46659. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  46660. * @param effect The effect to update
  46661. * @param lightIndex The index of the light in the effect to update
  46662. * @returns The hemispheric light
  46663. */
  46664. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  46665. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46666. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  46667. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  46668. return this;
  46669. };
  46670. /**
  46671. * Computes the world matrix of the node
  46672. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46673. * @param useWasUpdatedFlag defines a reserved property
  46674. * @returns the world matrix
  46675. */
  46676. HemisphericLight.prototype.computeWorldMatrix = function () {
  46677. if (!this._worldMatrix) {
  46678. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46679. }
  46680. return this._worldMatrix;
  46681. };
  46682. /**
  46683. * Returns the integer 3.
  46684. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46685. */
  46686. HemisphericLight.prototype.getTypeID = function () {
  46687. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  46688. };
  46689. /**
  46690. * Prepares the list of defines specific to the light type.
  46691. * @param defines the list of defines
  46692. * @param lightIndex defines the index of the light for the effect
  46693. */
  46694. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46695. defines["HEMILIGHT" + lightIndex] = true;
  46696. };
  46697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46699. ], HemisphericLight.prototype, "groundColor", void 0);
  46700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46702. ], HemisphericLight.prototype, "direction", void 0);
  46703. return HemisphericLight;
  46704. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  46705. /***/ }),
  46706. /***/ "./Lights/index.ts":
  46707. /*!*************************!*\
  46708. !*** ./Lights/index.ts ***!
  46709. \*************************/
  46710. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  46711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46712. "use strict";
  46713. __webpack_require__.r(__webpack_exports__);
  46714. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  46716. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  46718. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  46719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  46720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  46721. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  46722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  46723. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  46724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  46725. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  46726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  46727. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  46728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  46729. /***/ }),
  46730. /***/ "./Lights/light.ts":
  46731. /*!*************************!*\
  46732. !*** ./Lights/light.ts ***!
  46733. \*************************/
  46734. /*! exports provided: Light */
  46735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46736. "use strict";
  46737. __webpack_require__.r(__webpack_exports__);
  46738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  46739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46740. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46741. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46742. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46743. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  46744. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46745. /**
  46746. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  46747. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  46748. * 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.
  46749. */
  46750. var Light = /** @class */ (function (_super) {
  46751. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  46752. /**
  46753. * Creates a Light object in the scene.
  46754. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46755. * @param name The firendly name of the light
  46756. * @param scene The scene the light belongs too
  46757. */
  46758. function Light(name, scene) {
  46759. var _this = _super.call(this, name, scene) || this;
  46760. /**
  46761. * Diffuse gives the basic color to an object.
  46762. */
  46763. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46764. /**
  46765. * Specular produces a highlight color on an object.
  46766. * Note: This is note affecting PBR materials.
  46767. */
  46768. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46769. /**
  46770. * Defines the falloff type for this light. This lets overrriding how punctual light are
  46771. * falling off base on range or angle.
  46772. * This can be set to any values in Light.FALLOFF_x.
  46773. *
  46774. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  46775. * other types of materials.
  46776. */
  46777. _this.falloffType = Light.FALLOFF_DEFAULT;
  46778. /**
  46779. * Strength of the light.
  46780. * Note: By default it is define in the framework own unit.
  46781. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  46782. */
  46783. _this.intensity = 1.0;
  46784. _this._range = Number.MAX_VALUE;
  46785. _this._inverseSquaredRange = 0;
  46786. /**
  46787. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  46788. * of light.
  46789. */
  46790. _this._photometricScale = 1.0;
  46791. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  46792. _this._radius = 0.00001;
  46793. /**
  46794. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  46795. * exceeding the number allowed of the materials.
  46796. */
  46797. _this.renderPriority = 0;
  46798. _this._shadowEnabled = true;
  46799. _this._excludeWithLayerMask = 0;
  46800. _this._includeOnlyWithLayerMask = 0;
  46801. _this._lightmapMode = 0;
  46802. /**
  46803. * @hidden Internal use only.
  46804. */
  46805. _this._excludedMeshesIds = new Array();
  46806. /**
  46807. * @hidden Internal use only.
  46808. */
  46809. _this._includedOnlyMeshesIds = new Array();
  46810. /** @hidden */
  46811. _this._isLight = true;
  46812. _this.getScene().addLight(_this);
  46813. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  46814. _this._buildUniformLayout();
  46815. _this.includedOnlyMeshes = new Array();
  46816. _this.excludedMeshes = new Array();
  46817. _this._resyncMeshes();
  46818. return _this;
  46819. }
  46820. Object.defineProperty(Light.prototype, "range", {
  46821. /**
  46822. * Defines how far from the source the light is impacting in scene units.
  46823. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46824. */
  46825. get: function () {
  46826. return this._range;
  46827. },
  46828. /**
  46829. * Defines how far from the source the light is impacting in scene units.
  46830. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46831. */
  46832. set: function (value) {
  46833. this._range = value;
  46834. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  46835. },
  46836. enumerable: true,
  46837. configurable: true
  46838. });
  46839. Object.defineProperty(Light.prototype, "intensityMode", {
  46840. /**
  46841. * Gets the photometric scale used to interpret the intensity.
  46842. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46843. */
  46844. get: function () {
  46845. return this._intensityMode;
  46846. },
  46847. /**
  46848. * Sets the photometric scale used to interpret the intensity.
  46849. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46850. */
  46851. set: function (value) {
  46852. this._intensityMode = value;
  46853. this._computePhotometricScale();
  46854. },
  46855. enumerable: true,
  46856. configurable: true
  46857. });
  46858. Object.defineProperty(Light.prototype, "radius", {
  46859. /**
  46860. * Gets the light radius used by PBR Materials to simulate soft area lights.
  46861. */
  46862. get: function () {
  46863. return this._radius;
  46864. },
  46865. /**
  46866. * sets the light radius used by PBR Materials to simulate soft area lights.
  46867. */
  46868. set: function (value) {
  46869. this._radius = value;
  46870. this._computePhotometricScale();
  46871. },
  46872. enumerable: true,
  46873. configurable: true
  46874. });
  46875. Object.defineProperty(Light.prototype, "shadowEnabled", {
  46876. /**
  46877. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46878. * the current shadow generator.
  46879. */
  46880. get: function () {
  46881. return this._shadowEnabled;
  46882. },
  46883. /**
  46884. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46885. * the current shadow generator.
  46886. */
  46887. set: function (value) {
  46888. if (this._shadowEnabled === value) {
  46889. return;
  46890. }
  46891. this._shadowEnabled = value;
  46892. this._markMeshesAsLightDirty();
  46893. },
  46894. enumerable: true,
  46895. configurable: true
  46896. });
  46897. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  46898. /**
  46899. * Gets the only meshes impacted by this light.
  46900. */
  46901. get: function () {
  46902. return this._includedOnlyMeshes;
  46903. },
  46904. /**
  46905. * Sets the only meshes impacted by this light.
  46906. */
  46907. set: function (value) {
  46908. this._includedOnlyMeshes = value;
  46909. this._hookArrayForIncludedOnly(value);
  46910. },
  46911. enumerable: true,
  46912. configurable: true
  46913. });
  46914. Object.defineProperty(Light.prototype, "excludedMeshes", {
  46915. /**
  46916. * Gets the meshes not impacted by this light.
  46917. */
  46918. get: function () {
  46919. return this._excludedMeshes;
  46920. },
  46921. /**
  46922. * Sets the meshes not impacted by this light.
  46923. */
  46924. set: function (value) {
  46925. this._excludedMeshes = value;
  46926. this._hookArrayForExcluded(value);
  46927. },
  46928. enumerable: true,
  46929. configurable: true
  46930. });
  46931. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  46932. /**
  46933. * Gets the layer id use to find what meshes are not impacted by the light.
  46934. * Inactive if 0
  46935. */
  46936. get: function () {
  46937. return this._excludeWithLayerMask;
  46938. },
  46939. /**
  46940. * Sets the layer id use to find what meshes are not impacted by the light.
  46941. * Inactive if 0
  46942. */
  46943. set: function (value) {
  46944. this._excludeWithLayerMask = value;
  46945. this._resyncMeshes();
  46946. },
  46947. enumerable: true,
  46948. configurable: true
  46949. });
  46950. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  46951. /**
  46952. * Gets the layer id use to find what meshes are impacted by the light.
  46953. * Inactive if 0
  46954. */
  46955. get: function () {
  46956. return this._includeOnlyWithLayerMask;
  46957. },
  46958. /**
  46959. * Sets the layer id use to find what meshes are impacted by the light.
  46960. * Inactive if 0
  46961. */
  46962. set: function (value) {
  46963. this._includeOnlyWithLayerMask = value;
  46964. this._resyncMeshes();
  46965. },
  46966. enumerable: true,
  46967. configurable: true
  46968. });
  46969. Object.defineProperty(Light.prototype, "lightmapMode", {
  46970. /**
  46971. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46972. */
  46973. get: function () {
  46974. return this._lightmapMode;
  46975. },
  46976. /**
  46977. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46978. */
  46979. set: function (value) {
  46980. if (this._lightmapMode === value) {
  46981. return;
  46982. }
  46983. this._lightmapMode = value;
  46984. this._markMeshesAsLightDirty();
  46985. },
  46986. enumerable: true,
  46987. configurable: true
  46988. });
  46989. /**
  46990. * Returns the string "Light".
  46991. * @returns the class name
  46992. */
  46993. Light.prototype.getClassName = function () {
  46994. return "Light";
  46995. };
  46996. /**
  46997. * Converts the light information to a readable string for debug purpose.
  46998. * @param fullDetails Supports for multiple levels of logging within scene loading
  46999. * @returns the human readable light info
  47000. */
  47001. Light.prototype.toString = function (fullDetails) {
  47002. var ret = "Name: " + this.name;
  47003. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  47004. if (this.animations) {
  47005. for (var i = 0; i < this.animations.length; i++) {
  47006. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  47007. }
  47008. }
  47009. if (fullDetails) {
  47010. }
  47011. return ret;
  47012. };
  47013. /** @hidden */
  47014. Light.prototype._syncParentEnabledState = function () {
  47015. _super.prototype._syncParentEnabledState.call(this);
  47016. this._resyncMeshes();
  47017. };
  47018. /**
  47019. * Set the enabled state of this node.
  47020. * @param value - the new enabled state
  47021. */
  47022. Light.prototype.setEnabled = function (value) {
  47023. _super.prototype.setEnabled.call(this, value);
  47024. this._resyncMeshes();
  47025. };
  47026. /**
  47027. * Returns the Light associated shadow generator if any.
  47028. * @return the associated shadow generator.
  47029. */
  47030. Light.prototype.getShadowGenerator = function () {
  47031. return this._shadowGenerator;
  47032. };
  47033. /**
  47034. * Returns a Vector3, the absolute light position in the World.
  47035. * @returns the world space position of the light
  47036. */
  47037. Light.prototype.getAbsolutePosition = function () {
  47038. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47039. };
  47040. /**
  47041. * Specifies if the light will affect the passed mesh.
  47042. * @param mesh The mesh to test against the light
  47043. * @return true the mesh is affected otherwise, false.
  47044. */
  47045. Light.prototype.canAffectMesh = function (mesh) {
  47046. if (!mesh) {
  47047. return true;
  47048. }
  47049. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  47050. return false;
  47051. }
  47052. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  47053. return false;
  47054. }
  47055. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  47056. return false;
  47057. }
  47058. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  47059. return false;
  47060. }
  47061. return true;
  47062. };
  47063. /**
  47064. * Sort function to order lights for rendering.
  47065. * @param a First Light object to compare to second.
  47066. * @param b Second Light object to compare first.
  47067. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  47068. */
  47069. Light.CompareLightsPriority = function (a, b) {
  47070. //shadow-casting lights have priority over non-shadow-casting lights
  47071. //the renderPrioirty is a secondary sort criterion
  47072. if (a.shadowEnabled !== b.shadowEnabled) {
  47073. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  47074. }
  47075. return b.renderPriority - a.renderPriority;
  47076. };
  47077. /**
  47078. * Releases resources associated with this node.
  47079. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47080. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47081. */
  47082. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  47083. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  47084. if (this._shadowGenerator) {
  47085. this._shadowGenerator.dispose();
  47086. this._shadowGenerator = null;
  47087. }
  47088. // Animations
  47089. this.getScene().stopAnimation(this);
  47090. // Remove from meshes
  47091. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47092. var mesh = _a[_i];
  47093. mesh._removeLightSource(this);
  47094. }
  47095. this._uniformBuffer.dispose();
  47096. // Remove from scene
  47097. this.getScene().removeLight(this);
  47098. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  47099. };
  47100. /**
  47101. * Returns the light type ID (integer).
  47102. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47103. */
  47104. Light.prototype.getTypeID = function () {
  47105. return 0;
  47106. };
  47107. /**
  47108. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  47109. * @returns the scaled intensity in intensity mode unit
  47110. */
  47111. Light.prototype.getScaledIntensity = function () {
  47112. return this._photometricScale * this.intensity;
  47113. };
  47114. /**
  47115. * Returns a new Light object, named "name", from the current one.
  47116. * @param name The name of the cloned light
  47117. * @returns the new created light
  47118. */
  47119. Light.prototype.clone = function (name) {
  47120. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  47121. if (!constructor) {
  47122. return null;
  47123. }
  47124. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  47125. };
  47126. /**
  47127. * Serializes the current light into a Serialization object.
  47128. * @returns the serialized object.
  47129. */
  47130. Light.prototype.serialize = function () {
  47131. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  47132. // Type
  47133. serializationObject.type = this.getTypeID();
  47134. // Parent
  47135. if (this.parent) {
  47136. serializationObject.parentId = this.parent.id;
  47137. }
  47138. // Inclusion / exclusions
  47139. if (this.excludedMeshes.length > 0) {
  47140. serializationObject.excludedMeshesIds = [];
  47141. this.excludedMeshes.forEach(function (mesh) {
  47142. serializationObject.excludedMeshesIds.push(mesh.id);
  47143. });
  47144. }
  47145. if (this.includedOnlyMeshes.length > 0) {
  47146. serializationObject.includedOnlyMeshesIds = [];
  47147. this.includedOnlyMeshes.forEach(function (mesh) {
  47148. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  47149. });
  47150. }
  47151. // Animations
  47152. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  47153. serializationObject.ranges = this.serializeAnimationRanges();
  47154. return serializationObject;
  47155. };
  47156. /**
  47157. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  47158. * This new light is named "name" and added to the passed scene.
  47159. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  47160. * @param name The friendly name of the light
  47161. * @param scene The scene the new light will belong to
  47162. * @returns the constructor function
  47163. */
  47164. Light.GetConstructorFromName = function (type, name, scene) {
  47165. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  47166. if (constructorFunc) {
  47167. return constructorFunc;
  47168. }
  47169. // Default to no light for none present once.
  47170. return null;
  47171. };
  47172. /**
  47173. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  47174. * @param parsedLight The JSON representation of the light
  47175. * @param scene The scene to create the parsed light in
  47176. * @returns the created light after parsing
  47177. */
  47178. Light.Parse = function (parsedLight, scene) {
  47179. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  47180. if (!constructor) {
  47181. return null;
  47182. }
  47183. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  47184. // Inclusion / exclusions
  47185. if (parsedLight.excludedMeshesIds) {
  47186. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  47187. }
  47188. if (parsedLight.includedOnlyMeshesIds) {
  47189. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  47190. }
  47191. // Parent
  47192. if (parsedLight.parentId) {
  47193. light._waitingParentId = parsedLight.parentId;
  47194. }
  47195. // Animations
  47196. if (parsedLight.animations) {
  47197. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  47198. var parsedAnimation = parsedLight.animations[animationIndex];
  47199. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  47200. if (internalClass) {
  47201. light.animations.push(internalClass.Parse(parsedAnimation));
  47202. }
  47203. }
  47204. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  47205. }
  47206. if (parsedLight.autoAnimate) {
  47207. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  47208. }
  47209. return light;
  47210. };
  47211. Light.prototype._hookArrayForExcluded = function (array) {
  47212. var _this = this;
  47213. var oldPush = array.push;
  47214. array.push = function () {
  47215. var items = [];
  47216. for (var _i = 0; _i < arguments.length; _i++) {
  47217. items[_i] = arguments[_i];
  47218. }
  47219. var result = oldPush.apply(array, items);
  47220. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  47221. var item = items_1[_a];
  47222. item._resyncLighSource(_this);
  47223. }
  47224. return result;
  47225. };
  47226. var oldSplice = array.splice;
  47227. array.splice = function (index, deleteCount) {
  47228. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47229. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  47230. var item = deleted_1[_i];
  47231. item._resyncLighSource(_this);
  47232. }
  47233. return deleted;
  47234. };
  47235. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  47236. var item = array_1[_i];
  47237. item._resyncLighSource(this);
  47238. }
  47239. };
  47240. Light.prototype._hookArrayForIncludedOnly = function (array) {
  47241. var _this = this;
  47242. var oldPush = array.push;
  47243. array.push = function () {
  47244. var items = [];
  47245. for (var _i = 0; _i < arguments.length; _i++) {
  47246. items[_i] = arguments[_i];
  47247. }
  47248. var result = oldPush.apply(array, items);
  47249. _this._resyncMeshes();
  47250. return result;
  47251. };
  47252. var oldSplice = array.splice;
  47253. array.splice = function (index, deleteCount) {
  47254. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47255. _this._resyncMeshes();
  47256. return deleted;
  47257. };
  47258. this._resyncMeshes();
  47259. };
  47260. Light.prototype._resyncMeshes = function () {
  47261. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47262. var mesh = _a[_i];
  47263. mesh._resyncLighSource(this);
  47264. }
  47265. };
  47266. /**
  47267. * Forces the meshes to update their light related information in their rendering used effects
  47268. * @hidden Internal Use Only
  47269. */
  47270. Light.prototype._markMeshesAsLightDirty = function () {
  47271. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47272. var mesh = _a[_i];
  47273. if (mesh._lightSources.indexOf(this) !== -1) {
  47274. mesh._markSubMeshesAsLightDirty();
  47275. }
  47276. }
  47277. };
  47278. /**
  47279. * Recomputes the cached photometric scale if needed.
  47280. */
  47281. Light.prototype._computePhotometricScale = function () {
  47282. this._photometricScale = this._getPhotometricScale();
  47283. this.getScene().resetCachedMaterial();
  47284. };
  47285. /**
  47286. * Returns the Photometric Scale according to the light type and intensity mode.
  47287. */
  47288. Light.prototype._getPhotometricScale = function () {
  47289. var photometricScale = 0.0;
  47290. var lightTypeID = this.getTypeID();
  47291. //get photometric mode
  47292. var photometricMode = this.intensityMode;
  47293. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  47294. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  47295. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  47296. }
  47297. else {
  47298. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  47299. }
  47300. }
  47301. //compute photometric scale
  47302. switch (lightTypeID) {
  47303. case Light.LIGHTTYPEID_POINTLIGHT:
  47304. case Light.LIGHTTYPEID_SPOTLIGHT:
  47305. switch (photometricMode) {
  47306. case Light.INTENSITYMODE_LUMINOUSPOWER:
  47307. photometricScale = 1.0 / (4.0 * Math.PI);
  47308. break;
  47309. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  47310. photometricScale = 1.0;
  47311. break;
  47312. case Light.INTENSITYMODE_LUMINANCE:
  47313. photometricScale = this.radius * this.radius;
  47314. break;
  47315. }
  47316. break;
  47317. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  47318. switch (photometricMode) {
  47319. case Light.INTENSITYMODE_ILLUMINANCE:
  47320. photometricScale = 1.0;
  47321. break;
  47322. case Light.INTENSITYMODE_LUMINANCE:
  47323. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  47324. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  47325. var apexAngleRadians = this.radius;
  47326. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  47327. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  47328. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  47329. photometricScale = solidAngle;
  47330. break;
  47331. }
  47332. break;
  47333. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  47334. // No fall off in hemisperic light.
  47335. photometricScale = 1.0;
  47336. break;
  47337. }
  47338. return photometricScale;
  47339. };
  47340. /**
  47341. * Reorder the light in the scene according to their defined priority.
  47342. * @hidden Internal Use Only
  47343. */
  47344. Light.prototype._reorderLightsInScene = function () {
  47345. var scene = this.getScene();
  47346. if (this._renderPriority != 0) {
  47347. scene.requireLightSorting = true;
  47348. }
  47349. this.getScene().sortLightsByPriority();
  47350. };
  47351. /**
  47352. * Falloff Default: light is falling off following the material specification:
  47353. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  47354. */
  47355. Light.FALLOFF_DEFAULT = 0;
  47356. /**
  47357. * Falloff Physical: light is falling off following the inverse squared distance law.
  47358. */
  47359. Light.FALLOFF_PHYSICAL = 1;
  47360. /**
  47361. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  47362. * to enhance interoperability with other engines.
  47363. */
  47364. Light.FALLOFF_GLTF = 2;
  47365. /**
  47366. * Falloff Standard: light is falling off like in the standard material
  47367. * to enhance interoperability with other materials.
  47368. */
  47369. Light.FALLOFF_STANDARD = 3;
  47370. //lightmapMode Consts
  47371. /**
  47372. * If every light affecting the material is in this lightmapMode,
  47373. * material.lightmapTexture adds or multiplies
  47374. * (depends on material.useLightmapAsShadowmap)
  47375. * after every other light calculations.
  47376. */
  47377. Light.LIGHTMAP_DEFAULT = 0;
  47378. /**
  47379. * material.lightmapTexture as only diffuse lighting from this light
  47380. * adds only specular lighting from this light
  47381. * adds dynamic shadows
  47382. */
  47383. Light.LIGHTMAP_SPECULAR = 1;
  47384. /**
  47385. * material.lightmapTexture as only lighting
  47386. * no light calculation from this light
  47387. * only adds dynamic shadows from this light
  47388. */
  47389. Light.LIGHTMAP_SHADOWSONLY = 2;
  47390. // Intensity Mode Consts
  47391. /**
  47392. * Each light type uses the default quantity according to its type:
  47393. * point/spot lights use luminous intensity
  47394. * directional lights use illuminance
  47395. */
  47396. Light.INTENSITYMODE_AUTOMATIC = 0;
  47397. /**
  47398. * lumen (lm)
  47399. */
  47400. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  47401. /**
  47402. * candela (lm/sr)
  47403. */
  47404. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  47405. /**
  47406. * lux (lm/m^2)
  47407. */
  47408. Light.INTENSITYMODE_ILLUMINANCE = 3;
  47409. /**
  47410. * nit (cd/m^2)
  47411. */
  47412. Light.INTENSITYMODE_LUMINANCE = 4;
  47413. // Light types ids const.
  47414. /**
  47415. * Light type const id of the point light.
  47416. */
  47417. Light.LIGHTTYPEID_POINTLIGHT = 0;
  47418. /**
  47419. * Light type const id of the directional light.
  47420. */
  47421. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  47422. /**
  47423. * Light type const id of the spot light.
  47424. */
  47425. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  47426. /**
  47427. * Light type const id of the hemispheric light.
  47428. */
  47429. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  47430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47432. ], Light.prototype, "diffuse", void 0);
  47433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47435. ], Light.prototype, "specular", void 0);
  47436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47438. ], Light.prototype, "falloffType", void 0);
  47439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47441. ], Light.prototype, "intensity", void 0);
  47442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47444. ], Light.prototype, "range", null);
  47445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47447. ], Light.prototype, "intensityMode", null);
  47448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47450. ], Light.prototype, "radius", null);
  47451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47453. ], Light.prototype, "_renderPriority", void 0);
  47454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  47456. ], Light.prototype, "renderPriority", void 0);
  47457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  47459. ], Light.prototype, "_shadowEnabled", void 0);
  47460. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  47462. ], Light.prototype, "_excludeWithLayerMask", void 0);
  47463. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47464. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  47465. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  47466. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47467. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  47468. ], Light.prototype, "_lightmapMode", void 0);
  47469. return Light;
  47470. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  47471. /***/ }),
  47472. /***/ "./Lights/pointLight.ts":
  47473. /*!******************************!*\
  47474. !*** ./Lights/pointLight.ts ***!
  47475. \******************************/
  47476. /*! exports provided: PointLight */
  47477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47478. "use strict";
  47479. __webpack_require__.r(__webpack_exports__);
  47480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  47481. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47482. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47483. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47484. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47485. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47486. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47487. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  47488. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  47489. });
  47490. /**
  47491. * A point light is a light defined by an unique point in world space.
  47492. * The light is emitted in every direction from this point.
  47493. * A good example of a point light is a standard light bulb.
  47494. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47495. */
  47496. var PointLight = /** @class */ (function (_super) {
  47497. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  47498. /**
  47499. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47500. * A PointLight emits the light in every direction.
  47501. * It can cast shadows.
  47502. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47503. * ```javascript
  47504. * var pointLight = new PointLight("pl", camera.position, scene);
  47505. * ```
  47506. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47507. * @param name The light friendly name
  47508. * @param position The position of the point light in the scene
  47509. * @param scene The scene the lights belongs to
  47510. */
  47511. function PointLight(name, position, scene) {
  47512. var _this = _super.call(this, name, scene) || this;
  47513. _this._shadowAngle = Math.PI / 2;
  47514. _this.position = position;
  47515. return _this;
  47516. }
  47517. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  47518. /**
  47519. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47520. * This specifies what angle the shadow will use to be created.
  47521. *
  47522. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47523. */
  47524. get: function () {
  47525. return this._shadowAngle;
  47526. },
  47527. /**
  47528. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47529. * This specifies what angle the shadow will use to be created.
  47530. *
  47531. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47532. */
  47533. set: function (value) {
  47534. this._shadowAngle = value;
  47535. this.forceProjectionMatrixCompute();
  47536. },
  47537. enumerable: true,
  47538. configurable: true
  47539. });
  47540. Object.defineProperty(PointLight.prototype, "direction", {
  47541. /**
  47542. * Gets the direction if it has been set.
  47543. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47544. */
  47545. get: function () {
  47546. return this._direction;
  47547. },
  47548. /**
  47549. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47550. */
  47551. set: function (value) {
  47552. var previousNeedCube = this.needCube();
  47553. this._direction = value;
  47554. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  47555. this._shadowGenerator.recreateShadowMap();
  47556. }
  47557. },
  47558. enumerable: true,
  47559. configurable: true
  47560. });
  47561. /**
  47562. * Returns the string "PointLight"
  47563. * @returns the class name
  47564. */
  47565. PointLight.prototype.getClassName = function () {
  47566. return "PointLight";
  47567. };
  47568. /**
  47569. * Returns the integer 0.
  47570. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47571. */
  47572. PointLight.prototype.getTypeID = function () {
  47573. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  47574. };
  47575. /**
  47576. * Specifies wether or not the shadowmap should be a cube texture.
  47577. * @returns true if the shadowmap needs to be a cube texture.
  47578. */
  47579. PointLight.prototype.needCube = function () {
  47580. return !this.direction;
  47581. };
  47582. /**
  47583. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47584. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47585. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47586. */
  47587. PointLight.prototype.getShadowDirection = function (faceIndex) {
  47588. if (this.direction) {
  47589. return _super.prototype.getShadowDirection.call(this, faceIndex);
  47590. }
  47591. else {
  47592. switch (faceIndex) {
  47593. case 0:
  47594. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  47595. case 1:
  47596. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  47597. case 2:
  47598. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  47599. case 3:
  47600. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  47601. case 4:
  47602. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  47603. case 5:
  47604. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  47605. }
  47606. }
  47607. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47608. };
  47609. /**
  47610. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47611. * - fov = PI / 2
  47612. * - aspect ratio : 1.0
  47613. * - z-near and far equal to the active camera minZ and maxZ.
  47614. * Returns the PointLight.
  47615. */
  47616. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47617. var activeCamera = this.getScene().activeCamera;
  47618. if (!activeCamera) {
  47619. return;
  47620. }
  47621. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47622. };
  47623. PointLight.prototype._buildUniformLayout = function () {
  47624. this._uniformBuffer.addUniform("vLightData", 4);
  47625. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47626. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47627. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47628. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47629. this._uniformBuffer.addUniform("depthValues", 2);
  47630. this._uniformBuffer.create();
  47631. };
  47632. /**
  47633. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47634. * @param effect The effect to update
  47635. * @param lightIndex The index of the light in the effect to update
  47636. * @returns The point light
  47637. */
  47638. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  47639. if (this.computeTransformedInformation()) {
  47640. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  47641. }
  47642. else {
  47643. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  47644. }
  47645. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  47646. return this;
  47647. };
  47648. /**
  47649. * Prepares the list of defines specific to the light type.
  47650. * @param defines the list of defines
  47651. * @param lightIndex defines the index of the light for the effect
  47652. */
  47653. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47654. defines["POINTLIGHT" + lightIndex] = true;
  47655. };
  47656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47658. ], PointLight.prototype, "shadowAngle", null);
  47659. return PointLight;
  47660. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47661. /***/ }),
  47662. /***/ "./Lights/shadowLight.ts":
  47663. /*!*******************************!*\
  47664. !*** ./Lights/shadowLight.ts ***!
  47665. \*******************************/
  47666. /*! exports provided: ShadowLight */
  47667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47668. "use strict";
  47669. __webpack_require__.r(__webpack_exports__);
  47670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  47671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47672. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47673. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47674. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47675. /**
  47676. * Base implementation IShadowLight
  47677. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  47678. */
  47679. var ShadowLight = /** @class */ (function (_super) {
  47680. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  47681. function ShadowLight() {
  47682. var _this = _super !== null && _super.apply(this, arguments) || this;
  47683. _this._needProjectionMatrixCompute = true;
  47684. return _this;
  47685. }
  47686. ShadowLight.prototype._setPosition = function (value) {
  47687. this._position = value;
  47688. };
  47689. Object.defineProperty(ShadowLight.prototype, "position", {
  47690. /**
  47691. * Sets the position the shadow will be casted from. Also use as the light position for both
  47692. * point and spot lights.
  47693. */
  47694. get: function () {
  47695. return this._position;
  47696. },
  47697. /**
  47698. * Sets the position the shadow will be casted from. Also use as the light position for both
  47699. * point and spot lights.
  47700. */
  47701. set: function (value) {
  47702. this._setPosition(value);
  47703. },
  47704. enumerable: true,
  47705. configurable: true
  47706. });
  47707. ShadowLight.prototype._setDirection = function (value) {
  47708. this._direction = value;
  47709. };
  47710. Object.defineProperty(ShadowLight.prototype, "direction", {
  47711. /**
  47712. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  47713. * Also use as the light direction on spot and directional lights.
  47714. */
  47715. get: function () {
  47716. return this._direction;
  47717. },
  47718. /**
  47719. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  47720. * Also use as the light direction on spot and directional lights.
  47721. */
  47722. set: function (value) {
  47723. this._setDirection(value);
  47724. },
  47725. enumerable: true,
  47726. configurable: true
  47727. });
  47728. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  47729. /**
  47730. * Gets the shadow projection clipping minimum z value.
  47731. */
  47732. get: function () {
  47733. return this._shadowMinZ;
  47734. },
  47735. /**
  47736. * Sets the shadow projection clipping minimum z value.
  47737. */
  47738. set: function (value) {
  47739. this._shadowMinZ = value;
  47740. this.forceProjectionMatrixCompute();
  47741. },
  47742. enumerable: true,
  47743. configurable: true
  47744. });
  47745. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  47746. /**
  47747. * Sets the shadow projection clipping maximum z value.
  47748. */
  47749. get: function () {
  47750. return this._shadowMaxZ;
  47751. },
  47752. /**
  47753. * Gets the shadow projection clipping maximum z value.
  47754. */
  47755. set: function (value) {
  47756. this._shadowMaxZ = value;
  47757. this.forceProjectionMatrixCompute();
  47758. },
  47759. enumerable: true,
  47760. configurable: true
  47761. });
  47762. /**
  47763. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  47764. * @returns true if the information has been computed, false if it does not need to (no parenting)
  47765. */
  47766. ShadowLight.prototype.computeTransformedInformation = function () {
  47767. if (this.parent && this.parent.getWorldMatrix) {
  47768. if (!this.transformedPosition) {
  47769. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47770. }
  47771. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  47772. // In case the direction is present.
  47773. if (this.direction) {
  47774. if (!this.transformedDirection) {
  47775. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47776. }
  47777. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  47778. }
  47779. return true;
  47780. }
  47781. return false;
  47782. };
  47783. /**
  47784. * Return the depth scale used for the shadow map.
  47785. * @returns the depth scale.
  47786. */
  47787. ShadowLight.prototype.getDepthScale = function () {
  47788. return 50.0;
  47789. };
  47790. /**
  47791. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  47792. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47793. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47794. */
  47795. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  47796. return this.transformedDirection ? this.transformedDirection : this.direction;
  47797. };
  47798. /**
  47799. * Returns the ShadowLight absolute position in the World.
  47800. * @returns the position vector in world space
  47801. */
  47802. ShadowLight.prototype.getAbsolutePosition = function () {
  47803. return this.transformedPosition ? this.transformedPosition : this.position;
  47804. };
  47805. /**
  47806. * Sets the ShadowLight direction toward the passed target.
  47807. * @param target The point to target in local space
  47808. * @returns the updated ShadowLight direction
  47809. */
  47810. ShadowLight.prototype.setDirectionToTarget = function (target) {
  47811. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  47812. return this.direction;
  47813. };
  47814. /**
  47815. * Returns the light rotation in euler definition.
  47816. * @returns the x y z rotation in local space.
  47817. */
  47818. ShadowLight.prototype.getRotation = function () {
  47819. this.direction.normalize();
  47820. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  47821. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  47822. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  47823. };
  47824. /**
  47825. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  47826. * @returns true if a cube texture needs to be use
  47827. */
  47828. ShadowLight.prototype.needCube = function () {
  47829. return false;
  47830. };
  47831. /**
  47832. * Detects if the projection matrix requires to be recomputed this frame.
  47833. * @returns true if it requires to be recomputed otherwise, false.
  47834. */
  47835. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  47836. return this._needProjectionMatrixCompute;
  47837. };
  47838. /**
  47839. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  47840. */
  47841. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  47842. this._needProjectionMatrixCompute = true;
  47843. };
  47844. /** @hidden */
  47845. ShadowLight.prototype._initCache = function () {
  47846. _super.prototype._initCache.call(this);
  47847. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47848. };
  47849. /** @hidden */
  47850. ShadowLight.prototype._isSynchronized = function () {
  47851. if (!this._cache.position.equals(this.position)) {
  47852. return false;
  47853. }
  47854. return true;
  47855. };
  47856. /**
  47857. * Computes the world matrix of the node
  47858. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47859. * @returns the world matrix
  47860. */
  47861. ShadowLight.prototype.computeWorldMatrix = function (force) {
  47862. if (!force && this.isSynchronized()) {
  47863. this._currentRenderId = this.getScene().getRenderId();
  47864. return this._worldMatrix;
  47865. }
  47866. this._updateCache();
  47867. this._cache.position.copyFrom(this.position);
  47868. if (!this._worldMatrix) {
  47869. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47870. }
  47871. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  47872. if (this.parent && this.parent.getWorldMatrix) {
  47873. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  47874. this._markSyncedWithParent();
  47875. }
  47876. // Cache the determinant
  47877. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  47878. return this._worldMatrix;
  47879. };
  47880. /**
  47881. * Gets the minZ used for shadow according to both the scene and the light.
  47882. * @param activeCamera The camera we are returning the min for
  47883. * @returns the depth min z
  47884. */
  47885. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  47886. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  47887. };
  47888. /**
  47889. * Gets the maxZ used for shadow according to both the scene and the light.
  47890. * @param activeCamera The camera we are returning the max for
  47891. * @returns the depth max z
  47892. */
  47893. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  47894. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  47895. };
  47896. /**
  47897. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  47898. * @param matrix The materix to updated with the projection information
  47899. * @param viewMatrix The transform matrix of the light
  47900. * @param renderList The list of mesh to render in the map
  47901. * @returns The current light
  47902. */
  47903. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47904. if (this.customProjectionMatrixBuilder) {
  47905. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  47906. }
  47907. else {
  47908. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47909. }
  47910. return this;
  47911. };
  47912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47914. ], ShadowLight.prototype, "position", null);
  47915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47917. ], ShadowLight.prototype, "direction", null);
  47918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47920. ], ShadowLight.prototype, "shadowMinZ", null);
  47921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47923. ], ShadowLight.prototype, "shadowMaxZ", null);
  47924. return ShadowLight;
  47925. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  47926. /***/ }),
  47927. /***/ "./Lights/spotLight.ts":
  47928. /*!*****************************!*\
  47929. !*** ./Lights/spotLight.ts ***!
  47930. \*****************************/
  47931. /*! exports provided: SpotLight */
  47932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47933. "use strict";
  47934. __webpack_require__.r(__webpack_exports__);
  47935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  47936. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47937. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47938. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47939. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47940. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47941. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47942. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  47943. 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); };
  47944. });
  47945. /**
  47946. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47947. * These values define a cone of light starting from the position, emitting toward the direction.
  47948. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47949. * and the exponent defines the speed of the decay of the light with distance (reach).
  47950. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47951. */
  47952. var SpotLight = /** @class */ (function (_super) {
  47953. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  47954. /**
  47955. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47956. * It can cast shadows.
  47957. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47958. * @param name The light friendly name
  47959. * @param position The position of the spot light in the scene
  47960. * @param direction The direction of the light in the scene
  47961. * @param angle The cone angle of the light in Radians
  47962. * @param exponent The light decay speed with the distance from the emission spot
  47963. * @param scene The scene the lights belongs to
  47964. */
  47965. function SpotLight(name, position, direction, angle, exponent, scene) {
  47966. var _this = _super.call(this, name, scene) || this;
  47967. _this._innerAngle = 0;
  47968. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47969. _this._projectionTextureLightNear = 1e-6;
  47970. _this._projectionTextureLightFar = 1000.0;
  47971. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47972. _this._projectionTextureViewLightDirty = true;
  47973. _this._projectionTextureProjectionLightDirty = true;
  47974. _this._projectionTextureDirty = true;
  47975. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47976. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47977. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47978. _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);
  47979. _this.position = position;
  47980. _this.direction = direction;
  47981. _this.angle = angle;
  47982. _this.exponent = exponent;
  47983. return _this;
  47984. }
  47985. Object.defineProperty(SpotLight.prototype, "angle", {
  47986. /**
  47987. * Gets the cone angle of the spot light in Radians.
  47988. */
  47989. get: function () {
  47990. return this._angle;
  47991. },
  47992. /**
  47993. * Sets the cone angle of the spot light in Radians.
  47994. */
  47995. set: function (value) {
  47996. this._angle = value;
  47997. this._cosHalfAngle = Math.cos(value * 0.5);
  47998. this._projectionTextureProjectionLightDirty = true;
  47999. this.forceProjectionMatrixCompute();
  48000. this._computeAngleValues();
  48001. },
  48002. enumerable: true,
  48003. configurable: true
  48004. });
  48005. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  48006. /**
  48007. * Only used in gltf falloff mode, this defines the angle where
  48008. * the directional falloff will start before cutting at angle which could be seen
  48009. * as outer angle.
  48010. */
  48011. get: function () {
  48012. return this._innerAngle;
  48013. },
  48014. /**
  48015. * Only used in gltf falloff mode, this defines the angle where
  48016. * the directional falloff will start before cutting at angle which could be seen
  48017. * as outer angle.
  48018. */
  48019. set: function (value) {
  48020. this._innerAngle = value;
  48021. this._computeAngleValues();
  48022. },
  48023. enumerable: true,
  48024. configurable: true
  48025. });
  48026. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  48027. /**
  48028. * Allows scaling the angle of the light for shadow generation only.
  48029. */
  48030. get: function () {
  48031. return this._shadowAngleScale;
  48032. },
  48033. /**
  48034. * Allows scaling the angle of the light for shadow generation only.
  48035. */
  48036. set: function (value) {
  48037. this._shadowAngleScale = value;
  48038. this.forceProjectionMatrixCompute();
  48039. },
  48040. enumerable: true,
  48041. configurable: true
  48042. });
  48043. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  48044. /**
  48045. * Allows reading the projecton texture
  48046. */
  48047. get: function () {
  48048. return this._projectionTextureMatrix;
  48049. },
  48050. enumerable: true,
  48051. configurable: true
  48052. });
  48053. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  48054. /**
  48055. * Gets the near clip of the Spotlight for texture projection.
  48056. */
  48057. get: function () {
  48058. return this._projectionTextureLightNear;
  48059. },
  48060. /**
  48061. * Sets the near clip of the Spotlight for texture projection.
  48062. */
  48063. set: function (value) {
  48064. this._projectionTextureLightNear = value;
  48065. this._projectionTextureProjectionLightDirty = true;
  48066. },
  48067. enumerable: true,
  48068. configurable: true
  48069. });
  48070. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  48071. /**
  48072. * Gets the far clip of the Spotlight for texture projection.
  48073. */
  48074. get: function () {
  48075. return this._projectionTextureLightFar;
  48076. },
  48077. /**
  48078. * Sets the far clip of the Spotlight for texture projection.
  48079. */
  48080. set: function (value) {
  48081. this._projectionTextureLightFar = value;
  48082. this._projectionTextureProjectionLightDirty = true;
  48083. },
  48084. enumerable: true,
  48085. configurable: true
  48086. });
  48087. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  48088. /**
  48089. * Gets the Up vector of the Spotlight for texture projection.
  48090. */
  48091. get: function () {
  48092. return this._projectionTextureUpDirection;
  48093. },
  48094. /**
  48095. * Sets the Up vector of the Spotlight for texture projection.
  48096. */
  48097. set: function (value) {
  48098. this._projectionTextureUpDirection = value;
  48099. this._projectionTextureProjectionLightDirty = true;
  48100. },
  48101. enumerable: true,
  48102. configurable: true
  48103. });
  48104. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  48105. /**
  48106. * Gets the projection texture of the light.
  48107. */
  48108. get: function () {
  48109. return this._projectionTexture;
  48110. },
  48111. /**
  48112. * Sets the projection texture of the light.
  48113. */
  48114. set: function (value) {
  48115. this._projectionTexture = value;
  48116. this._projectionTextureDirty = true;
  48117. },
  48118. enumerable: true,
  48119. configurable: true
  48120. });
  48121. /**
  48122. * Returns the string "SpotLight".
  48123. * @returns the class name
  48124. */
  48125. SpotLight.prototype.getClassName = function () {
  48126. return "SpotLight";
  48127. };
  48128. /**
  48129. * Returns the integer 2.
  48130. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48131. */
  48132. SpotLight.prototype.getTypeID = function () {
  48133. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  48134. };
  48135. /**
  48136. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48137. */
  48138. SpotLight.prototype._setDirection = function (value) {
  48139. _super.prototype._setDirection.call(this, value);
  48140. this._projectionTextureViewLightDirty = true;
  48141. };
  48142. /**
  48143. * Overrides the position setter to recompute the projection texture view light Matrix.
  48144. */
  48145. SpotLight.prototype._setPosition = function (value) {
  48146. _super.prototype._setPosition.call(this, value);
  48147. this._projectionTextureViewLightDirty = true;
  48148. };
  48149. /**
  48150. * 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.
  48151. * Returns the SpotLight.
  48152. */
  48153. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48154. var activeCamera = this.getScene().activeCamera;
  48155. if (!activeCamera) {
  48156. return;
  48157. }
  48158. this._shadowAngleScale = this._shadowAngleScale || 1;
  48159. var angle = this._shadowAngleScale * this._angle;
  48160. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48161. };
  48162. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  48163. this._projectionTextureViewLightDirty = false;
  48164. this._projectionTextureDirty = true;
  48165. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  48166. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  48167. };
  48168. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  48169. this._projectionTextureProjectionLightDirty = false;
  48170. this._projectionTextureDirty = true;
  48171. var light_far = this.projectionTextureLightFar;
  48172. var light_near = this.projectionTextureLightNear;
  48173. var P = light_far / (light_far - light_near);
  48174. var Q = -P * light_near;
  48175. var S = 1.0 / Math.tan(this._angle / 2.0);
  48176. var A = 1.0;
  48177. _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);
  48178. };
  48179. /**
  48180. * Main function for light texture projection matrix computing.
  48181. */
  48182. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  48183. this._projectionTextureDirty = false;
  48184. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  48185. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  48186. };
  48187. SpotLight.prototype._buildUniformLayout = function () {
  48188. this._uniformBuffer.addUniform("vLightData", 4);
  48189. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48190. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48191. this._uniformBuffer.addUniform("vLightDirection", 3);
  48192. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48193. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48194. this._uniformBuffer.addUniform("depthValues", 2);
  48195. this._uniformBuffer.create();
  48196. };
  48197. SpotLight.prototype._computeAngleValues = function () {
  48198. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  48199. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  48200. };
  48201. /**
  48202. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48203. * @param effect The effect to update
  48204. * @param lightIndex The index of the light in the effect to update
  48205. * @returns The spot light
  48206. */
  48207. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  48208. var normalizeDirection;
  48209. if (this.computeTransformedInformation()) {
  48210. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  48211. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  48212. }
  48213. else {
  48214. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  48215. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  48216. }
  48217. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  48218. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  48219. if (this.projectionTexture && this.projectionTexture.isReady()) {
  48220. if (this._projectionTextureViewLightDirty) {
  48221. this._computeProjectionTextureViewLightMatrix();
  48222. }
  48223. if (this._projectionTextureProjectionLightDirty) {
  48224. this._computeProjectionTextureProjectionLightMatrix();
  48225. }
  48226. if (this._projectionTextureDirty) {
  48227. this._computeProjectionTextureMatrix();
  48228. }
  48229. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  48230. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  48231. }
  48232. return this;
  48233. };
  48234. /**
  48235. * Disposes the light and the associated resources.
  48236. */
  48237. SpotLight.prototype.dispose = function () {
  48238. _super.prototype.dispose.call(this);
  48239. if (this._projectionTexture) {
  48240. this._projectionTexture.dispose();
  48241. }
  48242. };
  48243. /**
  48244. * Prepares the list of defines specific to the light type.
  48245. * @param defines the list of defines
  48246. * @param lightIndex defines the index of the light for the effect
  48247. */
  48248. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48249. defines["SPOTLIGHT" + lightIndex] = true;
  48250. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  48251. };
  48252. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48253. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48254. ], SpotLight.prototype, "angle", null);
  48255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48257. ], SpotLight.prototype, "innerAngle", null);
  48258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48260. ], SpotLight.prototype, "shadowAngleScale", null);
  48261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48263. ], SpotLight.prototype, "exponent", void 0);
  48264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48266. ], SpotLight.prototype, "projectionTextureLightNear", null);
  48267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48269. ], SpotLight.prototype, "projectionTextureLightFar", null);
  48270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48272. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  48273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  48275. ], SpotLight.prototype, "_projectionTexture", void 0);
  48276. return SpotLight;
  48277. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48278. /***/ }),
  48279. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  48280. /*!**********************************************!*\
  48281. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  48282. \**********************************************/
  48283. /*! exports provided: _BabylonLoaderRegistered */
  48284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48285. "use strict";
  48286. __webpack_require__.r(__webpack_exports__);
  48287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  48288. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48289. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  48290. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48291. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  48292. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  48293. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  48294. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  48295. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  48296. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  48297. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  48298. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  48299. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  48300. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  48301. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  48302. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  48303. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  48304. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  48305. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  48306. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  48307. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  48308. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  48309. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  48310. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48311. /** @hidden */
  48312. var _BabylonLoaderRegistered = true;
  48313. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  48314. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48315. var parsedMaterial = parsedData.materials[index];
  48316. if (parsedMaterial.id === id) {
  48317. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48318. }
  48319. }
  48320. return null;
  48321. };
  48322. var isDescendantOf = function (mesh, names, hierarchyIds) {
  48323. for (var i in names) {
  48324. if (mesh.name === names[i]) {
  48325. hierarchyIds.push(mesh.id);
  48326. return true;
  48327. }
  48328. }
  48329. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  48330. hierarchyIds.push(mesh.id);
  48331. return true;
  48332. }
  48333. return false;
  48334. };
  48335. var logOperation = function (operation, producer) {
  48336. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  48337. };
  48338. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  48339. if (addToScene === void 0) { addToScene = false; }
  48340. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  48341. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48342. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48343. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48344. // and avoid problems with multiple concurrent .babylon loads.
  48345. var log = "importScene has failed JSON parse";
  48346. try {
  48347. var parsedData = JSON.parse(data);
  48348. log = "";
  48349. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48350. var index;
  48351. var cache;
  48352. // Lights
  48353. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  48354. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  48355. var parsedLight = parsedData.lights[index];
  48356. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  48357. if (light) {
  48358. container.lights.push(light);
  48359. log += (index === 0 ? "\n\tLights:" : "");
  48360. log += "\n\t\t" + light.toString(fullDetails);
  48361. }
  48362. }
  48363. }
  48364. // Reflection probes
  48365. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  48366. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  48367. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  48368. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  48369. if (reflectionProbe) {
  48370. container.reflectionProbes.push(reflectionProbe);
  48371. log += (index === 0 ? "\n\tReflection Probes:" : "");
  48372. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  48373. }
  48374. }
  48375. }
  48376. // Animations
  48377. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  48378. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  48379. var parsedAnimation = parsedData.animations[index];
  48380. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  48381. if (internalClass) {
  48382. var animation = internalClass.Parse(parsedAnimation);
  48383. scene.animations.push(animation);
  48384. container.animations.push(animation);
  48385. log += (index === 0 ? "\n\tAnimations:" : "");
  48386. log += "\n\t\t" + animation.toString(fullDetails);
  48387. }
  48388. }
  48389. }
  48390. // Materials
  48391. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  48392. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48393. var parsedMaterial = parsedData.materials[index];
  48394. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48395. container.materials.push(mat);
  48396. log += (index === 0 ? "\n\tMaterials:" : "");
  48397. log += "\n\t\t" + mat.toString(fullDetails);
  48398. }
  48399. }
  48400. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48401. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  48402. var parsedMultiMaterial = parsedData.multiMaterials[index];
  48403. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48404. container.multiMaterials.push(mmat);
  48405. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  48406. log += "\n\t\t" + mmat.toString(fullDetails);
  48407. }
  48408. }
  48409. // Morph targets
  48410. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48411. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48412. var managerData = _a[_i];
  48413. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  48414. }
  48415. }
  48416. // Skeletons
  48417. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48418. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  48419. var parsedSkeleton = parsedData.skeletons[index];
  48420. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48421. container.skeletons.push(skeleton);
  48422. log += (index === 0 ? "\n\tSkeletons:" : "");
  48423. log += "\n\t\t" + skeleton.toString(fullDetails);
  48424. }
  48425. }
  48426. // Geometries
  48427. var geometries = parsedData.geometries;
  48428. if (geometries !== undefined && geometries !== null) {
  48429. var addedGeometry = new Array();
  48430. // VertexData
  48431. var vertexData = geometries.vertexData;
  48432. if (vertexData !== undefined && vertexData !== null) {
  48433. for (index = 0, cache = vertexData.length; index < cache; index++) {
  48434. var parsedVertexData = vertexData[index];
  48435. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  48436. }
  48437. }
  48438. addedGeometry.forEach(function (g) {
  48439. if (g) {
  48440. container.geometries.push(g);
  48441. }
  48442. });
  48443. }
  48444. // Transform nodes
  48445. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  48446. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  48447. var parsedTransformNode = parsedData.transformNodes[index];
  48448. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  48449. container.transformNodes.push(node);
  48450. }
  48451. }
  48452. // Meshes
  48453. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48454. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48455. var parsedMesh = parsedData.meshes[index];
  48456. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48457. container.meshes.push(mesh);
  48458. log += (index === 0 ? "\n\tMeshes:" : "");
  48459. log += "\n\t\t" + mesh.toString(fullDetails);
  48460. }
  48461. }
  48462. // Cameras
  48463. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  48464. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  48465. var parsedCamera = parsedData.cameras[index];
  48466. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  48467. container.cameras.push(camera);
  48468. log += (index === 0 ? "\n\tCameras:" : "");
  48469. log += "\n\t\t" + camera.toString(fullDetails);
  48470. }
  48471. }
  48472. // Animation Groups
  48473. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  48474. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  48475. var parsedAnimationGroup = parsedData.animationGroups[index];
  48476. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  48477. container.animationGroups.push(animationGroup);
  48478. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  48479. log += "\n\t\t" + animationGroup.toString(fullDetails);
  48480. }
  48481. }
  48482. // Browsing all the graph to connect the dots
  48483. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  48484. var camera = scene.cameras[index];
  48485. if (camera._waitingParentId) {
  48486. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  48487. camera._waitingParentId = null;
  48488. }
  48489. }
  48490. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  48491. var light_1 = scene.lights[index];
  48492. if (light_1 && light_1._waitingParentId) {
  48493. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  48494. light_1._waitingParentId = null;
  48495. }
  48496. }
  48497. // Connect parents & children and parse actions
  48498. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  48499. var transformNode = scene.transformNodes[index];
  48500. if (transformNode._waitingParentId) {
  48501. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  48502. transformNode._waitingParentId = null;
  48503. }
  48504. }
  48505. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48506. var mesh = scene.meshes[index];
  48507. if (mesh._waitingParentId) {
  48508. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  48509. mesh._waitingParentId = null;
  48510. }
  48511. }
  48512. // freeze world matrix application
  48513. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48514. var currentMesh = scene.meshes[index];
  48515. if (currentMesh._waitingFreezeWorldMatrix) {
  48516. currentMesh.freezeWorldMatrix();
  48517. currentMesh._waitingFreezeWorldMatrix = null;
  48518. }
  48519. else {
  48520. currentMesh.computeWorldMatrix(true);
  48521. }
  48522. }
  48523. // Lights exclusions / inclusions
  48524. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  48525. var light_2 = scene.lights[index];
  48526. // Excluded check
  48527. if (light_2._excludedMeshesIds.length > 0) {
  48528. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  48529. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  48530. if (excludedMesh) {
  48531. light_2.excludedMeshes.push(excludedMesh);
  48532. }
  48533. }
  48534. light_2._excludedMeshesIds = [];
  48535. }
  48536. // Included check
  48537. if (light_2._includedOnlyMeshesIds.length > 0) {
  48538. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  48539. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  48540. if (includedOnlyMesh) {
  48541. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  48542. }
  48543. }
  48544. light_2._includedOnlyMeshesIds = [];
  48545. }
  48546. }
  48547. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  48548. // Actions (scene) Done last as it can access other objects.
  48549. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48550. var mesh = scene.meshes[index];
  48551. if (mesh._waitingActions) {
  48552. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  48553. mesh._waitingActions = null;
  48554. }
  48555. }
  48556. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  48557. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  48558. }
  48559. if (!addToScene) {
  48560. container.removeAllFromScene();
  48561. }
  48562. }
  48563. catch (err) {
  48564. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  48565. if (onError) {
  48566. onError(msg, err);
  48567. }
  48568. else {
  48569. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48570. throw err;
  48571. }
  48572. }
  48573. finally {
  48574. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48575. _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 : ""));
  48576. }
  48577. }
  48578. return container;
  48579. };
  48580. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  48581. name: "babylon.js",
  48582. extensions: ".babylon",
  48583. canDirectLoad: function (data) {
  48584. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  48585. return true;
  48586. }
  48587. return false;
  48588. },
  48589. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  48590. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48591. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48592. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48593. // and avoid problems with multiple concurrent .babylon loads.
  48594. var log = "importMesh has failed JSON parse";
  48595. try {
  48596. var parsedData = JSON.parse(data);
  48597. log = "";
  48598. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48599. if (!meshesNames) {
  48600. meshesNames = null;
  48601. }
  48602. else if (!Array.isArray(meshesNames)) {
  48603. meshesNames = [meshesNames];
  48604. }
  48605. var hierarchyIds = new Array();
  48606. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48607. var loadedSkeletonsIds = [];
  48608. var loadedMaterialsIds = [];
  48609. var index;
  48610. var cache;
  48611. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48612. var parsedMesh = parsedData.meshes[index];
  48613. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  48614. if (meshesNames !== null) {
  48615. // Remove found mesh name from list.
  48616. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  48617. }
  48618. //Geometry?
  48619. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  48620. //does the file contain geometries?
  48621. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  48622. //find the correct geometry and add it to the scene
  48623. var found = false;
  48624. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  48625. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  48626. return;
  48627. }
  48628. else {
  48629. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  48630. if (parsedGeometryData.id === parsedMesh.geometryId) {
  48631. switch (geometryType) {
  48632. case "vertexData":
  48633. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  48634. break;
  48635. }
  48636. found = true;
  48637. }
  48638. });
  48639. }
  48640. });
  48641. if (found === false) {
  48642. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  48643. }
  48644. }
  48645. }
  48646. // Material ?
  48647. if (parsedMesh.materialId) {
  48648. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  48649. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48650. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  48651. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  48652. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  48653. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  48654. var subMatId = parsedMultiMaterial.materials[matIndex];
  48655. loadedMaterialsIds.push(subMatId);
  48656. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  48657. if (mat) {
  48658. log += "\n\tMaterial " + mat.toString(fullDetails);
  48659. }
  48660. }
  48661. loadedMaterialsIds.push(parsedMultiMaterial.id);
  48662. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48663. if (mmat) {
  48664. materialFound = true;
  48665. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  48666. }
  48667. break;
  48668. }
  48669. }
  48670. }
  48671. if (materialFound === false) {
  48672. loadedMaterialsIds.push(parsedMesh.materialId);
  48673. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  48674. if (!mat) {
  48675. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  48676. }
  48677. else {
  48678. log += "\n\tMaterial " + mat.toString(fullDetails);
  48679. }
  48680. }
  48681. }
  48682. // Skeleton ?
  48683. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48684. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  48685. if (skeletonAlreadyLoaded === false) {
  48686. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  48687. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  48688. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  48689. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48690. skeletons.push(skeleton);
  48691. loadedSkeletonsIds.push(parsedSkeleton.id);
  48692. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  48693. }
  48694. }
  48695. }
  48696. }
  48697. // Morph targets ?
  48698. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48699. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48700. var managerData = _a[_i];
  48701. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  48702. }
  48703. }
  48704. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48705. meshes.push(mesh);
  48706. log += "\n\tMesh " + mesh.toString(fullDetails);
  48707. }
  48708. }
  48709. // Connecting parents
  48710. var currentMesh;
  48711. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48712. currentMesh = scene.meshes[index];
  48713. if (currentMesh._waitingParentId) {
  48714. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  48715. currentMesh._waitingParentId = null;
  48716. }
  48717. }
  48718. // freeze and compute world matrix application
  48719. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48720. currentMesh = scene.meshes[index];
  48721. if (currentMesh._waitingFreezeWorldMatrix) {
  48722. currentMesh.freezeWorldMatrix();
  48723. currentMesh._waitingFreezeWorldMatrix = null;
  48724. }
  48725. else {
  48726. currentMesh.computeWorldMatrix(true);
  48727. }
  48728. }
  48729. }
  48730. // Particles
  48731. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  48732. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  48733. if (parser) {
  48734. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  48735. var parsedParticleSystem = parsedData.particleSystems[index];
  48736. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  48737. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  48738. }
  48739. }
  48740. }
  48741. }
  48742. return true;
  48743. }
  48744. catch (err) {
  48745. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  48746. if (onError) {
  48747. onError(msg, err);
  48748. }
  48749. else {
  48750. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48751. throw err;
  48752. }
  48753. }
  48754. finally {
  48755. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48756. _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 : ""));
  48757. }
  48758. }
  48759. return false;
  48760. },
  48761. load: function (scene, data, rootUrl, onError) {
  48762. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48763. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48764. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48765. // and avoid problems with multiple concurrent .babylon loads.
  48766. var log = "importScene has failed JSON parse";
  48767. try {
  48768. var parsedData = JSON.parse(data);
  48769. log = "";
  48770. // Scene
  48771. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  48772. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  48773. }
  48774. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  48775. scene.autoClear = parsedData.autoClear;
  48776. }
  48777. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  48778. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  48779. }
  48780. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  48781. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  48782. }
  48783. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  48784. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  48785. }
  48786. // Fog
  48787. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  48788. scene.fogMode = parsedData.fogMode;
  48789. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  48790. scene.fogStart = parsedData.fogStart;
  48791. scene.fogEnd = parsedData.fogEnd;
  48792. scene.fogDensity = parsedData.fogDensity;
  48793. log += "\tFog mode for scene: ";
  48794. switch (scene.fogMode) {
  48795. // getters not compiling, so using hardcoded
  48796. case 1:
  48797. log += "exp\n";
  48798. break;
  48799. case 2:
  48800. log += "exp2\n";
  48801. break;
  48802. case 3:
  48803. log += "linear\n";
  48804. break;
  48805. }
  48806. }
  48807. //Physics
  48808. if (parsedData.physicsEnabled) {
  48809. var physicsPlugin;
  48810. if (parsedData.physicsEngine === "cannon") {
  48811. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  48812. }
  48813. else if (parsedData.physicsEngine === "oimo") {
  48814. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  48815. }
  48816. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  48817. //else - default engine, which is currently oimo
  48818. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  48819. scene.enablePhysics(physicsGravity, physicsPlugin);
  48820. }
  48821. // Metadata
  48822. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  48823. scene.metadata = parsedData.metadata;
  48824. }
  48825. //collisions, if defined. otherwise, default is true
  48826. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  48827. scene.collisionsEnabled = parsedData.collisionsEnabled;
  48828. }
  48829. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  48830. if (!container) {
  48831. return false;
  48832. }
  48833. if (parsedData.autoAnimate) {
  48834. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  48835. }
  48836. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  48837. scene.setActiveCameraByID(parsedData.activeCameraID);
  48838. }
  48839. // Environment texture
  48840. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48841. // PBR needed for both HDR texture (gamma space) & a sky box
  48842. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48843. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48844. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48845. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48846. if (parsedData.environmentTextureRotationY) {
  48847. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48848. }
  48849. scene.environmentTexture = hdrTexture;
  48850. }
  48851. else {
  48852. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  48853. if (parsedData.environmentTextureRotationY) {
  48854. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48855. }
  48856. scene.environmentTexture = cubeTexture;
  48857. }
  48858. if (parsedData.createDefaultSkybox === true) {
  48859. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48860. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48861. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48862. }
  48863. }
  48864. // Finish
  48865. return true;
  48866. }
  48867. catch (err) {
  48868. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  48869. if (onError) {
  48870. onError(msg, err);
  48871. }
  48872. else {
  48873. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48874. throw err;
  48875. }
  48876. }
  48877. finally {
  48878. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48879. _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 : ""));
  48880. }
  48881. }
  48882. return false;
  48883. },
  48884. loadAssetContainer: function (scene, data, rootUrl, onError) {
  48885. var container = loadAssetContainer(scene, data, rootUrl, onError);
  48886. return container;
  48887. }
  48888. });
  48889. /***/ }),
  48890. /***/ "./Loading/Plugins/index.ts":
  48891. /*!**********************************!*\
  48892. !*** ./Loading/Plugins/index.ts ***!
  48893. \**********************************/
  48894. /*! exports provided: _BabylonLoaderRegistered */
  48895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48896. "use strict";
  48897. __webpack_require__.r(__webpack_exports__);
  48898. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  48899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  48900. /***/ }),
  48901. /***/ "./Loading/index.ts":
  48902. /*!**************************!*\
  48903. !*** ./Loading/index.ts ***!
  48904. \**************************/
  48905. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  48906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48907. "use strict";
  48908. __webpack_require__.r(__webpack_exports__);
  48909. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  48910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  48911. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  48912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  48913. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  48914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  48915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  48916. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  48918. /***/ }),
  48919. /***/ "./Loading/loadingScreen.ts":
  48920. /*!**********************************!*\
  48921. !*** ./Loading/loadingScreen.ts ***!
  48922. \**********************************/
  48923. /*! exports provided: DefaultLoadingScreen */
  48924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48925. "use strict";
  48926. __webpack_require__.r(__webpack_exports__);
  48927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  48928. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48929. /**
  48930. * Class used for the default loading screen
  48931. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  48932. */
  48933. var DefaultLoadingScreen = /** @class */ (function () {
  48934. /**
  48935. * Creates a new default loading screen
  48936. * @param _renderingCanvas defines the canvas used to render the scene
  48937. * @param _loadingText defines the default text to display
  48938. * @param _loadingDivBackgroundColor defines the default background color
  48939. */
  48940. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  48941. if (_loadingText === void 0) { _loadingText = ""; }
  48942. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  48943. var _this = this;
  48944. this._renderingCanvas = _renderingCanvas;
  48945. this._loadingText = _loadingText;
  48946. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  48947. // Resize
  48948. this._resizeLoadingUI = function () {
  48949. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  48950. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  48951. if (!_this._loadingDiv) {
  48952. return;
  48953. }
  48954. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  48955. _this._loadingDiv.style.left = canvasRect.left + "px";
  48956. _this._loadingDiv.style.top = canvasRect.top + "px";
  48957. _this._loadingDiv.style.width = canvasRect.width + "px";
  48958. _this._loadingDiv.style.height = canvasRect.height + "px";
  48959. };
  48960. }
  48961. /**
  48962. * Function called to display the loading screen
  48963. */
  48964. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  48965. if (this._loadingDiv) {
  48966. // Do not add a loading screen if there is already one
  48967. return;
  48968. }
  48969. this._loadingDiv = document.createElement("div");
  48970. this._loadingDiv.id = "babylonjsLoadingDiv";
  48971. this._loadingDiv.style.opacity = "0";
  48972. this._loadingDiv.style.transition = "opacity 1.5s ease";
  48973. this._loadingDiv.style.pointerEvents = "none";
  48974. // Loading text
  48975. this._loadingTextDiv = document.createElement("div");
  48976. this._loadingTextDiv.style.position = "absolute";
  48977. this._loadingTextDiv.style.left = "0";
  48978. this._loadingTextDiv.style.top = "50%";
  48979. this._loadingTextDiv.style.marginTop = "80px";
  48980. this._loadingTextDiv.style.width = "100%";
  48981. this._loadingTextDiv.style.height = "20px";
  48982. this._loadingTextDiv.style.fontFamily = "Arial";
  48983. this._loadingTextDiv.style.fontSize = "14px";
  48984. this._loadingTextDiv.style.color = "white";
  48985. this._loadingTextDiv.style.textAlign = "center";
  48986. this._loadingTextDiv.innerHTML = "Loading";
  48987. this._loadingDiv.appendChild(this._loadingTextDiv);
  48988. //set the predefined text
  48989. this._loadingTextDiv.innerHTML = this._loadingText;
  48990. // Generating keyframes
  48991. var style = document.createElement('style');
  48992. style.type = 'text/css';
  48993. 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 }";
  48994. style.innerHTML = keyFrames;
  48995. document.getElementsByTagName('head')[0].appendChild(style);
  48996. // Loading img
  48997. var imgBack = new Image();
  48998. 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";
  48999. imgBack.style.position = "absolute";
  49000. imgBack.style.left = "50%";
  49001. imgBack.style.top = "50%";
  49002. imgBack.style.marginLeft = "-60px";
  49003. imgBack.style.marginTop = "-60px";
  49004. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  49005. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  49006. imgBack.style.transformOrigin = "50% 50%";
  49007. imgBack.style.webkitTransformOrigin = "50% 50%";
  49008. this._loadingDiv.appendChild(imgBack);
  49009. this._resizeLoadingUI();
  49010. window.addEventListener("resize", this._resizeLoadingUI);
  49011. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49012. document.body.appendChild(this._loadingDiv);
  49013. this._loadingDiv.style.opacity = "1";
  49014. };
  49015. /**
  49016. * Function called to hide the loading screen
  49017. */
  49018. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  49019. var _this = this;
  49020. if (!this._loadingDiv) {
  49021. return;
  49022. }
  49023. var onTransitionEnd = function () {
  49024. if (!_this._loadingDiv) {
  49025. return;
  49026. }
  49027. if (_this._loadingDiv.parentElement) {
  49028. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  49029. }
  49030. window.removeEventListener("resize", _this._resizeLoadingUI);
  49031. _this._loadingDiv = null;
  49032. };
  49033. this._loadingDiv.style.opacity = "0";
  49034. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  49035. };
  49036. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  49037. get: function () {
  49038. return this._loadingText;
  49039. },
  49040. /**
  49041. * Gets or sets the text to display while loading
  49042. */
  49043. set: function (text) {
  49044. this._loadingText = text;
  49045. if (this._loadingTextDiv) {
  49046. this._loadingTextDiv.innerHTML = this._loadingText;
  49047. }
  49048. },
  49049. enumerable: true,
  49050. configurable: true
  49051. });
  49052. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  49053. /**
  49054. * Gets or sets the color to use for the background
  49055. */
  49056. get: function () {
  49057. return this._loadingDivBackgroundColor;
  49058. },
  49059. set: function (color) {
  49060. this._loadingDivBackgroundColor = color;
  49061. if (!this._loadingDiv) {
  49062. return;
  49063. }
  49064. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49065. },
  49066. enumerable: true,
  49067. configurable: true
  49068. });
  49069. return DefaultLoadingScreen;
  49070. }());
  49071. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  49072. /***/ }),
  49073. /***/ "./Loading/sceneLoader.ts":
  49074. /*!********************************!*\
  49075. !*** ./Loading/sceneLoader.ts ***!
  49076. \********************************/
  49077. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  49078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49079. "use strict";
  49080. __webpack_require__.r(__webpack_exports__);
  49081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  49082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  49083. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  49084. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  49085. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  49086. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  49087. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49088. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  49089. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  49090. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49091. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49092. /**
  49093. * Class used to represent data loading progression
  49094. */
  49095. var SceneLoaderProgressEvent = /** @class */ (function () {
  49096. /**
  49097. * Create a new progress event
  49098. * @param lengthComputable defines if data length to load can be evaluated
  49099. * @param loaded defines the loaded data length
  49100. * @param total defines the data length to load
  49101. */
  49102. function SceneLoaderProgressEvent(
  49103. /** defines if data length to load can be evaluated */
  49104. lengthComputable,
  49105. /** defines the loaded data length */
  49106. loaded,
  49107. /** defines the data length to load */
  49108. total) {
  49109. this.lengthComputable = lengthComputable;
  49110. this.loaded = loaded;
  49111. this.total = total;
  49112. }
  49113. /**
  49114. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  49115. * @param event defines the source event
  49116. * @returns a new SceneLoaderProgressEvent
  49117. */
  49118. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  49119. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  49120. };
  49121. return SceneLoaderProgressEvent;
  49122. }());
  49123. /**
  49124. * Class used to load scene from various file formats using registered plugins
  49125. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  49126. */
  49127. var SceneLoader = /** @class */ (function () {
  49128. function SceneLoader() {
  49129. }
  49130. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  49131. /**
  49132. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49133. */
  49134. get: function () {
  49135. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  49136. },
  49137. set: function (value) {
  49138. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  49139. },
  49140. enumerable: true,
  49141. configurable: true
  49142. });
  49143. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  49144. /**
  49145. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49146. */
  49147. get: function () {
  49148. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  49149. },
  49150. set: function (value) {
  49151. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  49152. },
  49153. enumerable: true,
  49154. configurable: true
  49155. });
  49156. Object.defineProperty(SceneLoader, "loggingLevel", {
  49157. /**
  49158. * Defines the current logging level (while loading the scene)
  49159. * @ignorenaming
  49160. */
  49161. get: function () {
  49162. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  49163. },
  49164. set: function (value) {
  49165. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  49166. },
  49167. enumerable: true,
  49168. configurable: true
  49169. });
  49170. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  49171. /**
  49172. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49173. */
  49174. get: function () {
  49175. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  49176. },
  49177. set: function (value) {
  49178. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  49179. },
  49180. enumerable: true,
  49181. configurable: true
  49182. });
  49183. SceneLoader._getDefaultPlugin = function () {
  49184. return SceneLoader._registeredPlugins[".babylon"];
  49185. };
  49186. SceneLoader._getPluginForExtension = function (extension) {
  49187. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  49188. if (registeredPlugin) {
  49189. return registeredPlugin;
  49190. }
  49191. _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");
  49192. return SceneLoader._getDefaultPlugin();
  49193. };
  49194. SceneLoader._getPluginForDirectLoad = function (data) {
  49195. for (var extension in SceneLoader._registeredPlugins) {
  49196. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  49197. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  49198. return SceneLoader._registeredPlugins[extension];
  49199. }
  49200. }
  49201. return SceneLoader._getDefaultPlugin();
  49202. };
  49203. SceneLoader._getPluginForFilename = function (sceneFilename) {
  49204. var queryStringPosition = sceneFilename.indexOf("?");
  49205. if (queryStringPosition !== -1) {
  49206. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  49207. }
  49208. var dotPosition = sceneFilename.lastIndexOf(".");
  49209. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  49210. return SceneLoader._getPluginForExtension(extension);
  49211. };
  49212. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  49213. SceneLoader._getDirectLoad = function (sceneFilename) {
  49214. if (sceneFilename.substr(0, 5) === "data:") {
  49215. return sceneFilename.substr(5);
  49216. }
  49217. return null;
  49218. };
  49219. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  49220. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  49221. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  49222. var plugin;
  49223. if (registeredPlugin.plugin.createPlugin) {
  49224. plugin = registeredPlugin.plugin.createPlugin();
  49225. }
  49226. else {
  49227. plugin = registeredPlugin.plugin;
  49228. }
  49229. if (!plugin) {
  49230. 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.";
  49231. }
  49232. var useArrayBuffer = registeredPlugin.isBinary;
  49233. var offlineProvider;
  49234. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  49235. var dataCallback = function (data, responseURL) {
  49236. if (scene.isDisposed) {
  49237. onError("Scene has been disposed");
  49238. return;
  49239. }
  49240. scene.offlineProvider = offlineProvider;
  49241. onSuccess(plugin, data, responseURL);
  49242. };
  49243. var request = null;
  49244. var pluginDisposed = false;
  49245. var onDisposeObservable = plugin.onDisposeObservable;
  49246. if (onDisposeObservable) {
  49247. onDisposeObservable.add(function () {
  49248. pluginDisposed = true;
  49249. if (request) {
  49250. request.abort();
  49251. request = null;
  49252. }
  49253. onDispose();
  49254. });
  49255. }
  49256. var manifestChecked = function () {
  49257. if (pluginDisposed) {
  49258. return;
  49259. }
  49260. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  49261. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  49262. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  49263. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  49264. });
  49265. };
  49266. if (directLoad) {
  49267. dataCallback(directLoad);
  49268. return plugin;
  49269. }
  49270. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  49271. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  49272. var engine = scene.getEngine();
  49273. var canUseOfflineSupport = engine.enableOfflineSupport;
  49274. if (canUseOfflineSupport) {
  49275. // Also check for exceptions
  49276. var exceptionFound = false;
  49277. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  49278. var regex = _a[_i];
  49279. if (regex.test(fileInfo.url)) {
  49280. exceptionFound = true;
  49281. break;
  49282. }
  49283. }
  49284. canUseOfflineSupport = !exceptionFound;
  49285. }
  49286. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  49287. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  49288. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  49289. }
  49290. else {
  49291. manifestChecked();
  49292. }
  49293. }
  49294. // Loading file from disk via input file or drag'n'drop
  49295. else {
  49296. if (file) {
  49297. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  49298. }
  49299. else {
  49300. onError("Unable to find file named " + fileInfo.name);
  49301. }
  49302. }
  49303. return plugin;
  49304. };
  49305. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  49306. var url;
  49307. var name;
  49308. var file = null;
  49309. if (!sceneFilename) {
  49310. url = rootUrl;
  49311. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  49312. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  49313. }
  49314. else if (sceneFilename.name) {
  49315. var sceneFile = sceneFilename;
  49316. url = rootUrl + sceneFile.name;
  49317. name = sceneFile.name;
  49318. file = sceneFile;
  49319. }
  49320. else {
  49321. var filename = sceneFilename;
  49322. if (filename.substr(0, 1) === "/") {
  49323. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  49324. return null;
  49325. }
  49326. url = rootUrl + filename;
  49327. name = filename;
  49328. }
  49329. return {
  49330. url: url,
  49331. rootUrl: rootUrl,
  49332. name: name,
  49333. file: file
  49334. };
  49335. };
  49336. // Public functions
  49337. /**
  49338. * Gets a plugin that can load the given extension
  49339. * @param extension defines the extension to load
  49340. * @returns a plugin or null if none works
  49341. */
  49342. SceneLoader.GetPluginForExtension = function (extension) {
  49343. return SceneLoader._getPluginForExtension(extension).plugin;
  49344. };
  49345. /**
  49346. * Gets a boolean indicating that the given extension can be loaded
  49347. * @param extension defines the extension to load
  49348. * @returns true if the extension is supported
  49349. */
  49350. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  49351. return !!SceneLoader._registeredPlugins[extension];
  49352. };
  49353. /**
  49354. * Adds a new plugin to the list of registered plugins
  49355. * @param plugin defines the plugin to add
  49356. */
  49357. SceneLoader.RegisterPlugin = function (plugin) {
  49358. if (typeof plugin.extensions === "string") {
  49359. var extension = plugin.extensions;
  49360. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49361. plugin: plugin,
  49362. isBinary: false
  49363. };
  49364. }
  49365. else {
  49366. var extensions = plugin.extensions;
  49367. Object.keys(extensions).forEach(function (extension) {
  49368. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49369. plugin: plugin,
  49370. isBinary: extensions[extension].isBinary
  49371. };
  49372. });
  49373. }
  49374. };
  49375. /**
  49376. * Import meshes into a scene
  49377. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49378. * @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)
  49379. * @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)
  49380. * @param scene the instance of BABYLON.Scene to append to
  49381. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49382. * @param onProgress a callback with a progress event for each file being loaded
  49383. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49384. * @param pluginExtension the extension used to determine the plugin
  49385. * @returns The loaded plugin
  49386. */
  49387. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49388. if (sceneFilename === void 0) { sceneFilename = ""; }
  49389. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49390. if (onSuccess === void 0) { onSuccess = null; }
  49391. if (onProgress === void 0) { onProgress = null; }
  49392. if (onError === void 0) { onError = null; }
  49393. if (pluginExtension === void 0) { pluginExtension = null; }
  49394. if (!scene) {
  49395. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  49396. return null;
  49397. }
  49398. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49399. if (!fileInfo) {
  49400. return null;
  49401. }
  49402. var loadingToken = {};
  49403. scene._addPendingData(loadingToken);
  49404. var disposeHandler = function () {
  49405. scene._removePendingData(loadingToken);
  49406. };
  49407. var errorHandler = function (message, exception) {
  49408. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  49409. if (onError) {
  49410. onError(scene, errorMessage, exception);
  49411. }
  49412. else {
  49413. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49414. // should the exception be thrown?
  49415. }
  49416. disposeHandler();
  49417. };
  49418. var progressHandler = onProgress ? function (event) {
  49419. try {
  49420. onProgress(event);
  49421. }
  49422. catch (e) {
  49423. errorHandler("Error in onProgress callback", e);
  49424. }
  49425. } : undefined;
  49426. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  49427. scene.importedMeshesFiles.push(fileInfo.url);
  49428. if (onSuccess) {
  49429. try {
  49430. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  49431. }
  49432. catch (e) {
  49433. errorHandler("Error in onSuccess callback", e);
  49434. }
  49435. }
  49436. scene._removePendingData(loadingToken);
  49437. };
  49438. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  49439. if (plugin.rewriteRootURL) {
  49440. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  49441. }
  49442. if (plugin.importMesh) {
  49443. var syncedPlugin = plugin;
  49444. var meshes = new Array();
  49445. var particleSystems = new Array();
  49446. var skeletons = new Array();
  49447. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  49448. return;
  49449. }
  49450. scene.loadingPluginName = plugin.name;
  49451. successHandler(meshes, particleSystems, skeletons, []);
  49452. }
  49453. else {
  49454. var asyncedPlugin = plugin;
  49455. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  49456. scene.loadingPluginName = plugin.name;
  49457. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  49458. }).catch(function (error) {
  49459. errorHandler(error.message, error);
  49460. });
  49461. }
  49462. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49463. };
  49464. /**
  49465. * Import meshes into a scene
  49466. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49467. * @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)
  49468. * @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)
  49469. * @param scene the instance of BABYLON.Scene to append to
  49470. * @param onProgress a callback with a progress event for each file being loaded
  49471. * @param pluginExtension the extension used to determine the plugin
  49472. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49473. */
  49474. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49475. if (sceneFilename === void 0) { sceneFilename = ""; }
  49476. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49477. if (onProgress === void 0) { onProgress = null; }
  49478. if (pluginExtension === void 0) { pluginExtension = null; }
  49479. return new Promise(function (resolve, reject) {
  49480. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  49481. resolve({
  49482. meshes: meshes,
  49483. particleSystems: particleSystems,
  49484. skeletons: skeletons,
  49485. animationGroups: animationGroups
  49486. });
  49487. }, onProgress, function (scene, message, exception) {
  49488. reject(exception || new Error(message));
  49489. }, pluginExtension);
  49490. });
  49491. };
  49492. /**
  49493. * Load a scene
  49494. * @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)
  49495. * @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)
  49496. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49497. * @param onSuccess a callback with the scene when import succeeds
  49498. * @param onProgress a callback with a progress event for each file being loaded
  49499. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49500. * @param pluginExtension the extension used to determine the plugin
  49501. * @returns The loaded plugin
  49502. */
  49503. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  49504. if (sceneFilename === void 0) { sceneFilename = ""; }
  49505. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  49506. if (onSuccess === void 0) { onSuccess = null; }
  49507. if (onProgress === void 0) { onProgress = null; }
  49508. if (onError === void 0) { onError = null; }
  49509. if (pluginExtension === void 0) { pluginExtension = null; }
  49510. if (!engine) {
  49511. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  49512. return null;
  49513. }
  49514. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  49515. };
  49516. /**
  49517. * Load a scene
  49518. * @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)
  49519. * @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)
  49520. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49521. * @param onProgress a callback with a progress event for each file being loaded
  49522. * @param pluginExtension the extension used to determine the plugin
  49523. * @returns The loaded scene
  49524. */
  49525. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  49526. if (sceneFilename === void 0) { sceneFilename = ""; }
  49527. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  49528. if (onProgress === void 0) { onProgress = null; }
  49529. if (pluginExtension === void 0) { pluginExtension = null; }
  49530. return new Promise(function (resolve, reject) {
  49531. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  49532. resolve(scene);
  49533. }, onProgress, function (scene, message, exception) {
  49534. reject(exception || new Error(message));
  49535. }, pluginExtension);
  49536. });
  49537. };
  49538. /**
  49539. * Append a scene
  49540. * @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)
  49541. * @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)
  49542. * @param scene is the instance of BABYLON.Scene to append to
  49543. * @param onSuccess a callback with the scene when import succeeds
  49544. * @param onProgress a callback with a progress event for each file being loaded
  49545. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49546. * @param pluginExtension the extension used to determine the plugin
  49547. * @returns The loaded plugin
  49548. */
  49549. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49550. if (sceneFilename === void 0) { sceneFilename = ""; }
  49551. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49552. if (onSuccess === void 0) { onSuccess = null; }
  49553. if (onProgress === void 0) { onProgress = null; }
  49554. if (onError === void 0) { onError = null; }
  49555. if (pluginExtension === void 0) { pluginExtension = null; }
  49556. if (!scene) {
  49557. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  49558. return null;
  49559. }
  49560. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49561. if (!fileInfo) {
  49562. return null;
  49563. }
  49564. if (SceneLoader.ShowLoadingScreen) {
  49565. scene.getEngine().displayLoadingUI();
  49566. }
  49567. var loadingToken = {};
  49568. scene._addPendingData(loadingToken);
  49569. var disposeHandler = function () {
  49570. scene._removePendingData(loadingToken);
  49571. scene.getEngine().hideLoadingUI();
  49572. };
  49573. var errorHandler = function (message, exception) {
  49574. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  49575. if (onError) {
  49576. onError(scene, errorMessage, exception);
  49577. }
  49578. else {
  49579. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49580. // should the exception be thrown?
  49581. }
  49582. disposeHandler();
  49583. };
  49584. var progressHandler = onProgress ? function (event) {
  49585. try {
  49586. onProgress(event);
  49587. }
  49588. catch (e) {
  49589. errorHandler("Error in onProgress callback", e);
  49590. }
  49591. } : undefined;
  49592. var successHandler = function () {
  49593. if (onSuccess) {
  49594. try {
  49595. onSuccess(scene);
  49596. }
  49597. catch (e) {
  49598. errorHandler("Error in onSuccess callback", e);
  49599. }
  49600. }
  49601. scene._removePendingData(loadingToken);
  49602. };
  49603. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49604. if (plugin.load) {
  49605. var syncedPlugin = plugin;
  49606. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  49607. return;
  49608. }
  49609. scene.loadingPluginName = plugin.name;
  49610. successHandler();
  49611. }
  49612. else {
  49613. var asyncedPlugin = plugin;
  49614. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  49615. scene.loadingPluginName = plugin.name;
  49616. successHandler();
  49617. }).catch(function (error) {
  49618. errorHandler(error.message, error);
  49619. });
  49620. }
  49621. if (SceneLoader.ShowLoadingScreen) {
  49622. scene.executeWhenReady(function () {
  49623. scene.getEngine().hideLoadingUI();
  49624. });
  49625. }
  49626. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49627. };
  49628. /**
  49629. * Append a scene
  49630. * @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)
  49631. * @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)
  49632. * @param scene is the instance of BABYLON.Scene to append to
  49633. * @param onProgress a callback with a progress event for each file being loaded
  49634. * @param pluginExtension the extension used to determine the plugin
  49635. * @returns The given scene
  49636. */
  49637. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49638. if (sceneFilename === void 0) { sceneFilename = ""; }
  49639. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49640. if (onProgress === void 0) { onProgress = null; }
  49641. if (pluginExtension === void 0) { pluginExtension = null; }
  49642. return new Promise(function (resolve, reject) {
  49643. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  49644. resolve(scene);
  49645. }, onProgress, function (scene, message, exception) {
  49646. reject(exception || new Error(message));
  49647. }, pluginExtension);
  49648. });
  49649. };
  49650. /**
  49651. * Load a scene into an asset container
  49652. * @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)
  49653. * @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)
  49654. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49655. * @param onSuccess a callback with the scene when import succeeds
  49656. * @param onProgress a callback with a progress event for each file being loaded
  49657. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49658. * @param pluginExtension the extension used to determine the plugin
  49659. * @returns The loaded plugin
  49660. */
  49661. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49662. if (sceneFilename === void 0) { sceneFilename = ""; }
  49663. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49664. if (onSuccess === void 0) { onSuccess = null; }
  49665. if (onProgress === void 0) { onProgress = null; }
  49666. if (onError === void 0) { onError = null; }
  49667. if (pluginExtension === void 0) { pluginExtension = null; }
  49668. if (!scene) {
  49669. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  49670. return null;
  49671. }
  49672. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49673. if (!fileInfo) {
  49674. return null;
  49675. }
  49676. var loadingToken = {};
  49677. scene._addPendingData(loadingToken);
  49678. var disposeHandler = function () {
  49679. scene._removePendingData(loadingToken);
  49680. };
  49681. var errorHandler = function (message, exception) {
  49682. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  49683. if (onError) {
  49684. onError(scene, errorMessage, exception);
  49685. }
  49686. else {
  49687. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49688. // should the exception be thrown?
  49689. }
  49690. disposeHandler();
  49691. };
  49692. var progressHandler = onProgress ? function (event) {
  49693. try {
  49694. onProgress(event);
  49695. }
  49696. catch (e) {
  49697. errorHandler("Error in onProgress callback", e);
  49698. }
  49699. } : undefined;
  49700. var successHandler = function (assets) {
  49701. if (onSuccess) {
  49702. try {
  49703. onSuccess(assets);
  49704. }
  49705. catch (e) {
  49706. errorHandler("Error in onSuccess callback", e);
  49707. }
  49708. }
  49709. scene._removePendingData(loadingToken);
  49710. };
  49711. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49712. if (plugin.loadAssetContainer) {
  49713. var syncedPlugin = plugin;
  49714. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  49715. if (!assetContainer) {
  49716. return;
  49717. }
  49718. scene.loadingPluginName = plugin.name;
  49719. successHandler(assetContainer);
  49720. }
  49721. else if (plugin.loadAssetContainerAsync) {
  49722. var asyncedPlugin = plugin;
  49723. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  49724. scene.loadingPluginName = plugin.name;
  49725. successHandler(assetContainer);
  49726. }).catch(function (error) {
  49727. errorHandler(error.message, error);
  49728. });
  49729. }
  49730. else {
  49731. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  49732. }
  49733. if (SceneLoader.ShowLoadingScreen) {
  49734. scene.executeWhenReady(function () {
  49735. scene.getEngine().hideLoadingUI();
  49736. });
  49737. }
  49738. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49739. };
  49740. /**
  49741. * Load a scene into an asset container
  49742. * @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)
  49743. * @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)
  49744. * @param scene is the instance of Scene to append to
  49745. * @param onProgress a callback with a progress event for each file being loaded
  49746. * @param pluginExtension the extension used to determine the plugin
  49747. * @returns The loaded asset container
  49748. */
  49749. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49750. if (sceneFilename === void 0) { sceneFilename = ""; }
  49751. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49752. if (onProgress === void 0) { onProgress = null; }
  49753. if (pluginExtension === void 0) { pluginExtension = null; }
  49754. return new Promise(function (resolve, reject) {
  49755. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  49756. resolve(assetContainer);
  49757. }, onProgress, function (scene, message, exception) {
  49758. reject(exception || new Error(message));
  49759. }, pluginExtension);
  49760. });
  49761. };
  49762. /**
  49763. * No logging while loading
  49764. */
  49765. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  49766. /**
  49767. * Minimal logging while loading
  49768. */
  49769. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  49770. /**
  49771. * Summary logging while loading
  49772. */
  49773. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  49774. /**
  49775. * Detailled logging while loading
  49776. */
  49777. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  49778. // Members
  49779. /**
  49780. * Event raised when a plugin is used to load a scene
  49781. */
  49782. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  49783. SceneLoader._registeredPlugins = {};
  49784. return SceneLoader;
  49785. }());
  49786. /***/ }),
  49787. /***/ "./Loading/sceneLoaderFlags.ts":
  49788. /*!*************************************!*\
  49789. !*** ./Loading/sceneLoaderFlags.ts ***!
  49790. \*************************************/
  49791. /*! exports provided: SceneLoaderFlags */
  49792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49793. "use strict";
  49794. __webpack_require__.r(__webpack_exports__);
  49795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  49796. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49797. /**
  49798. * Class used to represent data loading progression
  49799. */
  49800. var SceneLoaderFlags = /** @class */ (function () {
  49801. function SceneLoaderFlags() {
  49802. }
  49803. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  49804. /**
  49805. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49806. */
  49807. get: function () {
  49808. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  49809. },
  49810. set: function (value) {
  49811. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  49812. },
  49813. enumerable: true,
  49814. configurable: true
  49815. });
  49816. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  49817. /**
  49818. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49819. */
  49820. get: function () {
  49821. return SceneLoaderFlags._ShowLoadingScreen;
  49822. },
  49823. set: function (value) {
  49824. SceneLoaderFlags._ShowLoadingScreen = value;
  49825. },
  49826. enumerable: true,
  49827. configurable: true
  49828. });
  49829. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  49830. /**
  49831. * Defines the current logging level (while loading the scene)
  49832. * @ignorenaming
  49833. */
  49834. get: function () {
  49835. return SceneLoaderFlags._loggingLevel;
  49836. },
  49837. set: function (value) {
  49838. SceneLoaderFlags._loggingLevel = value;
  49839. },
  49840. enumerable: true,
  49841. configurable: true
  49842. });
  49843. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  49844. /**
  49845. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49846. */
  49847. get: function () {
  49848. return SceneLoaderFlags._CleanBoneMatrixWeights;
  49849. },
  49850. set: function (value) {
  49851. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  49852. },
  49853. enumerable: true,
  49854. configurable: true
  49855. });
  49856. // Flags
  49857. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  49858. SceneLoaderFlags._ShowLoadingScreen = true;
  49859. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  49860. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  49861. return SceneLoaderFlags;
  49862. }());
  49863. /***/ }),
  49864. /***/ "./Materials/Background/backgroundMaterial.ts":
  49865. /*!****************************************************!*\
  49866. !*** ./Materials/Background/backgroundMaterial.ts ***!
  49867. \****************************************************/
  49868. /*! exports provided: BackgroundMaterial */
  49869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49870. "use strict";
  49871. __webpack_require__.r(__webpack_exports__);
  49872. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  49873. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49874. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49875. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49876. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49877. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49878. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49879. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49880. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49881. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49882. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49883. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49884. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49885. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49886. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  49887. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49888. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  49889. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  49890. /**
  49891. * Background material defines definition.
  49892. * @hidden Mainly internal Use
  49893. */
  49894. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  49895. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  49896. /**
  49897. * Constructor of the defines.
  49898. */
  49899. function BackgroundMaterialDefines() {
  49900. var _this = _super.call(this) || this;
  49901. /**
  49902. * True if the diffuse texture is in use.
  49903. */
  49904. _this.DIFFUSE = false;
  49905. /**
  49906. * The direct UV channel to use.
  49907. */
  49908. _this.DIFFUSEDIRECTUV = 0;
  49909. /**
  49910. * True if the diffuse texture is in gamma space.
  49911. */
  49912. _this.GAMMADIFFUSE = false;
  49913. /**
  49914. * True if the diffuse texture has opacity in the alpha channel.
  49915. */
  49916. _this.DIFFUSEHASALPHA = false;
  49917. /**
  49918. * True if you want the material to fade to transparent at grazing angle.
  49919. */
  49920. _this.OPACITYFRESNEL = false;
  49921. /**
  49922. * True if an extra blur needs to be added in the reflection.
  49923. */
  49924. _this.REFLECTIONBLUR = false;
  49925. /**
  49926. * True if you want the material to fade to reflection at grazing angle.
  49927. */
  49928. _this.REFLECTIONFRESNEL = false;
  49929. /**
  49930. * True if you want the material to falloff as far as you move away from the scene center.
  49931. */
  49932. _this.REFLECTIONFALLOFF = false;
  49933. /**
  49934. * False if the current Webgl implementation does not support the texture lod extension.
  49935. */
  49936. _this.TEXTURELODSUPPORT = false;
  49937. /**
  49938. * True to ensure the data are premultiplied.
  49939. */
  49940. _this.PREMULTIPLYALPHA = false;
  49941. /**
  49942. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  49943. */
  49944. _this.USERGBCOLOR = false;
  49945. /**
  49946. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  49947. * stays aligned with the desired configuration.
  49948. */
  49949. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  49950. /**
  49951. * True to add noise in order to reduce the banding effect.
  49952. */
  49953. _this.NOISE = false;
  49954. /**
  49955. * is the reflection texture in BGR color scheme?
  49956. * Mainly used to solve a bug in ios10 video tag
  49957. */
  49958. _this.REFLECTIONBGR = false;
  49959. _this.IMAGEPROCESSING = false;
  49960. _this.VIGNETTE = false;
  49961. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49962. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49963. _this.TONEMAPPING = false;
  49964. _this.TONEMAPPING_ACES = false;
  49965. _this.CONTRAST = false;
  49966. _this.COLORCURVES = false;
  49967. _this.COLORGRADING = false;
  49968. _this.COLORGRADING3D = false;
  49969. _this.SAMPLER3DGREENDEPTH = false;
  49970. _this.SAMPLER3DBGRMAP = false;
  49971. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49972. _this.EXPOSURE = false;
  49973. // Reflection.
  49974. _this.REFLECTION = false;
  49975. _this.REFLECTIONMAP_3D = false;
  49976. _this.REFLECTIONMAP_SPHERICAL = false;
  49977. _this.REFLECTIONMAP_PLANAR = false;
  49978. _this.REFLECTIONMAP_CUBIC = false;
  49979. _this.REFLECTIONMAP_PROJECTION = false;
  49980. _this.REFLECTIONMAP_SKYBOX = false;
  49981. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49982. _this.REFLECTIONMAP_EXPLICIT = false;
  49983. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49984. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49985. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49986. _this.INVERTCUBICMAP = false;
  49987. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49988. _this.LODINREFLECTIONALPHA = false;
  49989. _this.GAMMAREFLECTION = false;
  49990. _this.RGBDREFLECTION = false;
  49991. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  49992. // Default BJS.
  49993. _this.MAINUV1 = false;
  49994. _this.MAINUV2 = false;
  49995. _this.UV1 = false;
  49996. _this.UV2 = false;
  49997. _this.CLIPPLANE = false;
  49998. _this.CLIPPLANE2 = false;
  49999. _this.CLIPPLANE3 = false;
  50000. _this.CLIPPLANE4 = false;
  50001. _this.POINTSIZE = false;
  50002. _this.FOG = false;
  50003. _this.NORMAL = false;
  50004. _this.NUM_BONE_INFLUENCERS = 0;
  50005. _this.BonesPerMesh = 0;
  50006. _this.INSTANCES = false;
  50007. _this.SHADOWFLOAT = false;
  50008. _this.rebuild();
  50009. return _this;
  50010. }
  50011. return BackgroundMaterialDefines;
  50012. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  50013. /**
  50014. * Background material used to create an efficient environement around your scene.
  50015. */
  50016. var BackgroundMaterial = /** @class */ (function (_super) {
  50017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  50018. /**
  50019. * Instantiates a Background Material in the given scene
  50020. * @param name The friendly name of the material
  50021. * @param scene The scene to add the material to
  50022. */
  50023. function BackgroundMaterial(name, scene) {
  50024. var _this = _super.call(this, name, scene) || this;
  50025. /**
  50026. * Key light Color (multiply against the environement texture)
  50027. */
  50028. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50029. _this._primaryColorShadowLevel = 0;
  50030. _this._primaryColorHighlightLevel = 0;
  50031. /**
  50032. * Reflection Texture used in the material.
  50033. * Should be author in a specific way for the best result (refer to the documentation).
  50034. */
  50035. _this.reflectionTexture = null;
  50036. /**
  50037. * Reflection Texture level of blur.
  50038. *
  50039. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50040. * texture twice.
  50041. */
  50042. _this.reflectionBlur = 0;
  50043. /**
  50044. * Diffuse Texture used in the material.
  50045. * Should be author in a specific way for the best result (refer to the documentation).
  50046. */
  50047. _this.diffuseTexture = null;
  50048. _this._shadowLights = null;
  50049. /**
  50050. * Specify the list of lights casting shadow on the material.
  50051. * All scene shadow lights will be included if null.
  50052. */
  50053. _this.shadowLights = null;
  50054. /**
  50055. * Helps adjusting the shadow to a softer level if required.
  50056. * 0 means black shadows and 1 means no shadows.
  50057. */
  50058. _this.shadowLevel = 0;
  50059. /**
  50060. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50061. * It is usually zero but might be interesting to modify according to your setup.
  50062. */
  50063. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  50064. /**
  50065. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50066. * This helps ensuring a nice transition when the camera goes under the ground.
  50067. */
  50068. _this.opacityFresnel = true;
  50069. /**
  50070. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50071. * This helps adding a mirror texture on the ground.
  50072. */
  50073. _this.reflectionFresnel = false;
  50074. /**
  50075. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50076. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50077. */
  50078. _this.reflectionFalloffDistance = 0.0;
  50079. /**
  50080. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50081. */
  50082. _this.reflectionAmount = 1.0;
  50083. /**
  50084. * This specifies the weight of the reflection at grazing angle.
  50085. */
  50086. _this.reflectionReflectance0 = 0.05;
  50087. /**
  50088. * This specifies the weight of the reflection at a perpendicular point of view.
  50089. */
  50090. _this.reflectionReflectance90 = 0.5;
  50091. /**
  50092. * Helps to directly use the maps channels instead of their level.
  50093. */
  50094. _this.useRGBColor = true;
  50095. /**
  50096. * This helps reducing the banding effect that could occur on the background.
  50097. */
  50098. _this.enableNoise = false;
  50099. _this._fovMultiplier = 1.0;
  50100. /**
  50101. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50102. */
  50103. _this.useEquirectangularFOV = false;
  50104. _this._maxSimultaneousLights = 4;
  50105. /**
  50106. * Number of Simultaneous lights allowed on the material.
  50107. */
  50108. _this.maxSimultaneousLights = 4;
  50109. /**
  50110. * Keep track of the image processing observer to allow dispose and replace.
  50111. */
  50112. _this._imageProcessingObserver = null;
  50113. /**
  50114. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50115. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50116. */
  50117. _this.switchToBGR = false;
  50118. // Temp values kept as cache in the material.
  50119. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  50120. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  50121. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50122. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50123. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50124. // Setup the default processing configuration to the scene.
  50125. _this._attachImageProcessingConfiguration(null);
  50126. _this.getRenderTargetTextures = function () {
  50127. _this._renderTargets.reset();
  50128. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  50129. _this._renderTargets.push(_this._diffuseTexture);
  50130. }
  50131. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50132. _this._renderTargets.push(_this._reflectionTexture);
  50133. }
  50134. return _this._renderTargets;
  50135. };
  50136. return _this;
  50137. }
  50138. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  50139. /**
  50140. * Experimental Internal Use Only.
  50141. *
  50142. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50143. * This acts as a helper to set the primary color to a more "human friendly" value.
  50144. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50145. * output color as close as possible from the chosen value.
  50146. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50147. * part of lighting setup.)
  50148. */
  50149. get: function () {
  50150. return this.__perceptualColor;
  50151. },
  50152. set: function (value) {
  50153. this.__perceptualColor = value;
  50154. this._computePrimaryColorFromPerceptualColor();
  50155. this._markAllSubMeshesAsLightsDirty();
  50156. },
  50157. enumerable: true,
  50158. configurable: true
  50159. });
  50160. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  50161. /**
  50162. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50163. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50164. */
  50165. get: function () {
  50166. return this._primaryColorShadowLevel;
  50167. },
  50168. set: function (value) {
  50169. this._primaryColorShadowLevel = value;
  50170. this._computePrimaryColors();
  50171. this._markAllSubMeshesAsLightsDirty();
  50172. },
  50173. enumerable: true,
  50174. configurable: true
  50175. });
  50176. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  50177. /**
  50178. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50179. * The primary color is used at the level chosen to define what the white area would look.
  50180. */
  50181. get: function () {
  50182. return this._primaryColorHighlightLevel;
  50183. },
  50184. set: function (value) {
  50185. this._primaryColorHighlightLevel = value;
  50186. this._computePrimaryColors();
  50187. this._markAllSubMeshesAsLightsDirty();
  50188. },
  50189. enumerable: true,
  50190. configurable: true
  50191. });
  50192. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  50193. /**
  50194. * Sets the reflection reflectance fresnel values according to the default standard
  50195. * empirically know to work well :-)
  50196. */
  50197. set: function (value) {
  50198. var reflectionWeight = value;
  50199. if (reflectionWeight < 0.5) {
  50200. reflectionWeight = reflectionWeight * 2.0;
  50201. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  50202. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  50203. }
  50204. else {
  50205. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  50206. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  50207. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  50208. }
  50209. },
  50210. enumerable: true,
  50211. configurable: true
  50212. });
  50213. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  50214. /**
  50215. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50216. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50217. * Recommended to be keep at 1.0 except for special cases.
  50218. */
  50219. get: function () {
  50220. return this._fovMultiplier;
  50221. },
  50222. set: function (value) {
  50223. if (isNaN(value)) {
  50224. value = 1.0;
  50225. }
  50226. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  50227. },
  50228. enumerable: true,
  50229. configurable: true
  50230. });
  50231. /**
  50232. * Attaches a new image processing configuration to the PBR Material.
  50233. * @param configuration (if null the scene configuration will be use)
  50234. */
  50235. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50236. var _this = this;
  50237. if (configuration === this._imageProcessingConfiguration) {
  50238. return;
  50239. }
  50240. // Detaches observer.
  50241. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50242. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50243. }
  50244. // Pick the scene configuration if needed.
  50245. if (!configuration) {
  50246. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50247. }
  50248. else {
  50249. this._imageProcessingConfiguration = configuration;
  50250. }
  50251. // Attaches observer.
  50252. if (this._imageProcessingConfiguration) {
  50253. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50254. _this._computePrimaryColorFromPerceptualColor();
  50255. _this._markAllSubMeshesAsImageProcessingDirty();
  50256. });
  50257. }
  50258. };
  50259. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  50260. /**
  50261. * Gets the image processing configuration used either in this material.
  50262. */
  50263. get: function () {
  50264. return this._imageProcessingConfiguration;
  50265. },
  50266. /**
  50267. * Sets the Default image processing configuration used either in the this material.
  50268. *
  50269. * If sets to null, the scene one is in use.
  50270. */
  50271. set: function (value) {
  50272. this._attachImageProcessingConfiguration(value);
  50273. // Ensure the effect will be rebuilt.
  50274. this._markAllSubMeshesAsTexturesDirty();
  50275. },
  50276. enumerable: true,
  50277. configurable: true
  50278. });
  50279. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  50280. /**
  50281. * Gets wether the color curves effect is enabled.
  50282. */
  50283. get: function () {
  50284. return this.imageProcessingConfiguration.colorCurvesEnabled;
  50285. },
  50286. /**
  50287. * Sets wether the color curves effect is enabled.
  50288. */
  50289. set: function (value) {
  50290. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  50291. },
  50292. enumerable: true,
  50293. configurable: true
  50294. });
  50295. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  50296. /**
  50297. * Gets wether the color grading effect is enabled.
  50298. */
  50299. get: function () {
  50300. return this.imageProcessingConfiguration.colorGradingEnabled;
  50301. },
  50302. /**
  50303. * Gets wether the color grading effect is enabled.
  50304. */
  50305. set: function (value) {
  50306. this.imageProcessingConfiguration.colorGradingEnabled = value;
  50307. },
  50308. enumerable: true,
  50309. configurable: true
  50310. });
  50311. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  50312. /**
  50313. * Gets wether tonemapping is enabled or not.
  50314. */
  50315. get: function () {
  50316. return this._imageProcessingConfiguration.toneMappingEnabled;
  50317. },
  50318. /**
  50319. * Sets wether tonemapping is enabled or not
  50320. */
  50321. set: function (value) {
  50322. this._imageProcessingConfiguration.toneMappingEnabled = value;
  50323. },
  50324. enumerable: true,
  50325. configurable: true
  50326. });
  50327. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  50328. /**
  50329. * The camera exposure used on this material.
  50330. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50331. * This corresponds to a photographic exposure.
  50332. */
  50333. get: function () {
  50334. return this._imageProcessingConfiguration.exposure;
  50335. },
  50336. /**
  50337. * The camera exposure used on this material.
  50338. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50339. * This corresponds to a photographic exposure.
  50340. */
  50341. set: function (value) {
  50342. this._imageProcessingConfiguration.exposure = value;
  50343. },
  50344. enumerable: true,
  50345. configurable: true
  50346. });
  50347. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  50348. /**
  50349. * Gets The camera contrast used on this material.
  50350. */
  50351. get: function () {
  50352. return this._imageProcessingConfiguration.contrast;
  50353. },
  50354. /**
  50355. * Sets The camera contrast used on this material.
  50356. */
  50357. set: function (value) {
  50358. this._imageProcessingConfiguration.contrast = value;
  50359. },
  50360. enumerable: true,
  50361. configurable: true
  50362. });
  50363. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  50364. /**
  50365. * Gets the Color Grading 2D Lookup Texture.
  50366. */
  50367. get: function () {
  50368. return this._imageProcessingConfiguration.colorGradingTexture;
  50369. },
  50370. /**
  50371. * Sets the Color Grading 2D Lookup Texture.
  50372. */
  50373. set: function (value) {
  50374. this.imageProcessingConfiguration.colorGradingTexture = value;
  50375. },
  50376. enumerable: true,
  50377. configurable: true
  50378. });
  50379. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  50380. /**
  50381. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50382. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50383. * 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;
  50384. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50385. */
  50386. get: function () {
  50387. return this.imageProcessingConfiguration.colorCurves;
  50388. },
  50389. /**
  50390. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50391. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50392. * 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;
  50393. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50394. */
  50395. set: function (value) {
  50396. this.imageProcessingConfiguration.colorCurves = value;
  50397. },
  50398. enumerable: true,
  50399. configurable: true
  50400. });
  50401. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  50402. /**
  50403. * Gets a boolean indicating that current material needs to register RTT
  50404. */
  50405. get: function () {
  50406. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50407. return true;
  50408. }
  50409. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50410. return true;
  50411. }
  50412. return false;
  50413. },
  50414. enumerable: true,
  50415. configurable: true
  50416. });
  50417. /**
  50418. * The entire material has been created in order to prevent overdraw.
  50419. * @returns false
  50420. */
  50421. BackgroundMaterial.prototype.needAlphaTesting = function () {
  50422. return true;
  50423. };
  50424. /**
  50425. * The entire material has been created in order to prevent overdraw.
  50426. * @returns true if blending is enable
  50427. */
  50428. BackgroundMaterial.prototype.needAlphaBlending = function () {
  50429. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  50430. };
  50431. /**
  50432. * Checks wether the material is ready to be rendered for a given mesh.
  50433. * @param mesh The mesh to render
  50434. * @param subMesh The submesh to check against
  50435. * @param useInstances Specify wether or not the material is used with instances
  50436. * @returns true if all the dependencies are ready (Textures, Effects...)
  50437. */
  50438. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  50439. var _this = this;
  50440. if (useInstances === void 0) { useInstances = false; }
  50441. if (subMesh.effect && this.isFrozen) {
  50442. if (this._wasPreviouslyReady) {
  50443. return true;
  50444. }
  50445. }
  50446. if (!subMesh._materialDefines) {
  50447. subMesh._materialDefines = new BackgroundMaterialDefines();
  50448. }
  50449. var scene = this.getScene();
  50450. var defines = subMesh._materialDefines;
  50451. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  50452. if (defines._renderId === scene.getRenderId()) {
  50453. return true;
  50454. }
  50455. }
  50456. var engine = scene.getEngine();
  50457. // Lights
  50458. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  50459. defines._needNormals = true;
  50460. // Textures
  50461. if (defines._areTexturesDirty) {
  50462. defines._needUVs = false;
  50463. if (scene.texturesEnabled) {
  50464. if (scene.getEngine().getCaps().textureLOD) {
  50465. defines.TEXTURELODSUPPORT = true;
  50466. }
  50467. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50468. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  50469. return false;
  50470. }
  50471. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  50472. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  50473. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  50474. defines.OPACITYFRESNEL = this._opacityFresnel;
  50475. }
  50476. else {
  50477. defines.DIFFUSE = false;
  50478. defines.DIFFUSEHASALPHA = false;
  50479. defines.GAMMADIFFUSE = false;
  50480. defines.OPACITYFRESNEL = false;
  50481. }
  50482. var reflectionTexture = this._reflectionTexture;
  50483. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50484. if (!reflectionTexture.isReadyOrNotBlocking()) {
  50485. return false;
  50486. }
  50487. defines.REFLECTION = true;
  50488. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  50489. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  50490. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  50491. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  50492. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  50493. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  50494. defines.REFLECTIONBGR = this.switchToBGR;
  50495. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  50496. defines.INVERTCUBICMAP = true;
  50497. }
  50498. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  50499. switch (reflectionTexture.coordinatesMode) {
  50500. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  50501. defines.REFLECTIONMAP_EXPLICIT = true;
  50502. break;
  50503. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  50504. defines.REFLECTIONMAP_PLANAR = true;
  50505. break;
  50506. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  50507. defines.REFLECTIONMAP_PROJECTION = true;
  50508. break;
  50509. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  50510. defines.REFLECTIONMAP_SKYBOX = true;
  50511. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  50512. break;
  50513. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  50514. defines.REFLECTIONMAP_SPHERICAL = true;
  50515. break;
  50516. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  50517. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  50518. break;
  50519. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  50520. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  50521. break;
  50522. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  50523. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  50524. break;
  50525. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  50526. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  50527. default:
  50528. defines.REFLECTIONMAP_CUBIC = true;
  50529. break;
  50530. }
  50531. if (this.reflectionFresnel) {
  50532. defines.REFLECTIONFRESNEL = true;
  50533. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  50534. this._reflectionControls.x = this.reflectionAmount;
  50535. this._reflectionControls.y = this.reflectionReflectance0;
  50536. this._reflectionControls.z = this.reflectionReflectance90;
  50537. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  50538. }
  50539. else {
  50540. defines.REFLECTIONFRESNEL = false;
  50541. defines.REFLECTIONFALLOFF = false;
  50542. }
  50543. }
  50544. else {
  50545. defines.REFLECTION = false;
  50546. defines.REFLECTIONFRESNEL = false;
  50547. defines.REFLECTIONFALLOFF = false;
  50548. defines.REFLECTIONBLUR = false;
  50549. defines.REFLECTIONMAP_3D = false;
  50550. defines.REFLECTIONMAP_SPHERICAL = false;
  50551. defines.REFLECTIONMAP_PLANAR = false;
  50552. defines.REFLECTIONMAP_CUBIC = false;
  50553. defines.REFLECTIONMAP_PROJECTION = false;
  50554. defines.REFLECTIONMAP_SKYBOX = false;
  50555. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50556. defines.REFLECTIONMAP_EXPLICIT = false;
  50557. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50558. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50559. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50560. defines.INVERTCUBICMAP = false;
  50561. defines.REFLECTIONMAP_OPPOSITEZ = false;
  50562. defines.LODINREFLECTIONALPHA = false;
  50563. defines.GAMMAREFLECTION = false;
  50564. defines.RGBDREFLECTION = false;
  50565. }
  50566. }
  50567. 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);
  50568. defines.USERGBCOLOR = this._useRGBColor;
  50569. defines.NOISE = this._enableNoise;
  50570. }
  50571. if (defines._areLightsDirty) {
  50572. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  50573. }
  50574. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50575. if (!this._imageProcessingConfiguration.isReady()) {
  50576. return false;
  50577. }
  50578. this._imageProcessingConfiguration.prepareDefines(defines);
  50579. }
  50580. // Misc.
  50581. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  50582. // Values that need to be evaluated on every frame
  50583. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  50584. // Attribs
  50585. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  50586. if (mesh) {
  50587. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  50588. mesh.createNormals(true);
  50589. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  50590. }
  50591. }
  50592. }
  50593. // Get correct effect
  50594. if (defines.isDirty) {
  50595. defines.markAsProcessed();
  50596. scene.resetCachedMaterial();
  50597. // Fallbacks
  50598. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  50599. if (defines.FOG) {
  50600. fallbacks.addFallback(0, "FOG");
  50601. }
  50602. if (defines.POINTSIZE) {
  50603. fallbacks.addFallback(1, "POINTSIZE");
  50604. }
  50605. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  50606. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50607. fallbacks.addCPUSkinningFallback(0, mesh);
  50608. }
  50609. //Attributes
  50610. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  50611. if (defines.NORMAL) {
  50612. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  50613. }
  50614. if (defines.UV1) {
  50615. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  50616. }
  50617. if (defines.UV2) {
  50618. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  50619. }
  50620. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50621. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50622. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  50623. "vFogInfos", "vFogColor", "pointSize",
  50624. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  50625. "vPrimaryColor", "vPrimaryColorShadow",
  50626. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  50627. "shadowLevel", "alpha",
  50628. "vBackgroundCenter", "vReflectionControl",
  50629. "vDiffuseInfos", "diffuseMatrix",
  50630. ];
  50631. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  50632. var uniformBuffers = ["Material", "Scene"];
  50633. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  50634. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50635. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50636. }
  50637. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50638. uniformsNames: uniforms,
  50639. uniformBuffersNames: uniformBuffers,
  50640. samplers: samplers,
  50641. defines: defines,
  50642. maxSimultaneousLights: this._maxSimultaneousLights
  50643. });
  50644. var onCompiled = function (effect) {
  50645. if (_this.onCompiled) {
  50646. _this.onCompiled(effect);
  50647. }
  50648. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  50649. };
  50650. var join = defines.toString();
  50651. subMesh.setEffect(scene.getEngine().createEffect("background", {
  50652. attributes: attribs,
  50653. uniformsNames: uniforms,
  50654. uniformBuffersNames: uniformBuffers,
  50655. samplers: samplers,
  50656. defines: join,
  50657. fallbacks: fallbacks,
  50658. onCompiled: onCompiled,
  50659. onError: this.onError,
  50660. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  50661. }, engine), defines);
  50662. this.buildUniformLayout();
  50663. }
  50664. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50665. return false;
  50666. }
  50667. defines._renderId = scene.getRenderId();
  50668. this._wasPreviouslyReady = true;
  50669. return true;
  50670. };
  50671. /**
  50672. * Compute the primary color according to the chosen perceptual color.
  50673. */
  50674. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  50675. if (!this.__perceptualColor) {
  50676. return;
  50677. }
  50678. this._primaryColor.copyFrom(this.__perceptualColor);
  50679. // Revert gamma space.
  50680. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  50681. // Revert image processing configuration.
  50682. if (this._imageProcessingConfiguration) {
  50683. // Revert Exposure.
  50684. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  50685. }
  50686. this._computePrimaryColors();
  50687. };
  50688. /**
  50689. * Compute the highlights and shadow colors according to their chosen levels.
  50690. */
  50691. BackgroundMaterial.prototype._computePrimaryColors = function () {
  50692. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  50693. return;
  50694. }
  50695. // Find the highlight color based on the configuration.
  50696. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  50697. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  50698. // Find the shadow color based on the configuration.
  50699. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  50700. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  50701. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  50702. };
  50703. /**
  50704. * Build the uniform buffer used in the material.
  50705. */
  50706. BackgroundMaterial.prototype.buildUniformLayout = function () {
  50707. // Order is important !
  50708. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  50709. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  50710. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  50711. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50712. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  50713. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50714. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50715. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  50716. this._uniformBuffer.addUniform("pointSize", 1);
  50717. this._uniformBuffer.addUniform("shadowLevel", 1);
  50718. this._uniformBuffer.addUniform("alpha", 1);
  50719. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  50720. this._uniformBuffer.addUniform("vReflectionControl", 4);
  50721. this._uniformBuffer.create();
  50722. };
  50723. /**
  50724. * Unbind the material.
  50725. */
  50726. BackgroundMaterial.prototype.unbind = function () {
  50727. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50728. this._uniformBuffer.setTexture("diffuseSampler", null);
  50729. }
  50730. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50731. this._uniformBuffer.setTexture("reflectionSampler", null);
  50732. }
  50733. _super.prototype.unbind.call(this);
  50734. };
  50735. /**
  50736. * Bind only the world matrix to the material.
  50737. * @param world The world matrix to bind.
  50738. */
  50739. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  50740. this._activeEffect.setMatrix("world", world);
  50741. };
  50742. /**
  50743. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50744. * @param world The world matrix to bind.
  50745. * @param subMesh The submesh to bind for.
  50746. */
  50747. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50748. var scene = this.getScene();
  50749. var defines = subMesh._materialDefines;
  50750. if (!defines) {
  50751. return;
  50752. }
  50753. var effect = subMesh.effect;
  50754. if (!effect) {
  50755. return;
  50756. }
  50757. this._activeEffect = effect;
  50758. // Matrices
  50759. this.bindOnlyWorldMatrix(world);
  50760. // Bones
  50761. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50762. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50763. if (mustRebind) {
  50764. this._uniformBuffer.bindToEffect(effect, "Material");
  50765. this.bindViewProjection(effect);
  50766. var reflectionTexture = this._reflectionTexture;
  50767. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50768. // Texture uniforms
  50769. if (scene.texturesEnabled) {
  50770. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50771. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  50772. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  50773. }
  50774. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50775. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50776. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  50777. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50778. }
  50779. }
  50780. if (this.shadowLevel > 0) {
  50781. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  50782. }
  50783. this._uniformBuffer.updateFloat("alpha", this.alpha);
  50784. // Point size
  50785. if (this.pointsCloud) {
  50786. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50787. }
  50788. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  50789. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  50790. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  50791. }
  50792. else {
  50793. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  50794. }
  50795. }
  50796. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  50797. // Textures
  50798. if (scene.texturesEnabled) {
  50799. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50800. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  50801. }
  50802. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50803. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  50804. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50805. }
  50806. else if (!defines.REFLECTIONBLUR) {
  50807. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50808. }
  50809. else {
  50810. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50811. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50812. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50813. }
  50814. if (defines.REFLECTIONFRESNEL) {
  50815. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  50816. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  50817. }
  50818. }
  50819. }
  50820. // Clip plane
  50821. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50822. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  50823. }
  50824. if (mustRebind || !this.isFrozen) {
  50825. if (scene.lightsEnabled) {
  50826. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  50827. }
  50828. // View
  50829. this.bindView(effect);
  50830. // Fog
  50831. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50832. // image processing
  50833. if (this._imageProcessingConfiguration) {
  50834. this._imageProcessingConfiguration.bind(this._activeEffect);
  50835. }
  50836. }
  50837. this._uniformBuffer.update();
  50838. this._afterBind(mesh, this._activeEffect);
  50839. };
  50840. /**
  50841. * Dispose the material.
  50842. * @param forceDisposeEffect Force disposal of the associated effect.
  50843. * @param forceDisposeTextures Force disposal of the associated textures.
  50844. */
  50845. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  50846. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  50847. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  50848. if (forceDisposeTextures) {
  50849. if (this.diffuseTexture) {
  50850. this.diffuseTexture.dispose();
  50851. }
  50852. if (this.reflectionTexture) {
  50853. this.reflectionTexture.dispose();
  50854. }
  50855. }
  50856. this._renderTargets.dispose();
  50857. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50858. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50859. }
  50860. _super.prototype.dispose.call(this, forceDisposeEffect);
  50861. };
  50862. /**
  50863. * Clones the material.
  50864. * @param name The cloned name.
  50865. * @returns The cloned material.
  50866. */
  50867. BackgroundMaterial.prototype.clone = function (name) {
  50868. var _this = this;
  50869. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  50870. };
  50871. /**
  50872. * Serializes the current material to its JSON representation.
  50873. * @returns The JSON representation.
  50874. */
  50875. BackgroundMaterial.prototype.serialize = function () {
  50876. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50877. serializationObject.customType = "BABYLON.BackgroundMaterial";
  50878. return serializationObject;
  50879. };
  50880. /**
  50881. * Gets the class name of the material
  50882. * @returns "BackgroundMaterial"
  50883. */
  50884. BackgroundMaterial.prototype.getClassName = function () {
  50885. return "BackgroundMaterial";
  50886. };
  50887. /**
  50888. * Parse a JSON input to create back a background material.
  50889. * @param source The JSON data to parse
  50890. * @param scene The scene to create the parsed material in
  50891. * @param rootUrl The root url of the assets the material depends upon
  50892. * @returns the instantiated BackgroundMaterial.
  50893. */
  50894. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  50895. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  50896. };
  50897. /**
  50898. * Standard reflectance value at parallel view angle.
  50899. */
  50900. BackgroundMaterial.StandardReflectance0 = 0.05;
  50901. /**
  50902. * Standard reflectance value at grazing angle.
  50903. */
  50904. BackgroundMaterial.StandardReflectance90 = 0.5;
  50905. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50907. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  50908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50910. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  50911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50913. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  50914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50916. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  50917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50919. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  50920. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50921. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50922. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  50923. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50924. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50925. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  50926. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50928. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  50929. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50931. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  50932. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50933. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50934. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  50935. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50936. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50937. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  50938. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50940. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  50941. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50943. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  50944. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50945. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50946. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  50947. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50948. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50949. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  50950. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50951. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  50952. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  50953. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50954. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50955. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  50956. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50957. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50958. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  50959. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50960. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50961. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  50962. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50963. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50964. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  50965. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50967. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  50968. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50969. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50970. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  50971. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50972. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50973. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  50974. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50976. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  50977. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50978. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50979. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  50980. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50981. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50982. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  50983. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50984. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50985. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  50986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50988. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  50989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50991. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  50992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50994. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  50995. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50997. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  50998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51000. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  51001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51003. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  51004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51006. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  51007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51009. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  51010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51012. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51013. return BackgroundMaterial;
  51014. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  51015. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  51016. /***/ }),
  51017. /***/ "./Materials/Background/index.ts":
  51018. /*!***************************************!*\
  51019. !*** ./Materials/Background/index.ts ***!
  51020. \***************************************/
  51021. /*! exports provided: BackgroundMaterial */
  51022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51023. "use strict";
  51024. __webpack_require__.r(__webpack_exports__);
  51025. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  51026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  51027. /***/ }),
  51028. /***/ "./Materials/PBR/index.ts":
  51029. /*!********************************!*\
  51030. !*** ./Materials/PBR/index.ts ***!
  51031. \********************************/
  51032. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  51033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51034. "use strict";
  51035. __webpack_require__.r(__webpack_exports__);
  51036. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  51038. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  51039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  51040. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  51041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  51042. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  51043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  51044. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  51045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  51046. /***/ }),
  51047. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  51048. /*!******************************************************!*\
  51049. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  51050. \******************************************************/
  51051. /*! exports provided: PBRAnisotropicConfiguration */
  51052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51053. "use strict";
  51054. __webpack_require__.r(__webpack_exports__);
  51055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  51056. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51057. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51058. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51059. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51060. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  51061. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51062. /**
  51063. * Define the code related to the anisotropic parameters of the pbr material.
  51064. */
  51065. var PBRAnisotropicConfiguration = /** @class */ (function () {
  51066. /**
  51067. * Instantiate a new istance of anisotropy configuration.
  51068. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51069. */
  51070. function PBRAnisotropicConfiguration(markAllSubMeshesAsTexturesDirty) {
  51071. this._isEnabled = false;
  51072. /**
  51073. * Defines if the anisotropy is enabled in the material.
  51074. */
  51075. this.isEnabled = false;
  51076. /**
  51077. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51078. */
  51079. this.intensity = 1;
  51080. /**
  51081. * Defines if the effect is along the tangents, bitangents or in between.
  51082. * By default, the effect is "strectching" the highlights along the tangents.
  51083. */
  51084. this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0);
  51085. this._texture = null;
  51086. /**
  51087. * Stores the anisotropy values in a texture.
  51088. * rg is direction (like normal from -1 to 1)
  51089. * b is a intensity
  51090. */
  51091. this.texture = null;
  51092. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  51093. }
  51094. /** @hidden */
  51095. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  51096. this._internalMarkAllSubMeshesAsTexturesDirty();
  51097. };
  51098. /**
  51099. * Specifies that the submesh is ready to be used.
  51100. * @param defines the list of "defines" to update.
  51101. * @param scene defines the scene the material belongs to.
  51102. * @returns - boolean indicating that the submesh is ready or not.
  51103. */
  51104. PBRAnisotropicConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  51105. if (defines._areTexturesDirty) {
  51106. if (scene.texturesEnabled) {
  51107. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51108. if (!this._texture.isReadyOrNotBlocking()) {
  51109. return false;
  51110. }
  51111. }
  51112. }
  51113. }
  51114. return true;
  51115. };
  51116. /**
  51117. * Checks to see if a texture is used in the material.
  51118. * @param defines the list of "defines" to update.
  51119. * @param mesh the mesh we are preparing the defines for.
  51120. * @param scene defines the scene the material belongs to.
  51121. */
  51122. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh, scene) {
  51123. if (this._isEnabled) {
  51124. defines.ANISOTROPIC = this._isEnabled;
  51125. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  51126. defines._needUVs = true;
  51127. defines.MAINUV1 = true;
  51128. }
  51129. if (defines._areTexturesDirty) {
  51130. if (scene.texturesEnabled) {
  51131. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51132. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "ANISOTROPIC_TEXTURE");
  51133. }
  51134. else {
  51135. defines.ANISOTROPIC_TEXTURE = false;
  51136. }
  51137. }
  51138. }
  51139. }
  51140. else {
  51141. defines.ANISOTROPIC = false;
  51142. defines.ANISOTROPIC_TEXTURE = false;
  51143. }
  51144. };
  51145. /**
  51146. * Binds the material data.
  51147. * @param uniformBuffer defines the Uniform buffer to fill in.
  51148. * @param scene defines the scene the material belongs to.
  51149. * @param isFrozen defines wether the material is frozen or not.
  51150. */
  51151. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  51152. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  51153. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51154. uniformBuffer.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level);
  51155. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "anisotropy");
  51156. }
  51157. // Anisotropy
  51158. uniformBuffer.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity);
  51159. }
  51160. // Textures
  51161. if (scene.texturesEnabled) {
  51162. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51163. uniformBuffer.setTexture("anisotropySampler", this._texture);
  51164. }
  51165. }
  51166. };
  51167. /**
  51168. * Checks to see if a texture is used in the material.
  51169. * @param texture - Base texture to use.
  51170. * @returns - Boolean specifying if a texture is used in the material.
  51171. */
  51172. PBRAnisotropicConfiguration.prototype.hasTexture = function (texture) {
  51173. if (this._texture === texture) {
  51174. return true;
  51175. }
  51176. return false;
  51177. };
  51178. /**
  51179. * Returns an array of the actively used textures.
  51180. * @param activeTextures Array of BaseTextures
  51181. */
  51182. PBRAnisotropicConfiguration.prototype.getActiveTextures = function (activeTextures) {
  51183. if (this._texture) {
  51184. activeTextures.push(this._texture);
  51185. }
  51186. };
  51187. /**
  51188. * Returns the animatable textures.
  51189. * @param animatables Array of animatable textures.
  51190. */
  51191. PBRAnisotropicConfiguration.prototype.getAnimatables = function (animatables) {
  51192. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  51193. animatables.push(this._texture);
  51194. }
  51195. };
  51196. /**
  51197. * Disposes the resources of the material.
  51198. * @param forceDisposeTextures - Forces the disposal of all textures.
  51199. */
  51200. PBRAnisotropicConfiguration.prototype.dispose = function (forceDisposeTextures) {
  51201. if (forceDisposeTextures) {
  51202. if (this._texture) {
  51203. this._texture.dispose();
  51204. }
  51205. }
  51206. };
  51207. /**
  51208. * Get the current class name of the texture useful for serialization or dynamic coding.
  51209. * @returns "PBRAnisotropicConfiguration"
  51210. */
  51211. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  51212. return "PBRAnisotropicConfiguration";
  51213. };
  51214. /**
  51215. * Add fallbacks to the effect fallbacks list.
  51216. * @param defines defines the Base texture to use.
  51217. * @param fallbacks defines the current fallback list.
  51218. * @param currentRank defines the current fallback rank.
  51219. * @returns the new fallback rank.
  51220. */
  51221. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  51222. if (defines.ANISOTROPIC) {
  51223. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  51224. }
  51225. return currentRank;
  51226. };
  51227. /**
  51228. * Add the required uniforms to the current list.
  51229. * @param uniforms defines the current uniform list.
  51230. */
  51231. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  51232. uniforms.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
  51233. };
  51234. /**
  51235. * Add the required uniforms to the current buffer.
  51236. * @param uniformBuffer defines the current uniform buffer.
  51237. */
  51238. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  51239. uniformBuffer.addUniform("vAnisotropy", 3);
  51240. uniformBuffer.addUniform("vAnisotropyInfos", 2);
  51241. uniformBuffer.addUniform("anisotropyMatrix", 16);
  51242. };
  51243. /**
  51244. * Add the required samplers to the current list.
  51245. * @param samplers defines the current sampler list.
  51246. */
  51247. PBRAnisotropicConfiguration.AddSamplers = function (samplers) {
  51248. samplers.push("anisotropySampler");
  51249. };
  51250. /**
  51251. * Makes a duplicate of the current configuration into another one.
  51252. * @param anisotropicConfiguration define the config where to copy the info
  51253. */
  51254. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  51255. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  51256. };
  51257. /**
  51258. * Serializes this anisotropy configuration.
  51259. * @returns - An object with the serialized config.
  51260. */
  51261. PBRAnisotropicConfiguration.prototype.serialize = function () {
  51262. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51263. };
  51264. /**
  51265. * Parses a anisotropy Configuration from a serialized object.
  51266. * @param source - Serialized object.
  51267. */
  51268. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  51269. var _this = this;
  51270. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51271. };
  51272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51274. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  51275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51277. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  51278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51280. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  51281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
  51283. ], PBRAnisotropicConfiguration.prototype, "direction", void 0);
  51284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51286. ], PBRAnisotropicConfiguration.prototype, "_texture", void 0);
  51287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51289. ], PBRAnisotropicConfiguration.prototype, "texture", void 0);
  51290. return PBRAnisotropicConfiguration;
  51291. }());
  51292. /***/ }),
  51293. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  51294. /*!***********************************************!*\
  51295. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  51296. \***********************************************/
  51297. /*! exports provided: PBRBRDFConfiguration */
  51298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51299. "use strict";
  51300. __webpack_require__.r(__webpack_exports__);
  51301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  51302. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51303. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51304. /**
  51305. * Define the code related to the BRDF parameters of the pbr material.
  51306. */
  51307. var PBRBRDFConfiguration = /** @class */ (function () {
  51308. /**
  51309. * Instantiate a new istance of clear coat configuration.
  51310. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51311. */
  51312. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  51313. this._useEnergyConservation = true;
  51314. /**
  51315. * Defines if the material uses energy conservation.
  51316. */
  51317. this.useEnergyConservation = true;
  51318. this._useSmithVisibilityHeightCorrelated = true;
  51319. /**
  51320. * LEGACY Mode set to false
  51321. * Defines if the material uses height smith correlated visibility term.
  51322. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51323. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51324. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51325. * Not relying on height correlated will also disable energy conservation.
  51326. */
  51327. this.useSmithVisibilityHeightCorrelated = true;
  51328. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  51329. }
  51330. /** @hidden */
  51331. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  51332. this._internalMarkAllSubMeshesAsMiscDirty();
  51333. };
  51334. /**
  51335. * Checks to see if a texture is used in the material.
  51336. * @param defines the list of "defines" to update.
  51337. */
  51338. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  51339. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  51340. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  51341. };
  51342. /**
  51343. * Get the current class name of the texture useful for serialization or dynamic coding.
  51344. * @returns "PBRClearCoatConfiguration"
  51345. */
  51346. PBRBRDFConfiguration.prototype.getClassName = function () {
  51347. return "PBRClearCoatConfiguration";
  51348. };
  51349. /**
  51350. * Makes a duplicate of the current configuration into another one.
  51351. * @param brdfConfiguration define the config where to copy the info
  51352. */
  51353. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  51354. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  51355. };
  51356. /**
  51357. * Serializes this BRDF configuration.
  51358. * @returns - An object with the serialized config.
  51359. */
  51360. PBRBRDFConfiguration.prototype.serialize = function () {
  51361. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51362. };
  51363. /**
  51364. * Parses a BRDF Configuration from a serialized object.
  51365. * @param source - Serialized object.
  51366. */
  51367. PBRBRDFConfiguration.prototype.parse = function (source) {
  51368. var _this = this;
  51369. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51370. };
  51371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51373. ], PBRBRDFConfiguration.prototype, "_useEnergyConservation", void 0);
  51374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51376. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  51377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51379. ], PBRBRDFConfiguration.prototype, "_useSmithVisibilityHeightCorrelated", void 0);
  51380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51382. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  51383. return PBRBRDFConfiguration;
  51384. }());
  51385. /***/ }),
  51386. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  51387. /*!******************************************!*\
  51388. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  51389. \******************************************/
  51390. /*! exports provided: PBRBaseMaterial */
  51391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51392. "use strict";
  51393. __webpack_require__.r(__webpack_exports__);
  51394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  51395. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51396. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51397. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  51398. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  51399. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  51400. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  51401. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51402. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51403. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  51404. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  51405. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  51406. /* harmony import */ var _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./pbrSheenConfiguration */ "./Materials/PBR/pbrSheenConfiguration.ts");
  51407. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  51408. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  51409. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  51410. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  51411. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51412. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  51413. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  51414. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  51415. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  51416. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  51417. /**
  51418. * Manages the defines for the PBR Material.
  51419. * @hiddenChildren
  51420. */
  51421. var PBRMaterialDefines = /** @class */ (function (_super) {
  51422. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  51423. /**
  51424. * Initializes the PBR Material defines.
  51425. */
  51426. function PBRMaterialDefines() {
  51427. var _this = _super.call(this) || this;
  51428. _this.PBR = true;
  51429. _this.MAINUV1 = false;
  51430. _this.MAINUV2 = false;
  51431. _this.UV1 = false;
  51432. _this.UV2 = false;
  51433. _this.ALBEDO = false;
  51434. _this.ALBEDODIRECTUV = 0;
  51435. _this.VERTEXCOLOR = false;
  51436. _this.AMBIENT = false;
  51437. _this.AMBIENTDIRECTUV = 0;
  51438. _this.AMBIENTINGRAYSCALE = false;
  51439. _this.OPACITY = false;
  51440. _this.VERTEXALPHA = false;
  51441. _this.OPACITYDIRECTUV = 0;
  51442. _this.OPACITYRGB = false;
  51443. _this.ALPHATEST = false;
  51444. _this.DEPTHPREPASS = false;
  51445. _this.ALPHABLEND = false;
  51446. _this.ALPHAFROMALBEDO = false;
  51447. _this.ALPHATESTVALUE = "0.5";
  51448. _this.SPECULAROVERALPHA = false;
  51449. _this.RADIANCEOVERALPHA = false;
  51450. _this.ALPHAFRESNEL = false;
  51451. _this.LINEARALPHAFRESNEL = false;
  51452. _this.PREMULTIPLYALPHA = false;
  51453. _this.EMISSIVE = false;
  51454. _this.EMISSIVEDIRECTUV = 0;
  51455. _this.REFLECTIVITY = false;
  51456. _this.REFLECTIVITYDIRECTUV = 0;
  51457. _this.SPECULARTERM = false;
  51458. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  51459. _this.MICROSURFACEAUTOMATIC = false;
  51460. _this.LODBASEDMICROSFURACE = false;
  51461. _this.MICROSURFACEMAP = false;
  51462. _this.MICROSURFACEMAPDIRECTUV = 0;
  51463. _this.METALLICWORKFLOW = false;
  51464. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  51465. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  51466. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  51467. _this.AOSTOREINMETALMAPRED = false;
  51468. _this.ENVIRONMENTBRDF = false;
  51469. _this.NORMAL = false;
  51470. _this.TANGENT = false;
  51471. _this.BUMP = false;
  51472. _this.BUMPDIRECTUV = 0;
  51473. _this.OBJECTSPACE_NORMALMAP = false;
  51474. _this.PARALLAX = false;
  51475. _this.PARALLAXOCCLUSION = false;
  51476. _this.NORMALXYSCALE = true;
  51477. _this.LIGHTMAP = false;
  51478. _this.LIGHTMAPDIRECTUV = 0;
  51479. _this.USELIGHTMAPASSHADOWMAP = false;
  51480. _this.GAMMALIGHTMAP = false;
  51481. _this.REFLECTION = false;
  51482. _this.REFLECTIONMAP_3D = false;
  51483. _this.REFLECTIONMAP_SPHERICAL = false;
  51484. _this.REFLECTIONMAP_PLANAR = false;
  51485. _this.REFLECTIONMAP_CUBIC = false;
  51486. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51487. _this.REFLECTIONMAP_PROJECTION = false;
  51488. _this.REFLECTIONMAP_SKYBOX = false;
  51489. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51490. _this.REFLECTIONMAP_EXPLICIT = false;
  51491. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51492. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51493. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51494. _this.INVERTCUBICMAP = false;
  51495. _this.USESPHERICALFROMREFLECTIONMAP = false;
  51496. _this.USESPHERICALINVERTEX = false;
  51497. _this.REFLECTIONMAP_OPPOSITEZ = false;
  51498. _this.LODINREFLECTIONALPHA = false;
  51499. _this.GAMMAREFLECTION = false;
  51500. _this.RGBDREFLECTION = false;
  51501. _this.RADIANCEOCCLUSION = false;
  51502. _this.HORIZONOCCLUSION = false;
  51503. _this.REFRACTION = false;
  51504. _this.REFRACTIONMAP_3D = false;
  51505. _this.REFRACTIONMAP_OPPOSITEZ = false;
  51506. _this.LODINREFRACTIONALPHA = false;
  51507. _this.GAMMAREFRACTION = false;
  51508. _this.RGBDREFRACTION = false;
  51509. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  51510. _this.INSTANCES = false;
  51511. _this.NUM_BONE_INFLUENCERS = 0;
  51512. _this.BonesPerMesh = 0;
  51513. _this.BONETEXTURE = false;
  51514. _this.NONUNIFORMSCALING = false;
  51515. _this.MORPHTARGETS = false;
  51516. _this.MORPHTARGETS_NORMAL = false;
  51517. _this.MORPHTARGETS_TANGENT = false;
  51518. _this.NUM_MORPH_INFLUENCERS = 0;
  51519. _this.IMAGEPROCESSING = false;
  51520. _this.VIGNETTE = false;
  51521. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  51522. _this.VIGNETTEBLENDMODEOPAQUE = false;
  51523. _this.TONEMAPPING = false;
  51524. _this.TONEMAPPING_ACES = false;
  51525. _this.CONTRAST = false;
  51526. _this.COLORCURVES = false;
  51527. _this.COLORGRADING = false;
  51528. _this.COLORGRADING3D = false;
  51529. _this.SAMPLER3DGREENDEPTH = false;
  51530. _this.SAMPLER3DBGRMAP = false;
  51531. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  51532. _this.EXPOSURE = false;
  51533. _this.USEPHYSICALLIGHTFALLOFF = false;
  51534. _this.USEGLTFLIGHTFALLOFF = false;
  51535. _this.TWOSIDEDLIGHTING = false;
  51536. _this.SHADOWFLOAT = false;
  51537. _this.CLIPPLANE = false;
  51538. _this.CLIPPLANE2 = false;
  51539. _this.CLIPPLANE3 = false;
  51540. _this.CLIPPLANE4 = false;
  51541. _this.POINTSIZE = false;
  51542. _this.FOG = false;
  51543. _this.LOGARITHMICDEPTH = false;
  51544. _this.FORCENORMALFORWARD = false;
  51545. _this.SPECULARAA = false;
  51546. _this.CLEARCOAT = false;
  51547. _this.CLEARCOAT_DEFAULTIOR = false;
  51548. _this.CLEARCOAT_TEXTURE = false;
  51549. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  51550. _this.CLEARCOAT_BUMP = false;
  51551. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  51552. _this.CLEARCOAT_TINT = false;
  51553. _this.CLEARCOAT_TINT_TEXTURE = false;
  51554. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  51555. _this.ANISOTROPIC = false;
  51556. _this.ANISOTROPIC_TEXTURE = false;
  51557. _this.ANISOTROPIC_TEXTUREDIRECTUV = 0;
  51558. _this.BRDF_V_HEIGHT_CORRELATED = false;
  51559. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  51560. _this.SHEEN = false;
  51561. _this.SHEEN_TEXTURE = false;
  51562. _this.SHEEN_TEXTUREDIRECTUV = 0;
  51563. _this.SHEEN_LINKWITHALBEDO = false;
  51564. _this.UNLIT = false;
  51565. _this.DEBUGMODE = 0;
  51566. _this.rebuild();
  51567. return _this;
  51568. }
  51569. /**
  51570. * Resets the PBR Material defines.
  51571. */
  51572. PBRMaterialDefines.prototype.reset = function () {
  51573. _super.prototype.reset.call(this);
  51574. this.ALPHATESTVALUE = "0.5";
  51575. this.PBR = true;
  51576. };
  51577. return PBRMaterialDefines;
  51578. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_14__["MaterialDefines"]));
  51579. /**
  51580. * The Physically based material base class of BJS.
  51581. *
  51582. * This offers the main features of a standard PBR material.
  51583. * For more information, please refer to the documentation :
  51584. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  51585. */
  51586. var PBRBaseMaterial = /** @class */ (function (_super) {
  51587. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  51588. /**
  51589. * Instantiates a new PBRMaterial instance.
  51590. *
  51591. * @param name The material name
  51592. * @param scene The scene the material will be use in.
  51593. */
  51594. function PBRBaseMaterial(name, scene) {
  51595. var _this = _super.call(this, name, scene) || this;
  51596. /**
  51597. * Intensity of the direct lights e.g. the four lights available in your scene.
  51598. * This impacts both the direct diffuse and specular highlights.
  51599. */
  51600. _this._directIntensity = 1.0;
  51601. /**
  51602. * Intensity of the emissive part of the material.
  51603. * This helps controlling the emissive effect without modifying the emissive color.
  51604. */
  51605. _this._emissiveIntensity = 1.0;
  51606. /**
  51607. * Intensity of the environment e.g. how much the environment will light the object
  51608. * either through harmonics for rough material or through the refelction for shiny ones.
  51609. */
  51610. _this._environmentIntensity = 1.0;
  51611. /**
  51612. * This is a special control allowing the reduction of the specular highlights coming from the
  51613. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51614. */
  51615. _this._specularIntensity = 1.0;
  51616. /**
  51617. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51618. */
  51619. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  51620. /**
  51621. * Debug Control allowing disabling the bump map on this material.
  51622. */
  51623. _this._disableBumpMap = false;
  51624. /**
  51625. * AKA Occlusion Texture Intensity in other nomenclature.
  51626. */
  51627. _this._ambientTextureStrength = 1.0;
  51628. /**
  51629. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51630. * 1 means it completely occludes it
  51631. * 0 mean it has no impact
  51632. */
  51633. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51634. /**
  51635. * The color of a material in ambient lighting.
  51636. */
  51637. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51638. /**
  51639. * AKA Diffuse Color in other nomenclature.
  51640. */
  51641. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51642. /**
  51643. * AKA Specular Color in other nomenclature.
  51644. */
  51645. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51646. /**
  51647. * The color applied when light is reflected from a material.
  51648. */
  51649. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51650. /**
  51651. * The color applied when light is emitted from a material.
  51652. */
  51653. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51654. /**
  51655. * AKA Glossiness in other nomenclature.
  51656. */
  51657. _this._microSurface = 0.9;
  51658. /**
  51659. * source material index of refraction (IOR)' / 'destination material IOR.
  51660. */
  51661. _this._indexOfRefraction = 0.66;
  51662. /**
  51663. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51664. */
  51665. _this._invertRefractionY = false;
  51666. /**
  51667. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51668. * Materials half opaque for instance using refraction could benefit from this control.
  51669. */
  51670. _this._linkRefractionWithTransparency = false;
  51671. /**
  51672. * Specifies that the material will use the light map as a show map.
  51673. */
  51674. _this._useLightmapAsShadowmap = false;
  51675. /**
  51676. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51677. * makes the reflect vector face the model (under horizon).
  51678. */
  51679. _this._useHorizonOcclusion = true;
  51680. /**
  51681. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51682. * too much the area relying on ambient texture to define their ambient occlusion.
  51683. */
  51684. _this._useRadianceOcclusion = true;
  51685. /**
  51686. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51687. */
  51688. _this._useAlphaFromAlbedoTexture = false;
  51689. /**
  51690. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51691. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51692. */
  51693. _this._useSpecularOverAlpha = true;
  51694. /**
  51695. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51696. */
  51697. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  51698. /**
  51699. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51700. */
  51701. _this._useRoughnessFromMetallicTextureAlpha = true;
  51702. /**
  51703. * Specifies if the metallic texture contains the roughness information in its green channel.
  51704. */
  51705. _this._useRoughnessFromMetallicTextureGreen = false;
  51706. /**
  51707. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51708. */
  51709. _this._useMetallnessFromMetallicTextureBlue = false;
  51710. /**
  51711. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51712. */
  51713. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  51714. /**
  51715. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51716. */
  51717. _this._useAmbientInGrayScale = false;
  51718. /**
  51719. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51720. * The material will try to infer what glossiness each pixel should be.
  51721. */
  51722. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  51723. /**
  51724. * Defines the falloff type used in this material.
  51725. * It by default is Physical.
  51726. */
  51727. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  51728. /**
  51729. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51730. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51731. */
  51732. _this._useRadianceOverAlpha = true;
  51733. /**
  51734. * Allows using an object space normal map (instead of tangent space).
  51735. */
  51736. _this._useObjectSpaceNormalMap = false;
  51737. /**
  51738. * Allows using the bump map in parallax mode.
  51739. */
  51740. _this._useParallax = false;
  51741. /**
  51742. * Allows using the bump map in parallax occlusion mode.
  51743. */
  51744. _this._useParallaxOcclusion = false;
  51745. /**
  51746. * Controls the scale bias of the parallax mode.
  51747. */
  51748. _this._parallaxScaleBias = 0.05;
  51749. /**
  51750. * If sets to true, disables all the lights affecting the material.
  51751. */
  51752. _this._disableLighting = false;
  51753. /**
  51754. * Number of Simultaneous lights allowed on the material.
  51755. */
  51756. _this._maxSimultaneousLights = 4;
  51757. /**
  51758. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51759. */
  51760. _this._invertNormalMapX = false;
  51761. /**
  51762. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51763. */
  51764. _this._invertNormalMapY = false;
  51765. /**
  51766. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51767. */
  51768. _this._twoSidedLighting = false;
  51769. /**
  51770. * Defines the alpha limits in alpha test mode.
  51771. */
  51772. _this._alphaCutOff = 0.4;
  51773. /**
  51774. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51775. */
  51776. _this._forceAlphaTest = false;
  51777. /**
  51778. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51779. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51780. */
  51781. _this._useAlphaFresnel = false;
  51782. /**
  51783. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51784. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51785. */
  51786. _this._useLinearAlphaFresnel = false;
  51787. /**
  51788. * The transparency mode of the material.
  51789. */
  51790. _this._transparencyMode = null;
  51791. /**
  51792. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51793. * from cos thetav and roughness:
  51794. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51795. */
  51796. _this._environmentBRDFTexture = null;
  51797. /**
  51798. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51799. */
  51800. _this._forceIrradianceInFragment = false;
  51801. /**
  51802. * Force normal to face away from face.
  51803. */
  51804. _this._forceNormalForward = false;
  51805. /**
  51806. * Enables specular anti aliasing in the PBR shader.
  51807. * It will both interacts on the Geometry for analytical and IBL lighting.
  51808. * It also prefilter the roughness map based on the bump values.
  51809. */
  51810. _this._enableSpecularAntiAliasing = false;
  51811. /**
  51812. * Stores the available render targets.
  51813. */
  51814. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  51815. /**
  51816. * Sets the global ambient color for the material used in lighting calculations.
  51817. */
  51818. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51819. /**
  51820. * If set to true, no lighting calculations will be applied.
  51821. */
  51822. _this._unlit = false;
  51823. _this._debugMode = 0;
  51824. /**
  51825. * @hidden
  51826. * This is reserved for the inspector.
  51827. * Defines the material debug mode.
  51828. * It helps seeing only some components of the material while troubleshooting.
  51829. */
  51830. _this.debugMode = 0;
  51831. /**
  51832. * @hidden
  51833. * This is reserved for the inspector.
  51834. * Specify from where on screen the debug mode should start.
  51835. * The value goes from -1 (full screen) to 1 (not visible)
  51836. * It helps with side by side comparison against the final render
  51837. * This defaults to -1
  51838. */
  51839. _this.debugLimit = -1;
  51840. /**
  51841. * @hidden
  51842. * This is reserved for the inspector.
  51843. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51844. * You can use the factor to better multiply the final value.
  51845. */
  51846. _this.debugFactor = 1;
  51847. /**
  51848. * Defines the clear coat layer parameters for the material.
  51849. */
  51850. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  51851. /**
  51852. * Defines the anisotropic parameters for the material.
  51853. */
  51854. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  51855. /**
  51856. * Defines the BRDF parameters for the material.
  51857. */
  51858. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  51859. /**
  51860. * Defines the Sheen parameters for the material.
  51861. */
  51862. _this.sheen = new _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  51863. // Setup the default processing configuration to the scene.
  51864. _this._attachImageProcessingConfiguration(null);
  51865. _this.getRenderTargetTextures = function () {
  51866. _this._renderTargets.reset();
  51867. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  51868. _this._renderTargets.push(_this._reflectionTexture);
  51869. }
  51870. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  51871. _this._renderTargets.push(_this._refractionTexture);
  51872. }
  51873. return _this._renderTargets;
  51874. };
  51875. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  51876. return _this;
  51877. }
  51878. /**
  51879. * Attaches a new image processing configuration to the PBR Material.
  51880. * @param configuration
  51881. */
  51882. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  51883. var _this = this;
  51884. if (configuration === this._imageProcessingConfiguration) {
  51885. return;
  51886. }
  51887. // Detaches observer.
  51888. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51889. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51890. }
  51891. // Pick the scene configuration if needed.
  51892. if (!configuration) {
  51893. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  51894. }
  51895. else {
  51896. this._imageProcessingConfiguration = configuration;
  51897. }
  51898. // Attaches observer.
  51899. if (this._imageProcessingConfiguration) {
  51900. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  51901. _this._markAllSubMeshesAsImageProcessingDirty();
  51902. });
  51903. }
  51904. };
  51905. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  51906. /**
  51907. * Gets a boolean indicating that current material needs to register RTT
  51908. */
  51909. get: function () {
  51910. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51911. return true;
  51912. }
  51913. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  51914. return true;
  51915. }
  51916. return false;
  51917. },
  51918. enumerable: true,
  51919. configurable: true
  51920. });
  51921. /**
  51922. * Gets the name of the material class.
  51923. */
  51924. PBRBaseMaterial.prototype.getClassName = function () {
  51925. return "PBRBaseMaterial";
  51926. };
  51927. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  51928. /**
  51929. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51930. */
  51931. get: function () {
  51932. return this._useLogarithmicDepth;
  51933. },
  51934. /**
  51935. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51936. */
  51937. set: function (value) {
  51938. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  51939. },
  51940. enumerable: true,
  51941. configurable: true
  51942. });
  51943. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  51944. /**
  51945. * Gets the current transparency mode.
  51946. */
  51947. get: function () {
  51948. return this._transparencyMode;
  51949. },
  51950. /**
  51951. * Sets the transparency mode of the material.
  51952. *
  51953. * | Value | Type | Description |
  51954. * | ----- | ----------------------------------- | ----------- |
  51955. * | 0 | OPAQUE | |
  51956. * | 1 | ALPHATEST | |
  51957. * | 2 | ALPHABLEND | |
  51958. * | 3 | ALPHATESTANDBLEND | |
  51959. *
  51960. */
  51961. set: function (value) {
  51962. if (this._transparencyMode === value) {
  51963. return;
  51964. }
  51965. this._transparencyMode = value;
  51966. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  51967. this._markAllSubMeshesAsTexturesAndMiscDirty();
  51968. },
  51969. enumerable: true,
  51970. configurable: true
  51971. });
  51972. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  51973. /**
  51974. * Returns true if alpha blending should be disabled.
  51975. */
  51976. get: function () {
  51977. return (this._linkRefractionWithTransparency ||
  51978. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  51979. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  51980. },
  51981. enumerable: true,
  51982. configurable: true
  51983. });
  51984. /**
  51985. * Specifies whether or not this material should be rendered in alpha blend mode.
  51986. */
  51987. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  51988. if (this._disableAlphaBlending) {
  51989. return false;
  51990. }
  51991. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  51992. };
  51993. /**
  51994. * Specifies if the mesh will require alpha blending.
  51995. * @param mesh - BJS mesh.
  51996. */
  51997. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  51998. if (this._disableAlphaBlending) {
  51999. return false;
  52000. }
  52001. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  52002. };
  52003. /**
  52004. * Specifies whether or not this material should be rendered in alpha test mode.
  52005. */
  52006. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  52007. if (this._forceAlphaTest) {
  52008. return true;
  52009. }
  52010. if (this._linkRefractionWithTransparency) {
  52011. return false;
  52012. }
  52013. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52014. };
  52015. /**
  52016. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52017. */
  52018. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  52019. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  52020. };
  52021. /**
  52022. * Gets the texture used for the alpha test.
  52023. */
  52024. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  52025. return this._albedoTexture;
  52026. };
  52027. /**
  52028. * Specifies that the submesh is ready to be used.
  52029. * @param mesh - BJS mesh.
  52030. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52031. * @param useInstances - Specifies that instances should be used.
  52032. * @returns - boolean indicating that the submesh is ready or not.
  52033. */
  52034. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  52035. if (subMesh.effect && this.isFrozen) {
  52036. if (this._wasPreviouslyReady) {
  52037. return true;
  52038. }
  52039. }
  52040. if (!subMesh._materialDefines) {
  52041. subMesh._materialDefines = new PBRMaterialDefines();
  52042. }
  52043. var defines = subMesh._materialDefines;
  52044. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  52045. if (defines._renderId === this.getScene().getRenderId()) {
  52046. return true;
  52047. }
  52048. }
  52049. var scene = this.getScene();
  52050. var engine = scene.getEngine();
  52051. if (defines._areTexturesDirty) {
  52052. if (scene.texturesEnabled) {
  52053. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52054. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  52055. return false;
  52056. }
  52057. }
  52058. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52059. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  52060. return false;
  52061. }
  52062. }
  52063. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52064. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  52065. return false;
  52066. }
  52067. }
  52068. var reflectionTexture = this._getReflectionTexture();
  52069. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52070. if (!reflectionTexture.isReadyOrNotBlocking()) {
  52071. return false;
  52072. }
  52073. }
  52074. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52075. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  52076. return false;
  52077. }
  52078. }
  52079. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52080. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  52081. return false;
  52082. }
  52083. }
  52084. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52085. if (this._metallicTexture) {
  52086. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  52087. return false;
  52088. }
  52089. }
  52090. else if (this._reflectivityTexture) {
  52091. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  52092. return false;
  52093. }
  52094. }
  52095. if (this._microSurfaceTexture) {
  52096. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  52097. return false;
  52098. }
  52099. }
  52100. }
  52101. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52102. // Bump texture cannot be not blocking.
  52103. if (!this._bumpTexture.isReady()) {
  52104. return false;
  52105. }
  52106. }
  52107. var refractionTexture = this._getRefractionTexture();
  52108. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52109. if (!refractionTexture.isReadyOrNotBlocking()) {
  52110. return false;
  52111. }
  52112. }
  52113. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52114. // This is blocking.
  52115. if (!this._environmentBRDFTexture.isReady()) {
  52116. return false;
  52117. }
  52118. }
  52119. }
  52120. }
  52121. if (!this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap)) {
  52122. return false;
  52123. }
  52124. if (!this.sheen.isReadyForSubMesh(defines, scene)) {
  52125. return false;
  52126. }
  52127. if (!this.anisotropy.isReadyForSubMesh(defines, scene)) {
  52128. return false;
  52129. }
  52130. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52131. if (!this._imageProcessingConfiguration.isReady()) {
  52132. return false;
  52133. }
  52134. }
  52135. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  52136. mesh.createNormals(true);
  52137. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  52138. }
  52139. var previousEffect = subMesh.effect;
  52140. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  52141. if (effect) {
  52142. // Use previous effect while new one is compiling
  52143. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  52144. effect = previousEffect;
  52145. defines.markAsUnprocessed();
  52146. }
  52147. else {
  52148. scene.resetCachedMaterial();
  52149. subMesh.setEffect(effect, defines);
  52150. this.buildUniformLayout();
  52151. }
  52152. }
  52153. if (!subMesh.effect || !subMesh.effect.isReady()) {
  52154. return false;
  52155. }
  52156. defines._renderId = scene.getRenderId();
  52157. this._wasPreviouslyReady = true;
  52158. return true;
  52159. };
  52160. /**
  52161. * Specifies if the material uses metallic roughness workflow.
  52162. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52163. */
  52164. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  52165. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  52166. return true;
  52167. }
  52168. return false;
  52169. };
  52170. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  52171. if (onCompiled === void 0) { onCompiled = null; }
  52172. if (onError === void 0) { onError = null; }
  52173. if (useInstances === void 0) { useInstances = null; }
  52174. if (useClipPlane === void 0) { useClipPlane = null; }
  52175. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  52176. if (!defines.isDirty) {
  52177. return null;
  52178. }
  52179. defines.markAsProcessed();
  52180. var scene = this.getScene();
  52181. var engine = scene.getEngine();
  52182. // Fallbacks
  52183. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_13__["EffectFallbacks"]();
  52184. var fallbackRank = 0;
  52185. if (defines.USESPHERICALINVERTEX) {
  52186. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  52187. }
  52188. if (defines.FOG) {
  52189. fallbacks.addFallback(fallbackRank, "FOG");
  52190. }
  52191. if (defines.SPECULARAA) {
  52192. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  52193. }
  52194. if (defines.POINTSIZE) {
  52195. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  52196. }
  52197. if (defines.LOGARITHMICDEPTH) {
  52198. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  52199. }
  52200. if (defines.PARALLAX) {
  52201. fallbacks.addFallback(fallbackRank, "PARALLAX");
  52202. }
  52203. if (defines.PARALLAXOCCLUSION) {
  52204. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  52205. }
  52206. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52207. fallbackRank = _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52208. fallbackRank = _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52209. if (defines.ENVIRONMENTBRDF) {
  52210. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  52211. }
  52212. if (defines.TANGENT) {
  52213. fallbacks.addFallback(fallbackRank++, "TANGENT");
  52214. }
  52215. if (defines.BUMP) {
  52216. fallbacks.addFallback(fallbackRank++, "BUMP");
  52217. }
  52218. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  52219. if (defines.SPECULARTERM) {
  52220. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  52221. }
  52222. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  52223. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  52224. }
  52225. if (defines.LIGHTMAP) {
  52226. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  52227. }
  52228. if (defines.NORMAL) {
  52229. fallbacks.addFallback(fallbackRank++, "NORMAL");
  52230. }
  52231. if (defines.AMBIENT) {
  52232. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  52233. }
  52234. if (defines.EMISSIVE) {
  52235. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  52236. }
  52237. if (defines.VERTEXCOLOR) {
  52238. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  52239. }
  52240. if (defines.NUM_BONE_INFLUENCERS > 0) {
  52241. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  52242. }
  52243. if (defines.MORPHTARGETS) {
  52244. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  52245. }
  52246. //Attributes
  52247. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  52248. if (defines.NORMAL) {
  52249. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  52250. }
  52251. if (defines.TANGENT) {
  52252. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  52253. }
  52254. if (defines.UV1) {
  52255. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  52256. }
  52257. if (defines.UV2) {
  52258. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  52259. }
  52260. if (defines.VERTEXCOLOR) {
  52261. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  52262. }
  52263. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  52264. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  52265. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  52266. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  52267. "vFogInfos", "vFogColor", "pointSize",
  52268. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  52269. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  52270. "mBones",
  52271. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  52272. "vLightingIntensity",
  52273. "logarithmicDepthConstant",
  52274. "vSphericalX", "vSphericalY", "vSphericalZ",
  52275. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  52276. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  52277. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  52278. "vTangentSpaceParams", "boneTextureWidth",
  52279. "vDebugMode"
  52280. ];
  52281. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  52282. "bumpSampler", "lightmapSampler", "opacitySampler",
  52283. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  52284. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  52285. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  52286. var uniformBuffers = ["Material", "Scene"];
  52287. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  52288. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  52289. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  52290. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddSamplers(samplers);
  52291. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddUniforms(uniforms);
  52292. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddSamplers(samplers);
  52293. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  52294. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  52295. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  52296. }
  52297. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareUniformsAndSamplersList({
  52298. uniformsNames: uniforms,
  52299. uniformBuffersNames: uniformBuffers,
  52300. samplers: samplers,
  52301. defines: defines,
  52302. maxSimultaneousLights: this._maxSimultaneousLights
  52303. });
  52304. var join = defines.toString();
  52305. return engine.createEffect("pbr", {
  52306. attributes: attribs,
  52307. uniformsNames: uniforms,
  52308. uniformBuffersNames: uniformBuffers,
  52309. samplers: samplers,
  52310. defines: join,
  52311. fallbacks: fallbacks,
  52312. onCompiled: onCompiled,
  52313. onError: onError,
  52314. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  52315. }, engine);
  52316. };
  52317. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  52318. if (useInstances === void 0) { useInstances = null; }
  52319. if (useClipPlane === void 0) { useClipPlane = null; }
  52320. var scene = this.getScene();
  52321. var engine = scene.getEngine();
  52322. // Lights
  52323. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  52324. defines._needNormals = true;
  52325. // Textures
  52326. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  52327. if (defines._areTexturesDirty) {
  52328. defines._needUVs = false;
  52329. if (scene.texturesEnabled) {
  52330. if (scene.getEngine().getCaps().textureLOD) {
  52331. defines.LODBASEDMICROSFURACE = true;
  52332. }
  52333. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52334. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  52335. }
  52336. else {
  52337. defines.ALBEDO = false;
  52338. }
  52339. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52340. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  52341. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  52342. }
  52343. else {
  52344. defines.AMBIENT = false;
  52345. }
  52346. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52347. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  52348. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  52349. }
  52350. else {
  52351. defines.OPACITY = false;
  52352. }
  52353. var reflectionTexture = this._getReflectionTexture();
  52354. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52355. defines.REFLECTION = true;
  52356. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  52357. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  52358. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  52359. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  52360. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].INVCUBIC_MODE) {
  52361. defines.INVERTCUBICMAP = true;
  52362. }
  52363. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  52364. defines.REFLECTIONMAP_CUBIC = false;
  52365. defines.REFLECTIONMAP_EXPLICIT = false;
  52366. defines.REFLECTIONMAP_PLANAR = false;
  52367. defines.REFLECTIONMAP_PROJECTION = false;
  52368. defines.REFLECTIONMAP_SKYBOX = false;
  52369. defines.REFLECTIONMAP_SPHERICAL = false;
  52370. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52371. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52372. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52373. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52374. switch (reflectionTexture.coordinatesMode) {
  52375. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].EXPLICIT_MODE:
  52376. defines.REFLECTIONMAP_EXPLICIT = true;
  52377. break;
  52378. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].PLANAR_MODE:
  52379. defines.REFLECTIONMAP_PLANAR = true;
  52380. break;
  52381. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].PROJECTION_MODE:
  52382. defines.REFLECTIONMAP_PROJECTION = true;
  52383. break;
  52384. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SKYBOX_MODE:
  52385. defines.REFLECTIONMAP_SKYBOX = true;
  52386. break;
  52387. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SPHERICAL_MODE:
  52388. defines.REFLECTIONMAP_SPHERICAL = true;
  52389. break;
  52390. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].EQUIRECTANGULAR_MODE:
  52391. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  52392. break;
  52393. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  52394. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  52395. break;
  52396. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  52397. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  52398. break;
  52399. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].CUBIC_MODE:
  52400. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].INVCUBIC_MODE:
  52401. default:
  52402. defines.REFLECTIONMAP_CUBIC = true;
  52403. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  52404. break;
  52405. }
  52406. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SKYBOX_MODE) {
  52407. if (reflectionTexture.sphericalPolynomial) {
  52408. defines.USESPHERICALFROMREFLECTIONMAP = true;
  52409. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  52410. defines.USESPHERICALINVERTEX = false;
  52411. }
  52412. else {
  52413. defines.USESPHERICALINVERTEX = true;
  52414. }
  52415. }
  52416. }
  52417. else {
  52418. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  52419. }
  52420. }
  52421. else {
  52422. defines.REFLECTION = false;
  52423. defines.REFLECTIONMAP_3D = false;
  52424. defines.REFLECTIONMAP_SPHERICAL = false;
  52425. defines.REFLECTIONMAP_PLANAR = false;
  52426. defines.REFLECTIONMAP_CUBIC = false;
  52427. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  52428. defines.REFLECTIONMAP_PROJECTION = false;
  52429. defines.REFLECTIONMAP_SKYBOX = false;
  52430. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52431. defines.REFLECTIONMAP_EXPLICIT = false;
  52432. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52433. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52434. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52435. defines.INVERTCUBICMAP = false;
  52436. defines.USESPHERICALFROMREFLECTIONMAP = false;
  52437. defines.USESPHERICALINVERTEX = false;
  52438. defines.REFLECTIONMAP_OPPOSITEZ = false;
  52439. defines.LODINREFLECTIONALPHA = false;
  52440. defines.GAMMAREFLECTION = false;
  52441. defines.RGBDREFLECTION = false;
  52442. }
  52443. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52444. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  52445. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  52446. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  52447. }
  52448. else {
  52449. defines.LIGHTMAP = false;
  52450. }
  52451. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52452. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  52453. }
  52454. else {
  52455. defines.EMISSIVE = false;
  52456. }
  52457. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52458. if (this._metallicTexture) {
  52459. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  52460. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  52461. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  52462. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  52463. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  52464. }
  52465. else if (this._reflectivityTexture) {
  52466. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  52467. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  52468. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  52469. }
  52470. else {
  52471. defines.REFLECTIVITY = false;
  52472. }
  52473. if (this._microSurfaceTexture) {
  52474. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  52475. }
  52476. else {
  52477. defines.MICROSURFACEMAP = false;
  52478. }
  52479. }
  52480. else {
  52481. defines.REFLECTIVITY = false;
  52482. defines.MICROSURFACEMAP = false;
  52483. }
  52484. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52485. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  52486. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52487. defines.PARALLAX = true;
  52488. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  52489. }
  52490. else {
  52491. defines.PARALLAX = false;
  52492. }
  52493. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  52494. }
  52495. else {
  52496. defines.BUMP = false;
  52497. }
  52498. var refractionTexture = this._getRefractionTexture();
  52499. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52500. defines.REFRACTION = true;
  52501. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  52502. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  52503. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  52504. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  52505. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  52506. if (this._linkRefractionWithTransparency) {
  52507. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  52508. }
  52509. }
  52510. else {
  52511. defines.REFRACTION = false;
  52512. }
  52513. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52514. defines.ENVIRONMENTBRDF = true;
  52515. }
  52516. else {
  52517. defines.ENVIRONMENTBRDF = false;
  52518. }
  52519. if (this._shouldUseAlphaFromAlbedoTexture()) {
  52520. defines.ALPHAFROMALBEDO = true;
  52521. }
  52522. else {
  52523. defines.ALPHAFROMALBEDO = false;
  52524. }
  52525. }
  52526. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  52527. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  52528. defines.USEPHYSICALLIGHTFALLOFF = false;
  52529. defines.USEGLTFLIGHTFALLOFF = false;
  52530. }
  52531. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  52532. defines.USEPHYSICALLIGHTFALLOFF = false;
  52533. defines.USEGLTFLIGHTFALLOFF = true;
  52534. }
  52535. else {
  52536. defines.USEPHYSICALLIGHTFALLOFF = true;
  52537. defines.USEGLTFLIGHTFALLOFF = false;
  52538. }
  52539. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  52540. if (!this.backFaceCulling && this._twoSidedLighting) {
  52541. defines.TWOSIDEDLIGHTING = true;
  52542. }
  52543. else {
  52544. defines.TWOSIDEDLIGHTING = false;
  52545. }
  52546. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  52547. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  52548. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  52549. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  52550. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  52551. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  52552. }
  52553. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52554. this._imageProcessingConfiguration.prepareDefines(defines);
  52555. }
  52556. defines.FORCENORMALFORWARD = this._forceNormalForward;
  52557. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  52558. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  52559. // Misc.
  52560. if (defines._areMiscDirty) {
  52561. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  52562. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  52563. defines.DEBUGMODE = this._debugMode;
  52564. }
  52565. // External config
  52566. this.clearCoat.prepareDefines(defines, scene);
  52567. this.anisotropy.prepareDefines(defines, mesh, scene);
  52568. this.brdf.prepareDefines(defines);
  52569. this.sheen.prepareDefines(defines, scene);
  52570. // Values that need to be evaluated on every frame
  52571. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  52572. // Attribs
  52573. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  52574. };
  52575. /**
  52576. * Force shader compilation
  52577. */
  52578. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  52579. var _this = this;
  52580. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  52581. var defines = new PBRMaterialDefines();
  52582. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  52583. if (effect.isReady()) {
  52584. if (onCompiled) {
  52585. onCompiled(this);
  52586. }
  52587. }
  52588. else {
  52589. effect.onCompileObservable.add(function () {
  52590. if (onCompiled) {
  52591. onCompiled(_this);
  52592. }
  52593. });
  52594. }
  52595. };
  52596. /**
  52597. * Initializes the uniform buffer layout for the shader.
  52598. */
  52599. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  52600. // Order is important !
  52601. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  52602. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  52603. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  52604. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  52605. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  52606. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  52607. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  52608. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  52609. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  52610. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  52611. this._uniformBuffer.addUniform("vReflectionSize", 3);
  52612. this._uniformBuffer.addUniform("vBumpInfos", 3);
  52613. this._uniformBuffer.addUniform("albedoMatrix", 16);
  52614. this._uniformBuffer.addUniform("ambientMatrix", 16);
  52615. this._uniformBuffer.addUniform("opacityMatrix", 16);
  52616. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  52617. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  52618. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  52619. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  52620. this._uniformBuffer.addUniform("bumpMatrix", 16);
  52621. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  52622. this._uniformBuffer.addUniform("refractionMatrix", 16);
  52623. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  52624. this._uniformBuffer.addUniform("vReflectionColor", 3);
  52625. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  52626. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  52627. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  52628. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  52629. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  52630. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  52631. this._uniformBuffer.addUniform("pointSize", 1);
  52632. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52633. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52634. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52635. this._uniformBuffer.create();
  52636. };
  52637. /**
  52638. * Unbinds the textures.
  52639. */
  52640. PBRBaseMaterial.prototype.unbind = function () {
  52641. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52642. this._uniformBuffer.setTexture("reflectionSampler", null);
  52643. }
  52644. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  52645. this._uniformBuffer.setTexture("refractionSampler", null);
  52646. }
  52647. _super.prototype.unbind.call(this);
  52648. };
  52649. /**
  52650. * Binds the submesh data.
  52651. * @param world - The world matrix.
  52652. * @param mesh - The BJS mesh.
  52653. * @param subMesh - A submesh of the BJS mesh.
  52654. */
  52655. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  52656. var scene = this.getScene();
  52657. var defines = subMesh._materialDefines;
  52658. if (!defines) {
  52659. return;
  52660. }
  52661. var effect = subMesh.effect;
  52662. if (!effect) {
  52663. return;
  52664. }
  52665. this._activeEffect = effect;
  52666. // Matrices
  52667. this.bindOnlyWorldMatrix(world);
  52668. // Normal Matrix
  52669. if (defines.OBJECTSPACE_NORMALMAP) {
  52670. world.toNormalMatrix(this._normalMatrix);
  52671. this.bindOnlyNormalMatrix(this._normalMatrix);
  52672. }
  52673. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  52674. // Bones
  52675. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  52676. var reflectionTexture = null;
  52677. if (mustRebind) {
  52678. var engine = scene.getEngine();
  52679. this._uniformBuffer.bindToEffect(effect, "Material");
  52680. this.bindViewProjection(effect);
  52681. reflectionTexture = this._getReflectionTexture();
  52682. var refractionTexture = this._getRefractionTexture();
  52683. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  52684. // Texture uniforms
  52685. if (scene.texturesEnabled) {
  52686. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52687. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  52688. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  52689. }
  52690. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52691. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  52692. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  52693. }
  52694. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52695. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  52696. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  52697. }
  52698. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52699. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  52700. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  52701. if (reflectionTexture.boundingBoxSize) {
  52702. var cubeTexture = reflectionTexture;
  52703. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  52704. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  52705. }
  52706. var polynomials = reflectionTexture.sphericalPolynomial;
  52707. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  52708. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  52709. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  52710. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  52711. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  52712. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  52713. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  52714. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  52715. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  52716. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  52717. }
  52718. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  52719. }
  52720. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52721. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  52722. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  52723. }
  52724. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52725. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  52726. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  52727. }
  52728. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52729. if (this._metallicTexture) {
  52730. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  52731. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  52732. }
  52733. else if (this._reflectivityTexture) {
  52734. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  52735. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  52736. }
  52737. if (this._microSurfaceTexture) {
  52738. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  52739. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  52740. }
  52741. }
  52742. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52743. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  52744. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  52745. if (scene._mirroredCameraPosition) {
  52746. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  52747. }
  52748. else {
  52749. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  52750. }
  52751. }
  52752. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52753. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  52754. var depth = 1.0;
  52755. if (!refractionTexture.isCube) {
  52756. if (refractionTexture.depth) {
  52757. depth = refractionTexture.depth;
  52758. }
  52759. }
  52760. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  52761. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  52762. }
  52763. }
  52764. // Point size
  52765. if (this.pointsCloud) {
  52766. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  52767. }
  52768. // Colors
  52769. if (defines.METALLICWORKFLOW) {
  52770. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  52771. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  52772. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  52773. }
  52774. else {
  52775. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  52776. }
  52777. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  52778. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  52779. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  52780. // Misc
  52781. this._lightingInfos.x = this._directIntensity;
  52782. this._lightingInfos.y = this._emissiveIntensity;
  52783. this._lightingInfos.z = this._environmentIntensity;
  52784. this._lightingInfos.w = this._specularIntensity;
  52785. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  52786. }
  52787. // Textures
  52788. if (scene.texturesEnabled) {
  52789. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52790. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  52791. }
  52792. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52793. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  52794. }
  52795. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52796. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  52797. }
  52798. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52799. if (defines.LODBASEDMICROSFURACE) {
  52800. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  52801. }
  52802. else {
  52803. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  52804. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  52805. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  52806. }
  52807. }
  52808. if (defines.ENVIRONMENTBRDF) {
  52809. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  52810. }
  52811. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52812. if (defines.LODBASEDMICROSFURACE) {
  52813. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  52814. }
  52815. else {
  52816. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  52817. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  52818. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  52819. }
  52820. }
  52821. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52822. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  52823. }
  52824. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52825. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  52826. }
  52827. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52828. if (this._metallicTexture) {
  52829. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  52830. }
  52831. else if (this._reflectivityTexture) {
  52832. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  52833. }
  52834. if (this._microSurfaceTexture) {
  52835. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  52836. }
  52837. }
  52838. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52839. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  52840. }
  52841. }
  52842. this.clearCoat.bindForSubMesh(this._uniformBuffer, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  52843. this.anisotropy.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  52844. this.sheen.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  52845. // Clip plane
  52846. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  52847. // Colors
  52848. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  52849. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  52850. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  52851. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  52852. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  52853. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  52854. }
  52855. if (mustRebind || !this.isFrozen) {
  52856. // Lights
  52857. if (scene.lightsEnabled && !this._disableLighting) {
  52858. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  52859. }
  52860. // View
  52861. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  52862. this.bindView(effect);
  52863. }
  52864. // Fog
  52865. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  52866. // Morph targets
  52867. if (defines.NUM_MORPH_INFLUENCERS) {
  52868. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  52869. }
  52870. // image processing
  52871. this._imageProcessingConfiguration.bind(this._activeEffect);
  52872. // Log. depth
  52873. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  52874. }
  52875. this._uniformBuffer.update();
  52876. this._afterBind(mesh, this._activeEffect);
  52877. };
  52878. /**
  52879. * Returns the animatable textures.
  52880. * @returns - Array of animatable textures.
  52881. */
  52882. PBRBaseMaterial.prototype.getAnimatables = function () {
  52883. var results = [];
  52884. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  52885. results.push(this._albedoTexture);
  52886. }
  52887. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  52888. results.push(this._ambientTexture);
  52889. }
  52890. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  52891. results.push(this._opacityTexture);
  52892. }
  52893. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  52894. results.push(this._reflectionTexture);
  52895. }
  52896. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  52897. results.push(this._emissiveTexture);
  52898. }
  52899. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  52900. results.push(this._metallicTexture);
  52901. }
  52902. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  52903. results.push(this._reflectivityTexture);
  52904. }
  52905. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  52906. results.push(this._bumpTexture);
  52907. }
  52908. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  52909. results.push(this._lightmapTexture);
  52910. }
  52911. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  52912. results.push(this._refractionTexture);
  52913. }
  52914. this.clearCoat.getAnimatables(results);
  52915. this.sheen.getAnimatables(results);
  52916. this.anisotropy.getAnimatables(results);
  52917. return results;
  52918. };
  52919. /**
  52920. * Returns the texture used for reflections.
  52921. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52922. */
  52923. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  52924. if (this._reflectionTexture) {
  52925. return this._reflectionTexture;
  52926. }
  52927. return this.getScene().environmentTexture;
  52928. };
  52929. /**
  52930. * Returns the texture used for refraction or null if none is used.
  52931. * @returns - Refection texture if present. If no refraction texture and refraction
  52932. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52933. */
  52934. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  52935. if (this._refractionTexture) {
  52936. return this._refractionTexture;
  52937. }
  52938. if (this._linkRefractionWithTransparency) {
  52939. return this.getScene().environmentTexture;
  52940. }
  52941. return null;
  52942. };
  52943. /**
  52944. * Returns an array of the actively used textures.
  52945. * @returns - Array of BaseTextures
  52946. */
  52947. PBRBaseMaterial.prototype.getActiveTextures = function () {
  52948. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52949. if (this._albedoTexture) {
  52950. activeTextures.push(this._albedoTexture);
  52951. }
  52952. if (this._ambientTexture) {
  52953. activeTextures.push(this._ambientTexture);
  52954. }
  52955. if (this._opacityTexture) {
  52956. activeTextures.push(this._opacityTexture);
  52957. }
  52958. if (this._reflectionTexture) {
  52959. activeTextures.push(this._reflectionTexture);
  52960. }
  52961. if (this._emissiveTexture) {
  52962. activeTextures.push(this._emissiveTexture);
  52963. }
  52964. if (this._reflectivityTexture) {
  52965. activeTextures.push(this._reflectivityTexture);
  52966. }
  52967. if (this._metallicTexture) {
  52968. activeTextures.push(this._metallicTexture);
  52969. }
  52970. if (this._microSurfaceTexture) {
  52971. activeTextures.push(this._microSurfaceTexture);
  52972. }
  52973. if (this._bumpTexture) {
  52974. activeTextures.push(this._bumpTexture);
  52975. }
  52976. if (this._lightmapTexture) {
  52977. activeTextures.push(this._lightmapTexture);
  52978. }
  52979. if (this._refractionTexture) {
  52980. activeTextures.push(this._refractionTexture);
  52981. }
  52982. this.clearCoat.getActiveTextures(activeTextures);
  52983. this.sheen.getActiveTextures(activeTextures);
  52984. this.anisotropy.getActiveTextures(activeTextures);
  52985. return activeTextures;
  52986. };
  52987. /**
  52988. * Checks to see if a texture is used in the material.
  52989. * @param texture - Base texture to use.
  52990. * @returns - Boolean specifying if a texture is used in the material.
  52991. */
  52992. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  52993. if (_super.prototype.hasTexture.call(this, texture)) {
  52994. return true;
  52995. }
  52996. if (this._albedoTexture === texture) {
  52997. return true;
  52998. }
  52999. if (this._ambientTexture === texture) {
  53000. return true;
  53001. }
  53002. if (this._opacityTexture === texture) {
  53003. return true;
  53004. }
  53005. if (this._reflectionTexture === texture) {
  53006. return true;
  53007. }
  53008. if (this._reflectivityTexture === texture) {
  53009. return true;
  53010. }
  53011. if (this._metallicTexture === texture) {
  53012. return true;
  53013. }
  53014. if (this._microSurfaceTexture === texture) {
  53015. return true;
  53016. }
  53017. if (this._bumpTexture === texture) {
  53018. return true;
  53019. }
  53020. if (this._lightmapTexture === texture) {
  53021. return true;
  53022. }
  53023. return this.clearCoat.hasTexture(texture) ||
  53024. this.sheen.hasTexture(texture) ||
  53025. this.anisotropy.hasTexture(texture);
  53026. };
  53027. /**
  53028. * Disposes the resources of the material.
  53029. * @param forceDisposeEffect - Forces the disposal of effects.
  53030. * @param forceDisposeTextures - Forces the disposal of all textures.
  53031. */
  53032. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  53033. if (forceDisposeTextures) {
  53034. if (this._albedoTexture) {
  53035. this._albedoTexture.dispose();
  53036. }
  53037. if (this._ambientTexture) {
  53038. this._ambientTexture.dispose();
  53039. }
  53040. if (this._opacityTexture) {
  53041. this._opacityTexture.dispose();
  53042. }
  53043. if (this._reflectionTexture) {
  53044. this._reflectionTexture.dispose();
  53045. }
  53046. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  53047. this._environmentBRDFTexture.dispose();
  53048. }
  53049. if (this._emissiveTexture) {
  53050. this._emissiveTexture.dispose();
  53051. }
  53052. if (this._metallicTexture) {
  53053. this._metallicTexture.dispose();
  53054. }
  53055. if (this._reflectivityTexture) {
  53056. this._reflectivityTexture.dispose();
  53057. }
  53058. if (this._bumpTexture) {
  53059. this._bumpTexture.dispose();
  53060. }
  53061. if (this._lightmapTexture) {
  53062. this._lightmapTexture.dispose();
  53063. }
  53064. if (this._refractionTexture) {
  53065. this._refractionTexture.dispose();
  53066. }
  53067. }
  53068. this.clearCoat.dispose(forceDisposeTextures);
  53069. this.sheen.dispose(forceDisposeTextures);
  53070. this.anisotropy.dispose(forceDisposeTextures);
  53071. this._renderTargets.dispose();
  53072. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  53073. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  53074. }
  53075. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  53076. };
  53077. /**
  53078. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53079. */
  53080. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  53081. /**
  53082. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53083. */
  53084. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  53085. /**
  53086. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53087. */
  53088. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  53089. /**
  53090. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53091. * They are also discarded below the alpha cutoff threshold to improve performances.
  53092. */
  53093. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  53094. /**
  53095. * Defines the default value of how much AO map is occluding the analytical lights
  53096. * (point spot...).
  53097. */
  53098. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  53099. /**
  53100. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53101. */
  53102. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  53103. /**
  53104. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53105. * to enhance interoperability with other engines.
  53106. */
  53107. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  53108. /**
  53109. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53110. * to enhance interoperability with other materials.
  53111. */
  53112. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  53113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  53115. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  53116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53118. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  53119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53121. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  53122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53124. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  53125. return PBRBaseMaterial;
  53126. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_15__["PushMaterial"]));
  53127. /***/ }),
  53128. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  53129. /*!************************************************!*\
  53130. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  53131. \************************************************/
  53132. /*! exports provided: PBRBaseSimpleMaterial */
  53133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53134. "use strict";
  53135. __webpack_require__.r(__webpack_exports__);
  53136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  53137. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53138. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53139. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53140. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53141. /**
  53142. * The Physically based simple base material of BJS.
  53143. *
  53144. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53145. * It is used as the base class for both the specGloss and metalRough conventions.
  53146. */
  53147. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  53148. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  53149. /**
  53150. * Instantiates a new PBRMaterial instance.
  53151. *
  53152. * @param name The material name
  53153. * @param scene The scene the material will be use in.
  53154. */
  53155. function PBRBaseSimpleMaterial(name, scene) {
  53156. var _this = _super.call(this, name, scene) || this;
  53157. /**
  53158. * Number of Simultaneous lights allowed on the material.
  53159. */
  53160. _this.maxSimultaneousLights = 4;
  53161. /**
  53162. * If sets to true, disables all the lights affecting the material.
  53163. */
  53164. _this.disableLighting = false;
  53165. /**
  53166. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53167. */
  53168. _this.invertNormalMapX = false;
  53169. /**
  53170. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53171. */
  53172. _this.invertNormalMapY = false;
  53173. /**
  53174. * Emissivie color used to self-illuminate the model.
  53175. */
  53176. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  53177. /**
  53178. * Occlusion Channel Strenght.
  53179. */
  53180. _this.occlusionStrength = 1.0;
  53181. /**
  53182. * If true, the light map contains occlusion information instead of lighting info.
  53183. */
  53184. _this.useLightmapAsShadowmap = false;
  53185. _this._useAlphaFromAlbedoTexture = true;
  53186. _this._useAmbientInGrayScale = true;
  53187. return _this;
  53188. }
  53189. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  53190. /**
  53191. * Gets the current double sided mode.
  53192. */
  53193. get: function () {
  53194. return this._twoSidedLighting;
  53195. },
  53196. /**
  53197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53198. */
  53199. set: function (value) {
  53200. if (this._twoSidedLighting === value) {
  53201. return;
  53202. }
  53203. this._twoSidedLighting = value;
  53204. this.backFaceCulling = !value;
  53205. this._markAllSubMeshesAsTexturesDirty();
  53206. },
  53207. enumerable: true,
  53208. configurable: true
  53209. });
  53210. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  53211. return "PBRBaseSimpleMaterial";
  53212. };
  53213. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53214. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53215. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53216. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  53217. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53218. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53220. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  53221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53223. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  53224. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  53225. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53228. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  53229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53232. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  53233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  53236. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  53237. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  53239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53240. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  53241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53244. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  53245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53247. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  53248. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  53249. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  53252. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  53253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  53256. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  53257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53259. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  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", null)
  53263. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  53264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53267. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  53268. return PBRBaseSimpleMaterial;
  53269. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  53270. /***/ }),
  53271. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  53272. /*!****************************************************!*\
  53273. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  53274. \****************************************************/
  53275. /*! exports provided: PBRClearCoatConfiguration */
  53276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53277. "use strict";
  53278. __webpack_require__.r(__webpack_exports__);
  53279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  53280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53281. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53282. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53283. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53284. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53285. /**
  53286. * Define the code related to the clear coat parameters of the pbr material.
  53287. */
  53288. var PBRClearCoatConfiguration = /** @class */ (function () {
  53289. /**
  53290. * Instantiate a new istance of clear coat configuration.
  53291. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53292. */
  53293. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  53294. this._isEnabled = false;
  53295. /**
  53296. * Defines if the clear coat is enabled in the material.
  53297. */
  53298. this.isEnabled = false;
  53299. /**
  53300. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53301. */
  53302. this.intensity = 1;
  53303. /**
  53304. * Defines the clear coat layer roughness.
  53305. */
  53306. this.roughness = 0;
  53307. this._indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53308. /**
  53309. * Defines the indice of refraction of the clear coat.
  53310. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53311. * The default fits with a polyurethane material.
  53312. * Changing the default value is more performance intensive.
  53313. */
  53314. this.indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53315. this._texture = null;
  53316. /**
  53317. * Stores the clear coat values in a texture.
  53318. */
  53319. this.texture = null;
  53320. this._bumpTexture = null;
  53321. /**
  53322. * Define the clear coat specific bump texture.
  53323. */
  53324. this.bumpTexture = null;
  53325. this._isTintEnabled = false;
  53326. /**
  53327. * Defines if the clear coat tint is enabled in the material.
  53328. */
  53329. this.isTintEnabled = false;
  53330. /**
  53331. * Defines if the clear coat tint is enabled in the material.
  53332. * This is only use if tint is enabled
  53333. */
  53334. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  53335. /**
  53336. * Defines if the distance at which the tint color should be found in the
  53337. * clear coat media.
  53338. * This is only use if tint is enabled
  53339. */
  53340. this.tintColorAtDistance = 1;
  53341. /**
  53342. * Defines the clear coat layer thickness.
  53343. * This is only use if tint is enabled
  53344. */
  53345. this.tintThickness = 1;
  53346. this._tintTexture = null;
  53347. /**
  53348. * Stores the clear tint values in a texture.
  53349. * rgb is tint
  53350. * a is a thickness factor
  53351. */
  53352. this.tintTexture = null;
  53353. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  53354. }
  53355. /** @hidden */
  53356. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  53357. this._internalMarkAllSubMeshesAsTexturesDirty();
  53358. };
  53359. /**
  53360. * Specifies that the submesh is ready to be used.
  53361. * @param defines the list of "defines" to update.
  53362. * @param scene defines the scene the material belongs to.
  53363. * @param engine defines the engine the material belongs to.
  53364. * @param disableBumpMap defines wether the material disables bump or not.
  53365. * @returns - boolean indicating that the submesh is ready or not.
  53366. */
  53367. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  53368. if (defines._areTexturesDirty) {
  53369. if (scene.texturesEnabled) {
  53370. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53371. if (!this._texture.isReadyOrNotBlocking()) {
  53372. return false;
  53373. }
  53374. }
  53375. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53376. // Bump texture cannot be not blocking.
  53377. if (!this._bumpTexture.isReady()) {
  53378. return false;
  53379. }
  53380. }
  53381. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53382. if (!this._tintTexture.isReadyOrNotBlocking()) {
  53383. return false;
  53384. }
  53385. }
  53386. }
  53387. }
  53388. return true;
  53389. };
  53390. /**
  53391. * Checks to see if a texture is used in the material.
  53392. * @param defines the list of "defines" to update.
  53393. * @param scene defines the scene to the material belongs to.
  53394. */
  53395. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  53396. if (this._isEnabled) {
  53397. defines.CLEARCOAT = true;
  53398. if (defines._areTexturesDirty) {
  53399. if (scene.texturesEnabled) {
  53400. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53401. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  53402. }
  53403. else {
  53404. defines.CLEARCOAT_TEXTURE = false;
  53405. }
  53406. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  53407. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  53408. }
  53409. else {
  53410. defines.CLEARCOAT_BUMP = false;
  53411. }
  53412. defines.CLEARCOAT_DEFAULTIOR = this._indiceOfRefraction === PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53413. if (this._isTintEnabled) {
  53414. defines.CLEARCOAT_TINT = true;
  53415. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53416. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  53417. }
  53418. else {
  53419. defines.CLEARCOAT_TINT_TEXTURE = false;
  53420. }
  53421. }
  53422. else {
  53423. defines.CLEARCOAT_TINT = false;
  53424. defines.CLEARCOAT_TINT_TEXTURE = false;
  53425. }
  53426. }
  53427. }
  53428. }
  53429. else {
  53430. defines.CLEARCOAT = false;
  53431. defines.CLEARCOAT_TEXTURE = false;
  53432. defines.CLEARCOAT_BUMP = false;
  53433. defines.CLEARCOAT_TINT = false;
  53434. defines.CLEARCOAT_TINT_TEXTURE = false;
  53435. }
  53436. };
  53437. /**
  53438. * Binds the material data.
  53439. * @param uniformBuffer defines the Uniform buffer to fill in.
  53440. * @param scene defines the scene the material belongs to.
  53441. * @param engine defines the engine the material belongs to.
  53442. * @param disableBumpMap defines wether the material disables bump or not.
  53443. * @param isFrozen defines wether the material is frozen or not.
  53444. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53445. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53446. */
  53447. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  53448. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  53449. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53450. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  53451. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  53452. }
  53453. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  53454. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  53455. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  53456. if (scene._mirroredCameraPosition) {
  53457. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  53458. }
  53459. else {
  53460. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  53461. }
  53462. }
  53463. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53464. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  53465. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  53466. }
  53467. // Clear Coat General params
  53468. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  53469. // Clear Coat Refraction params
  53470. var a = 1 - this._indiceOfRefraction;
  53471. var b = 1 + this._indiceOfRefraction;
  53472. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  53473. var eta = 1 / this._indiceOfRefraction;
  53474. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  53475. if (this._isTintEnabled) {
  53476. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  53477. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  53478. }
  53479. }
  53480. // Textures
  53481. if (scene.texturesEnabled) {
  53482. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53483. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  53484. }
  53485. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53486. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  53487. }
  53488. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53489. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  53490. }
  53491. }
  53492. };
  53493. /**
  53494. * Checks to see if a texture is used in the material.
  53495. * @param texture - Base texture to use.
  53496. * @returns - Boolean specifying if a texture is used in the material.
  53497. */
  53498. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  53499. if (this._texture === texture) {
  53500. return true;
  53501. }
  53502. if (this._bumpTexture === texture) {
  53503. return true;
  53504. }
  53505. if (this._tintTexture === texture) {
  53506. return true;
  53507. }
  53508. return false;
  53509. };
  53510. /**
  53511. * Returns an array of the actively used textures.
  53512. * @param activeTextures Array of BaseTextures
  53513. */
  53514. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  53515. if (this._texture) {
  53516. activeTextures.push(this._texture);
  53517. }
  53518. if (this._bumpTexture) {
  53519. activeTextures.push(this._bumpTexture);
  53520. }
  53521. if (this._tintTexture) {
  53522. activeTextures.push(this._tintTexture);
  53523. }
  53524. };
  53525. /**
  53526. * Returns the animatable textures.
  53527. * @param animatables Array of animatable textures.
  53528. */
  53529. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  53530. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  53531. animatables.push(this._texture);
  53532. }
  53533. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53534. animatables.push(this._bumpTexture);
  53535. }
  53536. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  53537. animatables.push(this._tintTexture);
  53538. }
  53539. };
  53540. /**
  53541. * Disposes the resources of the material.
  53542. * @param forceDisposeTextures - Forces the disposal of all textures.
  53543. */
  53544. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  53545. if (forceDisposeTextures) {
  53546. if (this._texture) {
  53547. this._texture.dispose();
  53548. }
  53549. if (this._bumpTexture) {
  53550. this._bumpTexture.dispose();
  53551. }
  53552. if (this._tintTexture) {
  53553. this._tintTexture.dispose();
  53554. }
  53555. }
  53556. };
  53557. /**
  53558. * Get the current class name of the texture useful for serialization or dynamic coding.
  53559. * @returns "PBRClearCoatConfiguration"
  53560. */
  53561. PBRClearCoatConfiguration.prototype.getClassName = function () {
  53562. return "PBRClearCoatConfiguration";
  53563. };
  53564. /**
  53565. * Add fallbacks to the effect fallbacks list.
  53566. * @param defines defines the Base texture to use.
  53567. * @param fallbacks defines the current fallback list.
  53568. * @param currentRank defines the current fallback rank.
  53569. * @returns the new fallback rank.
  53570. */
  53571. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  53572. if (defines.CLEARCOAT_BUMP) {
  53573. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  53574. }
  53575. if (defines.CLEARCOAT_TINT) {
  53576. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  53577. }
  53578. if (defines.CLEARCOAT) {
  53579. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  53580. }
  53581. return currentRank;
  53582. };
  53583. /**
  53584. * Add the required uniforms to the current list.
  53585. * @param uniforms defines the current uniform list.
  53586. */
  53587. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  53588. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  53589. };
  53590. /**
  53591. * Add the required samplers to the current list.
  53592. * @param samplers defines the current sampler list.
  53593. */
  53594. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  53595. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  53596. };
  53597. /**
  53598. * Add the required uniforms to the current buffer.
  53599. * @param uniformBuffer defines the current uniform buffer.
  53600. */
  53601. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  53602. uniformBuffer.addUniform("vClearCoatParams", 2);
  53603. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  53604. uniformBuffer.addUniform("vClearCoatInfos", 2);
  53605. uniformBuffer.addUniform("clearCoatMatrix", 16);
  53606. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  53607. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  53608. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  53609. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  53610. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  53611. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  53612. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  53613. };
  53614. /**
  53615. * Makes a duplicate of the current configuration into another one.
  53616. * @param clearCoatConfiguration define the config where to copy the info
  53617. */
  53618. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  53619. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  53620. };
  53621. /**
  53622. * Serializes this clear coat configuration.
  53623. * @returns - An object with the serialized config.
  53624. */
  53625. PBRClearCoatConfiguration.prototype.serialize = function () {
  53626. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53627. };
  53628. /**
  53629. * Parses a Clear Coat Configuration from a serialized object.
  53630. * @param source - Serialized object.
  53631. */
  53632. PBRClearCoatConfiguration.prototype.parse = function (source) {
  53633. var _this = this;
  53634. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  53635. };
  53636. /**
  53637. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53638. * The default fits with a polyurethane material.
  53639. */
  53640. PBRClearCoatConfiguration._DefaultIndiceOfRefraction = 1.5;
  53641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53643. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  53644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53646. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  53647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53649. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  53650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53652. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  53653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53655. ], PBRClearCoatConfiguration.prototype, "_indiceOfRefraction", void 0);
  53656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53658. ], PBRClearCoatConfiguration.prototype, "indiceOfRefraction", void 0);
  53659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53661. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  53662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53664. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  53665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53667. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  53668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53670. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  53671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53673. ], PBRClearCoatConfiguration.prototype, "_isTintEnabled", void 0);
  53674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53676. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  53677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  53679. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  53680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53682. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  53683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53685. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  53686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53688. ], PBRClearCoatConfiguration.prototype, "_tintTexture", void 0);
  53689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53691. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  53692. return PBRClearCoatConfiguration;
  53693. }());
  53694. /***/ }),
  53695. /***/ "./Materials/PBR/pbrMaterial.ts":
  53696. /*!**************************************!*\
  53697. !*** ./Materials/PBR/pbrMaterial.ts ***!
  53698. \**************************************/
  53699. /*! exports provided: PBRMaterial */
  53700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53701. "use strict";
  53702. __webpack_require__.r(__webpack_exports__);
  53703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  53704. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53705. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53706. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  53707. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53708. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53709. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53710. /**
  53711. * The Physically based material of BJS.
  53712. *
  53713. * This offers the main features of a standard PBR material.
  53714. * For more information, please refer to the documentation :
  53715. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  53716. */
  53717. var PBRMaterial = /** @class */ (function (_super) {
  53718. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  53719. /**
  53720. * Instantiates a new PBRMaterial instance.
  53721. *
  53722. * @param name The material name
  53723. * @param scene The scene the material will be use in.
  53724. */
  53725. function PBRMaterial(name, scene) {
  53726. var _this = _super.call(this, name, scene) || this;
  53727. /**
  53728. * Intensity of the direct lights e.g. the four lights available in your scene.
  53729. * This impacts both the direct diffuse and specular highlights.
  53730. */
  53731. _this.directIntensity = 1.0;
  53732. /**
  53733. * Intensity of the emissive part of the material.
  53734. * This helps controlling the emissive effect without modifying the emissive color.
  53735. */
  53736. _this.emissiveIntensity = 1.0;
  53737. /**
  53738. * Intensity of the environment e.g. how much the environment will light the object
  53739. * either through harmonics for rough material or through the refelction for shiny ones.
  53740. */
  53741. _this.environmentIntensity = 1.0;
  53742. /**
  53743. * This is a special control allowing the reduction of the specular highlights coming from the
  53744. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53745. */
  53746. _this.specularIntensity = 1.0;
  53747. /**
  53748. * Debug Control allowing disabling the bump map on this material.
  53749. */
  53750. _this.disableBumpMap = false;
  53751. /**
  53752. * AKA Occlusion Texture Intensity in other nomenclature.
  53753. */
  53754. _this.ambientTextureStrength = 1.0;
  53755. /**
  53756. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53757. * 1 means it completely occludes it
  53758. * 0 mean it has no impact
  53759. */
  53760. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  53761. /**
  53762. * The color of a material in ambient lighting.
  53763. */
  53764. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  53765. /**
  53766. * AKA Diffuse Color in other nomenclature.
  53767. */
  53768. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  53769. /**
  53770. * AKA Specular Color in other nomenclature.
  53771. */
  53772. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  53773. /**
  53774. * The color reflected from the material.
  53775. */
  53776. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  53777. /**
  53778. * The color emitted from the material.
  53779. */
  53780. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  53781. /**
  53782. * AKA Glossiness in other nomenclature.
  53783. */
  53784. _this.microSurface = 1.0;
  53785. /**
  53786. * source material index of refraction (IOR)' / 'destination material IOR.
  53787. */
  53788. _this.indexOfRefraction = 0.66;
  53789. /**
  53790. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53791. */
  53792. _this.invertRefractionY = false;
  53793. /**
  53794. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53795. * Materials half opaque for instance using refraction could benefit from this control.
  53796. */
  53797. _this.linkRefractionWithTransparency = false;
  53798. /**
  53799. * If true, the light map contains occlusion information instead of lighting info.
  53800. */
  53801. _this.useLightmapAsShadowmap = false;
  53802. /**
  53803. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53804. */
  53805. _this.useAlphaFromAlbedoTexture = false;
  53806. /**
  53807. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53808. */
  53809. _this.forceAlphaTest = false;
  53810. /**
  53811. * Defines the alpha limits in alpha test mode.
  53812. */
  53813. _this.alphaCutOff = 0.4;
  53814. /**
  53815. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53816. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53817. */
  53818. _this.useSpecularOverAlpha = true;
  53819. /**
  53820. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53821. */
  53822. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  53823. /**
  53824. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53825. */
  53826. _this.useRoughnessFromMetallicTextureAlpha = true;
  53827. /**
  53828. * Specifies if the metallic texture contains the roughness information in its green channel.
  53829. */
  53830. _this.useRoughnessFromMetallicTextureGreen = false;
  53831. /**
  53832. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53833. */
  53834. _this.useMetallnessFromMetallicTextureBlue = false;
  53835. /**
  53836. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53837. */
  53838. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  53839. /**
  53840. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53841. */
  53842. _this.useAmbientInGrayScale = false;
  53843. /**
  53844. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53845. * The material will try to infer what glossiness each pixel should be.
  53846. */
  53847. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  53848. /**
  53849. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53850. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53851. */
  53852. _this.useRadianceOverAlpha = true;
  53853. /**
  53854. * Allows using an object space normal map (instead of tangent space).
  53855. */
  53856. _this.useObjectSpaceNormalMap = false;
  53857. /**
  53858. * Allows using the bump map in parallax mode.
  53859. */
  53860. _this.useParallax = false;
  53861. /**
  53862. * Allows using the bump map in parallax occlusion mode.
  53863. */
  53864. _this.useParallaxOcclusion = false;
  53865. /**
  53866. * Controls the scale bias of the parallax mode.
  53867. */
  53868. _this.parallaxScaleBias = 0.05;
  53869. /**
  53870. * If sets to true, disables all the lights affecting the material.
  53871. */
  53872. _this.disableLighting = false;
  53873. /**
  53874. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53875. */
  53876. _this.forceIrradianceInFragment = false;
  53877. /**
  53878. * Number of Simultaneous lights allowed on the material.
  53879. */
  53880. _this.maxSimultaneousLights = 4;
  53881. /**
  53882. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53883. */
  53884. _this.invertNormalMapX = false;
  53885. /**
  53886. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53887. */
  53888. _this.invertNormalMapY = false;
  53889. /**
  53890. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53891. */
  53892. _this.twoSidedLighting = false;
  53893. /**
  53894. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53895. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53896. */
  53897. _this.useAlphaFresnel = false;
  53898. /**
  53899. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53900. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53901. */
  53902. _this.useLinearAlphaFresnel = false;
  53903. /**
  53904. * Let user defines the brdf lookup texture used for IBL.
  53905. * A default 8bit version is embedded but you could point at :
  53906. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  53907. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53908. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53909. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53910. */
  53911. _this.environmentBRDFTexture = null;
  53912. /**
  53913. * Force normal to face away from face.
  53914. */
  53915. _this.forceNormalForward = false;
  53916. /**
  53917. * Enables specular anti aliasing in the PBR shader.
  53918. * It will both interacts on the Geometry for analytical and IBL lighting.
  53919. * It also prefilter the roughness map based on the bump values.
  53920. */
  53921. _this.enableSpecularAntiAliasing = false;
  53922. /**
  53923. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53924. * makes the reflect vector face the model (under horizon).
  53925. */
  53926. _this.useHorizonOcclusion = true;
  53927. /**
  53928. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53929. * too much the area relying on ambient texture to define their ambient occlusion.
  53930. */
  53931. _this.useRadianceOcclusion = true;
  53932. /**
  53933. * If set to true, no lighting calculations will be applied.
  53934. */
  53935. _this.unlit = false;
  53936. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  53937. return _this;
  53938. }
  53939. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  53940. /**
  53941. * BJS is using an harcoded light falloff based on a manually sets up range.
  53942. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53943. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53944. */
  53945. get: function () {
  53946. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  53947. },
  53948. /**
  53949. * BJS is using an harcoded light falloff based on a manually sets up range.
  53950. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53951. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53952. */
  53953. set: function (value) {
  53954. if (value !== this.usePhysicalLightFalloff) {
  53955. // Ensure the effect will be rebuilt.
  53956. this._markAllSubMeshesAsTexturesDirty();
  53957. if (value) {
  53958. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  53959. }
  53960. else {
  53961. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  53962. }
  53963. }
  53964. },
  53965. enumerable: true,
  53966. configurable: true
  53967. });
  53968. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  53969. /**
  53970. * In order to support the falloff compatibility with gltf, a special mode has been added
  53971. * to reproduce the gltf light falloff.
  53972. */
  53973. get: function () {
  53974. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  53975. },
  53976. /**
  53977. * In order to support the falloff compatibility with gltf, a special mode has been added
  53978. * to reproduce the gltf light falloff.
  53979. */
  53980. set: function (value) {
  53981. if (value !== this.useGLTFLightFalloff) {
  53982. // Ensure the effect will be rebuilt.
  53983. this._markAllSubMeshesAsTexturesDirty();
  53984. if (value) {
  53985. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  53986. }
  53987. else {
  53988. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  53989. }
  53990. }
  53991. },
  53992. enumerable: true,
  53993. configurable: true
  53994. });
  53995. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  53996. /**
  53997. * Gets the image processing configuration used either in this material.
  53998. */
  53999. get: function () {
  54000. return this._imageProcessingConfiguration;
  54001. },
  54002. /**
  54003. * Sets the Default image processing configuration used either in the this material.
  54004. *
  54005. * If sets to null, the scene one is in use.
  54006. */
  54007. set: function (value) {
  54008. this._attachImageProcessingConfiguration(value);
  54009. // Ensure the effect will be rebuilt.
  54010. this._markAllSubMeshesAsTexturesDirty();
  54011. },
  54012. enumerable: true,
  54013. configurable: true
  54014. });
  54015. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  54016. /**
  54017. * Gets wether the color curves effect is enabled.
  54018. */
  54019. get: function () {
  54020. return this.imageProcessingConfiguration.colorCurvesEnabled;
  54021. },
  54022. /**
  54023. * Sets wether the color curves effect is enabled.
  54024. */
  54025. set: function (value) {
  54026. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  54027. },
  54028. enumerable: true,
  54029. configurable: true
  54030. });
  54031. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  54032. /**
  54033. * Gets wether the color grading effect is enabled.
  54034. */
  54035. get: function () {
  54036. return this.imageProcessingConfiguration.colorGradingEnabled;
  54037. },
  54038. /**
  54039. * Gets wether the color grading effect is enabled.
  54040. */
  54041. set: function (value) {
  54042. this.imageProcessingConfiguration.colorGradingEnabled = value;
  54043. },
  54044. enumerable: true,
  54045. configurable: true
  54046. });
  54047. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  54048. /**
  54049. * Gets wether tonemapping is enabled or not.
  54050. */
  54051. get: function () {
  54052. return this._imageProcessingConfiguration.toneMappingEnabled;
  54053. },
  54054. /**
  54055. * Sets wether tonemapping is enabled or not
  54056. */
  54057. set: function (value) {
  54058. this._imageProcessingConfiguration.toneMappingEnabled = value;
  54059. },
  54060. enumerable: true,
  54061. configurable: true
  54062. });
  54063. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  54064. /**
  54065. * The camera exposure used on this material.
  54066. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54067. * This corresponds to a photographic exposure.
  54068. */
  54069. get: function () {
  54070. return this._imageProcessingConfiguration.exposure;
  54071. },
  54072. /**
  54073. * The camera exposure used on this material.
  54074. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54075. * This corresponds to a photographic exposure.
  54076. */
  54077. set: function (value) {
  54078. this._imageProcessingConfiguration.exposure = value;
  54079. },
  54080. enumerable: true,
  54081. configurable: true
  54082. });
  54083. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  54084. /**
  54085. * Gets The camera contrast used on this material.
  54086. */
  54087. get: function () {
  54088. return this._imageProcessingConfiguration.contrast;
  54089. },
  54090. /**
  54091. * Sets The camera contrast used on this material.
  54092. */
  54093. set: function (value) {
  54094. this._imageProcessingConfiguration.contrast = value;
  54095. },
  54096. enumerable: true,
  54097. configurable: true
  54098. });
  54099. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  54100. /**
  54101. * Gets the Color Grading 2D Lookup Texture.
  54102. */
  54103. get: function () {
  54104. return this._imageProcessingConfiguration.colorGradingTexture;
  54105. },
  54106. /**
  54107. * Sets the Color Grading 2D Lookup Texture.
  54108. */
  54109. set: function (value) {
  54110. this._imageProcessingConfiguration.colorGradingTexture = value;
  54111. },
  54112. enumerable: true,
  54113. configurable: true
  54114. });
  54115. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  54116. /**
  54117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54119. * 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;
  54120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54121. */
  54122. get: function () {
  54123. return this._imageProcessingConfiguration.colorCurves;
  54124. },
  54125. /**
  54126. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54127. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54128. * 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;
  54129. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54130. */
  54131. set: function (value) {
  54132. this._imageProcessingConfiguration.colorCurves = value;
  54133. },
  54134. enumerable: true,
  54135. configurable: true
  54136. });
  54137. /**
  54138. * Returns the name of this material class.
  54139. */
  54140. PBRMaterial.prototype.getClassName = function () {
  54141. return "PBRMaterial";
  54142. };
  54143. /**
  54144. * Makes a duplicate of the current material.
  54145. * @param name - name to use for the new material.
  54146. */
  54147. PBRMaterial.prototype.clone = function (name) {
  54148. var _this = this;
  54149. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  54150. clone.id = name;
  54151. clone.name = name;
  54152. this.clearCoat.copyTo(clone.clearCoat);
  54153. this.anisotropy.copyTo(clone.anisotropy);
  54154. this.brdf.copyTo(clone.brdf);
  54155. this.sheen.copyTo(clone.sheen);
  54156. return clone;
  54157. };
  54158. /**
  54159. * Serializes this PBR Material.
  54160. * @returns - An object with the serialized material.
  54161. */
  54162. PBRMaterial.prototype.serialize = function () {
  54163. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54164. serializationObject.customType = "BABYLON.PBRMaterial";
  54165. serializationObject.clearCoat = this.clearCoat.serialize();
  54166. serializationObject.anisotropy = this.anisotropy.serialize();
  54167. serializationObject.brdf = this.brdf.serialize();
  54168. serializationObject.sheen = this.sheen.serialize();
  54169. return serializationObject;
  54170. };
  54171. // Statics
  54172. /**
  54173. * Parses a PBR Material from a serialized object.
  54174. * @param source - Serialized object.
  54175. * @param scene - BJS scene instance.
  54176. * @param rootUrl - url for the scene object
  54177. * @returns - PBRMaterial
  54178. */
  54179. PBRMaterial.Parse = function (source, scene, rootUrl) {
  54180. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  54181. if (source.clearCoat) {
  54182. material.clearCoat.parse(source.clearCoat);
  54183. }
  54184. if (source.anisotropy) {
  54185. material.anisotropy.parse(source.anisotropy);
  54186. }
  54187. if (source.brdf) {
  54188. material.brdf.parse(source.brdf);
  54189. }
  54190. if (source.sheen) {
  54191. material.sheen.parse(source.brdf);
  54192. }
  54193. return material;
  54194. };
  54195. /**
  54196. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54197. */
  54198. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  54199. /**
  54200. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54201. */
  54202. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  54203. /**
  54204. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54205. */
  54206. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  54207. /**
  54208. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54209. * They are also discarded below the alpha cutoff threshold to improve performances.
  54210. */
  54211. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  54212. /**
  54213. * Defines the default value of how much AO map is occluding the analytical lights
  54214. * (point spot...).
  54215. */
  54216. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54217. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54218. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54220. ], PBRMaterial.prototype, "directIntensity", void 0);
  54221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54223. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54224. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  54225. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54228. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  54229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54232. ], PBRMaterial.prototype, "specularIntensity", void 0);
  54233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54236. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  54237. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54240. ], PBRMaterial.prototype, "albedoTexture", void 0);
  54241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54244. ], PBRMaterial.prototype, "ambientTexture", void 0);
  54245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54247. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54248. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  54249. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54252. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  54253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54256. ], PBRMaterial.prototype, "opacityTexture", void 0);
  54257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54260. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  54261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54264. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  54265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54268. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  54269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54272. ], PBRMaterial.prototype, "metallicTexture", void 0);
  54273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54276. ], PBRMaterial.prototype, "metallic", void 0);
  54277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54280. ], PBRMaterial.prototype, "roughness", void 0);
  54281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54284. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  54285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54288. ], PBRMaterial.prototype, "bumpTexture", void 0);
  54289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  54292. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  54293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54296. ], PBRMaterial.prototype, "refractionTexture", void 0);
  54297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  54299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54300. ], PBRMaterial.prototype, "ambientColor", void 0);
  54301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  54303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54304. ], PBRMaterial.prototype, "albedoColor", void 0);
  54305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  54307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54308. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  54309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  54311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54312. ], PBRMaterial.prototype, "reflectionColor", void 0);
  54313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  54315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54316. ], PBRMaterial.prototype, "emissiveColor", void 0);
  54317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54319. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54320. ], PBRMaterial.prototype, "microSurface", void 0);
  54321. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54324. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  54325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54328. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  54329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54332. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  54333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54336. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  54337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54340. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  54341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54344. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  54345. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54348. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  54349. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54352. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  54353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54356. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  54357. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54359. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54360. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  54361. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54362. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54364. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  54365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54368. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  54369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54372. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  54373. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54376. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  54377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54380. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  54381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54383. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  54384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54386. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  54387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54389. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54390. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  54391. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54392. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54393. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54394. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  54395. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54398. ], PBRMaterial.prototype, "useParallax", void 0);
  54399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54402. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  54403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54406. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  54407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54410. ], PBRMaterial.prototype, "disableLighting", void 0);
  54411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54413. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54414. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  54415. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54418. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  54419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54422. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  54423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54426. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  54427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54430. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  54431. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54432. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54434. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  54435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54438. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  54439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54442. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  54443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54446. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  54447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54450. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  54451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54454. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  54455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54458. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  54459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  54462. ], PBRMaterial.prototype, "unlit", void 0);
  54463. return PBRMaterial;
  54464. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  54465. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  54466. /***/ }),
  54467. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  54468. /*!*******************************************************!*\
  54469. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  54470. \*******************************************************/
  54471. /*! exports provided: PBRMetallicRoughnessMaterial */
  54472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54473. "use strict";
  54474. __webpack_require__.r(__webpack_exports__);
  54475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  54476. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54477. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54478. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  54479. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54480. /**
  54481. * The PBR material of BJS following the metal roughness convention.
  54482. *
  54483. * This fits to the PBR convention in the GLTF definition:
  54484. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54485. */
  54486. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  54487. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  54488. /**
  54489. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54490. *
  54491. * @param name The material name
  54492. * @param scene The scene the material will be use in.
  54493. */
  54494. function PBRMetallicRoughnessMaterial(name, scene) {
  54495. var _this = _super.call(this, name, scene) || this;
  54496. _this._useRoughnessFromMetallicTextureAlpha = false;
  54497. _this._useRoughnessFromMetallicTextureGreen = true;
  54498. _this._useMetallnessFromMetallicTextureBlue = true;
  54499. _this.metallic = 1.0;
  54500. _this.roughness = 1.0;
  54501. return _this;
  54502. }
  54503. /**
  54504. * Return the currrent class name of the material.
  54505. */
  54506. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  54507. return "PBRMetallicRoughnessMaterial";
  54508. };
  54509. /**
  54510. * Makes a duplicate of the current material.
  54511. * @param name - name to use for the new material.
  54512. */
  54513. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  54514. var _this = this;
  54515. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  54516. clone.id = name;
  54517. clone.name = name;
  54518. this.clearCoat.copyTo(clone.clearCoat);
  54519. this.anisotropy.copyTo(clone.anisotropy);
  54520. this.brdf.copyTo(clone.brdf);
  54521. this.sheen.copyTo(clone.sheen);
  54522. return clone;
  54523. };
  54524. /**
  54525. * Serialize the material to a parsable JSON object.
  54526. */
  54527. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  54528. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54529. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  54530. serializationObject.clearCoat = this.clearCoat.serialize();
  54531. serializationObject.anisotropy = this.anisotropy.serialize();
  54532. serializationObject.brdf = this.brdf.serialize();
  54533. serializationObject.sheen = this.sheen.serialize();
  54534. return serializationObject;
  54535. };
  54536. /**
  54537. * Parses a JSON object correponding to the serialize function.
  54538. */
  54539. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  54540. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  54541. if (source.clearCoat) {
  54542. material.clearCoat.parse(source.clearCoat);
  54543. }
  54544. if (source.anisotropy) {
  54545. material.anisotropy.parse(source.anisotropy);
  54546. }
  54547. if (source.brdf) {
  54548. material.brdf.parse(source.brdf);
  54549. }
  54550. if (source.sheen) {
  54551. material.sheen.parse(source.brdf);
  54552. }
  54553. return material;
  54554. };
  54555. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  54557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  54558. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  54559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  54562. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  54563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54565. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54566. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  54567. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54568. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54570. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  54571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54573. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  54574. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  54575. return PBRMetallicRoughnessMaterial;
  54576. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  54577. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  54578. /***/ }),
  54579. /***/ "./Materials/PBR/pbrSheenConfiguration.ts":
  54580. /*!************************************************!*\
  54581. !*** ./Materials/PBR/pbrSheenConfiguration.ts ***!
  54582. \************************************************/
  54583. /*! exports provided: PBRSheenConfiguration */
  54584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54585. "use strict";
  54586. __webpack_require__.r(__webpack_exports__);
  54587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSheenConfiguration", function() { return PBRSheenConfiguration; });
  54588. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54589. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54590. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54591. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  54592. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  54593. /**
  54594. * Define the code related to the Sheen parameters of the pbr material.
  54595. */
  54596. var PBRSheenConfiguration = /** @class */ (function () {
  54597. /**
  54598. * Instantiate a new istance of clear coat configuration.
  54599. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54600. */
  54601. function PBRSheenConfiguration(markAllSubMeshesAsTexturesDirty) {
  54602. this._isEnabled = false;
  54603. /**
  54604. * Defines if the material uses sheen.
  54605. */
  54606. this.isEnabled = false;
  54607. this._linkSheenWithAlbedo = false;
  54608. /**
  54609. * Defines if the sheen is linked to the sheen color.
  54610. */
  54611. this.linkSheenWithAlbedo = false;
  54612. /**
  54613. * Defines the sheen intensity.
  54614. */
  54615. this.intensity = 1;
  54616. /**
  54617. * Defines the sheen color.
  54618. */
  54619. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  54620. this._texture = null;
  54621. /**
  54622. * Stores the sheen tint values in a texture.
  54623. * rgb is tint
  54624. * a is a intensity
  54625. */
  54626. this.texture = null;
  54627. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  54628. }
  54629. /** @hidden */
  54630. PBRSheenConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  54631. this._internalMarkAllSubMeshesAsTexturesDirty();
  54632. };
  54633. /**
  54634. * Specifies that the submesh is ready to be used.
  54635. * @param defines the list of "defines" to update.
  54636. * @param scene defines the scene the material belongs to.
  54637. * @returns - boolean indicating that the submesh is ready or not.
  54638. */
  54639. PBRSheenConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  54640. if (defines._areTexturesDirty) {
  54641. if (scene.texturesEnabled) {
  54642. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54643. if (!this._texture.isReadyOrNotBlocking()) {
  54644. return false;
  54645. }
  54646. }
  54647. }
  54648. }
  54649. return true;
  54650. };
  54651. /**
  54652. * Checks to see if a texture is used in the material.
  54653. * @param defines the list of "defines" to update.
  54654. * @param scene defines the scene the material belongs to.
  54655. */
  54656. PBRSheenConfiguration.prototype.prepareDefines = function (defines, scene) {
  54657. if (this._isEnabled) {
  54658. defines.SHEEN = this._isEnabled;
  54659. defines.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo;
  54660. if (defines._areTexturesDirty) {
  54661. if (scene.texturesEnabled) {
  54662. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54663. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "SHEEN_TEXTURE");
  54664. }
  54665. else {
  54666. defines.SHEEN_TEXTURE = false;
  54667. }
  54668. }
  54669. }
  54670. }
  54671. else {
  54672. defines.SHEEN = false;
  54673. defines.SHEEN_TEXTURE = false;
  54674. defines.SHEEN_LINKWITHALBEDO = false;
  54675. }
  54676. };
  54677. /**
  54678. * Binds the material data.
  54679. * @param uniformBuffer defines the Uniform buffer to fill in.
  54680. * @param scene defines the scene the material belongs to.
  54681. * @param isFrozen defines wether the material is frozen or not.
  54682. */
  54683. PBRSheenConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  54684. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  54685. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54686. uniformBuffer.updateFloat2("vSheenInfos", this._texture.coordinatesIndex, this._texture.level);
  54687. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "sheen");
  54688. }
  54689. // Sheen
  54690. uniformBuffer.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity);
  54691. }
  54692. // Textures
  54693. if (scene.texturesEnabled) {
  54694. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  54695. uniformBuffer.setTexture("sheenSampler", this._texture);
  54696. }
  54697. }
  54698. };
  54699. /**
  54700. * Checks to see if a texture is used in the material.
  54701. * @param texture - Base texture to use.
  54702. * @returns - Boolean specifying if a texture is used in the material.
  54703. */
  54704. PBRSheenConfiguration.prototype.hasTexture = function (texture) {
  54705. if (this._texture === texture) {
  54706. return true;
  54707. }
  54708. return false;
  54709. };
  54710. /**
  54711. * Returns an array of the actively used textures.
  54712. * @param activeTextures Array of BaseTextures
  54713. */
  54714. PBRSheenConfiguration.prototype.getActiveTextures = function (activeTextures) {
  54715. if (this._texture) {
  54716. activeTextures.push(this._texture);
  54717. }
  54718. };
  54719. /**
  54720. * Returns the animatable textures.
  54721. * @param animatables Array of animatable textures.
  54722. */
  54723. PBRSheenConfiguration.prototype.getAnimatables = function (animatables) {
  54724. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  54725. animatables.push(this._texture);
  54726. }
  54727. };
  54728. /**
  54729. * Disposes the resources of the material.
  54730. * @param forceDisposeTextures - Forces the disposal of all textures.
  54731. */
  54732. PBRSheenConfiguration.prototype.dispose = function (forceDisposeTextures) {
  54733. if (forceDisposeTextures) {
  54734. if (this._texture) {
  54735. this._texture.dispose();
  54736. }
  54737. }
  54738. };
  54739. /**
  54740. * Get the current class name of the texture useful for serialization or dynamic coding.
  54741. * @returns "PBRSheenConfiguration"
  54742. */
  54743. PBRSheenConfiguration.prototype.getClassName = function () {
  54744. return "PBRSheenConfiguration";
  54745. };
  54746. /**
  54747. * Add fallbacks to the effect fallbacks list.
  54748. * @param defines defines the Base texture to use.
  54749. * @param fallbacks defines the current fallback list.
  54750. * @param currentRank defines the current fallback rank.
  54751. * @returns the new fallback rank.
  54752. */
  54753. PBRSheenConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  54754. if (defines.SHEEN) {
  54755. fallbacks.addFallback(currentRank++, "SHEEN");
  54756. }
  54757. return currentRank;
  54758. };
  54759. /**
  54760. * Add the required uniforms to the current list.
  54761. * @param uniforms defines the current uniform list.
  54762. */
  54763. PBRSheenConfiguration.AddUniforms = function (uniforms) {
  54764. uniforms.push("vSheenColor", "vSheenInfos", "sheenMatrix");
  54765. };
  54766. /**
  54767. * Add the required uniforms to the current buffer.
  54768. * @param uniformBuffer defines the current uniform buffer.
  54769. */
  54770. PBRSheenConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  54771. uniformBuffer.addUniform("vSheenColor", 4);
  54772. uniformBuffer.addUniform("vSheenInfos", 2);
  54773. uniformBuffer.addUniform("sheenMatrix", 16);
  54774. };
  54775. /**
  54776. * Add the required samplers to the current list.
  54777. * @param samplers defines the current sampler list.
  54778. */
  54779. PBRSheenConfiguration.AddSamplers = function (samplers) {
  54780. samplers.push("sheenSampler");
  54781. };
  54782. /**
  54783. * Makes a duplicate of the current configuration into another one.
  54784. * @param sheenConfiguration define the config where to copy the info
  54785. */
  54786. PBRSheenConfiguration.prototype.copyTo = function (sheenConfiguration) {
  54787. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return sheenConfiguration; }, this);
  54788. };
  54789. /**
  54790. * Serializes this BRDF configuration.
  54791. * @returns - An object with the serialized config.
  54792. */
  54793. PBRSheenConfiguration.prototype.serialize = function () {
  54794. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54795. };
  54796. /**
  54797. * Parses a Sheen Configuration from a serialized object.
  54798. * @param source - Serialized object.
  54799. */
  54800. PBRSheenConfiguration.prototype.parse = function (source) {
  54801. var _this = this;
  54802. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  54803. };
  54804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54806. ], PBRSheenConfiguration.prototype, "_isEnabled", void 0);
  54807. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54808. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54809. ], PBRSheenConfiguration.prototype, "isEnabled", void 0);
  54810. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54811. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54812. ], PBRSheenConfiguration.prototype, "_linkSheenWithAlbedo", void 0);
  54813. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54815. ], PBRSheenConfiguration.prototype, "linkSheenWithAlbedo", void 0);
  54816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54818. ], PBRSheenConfiguration.prototype, "intensity", void 0);
  54819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  54821. ], PBRSheenConfiguration.prototype, "color", void 0);
  54822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54824. ], PBRSheenConfiguration.prototype, "_texture", void 0);
  54825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54827. ], PBRSheenConfiguration.prototype, "texture", void 0);
  54828. return PBRSheenConfiguration;
  54829. }());
  54830. /***/ }),
  54831. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  54832. /*!********************************************************!*\
  54833. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  54834. \********************************************************/
  54835. /*! exports provided: PBRSpecularGlossinessMaterial */
  54836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54837. "use strict";
  54838. __webpack_require__.r(__webpack_exports__);
  54839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  54840. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54841. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54842. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  54843. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54844. /**
  54845. * The PBR material of BJS following the specular glossiness convention.
  54846. *
  54847. * This fits to the PBR convention in the GLTF definition:
  54848. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54849. */
  54850. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  54851. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  54852. /**
  54853. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54854. *
  54855. * @param name The material name
  54856. * @param scene The scene the material will be use in.
  54857. */
  54858. function PBRSpecularGlossinessMaterial(name, scene) {
  54859. var _this = _super.call(this, name, scene) || this;
  54860. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  54861. return _this;
  54862. }
  54863. /**
  54864. * Return the currrent class name of the material.
  54865. */
  54866. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  54867. return "PBRSpecularGlossinessMaterial";
  54868. };
  54869. /**
  54870. * Makes a duplicate of the current material.
  54871. * @param name - name to use for the new material.
  54872. */
  54873. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  54874. var _this = this;
  54875. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  54876. clone.id = name;
  54877. clone.name = name;
  54878. this.clearCoat.copyTo(clone.clearCoat);
  54879. this.anisotropy.copyTo(clone.anisotropy);
  54880. this.brdf.copyTo(clone.brdf);
  54881. this.sheen.copyTo(clone.sheen);
  54882. return clone;
  54883. };
  54884. /**
  54885. * Serialize the material to a parsable JSON object.
  54886. */
  54887. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  54888. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54889. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  54890. serializationObject.clearCoat = this.clearCoat.serialize();
  54891. serializationObject.anisotropy = this.anisotropy.serialize();
  54892. serializationObject.brdf = this.brdf.serialize();
  54893. serializationObject.sheen = this.sheen.serialize();
  54894. return serializationObject;
  54895. };
  54896. /**
  54897. * Parses a JSON object correponding to the serialize function.
  54898. */
  54899. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  54900. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  54901. if (source.clearCoat) {
  54902. material.clearCoat.parse(source.clearCoat);
  54903. }
  54904. if (source.anisotropy) {
  54905. material.anisotropy.parse(source.anisotropy);
  54906. }
  54907. if (source.brdf) {
  54908. material.brdf.parse(source.brdf);
  54909. }
  54910. if (source.sheen) {
  54911. material.sheen.parse(source.brdf);
  54912. }
  54913. return material;
  54914. };
  54915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  54917. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  54918. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  54919. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54920. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54921. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  54922. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  54923. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54924. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  54925. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  54926. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  54927. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54929. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  54930. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  54931. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54933. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  54934. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  54935. return PBRSpecularGlossinessMaterial;
  54936. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  54937. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  54938. /***/ }),
  54939. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  54940. /*!********************************************************!*\
  54941. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  54942. \********************************************************/
  54943. /*! exports provided: _DDSTextureLoader */
  54944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54945. "use strict";
  54946. __webpack_require__.r(__webpack_exports__);
  54947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  54948. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  54949. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  54950. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  54951. /**
  54952. * Implementation of the DDS Texture Loader.
  54953. * @hidden
  54954. */
  54955. var _DDSTextureLoader = /** @class */ (function () {
  54956. function _DDSTextureLoader() {
  54957. /**
  54958. * Defines wether the loader supports cascade loading the different faces.
  54959. */
  54960. this.supportCascades = true;
  54961. }
  54962. /**
  54963. * This returns if the loader support the current file information.
  54964. * @param extension defines the file extension of the file being loaded
  54965. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54966. * @param fallback defines the fallback internal texture if any
  54967. * @param isBase64 defines whether the texture is encoded as a base64
  54968. * @param isBuffer defines whether the texture data are stored as a buffer
  54969. * @returns true if the loader can load the specified file
  54970. */
  54971. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  54972. return extension.indexOf(".dds") === 0;
  54973. };
  54974. /**
  54975. * Transform the url before loading if required.
  54976. * @param rootUrl the url of the texture
  54977. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54978. * @returns the transformed texture
  54979. */
  54980. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  54981. return rootUrl;
  54982. };
  54983. /**
  54984. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54985. * @param rootUrl the url of the texture
  54986. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54987. * @returns the fallback texture
  54988. */
  54989. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  54990. return null;
  54991. };
  54992. /**
  54993. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54994. * @param data contains the texture data
  54995. * @param texture defines the BabylonJS internal texture
  54996. * @param createPolynomials will be true if polynomials have been requested
  54997. * @param onLoad defines the callback to trigger once the texture is ready
  54998. * @param onError defines the callback to trigger in case of error
  54999. */
  55000. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  55001. var engine = texture.getEngine();
  55002. var info;
  55003. var loadMipmap = false;
  55004. if (Array.isArray(imgs)) {
  55005. for (var index = 0; index < imgs.length; index++) {
  55006. var data_1 = imgs[index];
  55007. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  55008. texture.width = info.width;
  55009. texture.height = info.height;
  55010. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  55011. engine._unpackFlipY(info.isCompressed);
  55012. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  55013. if (!info.isFourCC && info.mipmapCount === 1) {
  55014. engine.generateMipMapsForCubemap(texture);
  55015. }
  55016. }
  55017. }
  55018. else {
  55019. var data = imgs;
  55020. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  55021. texture.width = info.width;
  55022. texture.height = info.height;
  55023. if (createPolynomials) {
  55024. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  55025. }
  55026. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  55027. engine._unpackFlipY(info.isCompressed);
  55028. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  55029. if (!info.isFourCC && info.mipmapCount === 1) {
  55030. engine.generateMipMapsForCubemap(texture);
  55031. }
  55032. }
  55033. engine._setCubeMapTextureParams(loadMipmap);
  55034. texture.isReady = true;
  55035. if (onLoad) {
  55036. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  55037. }
  55038. };
  55039. /**
  55040. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55041. * @param data contains the texture data
  55042. * @param texture defines the BabylonJS internal texture
  55043. * @param callback defines the method to call once ready to upload
  55044. */
  55045. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  55046. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  55047. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  55048. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  55049. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  55050. });
  55051. };
  55052. return _DDSTextureLoader;
  55053. }());
  55054. // Register the loader.
  55055. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  55056. /***/ }),
  55057. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  55058. /*!********************************************************!*\
  55059. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  55060. \********************************************************/
  55061. /*! exports provided: _ENVTextureLoader */
  55062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55063. "use strict";
  55064. __webpack_require__.r(__webpack_exports__);
  55065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  55066. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  55067. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55068. /**
  55069. * Implementation of the ENV Texture Loader.
  55070. * @hidden
  55071. */
  55072. var _ENVTextureLoader = /** @class */ (function () {
  55073. function _ENVTextureLoader() {
  55074. /**
  55075. * Defines wether the loader supports cascade loading the different faces.
  55076. */
  55077. this.supportCascades = false;
  55078. }
  55079. /**
  55080. * This returns if the loader support the current file information.
  55081. * @param extension defines the file extension of the file being loaded
  55082. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55083. * @param fallback defines the fallback internal texture if any
  55084. * @param isBase64 defines whether the texture is encoded as a base64
  55085. * @param isBuffer defines whether the texture data are stored as a buffer
  55086. * @returns true if the loader can load the specified file
  55087. */
  55088. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55089. return extension.indexOf(".env") === 0;
  55090. };
  55091. /**
  55092. * Transform the url before loading if required.
  55093. * @param rootUrl the url of the texture
  55094. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55095. * @returns the transformed texture
  55096. */
  55097. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55098. return rootUrl;
  55099. };
  55100. /**
  55101. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55102. * @param rootUrl the url of the texture
  55103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55104. * @returns the fallback texture
  55105. */
  55106. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55107. return null;
  55108. };
  55109. /**
  55110. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55111. * @param data contains the texture data
  55112. * @param texture defines the BabylonJS internal texture
  55113. * @param createPolynomials will be true if polynomials have been requested
  55114. * @param onLoad defines the callback to trigger once the texture is ready
  55115. * @param onError defines the callback to trigger in case of error
  55116. */
  55117. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55118. if (Array.isArray(data)) {
  55119. return;
  55120. }
  55121. data = data;
  55122. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  55123. if (info) {
  55124. texture.width = info.width;
  55125. texture.height = info.width;
  55126. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  55127. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  55128. texture.isReady = true;
  55129. if (onLoad) {
  55130. onLoad();
  55131. }
  55132. });
  55133. }
  55134. else if (onError) {
  55135. onError("Can not parse the environment file", null);
  55136. }
  55137. };
  55138. /**
  55139. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55140. * @param data contains the texture data
  55141. * @param texture defines the BabylonJS internal texture
  55142. * @param callback defines the method to call once ready to upload
  55143. */
  55144. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  55145. throw ".env not supported in 2d.";
  55146. };
  55147. return _ENVTextureLoader;
  55148. }());
  55149. // Register the loader.
  55150. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  55151. /***/ }),
  55152. /***/ "./Materials/Textures/Loaders/index.ts":
  55153. /*!*********************************************!*\
  55154. !*** ./Materials/Textures/Loaders/index.ts ***!
  55155. \*********************************************/
  55156. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  55157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55158. "use strict";
  55159. __webpack_require__.r(__webpack_exports__);
  55160. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  55161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  55162. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  55163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  55164. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  55165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  55166. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  55167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  55168. /***/ }),
  55169. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  55170. /*!********************************************************!*\
  55171. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  55172. \********************************************************/
  55173. /*! exports provided: _KTXTextureLoader */
  55174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55175. "use strict";
  55176. __webpack_require__.r(__webpack_exports__);
  55177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  55178. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  55179. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55180. /**
  55181. * Implementation of the KTX Texture Loader.
  55182. * @hidden
  55183. */
  55184. var _KTXTextureLoader = /** @class */ (function () {
  55185. function _KTXTextureLoader() {
  55186. /**
  55187. * Defines wether the loader supports cascade loading the different faces.
  55188. */
  55189. this.supportCascades = false;
  55190. }
  55191. /**
  55192. * This returns if the loader support the current file information.
  55193. * @param extension defines the file extension of the file being loaded
  55194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55195. * @param fallback defines the fallback internal texture if any
  55196. * @param isBase64 defines whether the texture is encoded as a base64
  55197. * @param isBuffer defines whether the texture data are stored as a buffer
  55198. * @returns true if the loader can load the specified file
  55199. */
  55200. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55201. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  55202. return true;
  55203. }
  55204. return false;
  55205. };
  55206. /**
  55207. * Transform the url before loading if required.
  55208. * @param rootUrl the url of the texture
  55209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55210. * @returns the transformed texture
  55211. */
  55212. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55213. var lastDot = rootUrl.lastIndexOf('.');
  55214. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  55215. // Already transformed
  55216. return rootUrl;
  55217. }
  55218. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  55219. };
  55220. /**
  55221. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55222. * @param rootUrl the url of the texture
  55223. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55224. * @returns the fallback texture
  55225. */
  55226. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55227. // remove the format appended to the rootUrl in the original createCubeTexture call.
  55228. var exp = new RegExp("" + textureFormatInUse + "$");
  55229. return rootUrl.replace(exp, "");
  55230. };
  55231. /**
  55232. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55233. * @param data contains the texture data
  55234. * @param texture defines the BabylonJS internal texture
  55235. * @param createPolynomials will be true if polynomials have been requested
  55236. * @param onLoad defines the callback to trigger once the texture is ready
  55237. * @param onError defines the callback to trigger in case of error
  55238. */
  55239. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55240. if (Array.isArray(data)) {
  55241. return;
  55242. }
  55243. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  55244. texture._invertVScale = !texture.invertY;
  55245. var engine = texture.getEngine();
  55246. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  55247. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  55248. engine._unpackFlipY(true);
  55249. ktx.uploadLevels(texture, texture.generateMipMaps);
  55250. texture.width = ktx.pixelWidth;
  55251. texture.height = ktx.pixelHeight;
  55252. engine._setCubeMapTextureParams(loadMipmap);
  55253. texture.isReady = true;
  55254. };
  55255. /**
  55256. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55257. * @param data contains the texture data
  55258. * @param texture defines the BabylonJS internal texture
  55259. * @param callback defines the method to call once ready to upload
  55260. */
  55261. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  55262. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  55263. texture._invertVScale = !texture.invertY;
  55264. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  55265. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  55266. ktx.uploadLevels(texture, texture.generateMipMaps);
  55267. }, ktx.isInvalid);
  55268. };
  55269. return _KTXTextureLoader;
  55270. }());
  55271. // Register the loader.
  55272. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  55273. /***/ }),
  55274. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  55275. /*!********************************************************!*\
  55276. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  55277. \********************************************************/
  55278. /*! exports provided: _TGATextureLoader */
  55279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55280. "use strict";
  55281. __webpack_require__.r(__webpack_exports__);
  55282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  55283. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  55284. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55285. /**
  55286. * Implementation of the TGA Texture Loader.
  55287. * @hidden
  55288. */
  55289. var _TGATextureLoader = /** @class */ (function () {
  55290. function _TGATextureLoader() {
  55291. /**
  55292. * Defines wether the loader supports cascade loading the different faces.
  55293. */
  55294. this.supportCascades = false;
  55295. }
  55296. /**
  55297. * This returns if the loader support the current file information.
  55298. * @param extension defines the file extension of the file being loaded
  55299. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55300. * @param fallback defines the fallback internal texture if any
  55301. * @param isBase64 defines whether the texture is encoded as a base64
  55302. * @param isBuffer defines whether the texture data are stored as a buffer
  55303. * @returns true if the loader can load the specified file
  55304. */
  55305. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55306. return extension.indexOf(".tga") === 0;
  55307. };
  55308. /**
  55309. * Transform the url before loading if required.
  55310. * @param rootUrl the url of the texture
  55311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55312. * @returns the transformed texture
  55313. */
  55314. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55315. return rootUrl;
  55316. };
  55317. /**
  55318. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55319. * @param rootUrl the url of the texture
  55320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55321. * @returns the fallback texture
  55322. */
  55323. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55324. return null;
  55325. };
  55326. /**
  55327. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55328. * @param data contains the texture data
  55329. * @param texture defines the BabylonJS internal texture
  55330. * @param createPolynomials will be true if polynomials have been requested
  55331. * @param onLoad defines the callback to trigger once the texture is ready
  55332. * @param onError defines the callback to trigger in case of error
  55333. */
  55334. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55335. throw ".env not supported in Cube.";
  55336. };
  55337. /**
  55338. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55339. * @param data contains the texture data
  55340. * @param texture defines the BabylonJS internal texture
  55341. * @param callback defines the method to call once ready to upload
  55342. */
  55343. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  55344. var uintData = new Uint8Array(data);
  55345. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  55346. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  55347. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  55348. });
  55349. };
  55350. return _TGATextureLoader;
  55351. }());
  55352. // Register the loader.
  55353. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  55354. /***/ }),
  55355. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  55356. /*!*******************************************************************!*\
  55357. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  55358. \*******************************************************************/
  55359. /*! exports provided: CustomProceduralTexture */
  55360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55361. "use strict";
  55362. __webpack_require__.r(__webpack_exports__);
  55363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  55364. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55365. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  55366. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  55367. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  55368. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55369. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55370. /**
  55371. * 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.
  55372. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55373. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55374. */
  55375. var CustomProceduralTexture = /** @class */ (function (_super) {
  55376. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  55377. /**
  55378. * Instantiates a new Custom Procedural Texture.
  55379. * 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.
  55380. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55381. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55382. * @param name Define the name of the texture
  55383. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55384. * @param size Define the size of the texture to create
  55385. * @param scene Define the scene the texture belongs to
  55386. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55387. * @param generateMipMaps Define if the texture should creates mip maps or not
  55388. */
  55389. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  55390. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  55391. _this._animate = true;
  55392. _this._time = 0;
  55393. _this._texturePath = texturePath;
  55394. //Try to load json
  55395. _this._loadJson(texturePath);
  55396. _this.refreshRate = 1;
  55397. return _this;
  55398. }
  55399. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  55400. var _this = this;
  55401. var noConfigFile = function () {
  55402. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  55403. try {
  55404. _this.setFragment(_this._texturePath);
  55405. }
  55406. catch (ex) {
  55407. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  55408. }
  55409. };
  55410. var configFileUrl = jsonUrl + "/config.json";
  55411. var xhr = new XMLHttpRequest();
  55412. xhr.open("GET", configFileUrl, true);
  55413. xhr.addEventListener("load", function () {
  55414. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  55415. try {
  55416. _this._config = JSON.parse(xhr.response);
  55417. _this.updateShaderUniforms();
  55418. _this.updateTextures();
  55419. _this.setFragment(_this._texturePath + "/custom");
  55420. _this._animate = _this._config.animate;
  55421. _this.refreshRate = _this._config.refreshrate;
  55422. }
  55423. catch (ex) {
  55424. noConfigFile();
  55425. }
  55426. }
  55427. else {
  55428. noConfigFile();
  55429. }
  55430. }, false);
  55431. xhr.addEventListener("error", function () {
  55432. noConfigFile();
  55433. }, false);
  55434. try {
  55435. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  55436. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  55437. }
  55438. xhr.send();
  55439. }
  55440. catch (ex) {
  55441. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  55442. }
  55443. };
  55444. /**
  55445. * Is the texture ready to be used ? (rendered at least once)
  55446. * @returns true if ready, otherwise, false.
  55447. */
  55448. CustomProceduralTexture.prototype.isReady = function () {
  55449. if (!_super.prototype.isReady.call(this)) {
  55450. return false;
  55451. }
  55452. for (var name in this._textures) {
  55453. var texture = this._textures[name];
  55454. if (!texture.isReady()) {
  55455. return false;
  55456. }
  55457. }
  55458. return true;
  55459. };
  55460. /**
  55461. * Render the texture to its associated render target.
  55462. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55463. */
  55464. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  55465. var scene = this.getScene();
  55466. if (this._animate && scene) {
  55467. this._time += scene.getAnimationRatio() * 0.03;
  55468. this.updateShaderUniforms();
  55469. }
  55470. _super.prototype.render.call(this, useCameraPostProcess);
  55471. };
  55472. /**
  55473. * Update the list of dependant textures samplers in the shader.
  55474. */
  55475. CustomProceduralTexture.prototype.updateTextures = function () {
  55476. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  55477. 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()));
  55478. }
  55479. };
  55480. /**
  55481. * Update the uniform values of the procedural texture in the shader.
  55482. */
  55483. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  55484. if (this._config) {
  55485. for (var j = 0; j < this._config.uniforms.length; j++) {
  55486. var uniform = this._config.uniforms[j];
  55487. switch (uniform.type) {
  55488. case "float":
  55489. this.setFloat(uniform.name, uniform.value);
  55490. break;
  55491. case "color3":
  55492. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  55493. break;
  55494. case "color4":
  55495. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  55496. break;
  55497. case "vector2":
  55498. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  55499. break;
  55500. case "vector3":
  55501. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  55502. break;
  55503. }
  55504. }
  55505. }
  55506. this.setFloat("time", this._time);
  55507. };
  55508. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  55509. /**
  55510. * Define if the texture animates or not.
  55511. */
  55512. get: function () {
  55513. return this._animate;
  55514. },
  55515. set: function (value) {
  55516. this._animate = value;
  55517. },
  55518. enumerable: true,
  55519. configurable: true
  55520. });
  55521. return CustomProceduralTexture;
  55522. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  55523. /***/ }),
  55524. /***/ "./Materials/Textures/Procedurals/index.ts":
  55525. /*!*************************************************!*\
  55526. !*** ./Materials/Textures/Procedurals/index.ts ***!
  55527. \*************************************************/
  55528. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  55529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55530. "use strict";
  55531. __webpack_require__.r(__webpack_exports__);
  55532. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  55533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  55534. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  55535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  55536. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  55538. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  55539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  55540. /***/ }),
  55541. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  55542. /*!******************************************************************!*\
  55543. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  55544. \******************************************************************/
  55545. /*! exports provided: NoiseProceduralTexture */
  55546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55547. "use strict";
  55548. __webpack_require__.r(__webpack_exports__);
  55549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  55550. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55551. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  55552. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55553. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55554. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  55555. /**
  55556. * Class used to generate noise procedural textures
  55557. */
  55558. var NoiseProceduralTexture = /** @class */ (function (_super) {
  55559. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  55560. /**
  55561. * Creates a new NoiseProceduralTexture
  55562. * @param name defines the name fo the texture
  55563. * @param size defines the size of the texture (default is 256)
  55564. * @param scene defines the hosting scene
  55565. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55566. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55567. */
  55568. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  55569. if (size === void 0) { size = 256; }
  55570. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  55571. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  55572. _this._time = 0;
  55573. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55574. _this.brightness = 0.2;
  55575. /** Defines the number of octaves to process */
  55576. _this.octaves = 3;
  55577. /** Defines the level of persistence (0.8 by default) */
  55578. _this.persistence = 0.8;
  55579. /** Gets or sets animation speed factor (default is 1) */
  55580. _this.animationSpeedFactor = 1;
  55581. _this.autoClear = false;
  55582. _this._updateShaderUniforms();
  55583. return _this;
  55584. }
  55585. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  55586. var scene = this.getScene();
  55587. if (!scene) {
  55588. return;
  55589. }
  55590. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  55591. this.setFloat("brightness", this.brightness);
  55592. this.setFloat("persistence", this.persistence);
  55593. this.setFloat("timeScale", this._time);
  55594. };
  55595. NoiseProceduralTexture.prototype._getDefines = function () {
  55596. return "#define OCTAVES " + (this.octaves | 0);
  55597. };
  55598. /** Generate the current state of the procedural texture */
  55599. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  55600. this._updateShaderUniforms();
  55601. _super.prototype.render.call(this, useCameraPostProcess);
  55602. };
  55603. /**
  55604. * Serializes this noise procedural texture
  55605. * @returns a serialized noise procedural texture object
  55606. */
  55607. NoiseProceduralTexture.prototype.serialize = function () {
  55608. var serializationObject = {};
  55609. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  55610. serializationObject.brightness = this.brightness;
  55611. serializationObject.octaves = this.octaves;
  55612. serializationObject.persistence = this.persistence;
  55613. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  55614. serializationObject.size = this.getSize().width;
  55615. serializationObject.generateMipMaps = this._generateMipMaps;
  55616. return serializationObject;
  55617. };
  55618. /**
  55619. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55620. * @param parsedTexture defines parsed texture data
  55621. * @param scene defines the current scene
  55622. * @param rootUrl defines the root URL containing noise procedural texture information
  55623. * @returns a parsed NoiseProceduralTexture
  55624. */
  55625. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  55626. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  55627. texture.brightness = parsedTexture.brightness;
  55628. texture.octaves = parsedTexture.octaves;
  55629. texture.persistence = parsedTexture.persistence;
  55630. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  55631. return texture;
  55632. };
  55633. return NoiseProceduralTexture;
  55634. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  55635. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  55636. /***/ }),
  55637. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  55638. /*!*************************************************************!*\
  55639. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  55640. \*************************************************************/
  55641. /*! exports provided: ProceduralTexture */
  55642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55643. "use strict";
  55644. __webpack_require__.r(__webpack_exports__);
  55645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  55646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55647. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  55648. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  55649. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  55650. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  55651. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  55652. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55653. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  55654. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  55655. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  55656. /**
  55657. * 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.
  55658. * This is the base class of any Procedural texture and contains most of the shareable code.
  55659. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  55660. */
  55661. var ProceduralTexture = /** @class */ (function (_super) {
  55662. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  55663. /**
  55664. * Instantiates a new procedural texture.
  55665. * 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.
  55666. * This is the base class of any Procedural texture and contains most of the shareable code.
  55667. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  55668. * @param name Define the name of the texture
  55669. * @param size Define the size of the texture to create
  55670. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  55671. * @param scene Define the scene the texture belongs to
  55672. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55673. * @param generateMipMaps Define if the texture should creates mip maps or not
  55674. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  55675. */
  55676. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  55677. if (fallbackTexture === void 0) { fallbackTexture = null; }
  55678. if (generateMipMaps === void 0) { generateMipMaps = true; }
  55679. if (isCube === void 0) { isCube = false; }
  55680. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  55681. _this.isCube = isCube;
  55682. /**
  55683. * Define if the texture is enabled or not (disabled texture will not render)
  55684. */
  55685. _this.isEnabled = true;
  55686. /**
  55687. * Define if the texture must be cleared before rendering (default is true)
  55688. */
  55689. _this.autoClear = true;
  55690. /**
  55691. * Event raised when the texture is generated
  55692. */
  55693. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  55694. /** @hidden */
  55695. _this._textures = {};
  55696. _this._currentRefreshId = -1;
  55697. _this._refreshRate = 1;
  55698. _this._vertexBuffers = {};
  55699. _this._uniforms = new Array();
  55700. _this._samplers = new Array();
  55701. _this._floats = {};
  55702. _this._ints = {};
  55703. _this._floatsArrays = {};
  55704. _this._colors3 = {};
  55705. _this._colors4 = {};
  55706. _this._vectors2 = {};
  55707. _this._vectors3 = {};
  55708. _this._matrices = {};
  55709. _this._fallbackTextureUsed = false;
  55710. _this._cachedDefines = "";
  55711. _this._contentUpdateId = -1;
  55712. scene = _this.getScene();
  55713. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  55714. if (!component) {
  55715. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  55716. scene._addComponent(component);
  55717. }
  55718. scene.proceduralTextures.push(_this);
  55719. _this._engine = scene.getEngine();
  55720. _this.name = name;
  55721. _this.isRenderTarget = true;
  55722. _this._size = size;
  55723. _this._generateMipMaps = generateMipMaps;
  55724. _this.setFragment(fragment);
  55725. _this._fallbackTexture = fallbackTexture;
  55726. if (isCube) {
  55727. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  55728. _this.setFloat("face", 0);
  55729. }
  55730. else {
  55731. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  55732. }
  55733. // VBO
  55734. var vertices = [];
  55735. vertices.push(1, 1);
  55736. vertices.push(-1, 1);
  55737. vertices.push(-1, -1);
  55738. vertices.push(1, -1);
  55739. _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);
  55740. _this._createIndexBuffer();
  55741. return _this;
  55742. }
  55743. /**
  55744. * The effect that is created when initializing the post process.
  55745. * @returns The created effect corrisponding the the postprocess.
  55746. */
  55747. ProceduralTexture.prototype.getEffect = function () {
  55748. return this._effect;
  55749. };
  55750. /**
  55751. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  55752. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  55753. */
  55754. ProceduralTexture.prototype.getContent = function () {
  55755. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  55756. return this._contentData;
  55757. }
  55758. this._contentData = this.readPixels(0, 0, this._contentData);
  55759. this._contentUpdateId = this._currentRefreshId;
  55760. return this._contentData;
  55761. };
  55762. ProceduralTexture.prototype._createIndexBuffer = function () {
  55763. var engine = this._engine;
  55764. // Indices
  55765. var indices = [];
  55766. indices.push(0);
  55767. indices.push(1);
  55768. indices.push(2);
  55769. indices.push(0);
  55770. indices.push(2);
  55771. indices.push(3);
  55772. this._indexBuffer = engine.createIndexBuffer(indices);
  55773. };
  55774. /** @hidden */
  55775. ProceduralTexture.prototype._rebuild = function () {
  55776. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  55777. if (vb) {
  55778. vb._rebuild();
  55779. }
  55780. this._createIndexBuffer();
  55781. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  55782. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  55783. }
  55784. };
  55785. /**
  55786. * Resets the texture in order to recreate its associated resources.
  55787. * This can be called in case of context loss
  55788. */
  55789. ProceduralTexture.prototype.reset = function () {
  55790. if (this._effect === undefined) {
  55791. return;
  55792. }
  55793. var engine = this._engine;
  55794. engine._releaseEffect(this._effect);
  55795. };
  55796. ProceduralTexture.prototype._getDefines = function () {
  55797. return "";
  55798. };
  55799. /**
  55800. * Is the texture ready to be used ? (rendered at least once)
  55801. * @returns true if ready, otherwise, false.
  55802. */
  55803. ProceduralTexture.prototype.isReady = function () {
  55804. var _this = this;
  55805. var engine = this._engine;
  55806. var shaders;
  55807. if (!this._fragment) {
  55808. return false;
  55809. }
  55810. if (this._fallbackTextureUsed) {
  55811. return true;
  55812. }
  55813. var defines = this._getDefines();
  55814. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  55815. return true;
  55816. }
  55817. if (this._fragment.fragmentElement !== undefined) {
  55818. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  55819. }
  55820. else {
  55821. shaders = { vertex: "procedural", fragment: this._fragment };
  55822. }
  55823. this._cachedDefines = defines;
  55824. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  55825. _this.releaseInternalTexture();
  55826. if (_this._fallbackTexture) {
  55827. _this._texture = _this._fallbackTexture._texture;
  55828. if (_this._texture) {
  55829. _this._texture.incrementReferences();
  55830. }
  55831. }
  55832. _this._fallbackTextureUsed = true;
  55833. });
  55834. return this._effect.isReady();
  55835. };
  55836. /**
  55837. * Resets the refresh counter of the texture and start bak from scratch.
  55838. * Could be useful to regenerate the texture if it is setup to render only once.
  55839. */
  55840. ProceduralTexture.prototype.resetRefreshCounter = function () {
  55841. this._currentRefreshId = -1;
  55842. };
  55843. /**
  55844. * Set the fragment shader to use in order to render the texture.
  55845. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  55846. */
  55847. ProceduralTexture.prototype.setFragment = function (fragment) {
  55848. this._fragment = fragment;
  55849. };
  55850. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  55851. /**
  55852. * Define the refresh rate of the texture or the rendering frequency.
  55853. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  55854. */
  55855. get: function () {
  55856. return this._refreshRate;
  55857. },
  55858. set: function (value) {
  55859. this._refreshRate = value;
  55860. this.resetRefreshCounter();
  55861. },
  55862. enumerable: true,
  55863. configurable: true
  55864. });
  55865. /** @hidden */
  55866. ProceduralTexture.prototype._shouldRender = function () {
  55867. if (!this.isEnabled || !this.isReady() || !this._texture) {
  55868. if (this._texture) {
  55869. this._texture.isReady = false;
  55870. }
  55871. return false;
  55872. }
  55873. if (this._fallbackTextureUsed) {
  55874. return false;
  55875. }
  55876. if (this._currentRefreshId === -1) { // At least render once
  55877. this._currentRefreshId = 1;
  55878. return true;
  55879. }
  55880. if (this.refreshRate === this._currentRefreshId) {
  55881. this._currentRefreshId = 1;
  55882. return true;
  55883. }
  55884. this._currentRefreshId++;
  55885. return false;
  55886. };
  55887. /**
  55888. * Get the size the texture is rendering at.
  55889. * @returns the size (texture is always squared)
  55890. */
  55891. ProceduralTexture.prototype.getRenderSize = function () {
  55892. return this._size;
  55893. };
  55894. /**
  55895. * Resize the texture to new value.
  55896. * @param size Define the new size the texture should have
  55897. * @param generateMipMaps Define whether the new texture should create mip maps
  55898. */
  55899. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  55900. if (this._fallbackTextureUsed) {
  55901. return;
  55902. }
  55903. this.releaseInternalTexture();
  55904. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  55905. // Update properties
  55906. this._size = size;
  55907. this._generateMipMaps = generateMipMaps;
  55908. };
  55909. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  55910. if (this._uniforms.indexOf(uniformName) === -1) {
  55911. this._uniforms.push(uniformName);
  55912. }
  55913. };
  55914. /**
  55915. * Set a texture in the shader program used to render.
  55916. * @param name Define the name of the uniform samplers as defined in the shader
  55917. * @param texture Define the texture to bind to this sampler
  55918. * @return the texture itself allowing "fluent" like uniform updates
  55919. */
  55920. ProceduralTexture.prototype.setTexture = function (name, texture) {
  55921. if (this._samplers.indexOf(name) === -1) {
  55922. this._samplers.push(name);
  55923. }
  55924. this._textures[name] = texture;
  55925. return this;
  55926. };
  55927. /**
  55928. * Set a float in the shader.
  55929. * @param name Define the name of the uniform as defined in the shader
  55930. * @param value Define the value to give to the uniform
  55931. * @return the texture itself allowing "fluent" like uniform updates
  55932. */
  55933. ProceduralTexture.prototype.setFloat = function (name, value) {
  55934. this._checkUniform(name);
  55935. this._floats[name] = value;
  55936. return this;
  55937. };
  55938. /**
  55939. * Set a int in the shader.
  55940. * @param name Define the name of the uniform as defined in the shader
  55941. * @param value Define the value to give to the uniform
  55942. * @return the texture itself allowing "fluent" like uniform updates
  55943. */
  55944. ProceduralTexture.prototype.setInt = function (name, value) {
  55945. this._checkUniform(name);
  55946. this._ints[name] = value;
  55947. return this;
  55948. };
  55949. /**
  55950. * Set an array of floats in the shader.
  55951. * @param name Define the name of the uniform as defined in the shader
  55952. * @param value Define the value to give to the uniform
  55953. * @return the texture itself allowing "fluent" like uniform updates
  55954. */
  55955. ProceduralTexture.prototype.setFloats = function (name, value) {
  55956. this._checkUniform(name);
  55957. this._floatsArrays[name] = value;
  55958. return this;
  55959. };
  55960. /**
  55961. * Set a vec3 in the shader from a Color3.
  55962. * @param name Define the name of the uniform as defined in the shader
  55963. * @param value Define the value to give to the uniform
  55964. * @return the texture itself allowing "fluent" like uniform updates
  55965. */
  55966. ProceduralTexture.prototype.setColor3 = function (name, value) {
  55967. this._checkUniform(name);
  55968. this._colors3[name] = value;
  55969. return this;
  55970. };
  55971. /**
  55972. * Set a vec4 in the shader from a Color4.
  55973. * @param name Define the name of the uniform as defined in the shader
  55974. * @param value Define the value to give to the uniform
  55975. * @return the texture itself allowing "fluent" like uniform updates
  55976. */
  55977. ProceduralTexture.prototype.setColor4 = function (name, value) {
  55978. this._checkUniform(name);
  55979. this._colors4[name] = value;
  55980. return this;
  55981. };
  55982. /**
  55983. * Set a vec2 in the shader from a Vector2.
  55984. * @param name Define the name of the uniform as defined in the shader
  55985. * @param value Define the value to give to the uniform
  55986. * @return the texture itself allowing "fluent" like uniform updates
  55987. */
  55988. ProceduralTexture.prototype.setVector2 = function (name, value) {
  55989. this._checkUniform(name);
  55990. this._vectors2[name] = value;
  55991. return this;
  55992. };
  55993. /**
  55994. * Set a vec3 in the shader from a Vector3.
  55995. * @param name Define the name of the uniform as defined in the shader
  55996. * @param value Define the value to give to the uniform
  55997. * @return the texture itself allowing "fluent" like uniform updates
  55998. */
  55999. ProceduralTexture.prototype.setVector3 = function (name, value) {
  56000. this._checkUniform(name);
  56001. this._vectors3[name] = value;
  56002. return this;
  56003. };
  56004. /**
  56005. * Set a mat4 in the shader from a MAtrix.
  56006. * @param name Define the name of the uniform as defined in the shader
  56007. * @param value Define the value to give to the uniform
  56008. * @return the texture itself allowing "fluent" like uniform updates
  56009. */
  56010. ProceduralTexture.prototype.setMatrix = function (name, value) {
  56011. this._checkUniform(name);
  56012. this._matrices[name] = value;
  56013. return this;
  56014. };
  56015. /**
  56016. * Render the texture to its associated render target.
  56017. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56018. */
  56019. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56020. var scene = this.getScene();
  56021. if (!scene) {
  56022. return;
  56023. }
  56024. var engine = this._engine;
  56025. // Render
  56026. engine.enableEffect(this._effect);
  56027. engine.setState(false);
  56028. // Texture
  56029. for (var name in this._textures) {
  56030. this._effect.setTexture(name, this._textures[name]);
  56031. }
  56032. // Float
  56033. for (name in this._ints) {
  56034. this._effect.setInt(name, this._ints[name]);
  56035. }
  56036. // Float
  56037. for (name in this._floats) {
  56038. this._effect.setFloat(name, this._floats[name]);
  56039. }
  56040. // Floats
  56041. for (name in this._floatsArrays) {
  56042. this._effect.setArray(name, this._floatsArrays[name]);
  56043. }
  56044. // Color3
  56045. for (name in this._colors3) {
  56046. this._effect.setColor3(name, this._colors3[name]);
  56047. }
  56048. // Color4
  56049. for (name in this._colors4) {
  56050. var color = this._colors4[name];
  56051. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  56052. }
  56053. // Vector2
  56054. for (name in this._vectors2) {
  56055. this._effect.setVector2(name, this._vectors2[name]);
  56056. }
  56057. // Vector3
  56058. for (name in this._vectors3) {
  56059. this._effect.setVector3(name, this._vectors3[name]);
  56060. }
  56061. // Matrix
  56062. for (name in this._matrices) {
  56063. this._effect.setMatrix(name, this._matrices[name]);
  56064. }
  56065. if (!this._texture) {
  56066. return;
  56067. }
  56068. if (this.isCube) {
  56069. for (var face = 0; face < 6; face++) {
  56070. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  56071. // VBOs
  56072. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  56073. this._effect.setFloat("face", face);
  56074. // Clear
  56075. if (this.autoClear) {
  56076. engine.clear(scene.clearColor, true, false, false);
  56077. }
  56078. // Draw order
  56079. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  56080. // Mipmaps
  56081. if (face === 5) {
  56082. engine.generateMipMapsForCubemap(this._texture);
  56083. }
  56084. }
  56085. }
  56086. else {
  56087. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  56088. // VBOs
  56089. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  56090. // Clear
  56091. if (this.autoClear) {
  56092. engine.clear(scene.clearColor, true, false, false);
  56093. }
  56094. // Draw order
  56095. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  56096. }
  56097. // Unbind
  56098. engine.unBindFramebuffer(this._texture, this.isCube);
  56099. if (this.onGenerated) {
  56100. this.onGenerated();
  56101. }
  56102. this.onGeneratedObservable.notifyObservers(this);
  56103. };
  56104. /**
  56105. * Clone the texture.
  56106. * @returns the cloned texture
  56107. */
  56108. ProceduralTexture.prototype.clone = function () {
  56109. var textureSize = this.getSize();
  56110. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  56111. // Base texture
  56112. newTexture.hasAlpha = this.hasAlpha;
  56113. newTexture.level = this.level;
  56114. // RenderTarget Texture
  56115. newTexture.coordinatesMode = this.coordinatesMode;
  56116. return newTexture;
  56117. };
  56118. /**
  56119. * Dispose the texture and release its asoociated resources.
  56120. */
  56121. ProceduralTexture.prototype.dispose = function () {
  56122. var scene = this.getScene();
  56123. if (!scene) {
  56124. return;
  56125. }
  56126. var index = scene.proceduralTextures.indexOf(this);
  56127. if (index >= 0) {
  56128. scene.proceduralTextures.splice(index, 1);
  56129. }
  56130. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  56131. if (vertexBuffer) {
  56132. vertexBuffer.dispose();
  56133. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  56134. }
  56135. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  56136. this._indexBuffer = null;
  56137. }
  56138. _super.prototype.dispose.call(this);
  56139. };
  56140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56142. ], ProceduralTexture.prototype, "isEnabled", void 0);
  56143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56145. ], ProceduralTexture.prototype, "autoClear", void 0);
  56146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56148. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  56149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56151. ], ProceduralTexture.prototype, "_size", void 0);
  56152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56154. ], ProceduralTexture.prototype, "refreshRate", null);
  56155. return ProceduralTexture;
  56156. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  56157. /***/ }),
  56158. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  56159. /*!***************************************************************************!*\
  56160. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  56161. \***************************************************************************/
  56162. /*! exports provided: ProceduralTextureSceneComponent */
  56163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56164. "use strict";
  56165. __webpack_require__.r(__webpack_exports__);
  56166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  56167. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  56168. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  56169. /**
  56170. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  56171. * in a given scene.
  56172. */
  56173. var ProceduralTextureSceneComponent = /** @class */ (function () {
  56174. /**
  56175. * Creates a new instance of the component for the given scene
  56176. * @param scene Defines the scene to register the component in
  56177. */
  56178. function ProceduralTextureSceneComponent(scene) {
  56179. /**
  56180. * The component name helpfull to identify the component in the list of scene components.
  56181. */
  56182. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  56183. this.scene = scene;
  56184. this.scene.proceduralTextures = new Array();
  56185. scene.layers = new Array();
  56186. }
  56187. /**
  56188. * Registers the component in a given scene
  56189. */
  56190. ProceduralTextureSceneComponent.prototype.register = function () {
  56191. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  56192. };
  56193. /**
  56194. * Rebuilds the elements related to this component in case of
  56195. * context lost for instance.
  56196. */
  56197. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  56198. // Nothing to do here.
  56199. };
  56200. /**
  56201. * Disposes the component and the associated ressources.
  56202. */
  56203. ProceduralTextureSceneComponent.prototype.dispose = function () {
  56204. // Nothing to do here.
  56205. };
  56206. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  56207. if (this.scene.proceduralTexturesEnabled) {
  56208. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  56209. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  56210. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  56211. if (proceduralTexture._shouldRender()) {
  56212. proceduralTexture.render();
  56213. }
  56214. }
  56215. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  56216. }
  56217. };
  56218. return ProceduralTextureSceneComponent;
  56219. }());
  56220. /***/ }),
  56221. /***/ "./Materials/Textures/baseTexture.ts":
  56222. /*!*******************************************!*\
  56223. !*** ./Materials/Textures/baseTexture.ts ***!
  56224. \*******************************************/
  56225. /*! exports provided: BaseTexture */
  56226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56227. "use strict";
  56228. __webpack_require__.r(__webpack_exports__);
  56229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  56230. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56231. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56232. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56233. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  56234. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  56235. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56236. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  56237. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56238. /**
  56239. * Base class of all the textures in babylon.
  56240. * It groups all the common properties the materials, post process, lights... might need
  56241. * in order to make a correct use of the texture.
  56242. */
  56243. var BaseTexture = /** @class */ (function () {
  56244. /**
  56245. * Instantiates a new BaseTexture.
  56246. * Base class of all the textures in babylon.
  56247. * It groups all the common properties the materials, post process, lights... might need
  56248. * in order to make a correct use of the texture.
  56249. * @param scene Define the scene the texture blongs to
  56250. */
  56251. function BaseTexture(scene) {
  56252. /**
  56253. * Gets or sets an object used to store user defined information.
  56254. */
  56255. this.metadata = null;
  56256. /**
  56257. * For internal use only. Please do not use.
  56258. */
  56259. this.reservedDataStore = null;
  56260. this._hasAlpha = false;
  56261. /**
  56262. * Defines if the alpha value should be determined via the rgb values.
  56263. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  56264. */
  56265. this.getAlphaFromRGB = false;
  56266. /**
  56267. * Intensity or strength of the texture.
  56268. * It is commonly used by materials to fine tune the intensity of the texture
  56269. */
  56270. this.level = 1;
  56271. /**
  56272. * Define the UV chanel to use starting from 0 and defaulting to 0.
  56273. * This is part of the texture as textures usually maps to one uv set.
  56274. */
  56275. this.coordinatesIndex = 0;
  56276. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  56277. /**
  56278. * | Value | Type | Description |
  56279. * | ----- | ------------------ | ----------- |
  56280. * | 0 | CLAMP_ADDRESSMODE | |
  56281. * | 1 | WRAP_ADDRESSMODE | |
  56282. * | 2 | MIRROR_ADDRESSMODE | |
  56283. */
  56284. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56285. /**
  56286. * | Value | Type | Description |
  56287. * | ----- | ------------------ | ----------- |
  56288. * | 0 | CLAMP_ADDRESSMODE | |
  56289. * | 1 | WRAP_ADDRESSMODE | |
  56290. * | 2 | MIRROR_ADDRESSMODE | |
  56291. */
  56292. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56293. /**
  56294. * | Value | Type | Description |
  56295. * | ----- | ------------------ | ----------- |
  56296. * | 0 | CLAMP_ADDRESSMODE | |
  56297. * | 1 | WRAP_ADDRESSMODE | |
  56298. * | 2 | MIRROR_ADDRESSMODE | |
  56299. */
  56300. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56301. /**
  56302. * With compliant hardware and browser (supporting anisotropic filtering)
  56303. * this defines the level of anisotropic filtering in the texture.
  56304. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  56305. */
  56306. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  56307. /**
  56308. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  56309. * HDR texture are usually stored in linear space.
  56310. * This only impacts the PBR and Background materials
  56311. */
  56312. this.gammaSpace = true;
  56313. /**
  56314. * Is Z inverted in the texture (useful in a cube texture).
  56315. */
  56316. this.invertZ = false;
  56317. /**
  56318. * @hidden
  56319. */
  56320. this.lodLevelInAlpha = false;
  56321. /**
  56322. * Define if the texture is a render target.
  56323. */
  56324. this.isRenderTarget = false;
  56325. /**
  56326. * Define the list of animation attached to the texture.
  56327. */
  56328. this.animations = new Array();
  56329. /**
  56330. * An event triggered when the texture is disposed.
  56331. */
  56332. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  56333. /**
  56334. * Define the current state of the loading sequence when in delayed load mode.
  56335. */
  56336. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  56337. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  56338. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  56339. if (this._scene) {
  56340. this.uniqueId = this._scene.getUniqueId();
  56341. this._scene.addTexture(this);
  56342. }
  56343. this._uid = null;
  56344. }
  56345. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  56346. get: function () {
  56347. return this._hasAlpha;
  56348. },
  56349. /**
  56350. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  56351. */
  56352. set: function (value) {
  56353. if (this._hasAlpha === value) {
  56354. return;
  56355. }
  56356. this._hasAlpha = value;
  56357. if (this._scene) {
  56358. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  56359. }
  56360. },
  56361. enumerable: true,
  56362. configurable: true
  56363. });
  56364. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  56365. get: function () {
  56366. return this._coordinatesMode;
  56367. },
  56368. /**
  56369. * How a texture is mapped.
  56370. *
  56371. * | Value | Type | Description |
  56372. * | ----- | ----------------------------------- | ----------- |
  56373. * | 0 | EXPLICIT_MODE | |
  56374. * | 1 | SPHERICAL_MODE | |
  56375. * | 2 | PLANAR_MODE | |
  56376. * | 3 | CUBIC_MODE | |
  56377. * | 4 | PROJECTION_MODE | |
  56378. * | 5 | SKYBOX_MODE | |
  56379. * | 6 | INVCUBIC_MODE | |
  56380. * | 7 | EQUIRECTANGULAR_MODE | |
  56381. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  56382. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  56383. */
  56384. set: function (value) {
  56385. if (this._coordinatesMode === value) {
  56386. return;
  56387. }
  56388. this._coordinatesMode = value;
  56389. if (this._scene) {
  56390. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  56391. }
  56392. },
  56393. enumerable: true,
  56394. configurable: true
  56395. });
  56396. Object.defineProperty(BaseTexture.prototype, "isCube", {
  56397. /**
  56398. * Define if the texture is a cube texture or if false a 2d texture.
  56399. */
  56400. get: function () {
  56401. if (!this._texture) {
  56402. return false;
  56403. }
  56404. return this._texture.isCube;
  56405. },
  56406. set: function (value) {
  56407. if (!this._texture) {
  56408. return;
  56409. }
  56410. this._texture.isCube = value;
  56411. },
  56412. enumerable: true,
  56413. configurable: true
  56414. });
  56415. Object.defineProperty(BaseTexture.prototype, "is3D", {
  56416. /**
  56417. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  56418. */
  56419. get: function () {
  56420. if (!this._texture) {
  56421. return false;
  56422. }
  56423. return this._texture.is3D;
  56424. },
  56425. set: function (value) {
  56426. if (!this._texture) {
  56427. return;
  56428. }
  56429. this._texture.is3D = value;
  56430. },
  56431. enumerable: true,
  56432. configurable: true
  56433. });
  56434. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  56435. /**
  56436. * Gets whether or not the texture contains RGBD data.
  56437. */
  56438. get: function () {
  56439. return this._texture != null && this._texture._isRGBD;
  56440. },
  56441. enumerable: true,
  56442. configurable: true
  56443. });
  56444. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  56445. /**
  56446. * Are mip maps generated for this texture or not.
  56447. */
  56448. get: function () {
  56449. return false;
  56450. },
  56451. enumerable: true,
  56452. configurable: true
  56453. });
  56454. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  56455. /**
  56456. * With prefiltered texture, defined the offset used during the prefiltering steps.
  56457. */
  56458. get: function () {
  56459. if (this._texture) {
  56460. return this._texture._lodGenerationOffset;
  56461. }
  56462. return 0.0;
  56463. },
  56464. set: function (value) {
  56465. if (this._texture) {
  56466. this._texture._lodGenerationOffset = value;
  56467. }
  56468. },
  56469. enumerable: true,
  56470. configurable: true
  56471. });
  56472. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  56473. /**
  56474. * With prefiltered texture, defined the scale used during the prefiltering steps.
  56475. */
  56476. get: function () {
  56477. if (this._texture) {
  56478. return this._texture._lodGenerationScale;
  56479. }
  56480. return 0.0;
  56481. },
  56482. set: function (value) {
  56483. if (this._texture) {
  56484. this._texture._lodGenerationScale = value;
  56485. }
  56486. },
  56487. enumerable: true,
  56488. configurable: true
  56489. });
  56490. Object.defineProperty(BaseTexture.prototype, "uid", {
  56491. /**
  56492. * Define the unique id of the texture in the scene.
  56493. */
  56494. get: function () {
  56495. if (!this._uid) {
  56496. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  56497. }
  56498. return this._uid;
  56499. },
  56500. enumerable: true,
  56501. configurable: true
  56502. });
  56503. /**
  56504. * Return a string representation of the texture.
  56505. * @returns the texture as a string
  56506. */
  56507. BaseTexture.prototype.toString = function () {
  56508. return this.name;
  56509. };
  56510. /**
  56511. * Get the class name of the texture.
  56512. * @returns "BaseTexture"
  56513. */
  56514. BaseTexture.prototype.getClassName = function () {
  56515. return "BaseTexture";
  56516. };
  56517. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  56518. /**
  56519. * Callback triggered when the texture has been disposed.
  56520. * Kept for back compatibility, you can use the onDisposeObservable instead.
  56521. */
  56522. set: function (callback) {
  56523. if (this._onDisposeObserver) {
  56524. this.onDisposeObservable.remove(this._onDisposeObserver);
  56525. }
  56526. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  56527. },
  56528. enumerable: true,
  56529. configurable: true
  56530. });
  56531. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  56532. /**
  56533. * Define if the texture is preventinga material to render or not.
  56534. * If not and the texture is not ready, the engine will use a default black texture instead.
  56535. */
  56536. get: function () {
  56537. return true;
  56538. },
  56539. enumerable: true,
  56540. configurable: true
  56541. });
  56542. /**
  56543. * Get the scene the texture belongs to.
  56544. * @returns the scene or null if undefined
  56545. */
  56546. BaseTexture.prototype.getScene = function () {
  56547. return this._scene;
  56548. };
  56549. /**
  56550. * Get the texture transform matrix used to offset tile the texture for istance.
  56551. * @returns the transformation matrix
  56552. */
  56553. BaseTexture.prototype.getTextureMatrix = function () {
  56554. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  56555. };
  56556. /**
  56557. * Get the texture reflection matrix used to rotate/transform the reflection.
  56558. * @returns the reflection matrix
  56559. */
  56560. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  56561. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  56562. };
  56563. /**
  56564. * Get the underlying lower level texture from Babylon.
  56565. * @returns the insternal texture
  56566. */
  56567. BaseTexture.prototype.getInternalTexture = function () {
  56568. return this._texture;
  56569. };
  56570. /**
  56571. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  56572. * @returns true if ready or not blocking
  56573. */
  56574. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  56575. return !this.isBlocking || this.isReady();
  56576. };
  56577. /**
  56578. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  56579. * @returns true if fully ready
  56580. */
  56581. BaseTexture.prototype.isReady = function () {
  56582. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  56583. this.delayLoad();
  56584. return false;
  56585. }
  56586. if (this._texture) {
  56587. return this._texture.isReady;
  56588. }
  56589. return false;
  56590. };
  56591. /**
  56592. * Get the size of the texture.
  56593. * @returns the texture size.
  56594. */
  56595. BaseTexture.prototype.getSize = function () {
  56596. if (this._texture) {
  56597. if (this._texture.width) {
  56598. this._cachedSize.width = this._texture.width;
  56599. this._cachedSize.height = this._texture.height;
  56600. return this._cachedSize;
  56601. }
  56602. if (this._texture._size) {
  56603. this._cachedSize.width = this._texture._size;
  56604. this._cachedSize.height = this._texture._size;
  56605. return this._cachedSize;
  56606. }
  56607. }
  56608. return this._cachedSize;
  56609. };
  56610. /**
  56611. * Get the base size of the texture.
  56612. * It can be different from the size if the texture has been resized for POT for instance
  56613. * @returns the base size
  56614. */
  56615. BaseTexture.prototype.getBaseSize = function () {
  56616. if (!this.isReady() || !this._texture) {
  56617. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  56618. }
  56619. if (this._texture._size) {
  56620. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  56621. }
  56622. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  56623. };
  56624. /**
  56625. * Update the sampling mode of the texture.
  56626. * Default is Trilinear mode.
  56627. *
  56628. * | Value | Type | Description |
  56629. * | ----- | ------------------ | ----------- |
  56630. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  56631. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  56632. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  56633. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  56634. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  56635. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  56636. * | 7 | NEAREST_LINEAR | |
  56637. * | 8 | NEAREST_NEAREST | |
  56638. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  56639. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  56640. * | 11 | LINEAR_LINEAR | |
  56641. * | 12 | LINEAR_NEAREST | |
  56642. *
  56643. * > _mag_: magnification filter (close to the viewer)
  56644. * > _min_: minification filter (far from the viewer)
  56645. * > _mip_: filter used between mip map levels
  56646. *@param samplingMode Define the new sampling mode of the texture
  56647. */
  56648. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  56649. if (!this._texture) {
  56650. return;
  56651. }
  56652. var scene = this.getScene();
  56653. if (!scene) {
  56654. return;
  56655. }
  56656. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  56657. };
  56658. /**
  56659. * Scales the texture if is `canRescale()`
  56660. * @param ratio the resize factor we want to use to rescale
  56661. */
  56662. BaseTexture.prototype.scale = function (ratio) {
  56663. };
  56664. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  56665. /**
  56666. * Get if the texture can rescale.
  56667. */
  56668. get: function () {
  56669. return false;
  56670. },
  56671. enumerable: true,
  56672. configurable: true
  56673. });
  56674. /** @hidden */
  56675. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  56676. if (!this._scene) {
  56677. return null;
  56678. }
  56679. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  56680. for (var index = 0; index < texturesCache.length; index++) {
  56681. var texturesCacheEntry = texturesCache[index];
  56682. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  56683. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  56684. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  56685. texturesCacheEntry.incrementReferences();
  56686. return texturesCacheEntry;
  56687. }
  56688. }
  56689. }
  56690. }
  56691. return null;
  56692. };
  56693. /** @hidden */
  56694. BaseTexture.prototype._rebuild = function () {
  56695. };
  56696. /**
  56697. * Triggers the load sequence in delayed load mode.
  56698. */
  56699. BaseTexture.prototype.delayLoad = function () {
  56700. };
  56701. /**
  56702. * Clones the texture.
  56703. * @returns the cloned texture
  56704. */
  56705. BaseTexture.prototype.clone = function () {
  56706. return null;
  56707. };
  56708. Object.defineProperty(BaseTexture.prototype, "textureType", {
  56709. /**
  56710. * Get the texture underlying type (INT, FLOAT...)
  56711. */
  56712. get: function () {
  56713. if (!this._texture) {
  56714. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  56715. }
  56716. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  56717. },
  56718. enumerable: true,
  56719. configurable: true
  56720. });
  56721. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  56722. /**
  56723. * Get the texture underlying format (RGB, RGBA...)
  56724. */
  56725. get: function () {
  56726. if (!this._texture) {
  56727. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  56728. }
  56729. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  56730. },
  56731. enumerable: true,
  56732. configurable: true
  56733. });
  56734. /**
  56735. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  56736. * This will returns an RGBA array buffer containing either in values (0-255) or
  56737. * float values (0-1) depending of the underlying buffer type.
  56738. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  56739. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  56740. * @param buffer defines a user defined buffer to fill with data (can be null)
  56741. * @returns The Array buffer containing the pixels data.
  56742. */
  56743. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  56744. if (faceIndex === void 0) { faceIndex = 0; }
  56745. if (level === void 0) { level = 0; }
  56746. if (buffer === void 0) { buffer = null; }
  56747. if (!this._texture) {
  56748. return null;
  56749. }
  56750. var size = this.getSize();
  56751. var width = size.width;
  56752. var height = size.height;
  56753. var scene = this.getScene();
  56754. if (!scene) {
  56755. return null;
  56756. }
  56757. var engine = scene.getEngine();
  56758. if (level != 0) {
  56759. width = width / Math.pow(2, level);
  56760. height = height / Math.pow(2, level);
  56761. width = Math.round(width);
  56762. height = Math.round(height);
  56763. }
  56764. if (this._texture.isCube) {
  56765. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  56766. }
  56767. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  56768. };
  56769. /**
  56770. * Release and destroy the underlying lower level texture aka internalTexture.
  56771. */
  56772. BaseTexture.prototype.releaseInternalTexture = function () {
  56773. if (this._texture) {
  56774. this._texture.dispose();
  56775. this._texture = null;
  56776. }
  56777. };
  56778. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  56779. /**
  56780. * Get the polynomial representation of the texture data.
  56781. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  56782. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  56783. */
  56784. get: function () {
  56785. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  56786. return null;
  56787. }
  56788. if (!this._texture._sphericalPolynomial) {
  56789. this._texture._sphericalPolynomial =
  56790. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  56791. }
  56792. return this._texture._sphericalPolynomial;
  56793. },
  56794. set: function (value) {
  56795. if (this._texture) {
  56796. this._texture._sphericalPolynomial = value;
  56797. }
  56798. },
  56799. enumerable: true,
  56800. configurable: true
  56801. });
  56802. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  56803. /** @hidden */
  56804. get: function () {
  56805. if (this._texture) {
  56806. return this._texture._lodTextureHigh;
  56807. }
  56808. return null;
  56809. },
  56810. enumerable: true,
  56811. configurable: true
  56812. });
  56813. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  56814. /** @hidden */
  56815. get: function () {
  56816. if (this._texture) {
  56817. return this._texture._lodTextureMid;
  56818. }
  56819. return null;
  56820. },
  56821. enumerable: true,
  56822. configurable: true
  56823. });
  56824. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  56825. /** @hidden */
  56826. get: function () {
  56827. if (this._texture) {
  56828. return this._texture._lodTextureLow;
  56829. }
  56830. return null;
  56831. },
  56832. enumerable: true,
  56833. configurable: true
  56834. });
  56835. /**
  56836. * Dispose the texture and release its associated resources.
  56837. */
  56838. BaseTexture.prototype.dispose = function () {
  56839. if (!this._scene) {
  56840. return;
  56841. }
  56842. // Animations
  56843. this._scene.stopAnimation(this);
  56844. // Remove from scene
  56845. this._scene._removePendingData(this);
  56846. var index = this._scene.textures.indexOf(this);
  56847. if (index >= 0) {
  56848. this._scene.textures.splice(index, 1);
  56849. }
  56850. this._scene.onTextureRemovedObservable.notifyObservers(this);
  56851. if (this._texture === undefined) {
  56852. return;
  56853. }
  56854. // Release
  56855. this.releaseInternalTexture();
  56856. // Callback
  56857. this.onDisposeObservable.notifyObservers(this);
  56858. this.onDisposeObservable.clear();
  56859. };
  56860. /**
  56861. * Serialize the texture into a JSON representation that can be parsed later on.
  56862. * @returns the JSON representation of the texture
  56863. */
  56864. BaseTexture.prototype.serialize = function () {
  56865. if (!this.name) {
  56866. return null;
  56867. }
  56868. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  56869. // Animations
  56870. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  56871. return serializationObject;
  56872. };
  56873. /**
  56874. * Helper function to be called back once a list of texture contains only ready textures.
  56875. * @param textures Define the list of textures to wait for
  56876. * @param callback Define the callback triggered once the entire list will be ready
  56877. */
  56878. BaseTexture.WhenAllReady = function (textures, callback) {
  56879. var numRemaining = textures.length;
  56880. if (numRemaining === 0) {
  56881. callback();
  56882. return;
  56883. }
  56884. var _loop_1 = function () {
  56885. texture = textures[i];
  56886. if (texture.isReady()) {
  56887. if (--numRemaining === 0) {
  56888. callback();
  56889. }
  56890. }
  56891. else {
  56892. onLoadObservable = texture.onLoadObservable;
  56893. var onLoadCallback_1 = function () {
  56894. onLoadObservable.removeCallback(onLoadCallback_1);
  56895. if (--numRemaining === 0) {
  56896. callback();
  56897. }
  56898. };
  56899. onLoadObservable.add(onLoadCallback_1);
  56900. }
  56901. };
  56902. var texture, onLoadObservable;
  56903. for (var i = 0; i < textures.length; i++) {
  56904. _loop_1();
  56905. }
  56906. };
  56907. /**
  56908. * Default anisotropic filtering level for the application.
  56909. * It is set to 4 as a good tradeoff between perf and quality.
  56910. */
  56911. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  56912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56914. ], BaseTexture.prototype, "uniqueId", void 0);
  56915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56917. ], BaseTexture.prototype, "name", void 0);
  56918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56920. ], BaseTexture.prototype, "metadata", void 0);
  56921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  56923. ], BaseTexture.prototype, "_hasAlpha", void 0);
  56924. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56925. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56926. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  56927. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56929. ], BaseTexture.prototype, "level", void 0);
  56930. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56932. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  56933. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  56935. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  56936. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56937. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56938. ], BaseTexture.prototype, "wrapU", void 0);
  56939. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56941. ], BaseTexture.prototype, "wrapV", void 0);
  56942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56944. ], BaseTexture.prototype, "wrapR", void 0);
  56945. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56947. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  56948. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56949. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56950. ], BaseTexture.prototype, "isCube", null);
  56951. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56952. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56953. ], BaseTexture.prototype, "is3D", null);
  56954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56956. ], BaseTexture.prototype, "gammaSpace", void 0);
  56957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56959. ], BaseTexture.prototype, "invertZ", void 0);
  56960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56962. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  56963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56965. ], BaseTexture.prototype, "lodGenerationOffset", null);
  56966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56968. ], BaseTexture.prototype, "lodGenerationScale", null);
  56969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56971. ], BaseTexture.prototype, "isRenderTarget", void 0);
  56972. return BaseTexture;
  56973. }());
  56974. /***/ }),
  56975. /***/ "./Materials/Textures/colorGradingTexture.ts":
  56976. /*!***************************************************!*\
  56977. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  56978. \***************************************************/
  56979. /*! exports provided: ColorGradingTexture */
  56980. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56981. "use strict";
  56982. __webpack_require__.r(__webpack_exports__);
  56983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  56984. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56985. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56986. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  56987. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56988. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  56989. /**
  56990. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56991. * It can help converting any input color in a desired output one. This can then be used to create effects
  56992. * from sepia, black and white to sixties or futuristic rendering...
  56993. *
  56994. * The only supported format is currently 3dl.
  56995. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56996. */
  56997. var ColorGradingTexture = /** @class */ (function (_super) {
  56998. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  56999. /**
  57000. * Instantiates a ColorGradingTexture from the following parameters.
  57001. *
  57002. * @param url The location of the color gradind data (currently only supporting 3dl)
  57003. * @param scene The scene the texture will be used in
  57004. */
  57005. function ColorGradingTexture(url, scene) {
  57006. var _this = _super.call(this, scene) || this;
  57007. if (!url) {
  57008. return _this;
  57009. }
  57010. _this._engine = scene.getEngine();
  57011. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  57012. _this.name = url;
  57013. _this.url = url;
  57014. _this.hasAlpha = false;
  57015. _this.isCube = false;
  57016. _this.is3D = _this._engine.webGLVersion > 1;
  57017. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57018. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57019. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57020. _this.anisotropicFilteringLevel = 1;
  57021. _this._texture = _this._getFromCache(url, true);
  57022. if (!_this._texture) {
  57023. if (!scene.useDelayedTextureLoading) {
  57024. _this.loadTexture();
  57025. }
  57026. else {
  57027. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57028. }
  57029. }
  57030. return _this;
  57031. }
  57032. /**
  57033. * Returns the texture matrix used in most of the material.
  57034. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  57035. */
  57036. ColorGradingTexture.prototype.getTextureMatrix = function () {
  57037. return this._textureMatrix;
  57038. };
  57039. /**
  57040. * Occurs when the file being loaded is a .3dl LUT file.
  57041. */
  57042. ColorGradingTexture.prototype.load3dlTexture = function () {
  57043. var engine = this._engine;
  57044. var texture;
  57045. if (engine.webGLVersion === 1) {
  57046. 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);
  57047. }
  57048. else {
  57049. 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);
  57050. }
  57051. this._texture = texture;
  57052. var callback = function (text) {
  57053. if (typeof text !== "string") {
  57054. return;
  57055. }
  57056. var data = null;
  57057. var tempData = null;
  57058. var line;
  57059. var lines = text.split('\n');
  57060. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  57061. var maxColor = 0;
  57062. for (var i = 0; i < lines.length; i++) {
  57063. line = lines[i];
  57064. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  57065. continue;
  57066. }
  57067. if (line.indexOf('#') === 0) {
  57068. continue;
  57069. }
  57070. var words = line.split(" ");
  57071. if (size === 0) {
  57072. // Number of space + one
  57073. size = words.length;
  57074. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  57075. tempData = new Float32Array(size * size * size * 4);
  57076. continue;
  57077. }
  57078. if (size != 0) {
  57079. var r = Math.max(parseInt(words[0]), 0);
  57080. var g = Math.max(parseInt(words[1]), 0);
  57081. var b = Math.max(parseInt(words[2]), 0);
  57082. maxColor = Math.max(r, maxColor);
  57083. maxColor = Math.max(g, maxColor);
  57084. maxColor = Math.max(b, maxColor);
  57085. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  57086. if (tempData) {
  57087. tempData[pixelStorageIndex + 0] = r;
  57088. tempData[pixelStorageIndex + 1] = g;
  57089. tempData[pixelStorageIndex + 2] = b;
  57090. }
  57091. // Keep for reference in case of back compat problems.
  57092. // pixelIndexSlice++;
  57093. // if (pixelIndexSlice % size == 0) {
  57094. // pixelIndexH++;
  57095. // pixelIndexSlice = 0;
  57096. // if (pixelIndexH % size == 0) {
  57097. // pixelIndexW++;
  57098. // pixelIndexH = 0;
  57099. // }
  57100. // }
  57101. pixelIndexH++;
  57102. if (pixelIndexH % size == 0) {
  57103. pixelIndexSlice++;
  57104. pixelIndexH = 0;
  57105. if (pixelIndexSlice % size == 0) {
  57106. pixelIndexW++;
  57107. pixelIndexSlice = 0;
  57108. }
  57109. }
  57110. }
  57111. }
  57112. if (tempData && data) {
  57113. for (var i = 0; i < tempData.length; i++) {
  57114. if (i > 0 && (i + 1) % 4 === 0) {
  57115. data[i] = 255;
  57116. }
  57117. else {
  57118. var value = tempData[i];
  57119. data[i] = (value / maxColor * 255);
  57120. }
  57121. }
  57122. }
  57123. if (texture.is3D) {
  57124. texture.updateSize(size, size, size);
  57125. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  57126. }
  57127. else {
  57128. texture.updateSize(size * size, size);
  57129. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  57130. }
  57131. };
  57132. var scene = this.getScene();
  57133. if (scene) {
  57134. scene._loadFile(this.url, callback);
  57135. }
  57136. else {
  57137. this._engine._loadFile(this.url, callback);
  57138. }
  57139. return this._texture;
  57140. };
  57141. /**
  57142. * Starts the loading process of the texture.
  57143. */
  57144. ColorGradingTexture.prototype.loadTexture = function () {
  57145. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  57146. this.load3dlTexture();
  57147. }
  57148. };
  57149. /**
  57150. * Clones the color gradind texture.
  57151. */
  57152. ColorGradingTexture.prototype.clone = function () {
  57153. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  57154. // Base texture
  57155. newTexture.level = this.level;
  57156. return newTexture;
  57157. };
  57158. /**
  57159. * Called during delayed load for textures.
  57160. */
  57161. ColorGradingTexture.prototype.delayLoad = function () {
  57162. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57163. return;
  57164. }
  57165. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  57166. this._texture = this._getFromCache(this.url, true);
  57167. if (!this._texture) {
  57168. this.loadTexture();
  57169. }
  57170. };
  57171. /**
  57172. * Parses a color grading texture serialized by Babylon.
  57173. * @param parsedTexture The texture information being parsedTexture
  57174. * @param scene The scene to load the texture in
  57175. * @param rootUrl The root url of the data assets to load
  57176. * @return A color gradind texture
  57177. */
  57178. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  57179. var texture = null;
  57180. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  57181. texture = new ColorGradingTexture(parsedTexture.name, scene);
  57182. texture.name = parsedTexture.name;
  57183. texture.level = parsedTexture.level;
  57184. }
  57185. return texture;
  57186. };
  57187. /**
  57188. * Serializes the LUT texture to json format.
  57189. */
  57190. ColorGradingTexture.prototype.serialize = function () {
  57191. if (!this.name) {
  57192. return null;
  57193. }
  57194. var serializationObject = {};
  57195. serializationObject.name = this.name;
  57196. serializationObject.level = this.level;
  57197. serializationObject.customType = "BABYLON.ColorGradingTexture";
  57198. return serializationObject;
  57199. };
  57200. /**
  57201. * Empty line regex stored for GC.
  57202. */
  57203. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  57204. return ColorGradingTexture;
  57205. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  57206. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  57207. /***/ }),
  57208. /***/ "./Materials/Textures/cubeTexture.ts":
  57209. /*!*******************************************!*\
  57210. !*** ./Materials/Textures/cubeTexture.ts ***!
  57211. \*******************************************/
  57212. /*! exports provided: CubeTexture */
  57213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57214. "use strict";
  57215. __webpack_require__.r(__webpack_exports__);
  57216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  57217. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57218. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57219. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57220. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57221. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57222. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57223. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57224. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  57225. /**
  57226. * Class for creating a cube texture
  57227. */
  57228. var CubeTexture = /** @class */ (function (_super) {
  57229. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  57230. /**
  57231. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  57232. * as prefiltered data.
  57233. * @param rootUrl defines the url of the texture or the root name of the six images
  57234. * @param scene defines the scene the texture is attached to
  57235. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  57236. * @param noMipmap defines if mipmaps should be created or not
  57237. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  57238. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  57239. * @param onError defines a callback triggered in case of error during load
  57240. * @param format defines the internal format to use for the texture once loaded
  57241. * @param prefiltered defines whether or not the texture is created from prefiltered data
  57242. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  57243. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  57244. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57245. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57246. * @return the cube texture
  57247. */
  57248. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  57249. if (extensions === void 0) { extensions = null; }
  57250. if (noMipmap === void 0) { noMipmap = false; }
  57251. if (files === void 0) { files = null; }
  57252. if (onLoad === void 0) { onLoad = null; }
  57253. if (onError === void 0) { onError = null; }
  57254. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  57255. if (prefiltered === void 0) { prefiltered = false; }
  57256. if (forcedExtension === void 0) { forcedExtension = null; }
  57257. if (createPolynomials === void 0) { createPolynomials = false; }
  57258. if (lodScale === void 0) { lodScale = 0.8; }
  57259. if (lodOffset === void 0) { lodOffset = 0; }
  57260. var _this = _super.call(this, scene) || this;
  57261. /**
  57262. * Gets or sets the center of the bounding box associated with the cube texture.
  57263. * It must define where the camera used to render the texture was set
  57264. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  57265. */
  57266. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57267. _this._rotationY = 0;
  57268. /** @hidden */
  57269. _this._prefiltered = false;
  57270. _this.name = rootUrl;
  57271. _this.url = rootUrl;
  57272. _this._noMipmap = noMipmap;
  57273. _this.hasAlpha = false;
  57274. _this._format = format;
  57275. _this.isCube = true;
  57276. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57277. _this._createPolynomials = createPolynomials;
  57278. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  57279. if (!rootUrl && !files) {
  57280. return _this;
  57281. }
  57282. var lastDot = rootUrl.lastIndexOf(".");
  57283. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  57284. var isDDS = (extension === ".dds");
  57285. var isEnv = (extension === ".env");
  57286. if (isEnv) {
  57287. _this.gammaSpace = false;
  57288. _this._prefiltered = false;
  57289. }
  57290. else {
  57291. _this._prefiltered = prefiltered;
  57292. if (prefiltered) {
  57293. _this.gammaSpace = false;
  57294. }
  57295. }
  57296. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  57297. if (!files) {
  57298. if (!isEnv && !isDDS && !extensions) {
  57299. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  57300. }
  57301. files = [];
  57302. if (extensions) {
  57303. for (var index = 0; index < extensions.length; index++) {
  57304. files.push(rootUrl + extensions[index]);
  57305. }
  57306. }
  57307. }
  57308. _this._files = files;
  57309. if (!_this._texture) {
  57310. if (!scene.useDelayedTextureLoading) {
  57311. if (prefiltered) {
  57312. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  57313. }
  57314. else {
  57315. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  57316. }
  57317. }
  57318. else {
  57319. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57320. }
  57321. }
  57322. else if (onLoad) {
  57323. if (_this._texture.isReady) {
  57324. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  57325. }
  57326. else {
  57327. _this._texture.onLoadedObservable.add(onLoad);
  57328. }
  57329. }
  57330. return _this;
  57331. }
  57332. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  57333. /**
  57334. * Returns the bounding box size
  57335. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  57336. */
  57337. get: function () {
  57338. return this._boundingBoxSize;
  57339. },
  57340. /**
  57341. * Gets or sets the size of the bounding box associated with the cube texture
  57342. * When defined, the cubemap will switch to local mode
  57343. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57344. * @example https://www.babylonjs-playground.com/#RNASML
  57345. */
  57346. set: function (value) {
  57347. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57348. return;
  57349. }
  57350. this._boundingBoxSize = value;
  57351. var scene = this.getScene();
  57352. if (scene) {
  57353. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  57354. }
  57355. },
  57356. enumerable: true,
  57357. configurable: true
  57358. });
  57359. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  57360. /**
  57361. * Gets texture matrix rotation angle around Y axis radians.
  57362. */
  57363. get: function () {
  57364. return this._rotationY;
  57365. },
  57366. /**
  57367. * Sets texture matrix rotation angle around Y axis in radians.
  57368. */
  57369. set: function (value) {
  57370. this._rotationY = value;
  57371. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  57372. },
  57373. enumerable: true,
  57374. configurable: true
  57375. });
  57376. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  57377. /**
  57378. * Are mip maps generated for this texture or not.
  57379. */
  57380. get: function () {
  57381. return this._noMipmap;
  57382. },
  57383. enumerable: true,
  57384. configurable: true
  57385. });
  57386. /**
  57387. * Creates a cube texture from an array of image urls
  57388. * @param files defines an array of image urls
  57389. * @param scene defines the hosting scene
  57390. * @param noMipmap specifies if mip maps are not used
  57391. * @returns a cube texture
  57392. */
  57393. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  57394. var rootUrlKey = "";
  57395. files.forEach(function (url) { return rootUrlKey += url; });
  57396. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  57397. };
  57398. /**
  57399. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  57400. * @param url defines the url of the prefiltered texture
  57401. * @param scene defines the scene the texture is attached to
  57402. * @param forcedExtension defines the extension of the file if different from the url
  57403. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  57404. * @return the prefiltered texture
  57405. */
  57406. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  57407. if (forcedExtension === void 0) { forcedExtension = null; }
  57408. if (createPolynomials === void 0) { createPolynomials = true; }
  57409. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  57410. };
  57411. /**
  57412. * Get the current class name of the texture useful for serialization or dynamic coding.
  57413. * @returns "CubeTexture"
  57414. */
  57415. CubeTexture.prototype.getClassName = function () {
  57416. return "CubeTexture";
  57417. };
  57418. /**
  57419. * Update the url (and optional buffer) of this texture if url was null during construction.
  57420. * @param url the url of the texture
  57421. * @param forcedExtension defines the extension to use
  57422. * @param onLoad callback called when the texture is loaded (defaults to null)
  57423. */
  57424. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  57425. if (this.url) {
  57426. this.releaseInternalTexture();
  57427. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  57428. }
  57429. this.url = url;
  57430. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57431. this._prefiltered = false;
  57432. if (onLoad) {
  57433. this._delayedOnLoad = onLoad;
  57434. }
  57435. this.delayLoad(forcedExtension);
  57436. };
  57437. /**
  57438. * Delays loading of the cube texture
  57439. * @param forcedExtension defines the extension to use
  57440. */
  57441. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  57442. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57443. return;
  57444. }
  57445. var scene = this.getScene();
  57446. if (!scene) {
  57447. return;
  57448. }
  57449. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  57450. this._texture = this._getFromCache(this.url, this._noMipmap);
  57451. if (!this._texture) {
  57452. if (this._prefiltered) {
  57453. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  57454. }
  57455. else {
  57456. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  57457. }
  57458. }
  57459. };
  57460. /**
  57461. * Returns the reflection texture matrix
  57462. * @returns the reflection texture matrix
  57463. */
  57464. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  57465. return this._textureMatrix;
  57466. };
  57467. /**
  57468. * Sets the reflection texture matrix
  57469. * @param value Reflection texture matrix
  57470. */
  57471. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  57472. var _this = this;
  57473. if (value.updateFlag === this._textureMatrix.updateFlag) {
  57474. return;
  57475. }
  57476. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  57477. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  57478. }
  57479. this._textureMatrix = value;
  57480. };
  57481. /**
  57482. * Parses text to create a cube texture
  57483. * @param parsedTexture define the serialized text to read from
  57484. * @param scene defines the hosting scene
  57485. * @param rootUrl defines the root url of the cube texture
  57486. * @returns a cube texture
  57487. */
  57488. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  57489. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  57490. var prefiltered = false;
  57491. if (parsedTexture.prefiltered) {
  57492. prefiltered = parsedTexture.prefiltered;
  57493. }
  57494. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  57495. }, parsedTexture, scene);
  57496. // Local Cubemaps
  57497. if (parsedTexture.boundingBoxPosition) {
  57498. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  57499. }
  57500. if (parsedTexture.boundingBoxSize) {
  57501. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  57502. }
  57503. // Animations
  57504. if (parsedTexture.animations) {
  57505. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  57506. var parsedAnimation = parsedTexture.animations[animationIndex];
  57507. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  57508. if (internalClass) {
  57509. texture.animations.push(internalClass.Parse(parsedAnimation));
  57510. }
  57511. }
  57512. }
  57513. return texture;
  57514. };
  57515. /**
  57516. * Makes a clone, or deep copy, of the cube texture
  57517. * @returns a new cube texture
  57518. */
  57519. CubeTexture.prototype.clone = function () {
  57520. var _this = this;
  57521. var scene = this.getScene();
  57522. var uniqueId = 0;
  57523. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57524. if (!scene) {
  57525. return _this;
  57526. }
  57527. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  57528. uniqueId = cubeTexture.uniqueId;
  57529. return cubeTexture;
  57530. }, this);
  57531. newCubeTexture.uniqueId = uniqueId;
  57532. return newCubeTexture;
  57533. };
  57534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  57536. ], CubeTexture.prototype, "rotationY", null);
  57537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("textureMatrix")
  57539. ], CubeTexture.prototype, "_textureMatrix", void 0);
  57540. return CubeTexture;
  57541. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  57542. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  57543. // Some exporters relies on Tools.Instantiate
  57544. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  57545. /***/ }),
  57546. /***/ "./Materials/Textures/dynamicTexture.ts":
  57547. /*!**********************************************!*\
  57548. !*** ./Materials/Textures/dynamicTexture.ts ***!
  57549. \**********************************************/
  57550. /*! exports provided: DynamicTexture */
  57551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57552. "use strict";
  57553. __webpack_require__.r(__webpack_exports__);
  57554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  57555. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57556. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  57557. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57558. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57559. /**
  57560. * A class extending Texture allowing drawing on a texture
  57561. * @see http://doc.babylonjs.com/how_to/dynamictexture
  57562. */
  57563. var DynamicTexture = /** @class */ (function (_super) {
  57564. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  57565. /**
  57566. * Creates a DynamicTexture
  57567. * @param name defines the name of the texture
  57568. * @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
  57569. * @param scene defines the scene where you want the texture
  57570. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  57571. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57572. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  57573. */
  57574. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  57575. if (scene === void 0) { scene = null; }
  57576. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57577. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  57578. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  57579. _this.name = name;
  57580. _this._engine = _this.getScene().getEngine();
  57581. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  57582. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  57583. _this._generateMipMaps = generateMipMaps;
  57584. if (options.getContext) {
  57585. _this._canvas = options;
  57586. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  57587. }
  57588. else {
  57589. _this._canvas = document.createElement("canvas");
  57590. if (options.width || options.width === 0) {
  57591. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  57592. }
  57593. else {
  57594. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  57595. }
  57596. }
  57597. var textureSize = _this.getSize();
  57598. _this._canvas.width = textureSize.width;
  57599. _this._canvas.height = textureSize.height;
  57600. _this._context = _this._canvas.getContext("2d");
  57601. return _this;
  57602. }
  57603. /**
  57604. * Get the current class name of the texture useful for serialization or dynamic coding.
  57605. * @returns "DynamicTexture"
  57606. */
  57607. DynamicTexture.prototype.getClassName = function () {
  57608. return "DynamicTexture";
  57609. };
  57610. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  57611. /**
  57612. * Gets the current state of canRescale
  57613. */
  57614. get: function () {
  57615. return true;
  57616. },
  57617. enumerable: true,
  57618. configurable: true
  57619. });
  57620. DynamicTexture.prototype._recreate = function (textureSize) {
  57621. this._canvas.width = textureSize.width;
  57622. this._canvas.height = textureSize.height;
  57623. this.releaseInternalTexture();
  57624. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  57625. };
  57626. /**
  57627. * Scales the texture
  57628. * @param ratio the scale factor to apply to both width and height
  57629. */
  57630. DynamicTexture.prototype.scale = function (ratio) {
  57631. var textureSize = this.getSize();
  57632. textureSize.width *= ratio;
  57633. textureSize.height *= ratio;
  57634. this._recreate(textureSize);
  57635. };
  57636. /**
  57637. * Resizes the texture
  57638. * @param width the new width
  57639. * @param height the new height
  57640. */
  57641. DynamicTexture.prototype.scaleTo = function (width, height) {
  57642. var textureSize = this.getSize();
  57643. textureSize.width = width;
  57644. textureSize.height = height;
  57645. this._recreate(textureSize);
  57646. };
  57647. /**
  57648. * Gets the context of the canvas used by the texture
  57649. * @returns the canvas context of the dynamic texture
  57650. */
  57651. DynamicTexture.prototype.getContext = function () {
  57652. return this._context;
  57653. };
  57654. /**
  57655. * Clears the texture
  57656. */
  57657. DynamicTexture.prototype.clear = function () {
  57658. var size = this.getSize();
  57659. this._context.fillRect(0, 0, size.width, size.height);
  57660. };
  57661. /**
  57662. * Updates the texture
  57663. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  57664. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  57665. */
  57666. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  57667. if (premulAlpha === void 0) { premulAlpha = false; }
  57668. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  57669. };
  57670. /**
  57671. * Draws text onto the texture
  57672. * @param text defines the text to be drawn
  57673. * @param x defines the placement of the text from the left
  57674. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  57675. * @param font defines the font to be used with font-style, font-size, font-name
  57676. * @param color defines the color used for the text
  57677. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  57678. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  57679. * @param update defines whether texture is immediately update (default is true)
  57680. */
  57681. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  57682. if (update === void 0) { update = true; }
  57683. var size = this.getSize();
  57684. if (clearColor) {
  57685. this._context.fillStyle = clearColor;
  57686. this._context.fillRect(0, 0, size.width, size.height);
  57687. }
  57688. this._context.font = font;
  57689. if (x === null || x === undefined) {
  57690. var textSize = this._context.measureText(text);
  57691. x = (size.width - textSize.width) / 2;
  57692. }
  57693. if (y === null || y === undefined) {
  57694. var fontSize = parseInt((font.replace(/\D/g, '')));
  57695. y = (size.height / 2) + (fontSize / 3.65);
  57696. }
  57697. this._context.fillStyle = color;
  57698. this._context.fillText(text, x, y);
  57699. if (update) {
  57700. this.update(invertY);
  57701. }
  57702. };
  57703. /**
  57704. * Clones the texture
  57705. * @returns the clone of the texture.
  57706. */
  57707. DynamicTexture.prototype.clone = function () {
  57708. var scene = this.getScene();
  57709. if (!scene) {
  57710. return this;
  57711. }
  57712. var textureSize = this.getSize();
  57713. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  57714. // Base texture
  57715. newTexture.hasAlpha = this.hasAlpha;
  57716. newTexture.level = this.level;
  57717. // Dynamic Texture
  57718. newTexture.wrapU = this.wrapU;
  57719. newTexture.wrapV = this.wrapV;
  57720. return newTexture;
  57721. };
  57722. /**
  57723. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  57724. * @returns a serialized dynamic texture object
  57725. */
  57726. DynamicTexture.prototype.serialize = function () {
  57727. var scene = this.getScene();
  57728. if (scene && !scene.isReady()) {
  57729. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  57730. }
  57731. var serializationObject = _super.prototype.serialize.call(this);
  57732. serializationObject.base64String = this._canvas.toDataURL();
  57733. serializationObject.invertY = this._invertY;
  57734. serializationObject.samplingMode = this.samplingMode;
  57735. return serializationObject;
  57736. };
  57737. /** @hidden */
  57738. DynamicTexture.prototype._rebuild = function () {
  57739. this.update();
  57740. };
  57741. return DynamicTexture;
  57742. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  57743. /***/ }),
  57744. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  57745. /*!**********************************************!*\
  57746. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  57747. \**********************************************/
  57748. /*! exports provided: HDRCubeTexture */
  57749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57750. "use strict";
  57751. __webpack_require__.r(__webpack_exports__);
  57752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  57753. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57754. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57755. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  57756. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57757. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57758. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57759. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  57760. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  57761. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  57762. /**
  57763. * This represents a texture coming from an HDR input.
  57764. *
  57765. * The only supported format is currently panorama picture stored in RGBE format.
  57766. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57767. */
  57768. var HDRCubeTexture = /** @class */ (function (_super) {
  57769. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  57770. /**
  57771. * Instantiates an HDRTexture from the following parameters.
  57772. *
  57773. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57774. * @param scene The scene the texture will be used in
  57775. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57776. * @param noMipmap Forces to not generate the mipmap if true
  57777. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57778. * @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)
  57779. * @param reserved Reserved flag for internal use.
  57780. */
  57781. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  57782. if (noMipmap === void 0) { noMipmap = false; }
  57783. if (generateHarmonics === void 0) { generateHarmonics = true; }
  57784. if (gammaSpace === void 0) { gammaSpace = false; }
  57785. if (reserved === void 0) { reserved = false; }
  57786. if (onLoad === void 0) { onLoad = null; }
  57787. if (onError === void 0) { onError = null; }
  57788. var _this = _super.call(this, scene) || this;
  57789. _this._generateHarmonics = true;
  57790. _this._onLoad = null;
  57791. _this._onError = null;
  57792. /**
  57793. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57794. */
  57795. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  57796. _this._isBlocking = true;
  57797. _this._rotationY = 0;
  57798. /**
  57799. * Gets or sets the center of the bounding box associated with the cube texture
  57800. * It must define where the camera used to render the texture was set
  57801. */
  57802. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  57803. if (!url) {
  57804. return _this;
  57805. }
  57806. _this.name = url;
  57807. _this.url = url;
  57808. _this.hasAlpha = false;
  57809. _this.isCube = true;
  57810. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  57811. _this._onLoad = onLoad;
  57812. _this._onError = onError;
  57813. _this.gammaSpace = gammaSpace;
  57814. _this._noMipmap = noMipmap;
  57815. _this._size = size;
  57816. _this._texture = _this._getFromCache(url, _this._noMipmap);
  57817. if (!_this._texture) {
  57818. if (!scene.useDelayedTextureLoading) {
  57819. _this.loadTexture();
  57820. }
  57821. else {
  57822. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  57823. }
  57824. }
  57825. return _this;
  57826. }
  57827. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  57828. /**
  57829. * Gets wether or not the texture is blocking during loading.
  57830. */
  57831. get: function () {
  57832. return this._isBlocking;
  57833. },
  57834. /**
  57835. * Sets wether or not the texture is blocking during loading.
  57836. */
  57837. set: function (value) {
  57838. this._isBlocking = value;
  57839. },
  57840. enumerable: true,
  57841. configurable: true
  57842. });
  57843. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  57844. /**
  57845. * Gets texture matrix rotation angle around Y axis radians.
  57846. */
  57847. get: function () {
  57848. return this._rotationY;
  57849. },
  57850. /**
  57851. * Sets texture matrix rotation angle around Y axis in radians.
  57852. */
  57853. set: function (value) {
  57854. this._rotationY = value;
  57855. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  57856. },
  57857. enumerable: true,
  57858. configurable: true
  57859. });
  57860. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  57861. get: function () {
  57862. return this._boundingBoxSize;
  57863. },
  57864. /**
  57865. * Gets or sets the size of the bounding box associated with the cube texture
  57866. * When defined, the cubemap will switch to local mode
  57867. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57868. * @example https://www.babylonjs-playground.com/#RNASML
  57869. */
  57870. set: function (value) {
  57871. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57872. return;
  57873. }
  57874. this._boundingBoxSize = value;
  57875. var scene = this.getScene();
  57876. if (scene) {
  57877. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  57878. }
  57879. },
  57880. enumerable: true,
  57881. configurable: true
  57882. });
  57883. /**
  57884. * Get the current class name of the texture useful for serialization or dynamic coding.
  57885. * @returns "HDRCubeTexture"
  57886. */
  57887. HDRCubeTexture.prototype.getClassName = function () {
  57888. return "HDRCubeTexture";
  57889. };
  57890. /**
  57891. * Occurs when the file is raw .hdr file.
  57892. */
  57893. HDRCubeTexture.prototype.loadTexture = function () {
  57894. var _this = this;
  57895. var callback = function (buffer) {
  57896. _this.lodGenerationOffset = 0.0;
  57897. _this.lodGenerationScale = 0.8;
  57898. var scene = _this.getScene();
  57899. if (!scene) {
  57900. return null;
  57901. }
  57902. // Extract the raw linear data.
  57903. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  57904. // Generate harmonics if needed.
  57905. if (_this._generateHarmonics) {
  57906. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  57907. _this.sphericalPolynomial = sphericalPolynomial;
  57908. }
  57909. var results = [];
  57910. var byteArray = null;
  57911. // Push each faces.
  57912. for (var j = 0; j < 6; j++) {
  57913. // Create uintarray fallback.
  57914. if (!scene.getEngine().getCaps().textureFloat) {
  57915. // 3 channels of 1 bytes per pixel in bytes.
  57916. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  57917. byteArray = new Uint8Array(byteBuffer);
  57918. }
  57919. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  57920. // If special cases.
  57921. if (_this.gammaSpace || byteArray) {
  57922. for (var i = 0; i < _this._size * _this._size; i++) {
  57923. // Put in gamma space if requested.
  57924. if (_this.gammaSpace) {
  57925. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  57926. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  57927. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  57928. }
  57929. // Convert to int texture for fallback.
  57930. if (byteArray) {
  57931. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  57932. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  57933. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  57934. // May use luminance instead if the result is not accurate.
  57935. var max = Math.max(Math.max(r, g), b);
  57936. if (max > 255) {
  57937. var scale = 255 / max;
  57938. r *= scale;
  57939. g *= scale;
  57940. b *= scale;
  57941. }
  57942. byteArray[(i * 3) + 0] = r;
  57943. byteArray[(i * 3) + 1] = g;
  57944. byteArray[(i * 3) + 2] = b;
  57945. }
  57946. }
  57947. }
  57948. if (byteArray) {
  57949. results.push(byteArray);
  57950. }
  57951. else {
  57952. results.push(dataFace);
  57953. }
  57954. }
  57955. return results;
  57956. };
  57957. var scene = this.getScene();
  57958. if (scene) {
  57959. 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);
  57960. }
  57961. };
  57962. HDRCubeTexture.prototype.clone = function () {
  57963. var scene = this.getScene();
  57964. if (!scene) {
  57965. return this;
  57966. }
  57967. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  57968. // Base texture
  57969. newTexture.level = this.level;
  57970. newTexture.wrapU = this.wrapU;
  57971. newTexture.wrapV = this.wrapV;
  57972. newTexture.coordinatesIndex = this.coordinatesIndex;
  57973. newTexture.coordinatesMode = this.coordinatesMode;
  57974. return newTexture;
  57975. };
  57976. // Methods
  57977. HDRCubeTexture.prototype.delayLoad = function () {
  57978. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  57979. return;
  57980. }
  57981. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  57982. this._texture = this._getFromCache(this.url, this._noMipmap);
  57983. if (!this._texture) {
  57984. this.loadTexture();
  57985. }
  57986. };
  57987. /**
  57988. * Get the texture reflection matrix used to rotate/transform the reflection.
  57989. * @returns the reflection matrix
  57990. */
  57991. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  57992. return this._textureMatrix;
  57993. };
  57994. /**
  57995. * Set the texture reflection matrix used to rotate/transform the reflection.
  57996. * @param value Define the reflection matrix to set
  57997. */
  57998. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  57999. var _this = this;
  58000. this._textureMatrix = value;
  58001. if (value.updateFlag === this._textureMatrix.updateFlag) {
  58002. return;
  58003. }
  58004. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  58005. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  58006. }
  58007. };
  58008. /**
  58009. * Parses a JSON representation of an HDR Texture in order to create the texture
  58010. * @param parsedTexture Define the JSON representation
  58011. * @param scene Define the scene the texture should be created in
  58012. * @param rootUrl Define the root url in case we need to load relative dependencies
  58013. * @returns the newly created texture after parsing
  58014. */
  58015. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  58016. var texture = null;
  58017. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  58018. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  58019. texture.name = parsedTexture.name;
  58020. texture.hasAlpha = parsedTexture.hasAlpha;
  58021. texture.level = parsedTexture.level;
  58022. texture.coordinatesMode = parsedTexture.coordinatesMode;
  58023. texture.isBlocking = parsedTexture.isBlocking;
  58024. }
  58025. if (texture) {
  58026. if (parsedTexture.boundingBoxPosition) {
  58027. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  58028. }
  58029. if (parsedTexture.boundingBoxSize) {
  58030. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  58031. }
  58032. if (parsedTexture.rotationY) {
  58033. texture.rotationY = parsedTexture.rotationY;
  58034. }
  58035. }
  58036. return texture;
  58037. };
  58038. HDRCubeTexture.prototype.serialize = function () {
  58039. if (!this.name) {
  58040. return null;
  58041. }
  58042. var serializationObject = {};
  58043. serializationObject.name = this.name;
  58044. serializationObject.hasAlpha = this.hasAlpha;
  58045. serializationObject.isCube = true;
  58046. serializationObject.level = this.level;
  58047. serializationObject.size = this._size;
  58048. serializationObject.coordinatesMode = this.coordinatesMode;
  58049. serializationObject.useInGammaSpace = this.gammaSpace;
  58050. serializationObject.generateHarmonics = this._generateHarmonics;
  58051. serializationObject.customType = "BABYLON.HDRCubeTexture";
  58052. serializationObject.noMipmap = this._noMipmap;
  58053. serializationObject.isBlocking = this._isBlocking;
  58054. serializationObject.rotationY = this._rotationY;
  58055. return serializationObject;
  58056. };
  58057. HDRCubeTexture._facesMapping = [
  58058. "right",
  58059. "left",
  58060. "up",
  58061. "down",
  58062. "front",
  58063. "back"
  58064. ];
  58065. return HDRCubeTexture;
  58066. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  58067. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  58068. /***/ }),
  58069. /***/ "./Materials/Textures/index.ts":
  58070. /*!*************************************!*\
  58071. !*** ./Materials/Textures/index.ts ***!
  58072. \*************************************/
  58073. /*! exports provided: BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  58074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58075. "use strict";
  58076. __webpack_require__.r(__webpack_exports__);
  58077. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  58078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  58079. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  58080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  58081. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  58082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  58083. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  58084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  58085. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  58086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  58087. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  58088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  58089. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  58090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  58091. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  58092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  58093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  58094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  58095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  58096. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  58097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  58098. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  58099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  58100. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  58101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  58102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  58103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  58104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  58105. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  58106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  58107. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  58108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  58109. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  58110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  58111. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  58112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  58113. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  58115. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  58116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  58117. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  58118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  58119. /***/ }),
  58120. /***/ "./Materials/Textures/internalTexture.ts":
  58121. /*!***********************************************!*\
  58122. !*** ./Materials/Textures/internalTexture.ts ***!
  58123. \***********************************************/
  58124. /*! exports provided: InternalTexture */
  58125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58126. "use strict";
  58127. __webpack_require__.r(__webpack_exports__);
  58128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  58129. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58130. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  58131. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58132. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  58133. /**
  58134. * Class used to store data associated with WebGL texture data for the engine
  58135. * This class should not be used directly
  58136. */
  58137. var InternalTexture = /** @class */ (function () {
  58138. /**
  58139. * Creates a new InternalTexture
  58140. * @param engine defines the engine to use
  58141. * @param dataSource defines the type of data that will be used
  58142. * @param delayAllocation if the texture allocation should be delayed (default: false)
  58143. */
  58144. function InternalTexture(engine, dataSource, delayAllocation) {
  58145. if (delayAllocation === void 0) { delayAllocation = false; }
  58146. /**
  58147. * Observable called when the texture is loaded
  58148. */
  58149. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  58150. /**
  58151. * Gets or set the previous tracker in the list
  58152. */
  58153. this.previous = null;
  58154. /**
  58155. * Gets or set the next tracker in the list
  58156. */
  58157. this.next = null;
  58158. // Private
  58159. /** @hidden */
  58160. this._invertVScale = false;
  58161. /** @hidden */
  58162. this._initialSlot = -1;
  58163. /** @hidden */
  58164. this._designatedSlot = -1;
  58165. /** @hidden */
  58166. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  58167. /** @hidden */
  58168. this._comparisonFunction = 0;
  58169. /** @hidden */
  58170. this._sphericalPolynomial = null;
  58171. /** @hidden */
  58172. this._lodGenerationScale = 0;
  58173. /** @hidden */
  58174. this._lodGenerationOffset = 0;
  58175. /** @hidden */
  58176. this._isRGBD = false;
  58177. /** @hidden */
  58178. this._references = 1;
  58179. this._engine = engine;
  58180. this._dataSource = dataSource;
  58181. if (!delayAllocation) {
  58182. this._webGLTexture = engine._createTexture();
  58183. }
  58184. }
  58185. /**
  58186. * Gets the Engine the texture belongs to.
  58187. * @returns The babylon engine
  58188. */
  58189. InternalTexture.prototype.getEngine = function () {
  58190. return this._engine;
  58191. };
  58192. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  58193. /**
  58194. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  58195. */
  58196. get: function () {
  58197. return this._dataSource;
  58198. },
  58199. enumerable: true,
  58200. configurable: true
  58201. });
  58202. /**
  58203. * Increments the number of references (ie. the number of Texture that point to it)
  58204. */
  58205. InternalTexture.prototype.incrementReferences = function () {
  58206. this._references++;
  58207. };
  58208. /**
  58209. * Change the size of the texture (not the size of the content)
  58210. * @param width defines the new width
  58211. * @param height defines the new height
  58212. * @param depth defines the new depth (1 by default)
  58213. */
  58214. InternalTexture.prototype.updateSize = function (width, height, depth) {
  58215. if (depth === void 0) { depth = 1; }
  58216. this.width = width;
  58217. this.height = height;
  58218. this.depth = depth;
  58219. this.baseWidth = width;
  58220. this.baseHeight = height;
  58221. this.baseDepth = depth;
  58222. this._size = width * height * depth;
  58223. };
  58224. /** @hidden */
  58225. InternalTexture.prototype._rebuild = function () {
  58226. var _this = this;
  58227. var proxy;
  58228. this.isReady = false;
  58229. this._cachedCoordinatesMode = null;
  58230. this._cachedWrapU = null;
  58231. this._cachedWrapV = null;
  58232. this._cachedAnisotropicFilteringLevel = null;
  58233. switch (this._dataSource) {
  58234. case InternalTexture.DATASOURCE_TEMP:
  58235. return;
  58236. case InternalTexture.DATASOURCE_URL:
  58237. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  58238. proxy._swapAndDie(_this);
  58239. _this.isReady = true;
  58240. }, null, this._buffer, undefined, this.format);
  58241. return;
  58242. case InternalTexture.DATASOURCE_RAW:
  58243. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58244. proxy._swapAndDie(this);
  58245. this.isReady = true;
  58246. return;
  58247. case InternalTexture.DATASOURCE_RAW3D:
  58248. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58249. proxy._swapAndDie(this);
  58250. this.isReady = true;
  58251. return;
  58252. case InternalTexture.DATASOURCE_DYNAMIC:
  58253. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  58254. proxy._swapAndDie(this);
  58255. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  58256. // The engine will make sure to update content so no need to flag it as isReady = true
  58257. return;
  58258. case InternalTexture.DATASOURCE_RENDERTARGET:
  58259. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  58260. options.generateDepthBuffer = this._generateDepthBuffer;
  58261. options.generateMipMaps = this.generateMipMaps;
  58262. options.generateStencilBuffer = this._generateStencilBuffer;
  58263. options.samplingMode = this.samplingMode;
  58264. options.type = this.type;
  58265. if (this.isCube) {
  58266. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  58267. }
  58268. else {
  58269. var size = {
  58270. width: this.width,
  58271. height: this.height
  58272. };
  58273. proxy = this._engine.createRenderTargetTexture(size, options);
  58274. }
  58275. proxy._swapAndDie(this);
  58276. this.isReady = true;
  58277. return;
  58278. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  58279. var depthTextureOptions = {
  58280. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  58281. comparisonFunction: this._comparisonFunction,
  58282. generateStencil: this._generateStencilBuffer,
  58283. isCube: this.isCube
  58284. };
  58285. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  58286. proxy._swapAndDie(this);
  58287. this.isReady = true;
  58288. return;
  58289. case InternalTexture.DATASOURCE_CUBE:
  58290. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  58291. proxy._swapAndDie(_this);
  58292. _this.isReady = true;
  58293. }, null, this.format, this._extension);
  58294. return;
  58295. case InternalTexture.DATASOURCE_CUBERAW:
  58296. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58297. proxy._swapAndDie(this);
  58298. this.isReady = true;
  58299. return;
  58300. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  58301. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  58302. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  58303. proxy._swapAndDie(_this);
  58304. _this.isReady = true;
  58305. });
  58306. return;
  58307. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  58308. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  58309. if (proxy) {
  58310. proxy._swapAndDie(_this);
  58311. }
  58312. _this.isReady = true;
  58313. }, null, this.format, this._extension);
  58314. proxy._sphericalPolynomial = this._sphericalPolynomial;
  58315. return;
  58316. }
  58317. };
  58318. /** @hidden */
  58319. InternalTexture.prototype._swapAndDie = function (target) {
  58320. target._webGLTexture = this._webGLTexture;
  58321. if (this._framebuffer) {
  58322. target._framebuffer = this._framebuffer;
  58323. }
  58324. if (this._depthStencilBuffer) {
  58325. target._depthStencilBuffer = this._depthStencilBuffer;
  58326. }
  58327. if (this._lodTextureHigh) {
  58328. if (target._lodTextureHigh) {
  58329. target._lodTextureHigh.dispose();
  58330. }
  58331. target._lodTextureHigh = this._lodTextureHigh;
  58332. }
  58333. if (this._lodTextureMid) {
  58334. if (target._lodTextureMid) {
  58335. target._lodTextureMid.dispose();
  58336. }
  58337. target._lodTextureMid = this._lodTextureMid;
  58338. }
  58339. if (this._lodTextureLow) {
  58340. if (target._lodTextureLow) {
  58341. target._lodTextureLow.dispose();
  58342. }
  58343. target._lodTextureLow = this._lodTextureLow;
  58344. }
  58345. var cache = this._engine.getLoadedTexturesCache();
  58346. var index = cache.indexOf(this);
  58347. if (index !== -1) {
  58348. cache.splice(index, 1);
  58349. }
  58350. };
  58351. /**
  58352. * Dispose the current allocated resources
  58353. */
  58354. InternalTexture.prototype.dispose = function () {
  58355. if (!this._webGLTexture) {
  58356. return;
  58357. }
  58358. this._references--;
  58359. if (this._references === 0) {
  58360. this._engine._releaseTexture(this);
  58361. this._webGLTexture = null;
  58362. this.previous = null;
  58363. this.next = null;
  58364. }
  58365. };
  58366. /** hidden */
  58367. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  58368. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  58369. };
  58370. /**
  58371. * The source of the texture data is unknown
  58372. */
  58373. InternalTexture.DATASOURCE_UNKNOWN = 0;
  58374. /**
  58375. * Texture data comes from an URL
  58376. */
  58377. InternalTexture.DATASOURCE_URL = 1;
  58378. /**
  58379. * Texture data is only used for temporary storage
  58380. */
  58381. InternalTexture.DATASOURCE_TEMP = 2;
  58382. /**
  58383. * Texture data comes from raw data (ArrayBuffer)
  58384. */
  58385. InternalTexture.DATASOURCE_RAW = 3;
  58386. /**
  58387. * Texture content is dynamic (video or dynamic texture)
  58388. */
  58389. InternalTexture.DATASOURCE_DYNAMIC = 4;
  58390. /**
  58391. * Texture content is generated by rendering to it
  58392. */
  58393. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  58394. /**
  58395. * Texture content is part of a multi render target process
  58396. */
  58397. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  58398. /**
  58399. * Texture data comes from a cube data file
  58400. */
  58401. InternalTexture.DATASOURCE_CUBE = 7;
  58402. /**
  58403. * Texture data comes from a raw cube data
  58404. */
  58405. InternalTexture.DATASOURCE_CUBERAW = 8;
  58406. /**
  58407. * Texture data come from a prefiltered cube data file
  58408. */
  58409. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  58410. /**
  58411. * Texture content is raw 3D data
  58412. */
  58413. InternalTexture.DATASOURCE_RAW3D = 10;
  58414. /**
  58415. * Texture content is a depth texture
  58416. */
  58417. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  58418. /**
  58419. * Texture data comes from a raw cube data encoded with RGBD
  58420. */
  58421. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  58422. return InternalTexture;
  58423. }());
  58424. /***/ }),
  58425. /***/ "./Materials/Textures/internalTextureTracker.ts":
  58426. /*!******************************************************!*\
  58427. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  58428. \******************************************************/
  58429. /*! exports provided: DummyInternalTextureTracker */
  58430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58431. "use strict";
  58432. __webpack_require__.r(__webpack_exports__);
  58433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  58434. /**
  58435. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  58436. */
  58437. var DummyInternalTextureTracker = /** @class */ (function () {
  58438. function DummyInternalTextureTracker() {
  58439. /**
  58440. * Gets or set the previous tracker in the list
  58441. */
  58442. this.previous = null;
  58443. /**
  58444. * Gets or set the next tracker in the list
  58445. */
  58446. this.next = null;
  58447. }
  58448. return DummyInternalTextureTracker;
  58449. }());
  58450. /***/ }),
  58451. /***/ "./Materials/Textures/mirrorTexture.ts":
  58452. /*!*********************************************!*\
  58453. !*** ./Materials/Textures/mirrorTexture.ts ***!
  58454. \*********************************************/
  58455. /*! exports provided: MirrorTexture */
  58456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58457. "use strict";
  58458. __webpack_require__.r(__webpack_exports__);
  58459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  58460. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58461. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58462. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58463. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58464. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  58465. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58466. /**
  58467. * Mirror texture can be used to simulate the view from a mirror in a scene.
  58468. * It will dynamically be rendered every frame to adapt to the camera point of view.
  58469. * You can then easily use it as a reflectionTexture on a flat surface.
  58470. * In case the surface is not a plane, please consider relying on reflection probes.
  58471. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58472. */
  58473. var MirrorTexture = /** @class */ (function (_super) {
  58474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  58475. /**
  58476. * Instantiates a Mirror Texture.
  58477. * Mirror texture can be used to simulate the view from a mirror in a scene.
  58478. * It will dynamically be rendered every frame to adapt to the camera point of view.
  58479. * You can then easily use it as a reflectionTexture on a flat surface.
  58480. * In case the surface is not a plane, please consider relying on reflection probes.
  58481. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58482. * @param name
  58483. * @param size
  58484. * @param scene
  58485. * @param generateMipMaps
  58486. * @param type
  58487. * @param samplingMode
  58488. * @param generateDepthBuffer
  58489. */
  58490. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  58491. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58492. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  58493. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  58494. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  58495. _this.scene = scene;
  58496. /**
  58497. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  58498. * 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.
  58499. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58500. */
  58501. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  58502. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  58503. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  58504. _this._adaptiveBlurKernel = 0;
  58505. _this._blurKernelX = 0;
  58506. _this._blurKernelY = 0;
  58507. _this._blurRatio = 1.0;
  58508. _this.ignoreCameraViewport = true;
  58509. _this._updateGammaSpace();
  58510. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  58511. _this._updateGammaSpace;
  58512. });
  58513. _this.onBeforeRenderObservable.add(function () {
  58514. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  58515. _this._savedViewMatrix = scene.getViewMatrix();
  58516. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  58517. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  58518. scene.clipPlane = _this.mirrorPlane;
  58519. scene.getEngine().cullBackFaces = false;
  58520. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  58521. });
  58522. _this.onAfterRenderObservable.add(function () {
  58523. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  58524. scene.getEngine().cullBackFaces = true;
  58525. scene._mirroredCameraPosition = null;
  58526. delete scene.clipPlane;
  58527. });
  58528. return _this;
  58529. }
  58530. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  58531. get: function () {
  58532. return this._blurRatio;
  58533. },
  58534. /**
  58535. * Define the blur ratio used to blur the reflection if needed.
  58536. */
  58537. set: function (value) {
  58538. if (this._blurRatio === value) {
  58539. return;
  58540. }
  58541. this._blurRatio = value;
  58542. this._preparePostProcesses();
  58543. },
  58544. enumerable: true,
  58545. configurable: true
  58546. });
  58547. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  58548. /**
  58549. * Define the adaptive blur kernel used to blur the reflection if needed.
  58550. * This will autocompute the closest best match for the `blurKernel`
  58551. */
  58552. set: function (value) {
  58553. this._adaptiveBlurKernel = value;
  58554. this._autoComputeBlurKernel();
  58555. },
  58556. enumerable: true,
  58557. configurable: true
  58558. });
  58559. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  58560. /**
  58561. * Define the blur kernel used to blur the reflection if needed.
  58562. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  58563. */
  58564. set: function (value) {
  58565. this.blurKernelX = value;
  58566. this.blurKernelY = value;
  58567. },
  58568. enumerable: true,
  58569. configurable: true
  58570. });
  58571. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  58572. get: function () {
  58573. return this._blurKernelX;
  58574. },
  58575. /**
  58576. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  58577. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  58578. */
  58579. set: function (value) {
  58580. if (this._blurKernelX === value) {
  58581. return;
  58582. }
  58583. this._blurKernelX = value;
  58584. this._preparePostProcesses();
  58585. },
  58586. enumerable: true,
  58587. configurable: true
  58588. });
  58589. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  58590. get: function () {
  58591. return this._blurKernelY;
  58592. },
  58593. /**
  58594. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  58595. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  58596. */
  58597. set: function (value) {
  58598. if (this._blurKernelY === value) {
  58599. return;
  58600. }
  58601. this._blurKernelY = value;
  58602. this._preparePostProcesses();
  58603. },
  58604. enumerable: true,
  58605. configurable: true
  58606. });
  58607. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  58608. var engine = this.getScene().getEngine();
  58609. var dw = this.getRenderWidth() / engine.getRenderWidth();
  58610. var dh = this.getRenderHeight() / engine.getRenderHeight();
  58611. this.blurKernelX = this._adaptiveBlurKernel * dw;
  58612. this.blurKernelY = this._adaptiveBlurKernel * dh;
  58613. };
  58614. MirrorTexture.prototype._onRatioRescale = function () {
  58615. if (this._sizeRatio) {
  58616. this.resize(this._initialSizeParameter);
  58617. if (!this._adaptiveBlurKernel) {
  58618. this._preparePostProcesses();
  58619. }
  58620. }
  58621. if (this._adaptiveBlurKernel) {
  58622. this._autoComputeBlurKernel();
  58623. }
  58624. };
  58625. MirrorTexture.prototype._updateGammaSpace = function () {
  58626. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  58627. };
  58628. MirrorTexture.prototype._preparePostProcesses = function () {
  58629. this.clearPostProcesses(true);
  58630. if (this._blurKernelX && this._blurKernelY) {
  58631. var engine = this.getScene().getEngine();
  58632. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  58633. 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);
  58634. this._blurX.autoClear = false;
  58635. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  58636. this._blurX.inputTexture = this._texture;
  58637. }
  58638. else {
  58639. this._blurX.alwaysForcePOT = true;
  58640. }
  58641. 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);
  58642. this._blurY.autoClear = false;
  58643. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  58644. this.addPostProcess(this._blurX);
  58645. this.addPostProcess(this._blurY);
  58646. }
  58647. else {
  58648. if (this._blurY) {
  58649. this.removePostProcess(this._blurY);
  58650. this._blurY.dispose();
  58651. this._blurY = null;
  58652. }
  58653. if (this._blurX) {
  58654. this.removePostProcess(this._blurX);
  58655. this._blurX.dispose();
  58656. this._blurX = null;
  58657. }
  58658. }
  58659. };
  58660. /**
  58661. * Clone the mirror texture.
  58662. * @returns the cloned texture
  58663. */
  58664. MirrorTexture.prototype.clone = function () {
  58665. var scene = this.getScene();
  58666. if (!scene) {
  58667. return this;
  58668. }
  58669. var textureSize = this.getSize();
  58670. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  58671. // Base texture
  58672. newTexture.hasAlpha = this.hasAlpha;
  58673. newTexture.level = this.level;
  58674. // Mirror Texture
  58675. newTexture.mirrorPlane = this.mirrorPlane.clone();
  58676. if (this.renderList) {
  58677. newTexture.renderList = this.renderList.slice(0);
  58678. }
  58679. return newTexture;
  58680. };
  58681. /**
  58682. * Serialize the texture to a JSON representation you could use in Parse later on
  58683. * @returns the serialized JSON representation
  58684. */
  58685. MirrorTexture.prototype.serialize = function () {
  58686. if (!this.name) {
  58687. return null;
  58688. }
  58689. var serializationObject = _super.prototype.serialize.call(this);
  58690. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  58691. return serializationObject;
  58692. };
  58693. /**
  58694. * Dispose the texture and release its associated resources.
  58695. */
  58696. MirrorTexture.prototype.dispose = function () {
  58697. _super.prototype.dispose.call(this);
  58698. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  58699. };
  58700. return MirrorTexture;
  58701. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  58702. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  58703. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  58704. };
  58705. /***/ }),
  58706. /***/ "./Materials/Textures/multiRenderTarget.ts":
  58707. /*!*************************************************!*\
  58708. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  58709. \*************************************************/
  58710. /*! exports provided: MultiRenderTarget */
  58711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58712. "use strict";
  58713. __webpack_require__.r(__webpack_exports__);
  58714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  58715. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58716. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58717. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58718. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58719. /**
  58720. * A multi render target, like a render target provides the ability to render to a texture.
  58721. * Unlike the render target, it can render to several draw buffers in one draw.
  58722. * This is specially interesting in deferred rendering or for any effects requiring more than
  58723. * just one color from a single pass.
  58724. */
  58725. var MultiRenderTarget = /** @class */ (function (_super) {
  58726. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  58727. /**
  58728. * Instantiate a new multi render target texture.
  58729. * A multi render target, like a render target provides the ability to render to a texture.
  58730. * Unlike the render target, it can render to several draw buffers in one draw.
  58731. * This is specially interesting in deferred rendering or for any effects requiring more than
  58732. * just one color from a single pass.
  58733. * @param name Define the name of the texture
  58734. * @param size Define the size of the buffers to render to
  58735. * @param count Define the number of target we are rendering into
  58736. * @param scene Define the scene the texture belongs to
  58737. * @param options Define the options used to create the multi render target
  58738. */
  58739. function MultiRenderTarget(name, size, count, scene, options) {
  58740. var _this = this;
  58741. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  58742. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  58743. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  58744. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  58745. _this._engine = scene.getEngine();
  58746. if (!_this.isSupported) {
  58747. _this.dispose();
  58748. return;
  58749. }
  58750. var types = [];
  58751. var samplingModes = [];
  58752. for (var i = 0; i < count; i++) {
  58753. if (options && options.types && options.types[i] !== undefined) {
  58754. types.push(options.types[i]);
  58755. }
  58756. else {
  58757. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  58758. }
  58759. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  58760. samplingModes.push(options.samplingModes[i]);
  58761. }
  58762. else {
  58763. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  58764. }
  58765. }
  58766. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  58767. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  58768. _this._size = size;
  58769. _this._multiRenderTargetOptions = {
  58770. samplingModes: samplingModes,
  58771. generateMipMaps: generateMipMaps,
  58772. generateDepthBuffer: generateDepthBuffer,
  58773. generateStencilBuffer: generateStencilBuffer,
  58774. generateDepthTexture: generateDepthTexture,
  58775. types: types,
  58776. textureCount: count
  58777. };
  58778. _this._createInternalTextures();
  58779. _this._createTextures();
  58780. return _this;
  58781. }
  58782. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  58783. /**
  58784. * Get if draw buffers are currently supported by the used hardware and browser.
  58785. */
  58786. get: function () {
  58787. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  58788. },
  58789. enumerable: true,
  58790. configurable: true
  58791. });
  58792. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  58793. /**
  58794. * Get the list of textures generated by the multi render target.
  58795. */
  58796. get: function () {
  58797. return this._textures;
  58798. },
  58799. enumerable: true,
  58800. configurable: true
  58801. });
  58802. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  58803. /**
  58804. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  58805. */
  58806. get: function () {
  58807. return this._textures[this._textures.length - 1];
  58808. },
  58809. enumerable: true,
  58810. configurable: true
  58811. });
  58812. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  58813. /**
  58814. * Set the wrapping mode on U of all the textures we are rendering to.
  58815. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  58816. */
  58817. set: function (wrap) {
  58818. if (this._textures) {
  58819. for (var i = 0; i < this._textures.length; i++) {
  58820. this._textures[i].wrapU = wrap;
  58821. }
  58822. }
  58823. },
  58824. enumerable: true,
  58825. configurable: true
  58826. });
  58827. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  58828. /**
  58829. * Set the wrapping mode on V of all the textures we are rendering to.
  58830. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  58831. */
  58832. set: function (wrap) {
  58833. if (this._textures) {
  58834. for (var i = 0; i < this._textures.length; i++) {
  58835. this._textures[i].wrapV = wrap;
  58836. }
  58837. }
  58838. },
  58839. enumerable: true,
  58840. configurable: true
  58841. });
  58842. /** @hidden */
  58843. MultiRenderTarget.prototype._rebuild = function () {
  58844. this.releaseInternalTextures();
  58845. this._createInternalTextures();
  58846. for (var i = 0; i < this._internalTextures.length; i++) {
  58847. var texture = this._textures[i];
  58848. texture._texture = this._internalTextures[i];
  58849. }
  58850. // Keeps references to frame buffer and stencil/depth buffer
  58851. this._texture = this._internalTextures[0];
  58852. };
  58853. MultiRenderTarget.prototype._createInternalTextures = function () {
  58854. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  58855. };
  58856. MultiRenderTarget.prototype._createTextures = function () {
  58857. this._textures = [];
  58858. for (var i = 0; i < this._internalTextures.length; i++) {
  58859. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  58860. texture._texture = this._internalTextures[i];
  58861. this._textures.push(texture);
  58862. }
  58863. // Keeps references to frame buffer and stencil/depth buffer
  58864. this._texture = this._internalTextures[0];
  58865. };
  58866. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  58867. /**
  58868. * Define the number of samples used if MSAA is enabled.
  58869. */
  58870. get: function () {
  58871. return this._samples;
  58872. },
  58873. set: function (value) {
  58874. if (this._samples === value) {
  58875. return;
  58876. }
  58877. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  58878. },
  58879. enumerable: true,
  58880. configurable: true
  58881. });
  58882. /**
  58883. * Resize all the textures in the multi render target.
  58884. * Be carrefull as it will recreate all the data in the new texture.
  58885. * @param size Define the new size
  58886. */
  58887. MultiRenderTarget.prototype.resize = function (size) {
  58888. this.releaseInternalTextures();
  58889. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  58890. this._createInternalTextures();
  58891. };
  58892. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  58893. var _this = this;
  58894. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  58895. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  58896. });
  58897. };
  58898. /**
  58899. * Dispose the render targets and their associated resources
  58900. */
  58901. MultiRenderTarget.prototype.dispose = function () {
  58902. this.releaseInternalTextures();
  58903. _super.prototype.dispose.call(this);
  58904. };
  58905. /**
  58906. * Release all the underlying texture used as draw buffers.
  58907. */
  58908. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  58909. if (!this._internalTextures) {
  58910. return;
  58911. }
  58912. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  58913. if (this._internalTextures[i] !== undefined) {
  58914. this._internalTextures[i].dispose();
  58915. this._internalTextures.splice(i, 1);
  58916. }
  58917. }
  58918. };
  58919. return MultiRenderTarget;
  58920. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  58921. /***/ }),
  58922. /***/ "./Materials/Textures/rawCubeTexture.ts":
  58923. /*!**********************************************!*\
  58924. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  58925. \**********************************************/
  58926. /*! exports provided: RawCubeTexture */
  58927. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58928. "use strict";
  58929. __webpack_require__.r(__webpack_exports__);
  58930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  58931. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58932. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58933. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  58934. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  58935. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  58936. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58937. /**
  58938. * Raw cube texture where the raw buffers are passed in
  58939. */
  58940. var RawCubeTexture = /** @class */ (function (_super) {
  58941. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  58942. /**
  58943. * Creates a cube texture where the raw buffers are passed in.
  58944. * @param scene defines the scene the texture is attached to
  58945. * @param data defines the array of data to use to create each face
  58946. * @param size defines the size of the textures
  58947. * @param format defines the format of the data
  58948. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58949. * @param generateMipMaps defines if the engine should generate the mip levels
  58950. * @param invertY defines if data must be stored with Y axis inverted
  58951. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58952. * @param compression defines the compression used (null by default)
  58953. */
  58954. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  58955. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  58956. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58957. if (generateMipMaps === void 0) { generateMipMaps = false; }
  58958. if (invertY === void 0) { invertY = false; }
  58959. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58960. if (compression === void 0) { compression = null; }
  58961. var _this = _super.call(this, "", scene) || this;
  58962. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  58963. return _this;
  58964. }
  58965. /**
  58966. * Updates the raw cube texture.
  58967. * @param data defines the data to store
  58968. * @param format defines the data format
  58969. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58970. * @param invertY defines if data must be stored with Y axis inverted
  58971. * @param compression defines the compression used (null by default)
  58972. * @param level defines which level of the texture to update
  58973. */
  58974. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  58975. if (compression === void 0) { compression = null; }
  58976. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  58977. };
  58978. /**
  58979. * Updates a raw cube texture with RGBD encoded data.
  58980. * @param data defines the array of data [mipmap][face] to use to create each face
  58981. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58982. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58983. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58984. * @returns a promsie that resolves when the operation is complete
  58985. */
  58986. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  58987. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  58988. if (lodScale === void 0) { lodScale = 0.8; }
  58989. if (lodOffset === void 0) { lodOffset = 0; }
  58990. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  58991. };
  58992. /**
  58993. * Clones the raw cube texture.
  58994. * @return a new cube texture
  58995. */
  58996. RawCubeTexture.prototype.clone = function () {
  58997. var _this = this;
  58998. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58999. var scene = _this.getScene();
  59000. var internalTexture = _this._texture;
  59001. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  59002. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  59003. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  59004. }
  59005. return texture;
  59006. }, this);
  59007. };
  59008. /** @hidden */
  59009. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  59010. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  59011. internalTexture._bufferViewArrayArray = data;
  59012. internalTexture._lodGenerationScale = lodScale;
  59013. internalTexture._lodGenerationOffset = lodOffset;
  59014. internalTexture._sphericalPolynomial = sphericalPolynomial;
  59015. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  59016. internalTexture.isReady = true;
  59017. });
  59018. };
  59019. return RawCubeTexture;
  59020. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  59021. /***/ }),
  59022. /***/ "./Materials/Textures/rawTexture.ts":
  59023. /*!******************************************!*\
  59024. !*** ./Materials/Textures/rawTexture.ts ***!
  59025. \******************************************/
  59026. /*! exports provided: RawTexture */
  59027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59028. "use strict";
  59029. __webpack_require__.r(__webpack_exports__);
  59030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  59031. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59032. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59033. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59034. /**
  59035. * Raw texture can help creating a texture directly from an array of data.
  59036. * This can be super useful if you either get the data from an uncompressed source or
  59037. * if you wish to create your texture pixel by pixel.
  59038. */
  59039. var RawTexture = /** @class */ (function (_super) {
  59040. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  59041. /**
  59042. * Instantiates a new RawTexture.
  59043. * Raw texture can help creating a texture directly from an array of data.
  59044. * This can be super useful if you either get the data from an uncompressed source or
  59045. * if you wish to create your texture pixel by pixel.
  59046. * @param data define the array of data to use to create the texture
  59047. * @param width define the width of the texture
  59048. * @param height define the height of the texture
  59049. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  59050. * @param scene define the scene the texture belongs to
  59051. * @param generateMipMaps define whether mip maps should be generated or not
  59052. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59053. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59054. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59055. */
  59056. function RawTexture(data, width, height,
  59057. /**
  59058. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  59059. */
  59060. format, scene, generateMipMaps, invertY, samplingMode, type) {
  59061. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59062. if (invertY === void 0) { invertY = false; }
  59063. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59064. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59065. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59066. _this.format = format;
  59067. _this._engine = scene.getEngine();
  59068. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  59069. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  59070. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  59071. return _this;
  59072. }
  59073. /**
  59074. * Updates the texture underlying data.
  59075. * @param data Define the new data of the texture
  59076. */
  59077. RawTexture.prototype.update = function (data) {
  59078. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  59079. };
  59080. /**
  59081. * Creates a luminance texture from some data.
  59082. * @param data Define the texture data
  59083. * @param width Define the width of the texture
  59084. * @param height Define the height of the texture
  59085. * @param scene Define the scene the texture belongs to
  59086. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59087. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59088. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59089. * @returns the luminance texture
  59090. */
  59091. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59092. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59093. if (invertY === void 0) { invertY = false; }
  59094. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59095. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  59096. };
  59097. /**
  59098. * Creates a luminance alpha texture from some data.
  59099. * @param data Define the texture data
  59100. * @param width Define the width of the texture
  59101. * @param height Define the height of the texture
  59102. * @param scene Define the scene the texture belongs to
  59103. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59104. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59105. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59106. * @returns the luminance alpha texture
  59107. */
  59108. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59109. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59110. if (invertY === void 0) { invertY = false; }
  59111. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59112. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  59113. };
  59114. /**
  59115. * Creates an alpha texture from some data.
  59116. * @param data Define the texture data
  59117. * @param width Define the width of the texture
  59118. * @param height Define the height of the texture
  59119. * @param scene Define the scene the texture belongs to
  59120. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59121. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59122. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59123. * @returns the alpha texture
  59124. */
  59125. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59126. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59127. if (invertY === void 0) { invertY = false; }
  59128. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59129. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  59130. };
  59131. /**
  59132. * Creates a RGB texture from some data.
  59133. * @param data Define the texture data
  59134. * @param width Define the width of the texture
  59135. * @param height Define the height of the texture
  59136. * @param scene Define the scene the texture belongs to
  59137. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59138. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59139. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59140. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59141. * @returns the RGB alpha texture
  59142. */
  59143. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59144. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59145. if (invertY === void 0) { invertY = false; }
  59146. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59147. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59148. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  59149. };
  59150. /**
  59151. * Creates a RGBA texture from some data.
  59152. * @param data Define the texture data
  59153. * @param width Define the width of the texture
  59154. * @param height Define the height of the texture
  59155. * @param scene Define the scene the texture belongs to
  59156. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59157. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59158. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59159. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59160. * @returns the RGBA texture
  59161. */
  59162. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59163. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59164. if (invertY === void 0) { invertY = false; }
  59165. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59166. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59167. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  59168. };
  59169. /**
  59170. * Creates a R texture from some data.
  59171. * @param data Define the texture data
  59172. * @param width Define the width of the texture
  59173. * @param height Define the height of the texture
  59174. * @param scene Define the scene the texture belongs to
  59175. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59176. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59177. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59178. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59179. * @returns the R texture
  59180. */
  59181. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59182. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59183. if (invertY === void 0) { invertY = false; }
  59184. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59185. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  59186. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  59187. };
  59188. return RawTexture;
  59189. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  59190. /***/ }),
  59191. /***/ "./Materials/Textures/rawTexture3D.ts":
  59192. /*!********************************************!*\
  59193. !*** ./Materials/Textures/rawTexture3D.ts ***!
  59194. \********************************************/
  59195. /*! exports provided: RawTexture3D */
  59196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59197. "use strict";
  59198. __webpack_require__.r(__webpack_exports__);
  59199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  59200. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59201. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59202. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59203. /**
  59204. * Class used to store 3D textures containing user data
  59205. */
  59206. var RawTexture3D = /** @class */ (function (_super) {
  59207. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  59208. /**
  59209. * Create a new RawTexture3D
  59210. * @param data defines the data of the texture
  59211. * @param width defines the width of the texture
  59212. * @param height defines the height of the texture
  59213. * @param depth defines the depth of the texture
  59214. * @param format defines the texture format to use
  59215. * @param scene defines the hosting scene
  59216. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59217. * @param invertY defines if texture must be stored with Y axis inverted
  59218. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59219. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59220. */
  59221. function RawTexture3D(data, width, height, depth,
  59222. /** Gets or sets the texture format to use */
  59223. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  59224. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59225. if (invertY === void 0) { invertY = false; }
  59226. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59227. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59228. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59229. _this.format = format;
  59230. _this._engine = scene.getEngine();
  59231. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  59232. _this.is3D = true;
  59233. return _this;
  59234. }
  59235. /**
  59236. * Update the texture with new data
  59237. * @param data defines the data to store in the texture
  59238. */
  59239. RawTexture3D.prototype.update = function (data) {
  59240. if (!this._texture) {
  59241. return;
  59242. }
  59243. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  59244. };
  59245. return RawTexture3D;
  59246. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  59247. /***/ }),
  59248. /***/ "./Materials/Textures/refractionTexture.ts":
  59249. /*!*************************************************!*\
  59250. !*** ./Materials/Textures/refractionTexture.ts ***!
  59251. \*************************************************/
  59252. /*! exports provided: RefractionTexture */
  59253. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59254. "use strict";
  59255. __webpack_require__.r(__webpack_exports__);
  59256. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  59257. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59258. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59259. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59260. /**
  59261. * Creates a refraction texture used by refraction channel of the standard material.
  59262. * It is like a mirror but to see through a material.
  59263. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59264. */
  59265. var RefractionTexture = /** @class */ (function (_super) {
  59266. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  59267. /**
  59268. * Creates a refraction texture used by refraction channel of the standard material.
  59269. * It is like a mirror but to see through a material.
  59270. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59271. * @param name Define the texture name
  59272. * @param size Define the size of the underlying texture
  59273. * @param scene Define the scene the refraction belongs to
  59274. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59275. */
  59276. function RefractionTexture(name, size, scene, generateMipMaps) {
  59277. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  59278. /**
  59279. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59280. * 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.
  59281. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59282. */
  59283. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  59284. /**
  59285. * Define how deep under the surface we should see.
  59286. */
  59287. _this.depth = 2.0;
  59288. _this.onBeforeRenderObservable.add(function () {
  59289. scene.clipPlane = _this.refractionPlane;
  59290. });
  59291. _this.onAfterRenderObservable.add(function () {
  59292. delete scene.clipPlane;
  59293. });
  59294. return _this;
  59295. }
  59296. /**
  59297. * Clone the refraction texture.
  59298. * @returns the cloned texture
  59299. */
  59300. RefractionTexture.prototype.clone = function () {
  59301. var scene = this.getScene();
  59302. if (!scene) {
  59303. return this;
  59304. }
  59305. var textureSize = this.getSize();
  59306. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  59307. // Base texture
  59308. newTexture.hasAlpha = this.hasAlpha;
  59309. newTexture.level = this.level;
  59310. // Refraction Texture
  59311. newTexture.refractionPlane = this.refractionPlane.clone();
  59312. if (this.renderList) {
  59313. newTexture.renderList = this.renderList.slice(0);
  59314. }
  59315. newTexture.depth = this.depth;
  59316. return newTexture;
  59317. };
  59318. /**
  59319. * Serialize the texture to a JSON representation you could use in Parse later on
  59320. * @returns the serialized JSON representation
  59321. */
  59322. RefractionTexture.prototype.serialize = function () {
  59323. if (!this.name) {
  59324. return null;
  59325. }
  59326. var serializationObject = _super.prototype.serialize.call(this);
  59327. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  59328. serializationObject.depth = this.depth;
  59329. return serializationObject;
  59330. };
  59331. return RefractionTexture;
  59332. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  59333. /***/ }),
  59334. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  59335. /*!***********************************************************!*\
  59336. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  59337. \***********************************************************/
  59338. /*! exports provided: RenderTargetCreationOptions */
  59339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59340. "use strict";
  59341. __webpack_require__.r(__webpack_exports__);
  59342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  59343. /**
  59344. * Define options used to create a render target texture
  59345. */
  59346. var RenderTargetCreationOptions = /** @class */ (function () {
  59347. function RenderTargetCreationOptions() {
  59348. }
  59349. return RenderTargetCreationOptions;
  59350. }());
  59351. /***/ }),
  59352. /***/ "./Materials/Textures/renderTargetTexture.ts":
  59353. /*!***************************************************!*\
  59354. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  59355. \***************************************************/
  59356. /*! exports provided: RenderTargetTexture */
  59357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59358. "use strict";
  59359. __webpack_require__.r(__webpack_exports__);
  59360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  59361. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59362. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59363. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59364. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59365. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59366. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  59367. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  59368. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59369. /**
  59370. * This Helps creating a texture that will be created from a camera in your scene.
  59371. * It is basically a dynamic texture that could be used to create special effects for instance.
  59372. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  59373. */
  59374. var RenderTargetTexture = /** @class */ (function (_super) {
  59375. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  59376. /**
  59377. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  59378. * or used a shadow, depth texture...
  59379. * @param name The friendly name of the texture
  59380. * @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)
  59381. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  59382. * @param generateMipMaps True if mip maps need to be generated after render.
  59383. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  59384. * @param type The type of the buffer in the RTT (int, half float, float...)
  59385. * @param isCube True if a cube texture needs to be created
  59386. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  59387. * @param generateDepthBuffer True to generate a depth buffer
  59388. * @param generateStencilBuffer True to generate a stencil buffer
  59389. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  59390. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  59391. * @param delayAllocation if the texture allocation should be delayed (default: false)
  59392. */
  59393. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  59394. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  59395. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59396. if (isCube === void 0) { isCube = false; }
  59397. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59398. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  59399. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  59400. if (isMulti === void 0) { isMulti = false; }
  59401. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  59402. if (delayAllocation === void 0) { delayAllocation = false; }
  59403. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  59404. _this.isCube = isCube;
  59405. /**
  59406. * Define if particles should be rendered in your texture.
  59407. */
  59408. _this.renderParticles = true;
  59409. /**
  59410. * Define if sprites should be rendered in your texture.
  59411. */
  59412. _this.renderSprites = false;
  59413. /**
  59414. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  59415. */
  59416. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  59417. /**
  59418. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  59419. */
  59420. _this.ignoreCameraViewport = false;
  59421. /**
  59422. * An event triggered when the texture is unbind.
  59423. */
  59424. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59425. /**
  59426. * An event triggered when the texture is unbind.
  59427. */
  59428. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59429. /**
  59430. * An event triggered before rendering the texture
  59431. */
  59432. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59433. /**
  59434. * An event triggered after rendering the texture
  59435. */
  59436. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59437. /**
  59438. * An event triggered after the texture clear
  59439. */
  59440. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59441. _this._currentRefreshId = -1;
  59442. _this._refreshRate = 1;
  59443. _this._samples = 1;
  59444. /**
  59445. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  59446. * It must define where the camera used to render the texture is set
  59447. */
  59448. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  59449. scene = _this.getScene();
  59450. if (!scene) {
  59451. return _this;
  59452. }
  59453. _this.renderList = new Array();
  59454. _this._engine = scene.getEngine();
  59455. _this.name = name;
  59456. _this.isRenderTarget = true;
  59457. _this._initialSizeParameter = size;
  59458. _this._processSizeParameter(size);
  59459. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  59460. });
  59461. _this._generateMipMaps = generateMipMaps ? true : false;
  59462. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  59463. // Rendering groups
  59464. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  59465. _this._renderingManager._useSceneAutoClearSetup = true;
  59466. if (isMulti) {
  59467. return _this;
  59468. }
  59469. _this._renderTargetOptions = {
  59470. generateMipMaps: generateMipMaps,
  59471. type: type,
  59472. format: format,
  59473. samplingMode: samplingMode,
  59474. generateDepthBuffer: generateDepthBuffer,
  59475. generateStencilBuffer: generateStencilBuffer
  59476. };
  59477. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  59478. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59479. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59480. }
  59481. if (!delayAllocation) {
  59482. if (isCube) {
  59483. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  59484. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  59485. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  59486. }
  59487. else {
  59488. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  59489. }
  59490. }
  59491. return _this;
  59492. }
  59493. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  59494. /**
  59495. * Use this list to define the list of mesh you want to render.
  59496. */
  59497. get: function () {
  59498. return this._renderList;
  59499. },
  59500. set: function (value) {
  59501. this._renderList = value;
  59502. if (this._renderList) {
  59503. this._hookArray(this._renderList);
  59504. }
  59505. },
  59506. enumerable: true,
  59507. configurable: true
  59508. });
  59509. RenderTargetTexture.prototype._hookArray = function (array) {
  59510. var _this = this;
  59511. var oldPush = array.push;
  59512. array.push = function () {
  59513. var items = [];
  59514. for (var _i = 0; _i < arguments.length; _i++) {
  59515. items[_i] = arguments[_i];
  59516. }
  59517. var wasEmpty = array.length === 0;
  59518. var result = oldPush.apply(array, items);
  59519. if (wasEmpty) {
  59520. _this.getScene().meshes.forEach(function (mesh) {
  59521. mesh._markSubMeshesAsLightDirty();
  59522. });
  59523. }
  59524. return result;
  59525. };
  59526. var oldSplice = array.splice;
  59527. array.splice = function (index, deleteCount) {
  59528. var deleted = oldSplice.apply(array, [index, deleteCount]);
  59529. if (array.length === 0) {
  59530. _this.getScene().meshes.forEach(function (mesh) {
  59531. mesh._markSubMeshesAsLightDirty();
  59532. });
  59533. }
  59534. return deleted;
  59535. };
  59536. };
  59537. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  59538. /**
  59539. * Set a after unbind callback in the texture.
  59540. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  59541. */
  59542. set: function (callback) {
  59543. if (this._onAfterUnbindObserver) {
  59544. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  59545. }
  59546. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  59547. },
  59548. enumerable: true,
  59549. configurable: true
  59550. });
  59551. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  59552. /**
  59553. * Set a before render callback in the texture.
  59554. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  59555. */
  59556. set: function (callback) {
  59557. if (this._onBeforeRenderObserver) {
  59558. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  59559. }
  59560. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  59561. },
  59562. enumerable: true,
  59563. configurable: true
  59564. });
  59565. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  59566. /**
  59567. * Set a after render callback in the texture.
  59568. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  59569. */
  59570. set: function (callback) {
  59571. if (this._onAfterRenderObserver) {
  59572. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  59573. }
  59574. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  59575. },
  59576. enumerable: true,
  59577. configurable: true
  59578. });
  59579. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  59580. /**
  59581. * Set a clear callback in the texture.
  59582. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  59583. */
  59584. set: function (callback) {
  59585. if (this._onClearObserver) {
  59586. this.onClearObservable.remove(this._onClearObserver);
  59587. }
  59588. this._onClearObserver = this.onClearObservable.add(callback);
  59589. },
  59590. enumerable: true,
  59591. configurable: true
  59592. });
  59593. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  59594. /**
  59595. * Gets render target creation options that were used.
  59596. */
  59597. get: function () {
  59598. return this._renderTargetOptions;
  59599. },
  59600. enumerable: true,
  59601. configurable: true
  59602. });
  59603. RenderTargetTexture.prototype._onRatioRescale = function () {
  59604. if (this._sizeRatio) {
  59605. this.resize(this._initialSizeParameter);
  59606. }
  59607. };
  59608. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  59609. get: function () {
  59610. return this._boundingBoxSize;
  59611. },
  59612. /**
  59613. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  59614. * When defined, the cubemap will switch to local mode
  59615. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59616. * @example https://www.babylonjs-playground.com/#RNASML
  59617. */
  59618. set: function (value) {
  59619. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  59620. return;
  59621. }
  59622. this._boundingBoxSize = value;
  59623. var scene = this.getScene();
  59624. if (scene) {
  59625. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  59626. }
  59627. },
  59628. enumerable: true,
  59629. configurable: true
  59630. });
  59631. /**
  59632. * Creates a depth stencil texture.
  59633. * This is only available in WebGL 2 or with the depth texture extension available.
  59634. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  59635. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  59636. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  59637. */
  59638. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  59639. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  59640. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  59641. if (generateStencil === void 0) { generateStencil = false; }
  59642. if (!this.getScene()) {
  59643. return;
  59644. }
  59645. var engine = this.getScene().getEngine();
  59646. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  59647. bilinearFiltering: bilinearFiltering,
  59648. comparisonFunction: comparisonFunction,
  59649. generateStencil: generateStencil,
  59650. isCube: this.isCube
  59651. });
  59652. engine.setFrameBufferDepthStencilTexture(this);
  59653. };
  59654. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  59655. if (size.ratio) {
  59656. this._sizeRatio = size.ratio;
  59657. this._size = {
  59658. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  59659. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  59660. };
  59661. }
  59662. else {
  59663. this._size = size;
  59664. }
  59665. };
  59666. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  59667. /**
  59668. * Define the number of samples to use in case of MSAA.
  59669. * It defaults to one meaning no MSAA has been enabled.
  59670. */
  59671. get: function () {
  59672. return this._samples;
  59673. },
  59674. set: function (value) {
  59675. if (this._samples === value) {
  59676. return;
  59677. }
  59678. var scene = this.getScene();
  59679. if (!scene) {
  59680. return;
  59681. }
  59682. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  59683. },
  59684. enumerable: true,
  59685. configurable: true
  59686. });
  59687. /**
  59688. * Resets the refresh counter of the texture and start bak from scratch.
  59689. * Could be useful to regenerate the texture if it is setup to render only once.
  59690. */
  59691. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  59692. this._currentRefreshId = -1;
  59693. };
  59694. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  59695. /**
  59696. * Define the refresh rate of the texture or the rendering frequency.
  59697. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  59698. */
  59699. get: function () {
  59700. return this._refreshRate;
  59701. },
  59702. set: function (value) {
  59703. this._refreshRate = value;
  59704. this.resetRefreshCounter();
  59705. },
  59706. enumerable: true,
  59707. configurable: true
  59708. });
  59709. /**
  59710. * Adds a post process to the render target rendering passes.
  59711. * @param postProcess define the post process to add
  59712. */
  59713. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  59714. if (!this._postProcessManager) {
  59715. var scene = this.getScene();
  59716. if (!scene) {
  59717. return;
  59718. }
  59719. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  59720. this._postProcesses = new Array();
  59721. }
  59722. this._postProcesses.push(postProcess);
  59723. this._postProcesses[0].autoClear = false;
  59724. };
  59725. /**
  59726. * Clear all the post processes attached to the render target
  59727. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  59728. */
  59729. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  59730. if (dispose === void 0) { dispose = false; }
  59731. if (!this._postProcesses) {
  59732. return;
  59733. }
  59734. if (dispose) {
  59735. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  59736. var postProcess = _a[_i];
  59737. postProcess.dispose();
  59738. }
  59739. }
  59740. this._postProcesses = [];
  59741. };
  59742. /**
  59743. * Remove one of the post process from the list of attached post processes to the texture
  59744. * @param postProcess define the post process to remove from the list
  59745. */
  59746. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  59747. if (!this._postProcesses) {
  59748. return;
  59749. }
  59750. var index = this._postProcesses.indexOf(postProcess);
  59751. if (index === -1) {
  59752. return;
  59753. }
  59754. this._postProcesses.splice(index, 1);
  59755. if (this._postProcesses.length > 0) {
  59756. this._postProcesses[0].autoClear = false;
  59757. }
  59758. };
  59759. /** @hidden */
  59760. RenderTargetTexture.prototype._shouldRender = function () {
  59761. if (this._currentRefreshId === -1) { // At least render once
  59762. this._currentRefreshId = 1;
  59763. return true;
  59764. }
  59765. if (this.refreshRate === this._currentRefreshId) {
  59766. this._currentRefreshId = 1;
  59767. return true;
  59768. }
  59769. this._currentRefreshId++;
  59770. return false;
  59771. };
  59772. /**
  59773. * Gets the actual render size of the texture.
  59774. * @returns the width of the render size
  59775. */
  59776. RenderTargetTexture.prototype.getRenderSize = function () {
  59777. return this.getRenderWidth();
  59778. };
  59779. /**
  59780. * Gets the actual render width of the texture.
  59781. * @returns the width of the render size
  59782. */
  59783. RenderTargetTexture.prototype.getRenderWidth = function () {
  59784. if (this._size.width) {
  59785. return this._size.width;
  59786. }
  59787. return this._size;
  59788. };
  59789. /**
  59790. * Gets the actual render height of the texture.
  59791. * @returns the height of the render size
  59792. */
  59793. RenderTargetTexture.prototype.getRenderHeight = function () {
  59794. if (this._size.width) {
  59795. return this._size.height;
  59796. }
  59797. return this._size;
  59798. };
  59799. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  59800. /**
  59801. * Get if the texture can be rescaled or not.
  59802. */
  59803. get: function () {
  59804. return true;
  59805. },
  59806. enumerable: true,
  59807. configurable: true
  59808. });
  59809. /**
  59810. * Resize the texture using a ratio.
  59811. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  59812. */
  59813. RenderTargetTexture.prototype.scale = function (ratio) {
  59814. var newSize = this.getRenderSize() * ratio;
  59815. this.resize(newSize);
  59816. };
  59817. /**
  59818. * Get the texture reflection matrix used to rotate/transform the reflection.
  59819. * @returns the reflection matrix
  59820. */
  59821. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  59822. if (this.isCube) {
  59823. return this._textureMatrix;
  59824. }
  59825. return _super.prototype.getReflectionTextureMatrix.call(this);
  59826. };
  59827. /**
  59828. * Resize the texture to a new desired size.
  59829. * Be carrefull as it will recreate all the data in the new texture.
  59830. * @param size Define the new size. It can be:
  59831. * - a number for squared texture,
  59832. * - an object containing { width: number, height: number }
  59833. * - or an object containing a ratio { ratio: number }
  59834. */
  59835. RenderTargetTexture.prototype.resize = function (size) {
  59836. this.releaseInternalTexture();
  59837. var scene = this.getScene();
  59838. if (!scene) {
  59839. return;
  59840. }
  59841. this._processSizeParameter(size);
  59842. if (this.isCube) {
  59843. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  59844. }
  59845. else {
  59846. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  59847. }
  59848. };
  59849. /**
  59850. * Renders all the objects from the render list into the texture.
  59851. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  59852. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  59853. */
  59854. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  59855. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  59856. if (dumpForDebug === void 0) { dumpForDebug = false; }
  59857. var scene = this.getScene();
  59858. if (!scene) {
  59859. return;
  59860. }
  59861. var engine = scene.getEngine();
  59862. if (this.useCameraPostProcesses !== undefined) {
  59863. useCameraPostProcess = this.useCameraPostProcesses;
  59864. }
  59865. if (this._waitingRenderList) {
  59866. this.renderList = [];
  59867. for (var index = 0; index < this._waitingRenderList.length; index++) {
  59868. var id = this._waitingRenderList[index];
  59869. var mesh_1 = scene.getMeshByID(id);
  59870. if (mesh_1) {
  59871. this.renderList.push(mesh_1);
  59872. }
  59873. }
  59874. delete this._waitingRenderList;
  59875. }
  59876. // Is predicate defined?
  59877. if (this.renderListPredicate) {
  59878. if (this.renderList) {
  59879. this.renderList.length = 0; // Clear previous renderList
  59880. }
  59881. else {
  59882. this.renderList = [];
  59883. }
  59884. var scene = this.getScene();
  59885. if (!scene) {
  59886. return;
  59887. }
  59888. var sceneMeshes = scene.meshes;
  59889. for (var index = 0; index < sceneMeshes.length; index++) {
  59890. var mesh = sceneMeshes[index];
  59891. if (this.renderListPredicate(mesh)) {
  59892. this.renderList.push(mesh);
  59893. }
  59894. }
  59895. }
  59896. this.onBeforeBindObservable.notifyObservers(this);
  59897. // Set custom projection.
  59898. // Needs to be before binding to prevent changing the aspect ratio.
  59899. var camera;
  59900. if (this.activeCamera) {
  59901. camera = this.activeCamera;
  59902. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  59903. if (this.activeCamera !== scene.activeCamera) {
  59904. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  59905. }
  59906. }
  59907. else {
  59908. camera = scene.activeCamera;
  59909. if (camera) {
  59910. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  59911. }
  59912. }
  59913. // Prepare renderingManager
  59914. this._renderingManager.reset();
  59915. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  59916. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  59917. var sceneRenderId = scene.getRenderId();
  59918. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  59919. var mesh = currentRenderList[meshIndex];
  59920. if (mesh) {
  59921. if (!mesh.isReady(this.refreshRate === 0)) {
  59922. this.resetRefreshCounter();
  59923. continue;
  59924. }
  59925. mesh._preActivateForIntermediateRendering(sceneRenderId);
  59926. var isMasked = void 0;
  59927. if (!this.renderList && camera) {
  59928. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  59929. }
  59930. else {
  59931. isMasked = false;
  59932. }
  59933. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  59934. mesh._activate(sceneRenderId);
  59935. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  59936. var subMesh = mesh.subMeshes[subIndex];
  59937. scene._activeIndices.addCount(subMesh.indexCount, false);
  59938. this._renderingManager.dispatch(subMesh, mesh);
  59939. }
  59940. }
  59941. }
  59942. }
  59943. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  59944. var particleSystem = scene.particleSystems[particleIndex];
  59945. var emitter = particleSystem.emitter;
  59946. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  59947. continue;
  59948. }
  59949. if (currentRenderList.indexOf(emitter) >= 0) {
  59950. this._renderingManager.dispatchParticles(particleSystem);
  59951. }
  59952. }
  59953. if (this.isCube) {
  59954. for (var face = 0; face < 6; face++) {
  59955. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  59956. scene.incrementRenderId();
  59957. scene.resetCachedMaterial();
  59958. }
  59959. }
  59960. else {
  59961. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  59962. }
  59963. this.onAfterUnbindObservable.notifyObservers(this);
  59964. if (scene.activeCamera) {
  59965. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  59966. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  59967. }
  59968. engine.setViewport(scene.activeCamera.viewport);
  59969. }
  59970. scene.resetCachedMaterial();
  59971. };
  59972. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  59973. var minimum = 128;
  59974. var x = renderDimension * scale;
  59975. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  59976. // Ensure we don't exceed the render dimension (while staying POT)
  59977. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  59978. };
  59979. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  59980. var _this = this;
  59981. if (!this._texture) {
  59982. return;
  59983. }
  59984. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  59985. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  59986. });
  59987. };
  59988. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  59989. var scene = this.getScene();
  59990. if (!scene) {
  59991. return;
  59992. }
  59993. var engine = scene.getEngine();
  59994. if (!this._texture) {
  59995. return;
  59996. }
  59997. // Bind
  59998. if (this._postProcessManager) {
  59999. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  60000. }
  60001. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  60002. if (this._texture) {
  60003. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  60004. }
  60005. }
  60006. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  60007. // Clear
  60008. if (this.onClearObservable.hasObservers()) {
  60009. this.onClearObservable.notifyObservers(engine);
  60010. }
  60011. else {
  60012. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  60013. }
  60014. if (!this._doNotChangeAspectRatio) {
  60015. scene.updateTransformMatrix(true);
  60016. }
  60017. // Before Camera Draw
  60018. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  60019. var step = _a[_i];
  60020. step.action(this);
  60021. }
  60022. // Render
  60023. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  60024. // After Camera Draw
  60025. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  60026. var step = _c[_b];
  60027. step.action(this);
  60028. }
  60029. if (this._postProcessManager) {
  60030. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  60031. }
  60032. else if (useCameraPostProcess) {
  60033. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  60034. }
  60035. if (!this._doNotChangeAspectRatio) {
  60036. scene.updateTransformMatrix(true);
  60037. }
  60038. // Dump ?
  60039. if (dumpForDebug) {
  60040. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  60041. }
  60042. // Unbind
  60043. if (!this.isCube || faceIndex === 5) {
  60044. if (this.isCube) {
  60045. if (faceIndex === 5) {
  60046. engine.generateMipMapsForCubemap(this._texture);
  60047. }
  60048. }
  60049. this.unbindFrameBuffer(engine, faceIndex);
  60050. }
  60051. else {
  60052. this.onAfterRenderObservable.notifyObservers(faceIndex);
  60053. }
  60054. };
  60055. /**
  60056. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  60057. * This allowed control for front to back rendering or reversly depending of the special needs.
  60058. *
  60059. * @param renderingGroupId The rendering group id corresponding to its index
  60060. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  60061. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  60062. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  60063. */
  60064. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  60065. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  60066. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  60067. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  60068. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  60069. };
  60070. /**
  60071. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  60072. *
  60073. * @param renderingGroupId The rendering group id corresponding to its index
  60074. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60075. */
  60076. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  60077. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  60078. this._renderingManager._useSceneAutoClearSetup = false;
  60079. };
  60080. /**
  60081. * Clones the texture.
  60082. * @returns the cloned texture
  60083. */
  60084. RenderTargetTexture.prototype.clone = function () {
  60085. var textureSize = this.getSize();
  60086. 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);
  60087. // Base texture
  60088. newTexture.hasAlpha = this.hasAlpha;
  60089. newTexture.level = this.level;
  60090. // RenderTarget Texture
  60091. newTexture.coordinatesMode = this.coordinatesMode;
  60092. if (this.renderList) {
  60093. newTexture.renderList = this.renderList.slice(0);
  60094. }
  60095. return newTexture;
  60096. };
  60097. /**
  60098. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  60099. * @returns The JSON representation of the texture
  60100. */
  60101. RenderTargetTexture.prototype.serialize = function () {
  60102. if (!this.name) {
  60103. return null;
  60104. }
  60105. var serializationObject = _super.prototype.serialize.call(this);
  60106. serializationObject.renderTargetSize = this.getRenderSize();
  60107. serializationObject.renderList = [];
  60108. if (this.renderList) {
  60109. for (var index = 0; index < this.renderList.length; index++) {
  60110. serializationObject.renderList.push(this.renderList[index].id);
  60111. }
  60112. }
  60113. return serializationObject;
  60114. };
  60115. /**
  60116. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  60117. */
  60118. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  60119. var objBuffer = this.getInternalTexture();
  60120. var scene = this.getScene();
  60121. if (objBuffer && scene) {
  60122. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  60123. }
  60124. };
  60125. /**
  60126. * Dispose the texture and release its associated resources.
  60127. */
  60128. RenderTargetTexture.prototype.dispose = function () {
  60129. if (this._postProcessManager) {
  60130. this._postProcessManager.dispose();
  60131. this._postProcessManager = null;
  60132. }
  60133. this.clearPostProcesses(true);
  60134. if (this._resizeObserver) {
  60135. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  60136. this._resizeObserver = null;
  60137. }
  60138. this.renderList = null;
  60139. // Remove from custom render targets
  60140. var scene = this.getScene();
  60141. if (!scene) {
  60142. return;
  60143. }
  60144. var index = scene.customRenderTargets.indexOf(this);
  60145. if (index >= 0) {
  60146. scene.customRenderTargets.splice(index, 1);
  60147. }
  60148. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  60149. var camera = _a[_i];
  60150. index = camera.customRenderTargets.indexOf(this);
  60151. if (index >= 0) {
  60152. camera.customRenderTargets.splice(index, 1);
  60153. }
  60154. }
  60155. _super.prototype.dispose.call(this);
  60156. };
  60157. /** @hidden */
  60158. RenderTargetTexture.prototype._rebuild = function () {
  60159. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  60160. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  60161. }
  60162. if (this._postProcessManager) {
  60163. this._postProcessManager._rebuild();
  60164. }
  60165. };
  60166. /**
  60167. * Clear the info related to rendering groups preventing retention point in material dispose.
  60168. */
  60169. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  60170. if (this._renderingManager) {
  60171. this._renderingManager.freeRenderingGroups();
  60172. }
  60173. };
  60174. /**
  60175. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  60176. */
  60177. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  60178. /**
  60179. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  60180. */
  60181. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  60182. /**
  60183. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  60184. * the central point of your effect and can save a lot of performances.
  60185. */
  60186. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  60187. return RenderTargetTexture;
  60188. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  60189. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  60190. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  60191. };
  60192. /***/ }),
  60193. /***/ "./Materials/Textures/texture.ts":
  60194. /*!***************************************!*\
  60195. !*** ./Materials/Textures/texture.ts ***!
  60196. \***************************************/
  60197. /*! exports provided: Texture */
  60198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60199. "use strict";
  60200. __webpack_require__.r(__webpack_exports__);
  60201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  60202. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60203. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  60204. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60205. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60206. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60207. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  60208. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60209. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  60210. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  60211. /**
  60212. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  60213. * @see http://doc.babylonjs.com/babylon101/materials#texture
  60214. */
  60215. var Texture = /** @class */ (function (_super) {
  60216. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  60217. /**
  60218. * Instantiates a new texture.
  60219. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  60220. * @see http://doc.babylonjs.com/babylon101/materials#texture
  60221. * @param url define the url of the picture to load as a texture
  60222. * @param scene define the scene the texture will belong to
  60223. * @param noMipmap define if the texture will require mip maps or not
  60224. * @param invertY define if the texture needs to be inverted on the y axis during loading
  60225. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  60226. * @param onLoad define a callback triggered when the texture has been loaded
  60227. * @param onError define a callback triggered when an error occurred during the loading session
  60228. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  60229. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  60230. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  60231. */
  60232. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  60233. if (noMipmap === void 0) { noMipmap = false; }
  60234. if (invertY === void 0) { invertY = true; }
  60235. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  60236. if (onLoad === void 0) { onLoad = null; }
  60237. if (onError === void 0) { onError = null; }
  60238. if (buffer === void 0) { buffer = null; }
  60239. if (deleteBuffer === void 0) { deleteBuffer = false; }
  60240. var _this = _super.call(this, scene) || this;
  60241. /**
  60242. * Define an offset on the texture to offset the u coordinates of the UVs
  60243. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  60244. */
  60245. _this.uOffset = 0;
  60246. /**
  60247. * Define an offset on the texture to offset the v coordinates of the UVs
  60248. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  60249. */
  60250. _this.vOffset = 0;
  60251. /**
  60252. * Define an offset on the texture to scale the u coordinates of the UVs
  60253. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  60254. */
  60255. _this.uScale = 1.0;
  60256. /**
  60257. * Define an offset on the texture to scale the v coordinates of the UVs
  60258. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  60259. */
  60260. _this.vScale = 1.0;
  60261. /**
  60262. * Define an offset on the texture to rotate around the u coordinates of the UVs
  60263. * @see http://doc.babylonjs.com/how_to/more_materials
  60264. */
  60265. _this.uAng = 0;
  60266. /**
  60267. * Define an offset on the texture to rotate around the v coordinates of the UVs
  60268. * @see http://doc.babylonjs.com/how_to/more_materials
  60269. */
  60270. _this.vAng = 0;
  60271. /**
  60272. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  60273. * @see http://doc.babylonjs.com/how_to/more_materials
  60274. */
  60275. _this.wAng = 0;
  60276. /**
  60277. * Defines the center of rotation (U)
  60278. */
  60279. _this.uRotationCenter = 0.5;
  60280. /**
  60281. * Defines the center of rotation (V)
  60282. */
  60283. _this.vRotationCenter = 0.5;
  60284. /**
  60285. * Defines the center of rotation (W)
  60286. */
  60287. _this.wRotationCenter = 0.5;
  60288. /** @hidden */
  60289. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  60290. /**
  60291. * Observable triggered once the texture has been loaded.
  60292. */
  60293. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  60294. _this._isBlocking = true;
  60295. _this.name = url || "";
  60296. _this.url = url;
  60297. _this._noMipmap = noMipmap;
  60298. _this._invertY = invertY;
  60299. _this._initialSamplingMode = samplingMode;
  60300. _this._buffer = buffer;
  60301. _this._deleteBuffer = deleteBuffer;
  60302. if (format) {
  60303. _this._format = format;
  60304. }
  60305. scene = _this.getScene();
  60306. if (!scene) {
  60307. return _this;
  60308. }
  60309. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  60310. var load = function () {
  60311. if (_this._texture && _this._texture._invertVScale) {
  60312. _this.vScale = -1;
  60313. }
  60314. if (_this.onLoadObservable.hasObservers()) {
  60315. _this.onLoadObservable.notifyObservers(_this);
  60316. }
  60317. if (onLoad) {
  60318. onLoad();
  60319. }
  60320. if (!_this.isBlocking && scene) {
  60321. scene.resetCachedMaterial();
  60322. }
  60323. };
  60324. if (!_this.url) {
  60325. _this._delayedOnLoad = load;
  60326. _this._delayedOnError = onError;
  60327. return _this;
  60328. }
  60329. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  60330. if (!_this._texture) {
  60331. if (!scene.useDelayedTextureLoading) {
  60332. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  60333. if (deleteBuffer) {
  60334. delete _this._buffer;
  60335. }
  60336. }
  60337. else {
  60338. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  60339. _this._delayedOnLoad = load;
  60340. _this._delayedOnError = onError;
  60341. }
  60342. }
  60343. else {
  60344. if (_this._texture.isReady) {
  60345. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  60346. }
  60347. else {
  60348. _this._texture.onLoadedObservable.add(load);
  60349. }
  60350. }
  60351. return _this;
  60352. }
  60353. Object.defineProperty(Texture.prototype, "noMipmap", {
  60354. /**
  60355. * Are mip maps generated for this texture or not.
  60356. */
  60357. get: function () {
  60358. return this._noMipmap;
  60359. },
  60360. enumerable: true,
  60361. configurable: true
  60362. });
  60363. Object.defineProperty(Texture.prototype, "isBlocking", {
  60364. get: function () {
  60365. return this._isBlocking;
  60366. },
  60367. /**
  60368. * Is the texture preventing material to render while loading.
  60369. * If false, a default texture will be used instead of the loading one during the preparation step.
  60370. */
  60371. set: function (value) {
  60372. this._isBlocking = value;
  60373. },
  60374. enumerable: true,
  60375. configurable: true
  60376. });
  60377. Object.defineProperty(Texture.prototype, "samplingMode", {
  60378. /**
  60379. * Get the current sampling mode associated with the texture.
  60380. */
  60381. get: function () {
  60382. if (!this._texture) {
  60383. return this._initialSamplingMode;
  60384. }
  60385. return this._texture.samplingMode;
  60386. },
  60387. enumerable: true,
  60388. configurable: true
  60389. });
  60390. Object.defineProperty(Texture.prototype, "invertY", {
  60391. /**
  60392. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  60393. */
  60394. get: function () {
  60395. return this._invertY;
  60396. },
  60397. enumerable: true,
  60398. configurable: true
  60399. });
  60400. /**
  60401. * Update the url (and optional buffer) of this texture if url was null during construction.
  60402. * @param url the url of the texture
  60403. * @param buffer the buffer of the texture (defaults to null)
  60404. * @param onLoad callback called when the texture is loaded (defaults to null)
  60405. */
  60406. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  60407. if (buffer === void 0) { buffer = null; }
  60408. if (this.url) {
  60409. this.releaseInternalTexture();
  60410. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  60411. }
  60412. this.url = url;
  60413. this._buffer = buffer;
  60414. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  60415. if (onLoad) {
  60416. this._delayedOnLoad = onLoad;
  60417. }
  60418. this.delayLoad();
  60419. };
  60420. /**
  60421. * Finish the loading sequence of a texture flagged as delayed load.
  60422. * @hidden
  60423. */
  60424. Texture.prototype.delayLoad = function () {
  60425. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  60426. return;
  60427. }
  60428. var scene = this.getScene();
  60429. if (!scene) {
  60430. return;
  60431. }
  60432. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  60433. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  60434. if (!this._texture) {
  60435. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  60436. if (this._deleteBuffer) {
  60437. delete this._buffer;
  60438. }
  60439. }
  60440. else {
  60441. if (this._delayedOnLoad) {
  60442. if (this._texture.isReady) {
  60443. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  60444. }
  60445. else {
  60446. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  60447. }
  60448. }
  60449. }
  60450. this._delayedOnLoad = null;
  60451. this._delayedOnError = null;
  60452. };
  60453. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  60454. x *= this.uScale;
  60455. y *= this.vScale;
  60456. x -= this.uRotationCenter * this.uScale;
  60457. y -= this.vRotationCenter * this.vScale;
  60458. z -= this.wRotationCenter;
  60459. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  60460. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  60461. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  60462. t.z += this.wRotationCenter;
  60463. };
  60464. /**
  60465. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  60466. * @returns the transform matrix of the texture.
  60467. */
  60468. Texture.prototype.getTextureMatrix = function () {
  60469. var _this = this;
  60470. if (this.uOffset === this._cachedUOffset &&
  60471. this.vOffset === this._cachedVOffset &&
  60472. this.uScale === this._cachedUScale &&
  60473. this.vScale === this._cachedVScale &&
  60474. this.uAng === this._cachedUAng &&
  60475. this.vAng === this._cachedVAng &&
  60476. this.wAng === this._cachedWAng) {
  60477. return this._cachedTextureMatrix;
  60478. }
  60479. this._cachedUOffset = this.uOffset;
  60480. this._cachedVOffset = this.vOffset;
  60481. this._cachedUScale = this.uScale;
  60482. this._cachedVScale = this.vScale;
  60483. this._cachedUAng = this.uAng;
  60484. this._cachedVAng = this.vAng;
  60485. this._cachedWAng = this.wAng;
  60486. if (!this._cachedTextureMatrix) {
  60487. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  60488. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  60489. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  60490. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  60491. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  60492. }
  60493. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  60494. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  60495. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  60496. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  60497. this._t1.subtractInPlace(this._t0);
  60498. this._t2.subtractInPlace(this._t0);
  60499. _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);
  60500. var scene = this.getScene();
  60501. if (!scene) {
  60502. return this._cachedTextureMatrix;
  60503. }
  60504. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  60505. return mat.hasTexture(_this);
  60506. });
  60507. return this._cachedTextureMatrix;
  60508. };
  60509. /**
  60510. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  60511. * @returns The reflection texture transform
  60512. */
  60513. Texture.prototype.getReflectionTextureMatrix = function () {
  60514. var _this = this;
  60515. var scene = this.getScene();
  60516. if (!scene) {
  60517. return this._cachedTextureMatrix;
  60518. }
  60519. if (this.uOffset === this._cachedUOffset &&
  60520. this.vOffset === this._cachedVOffset &&
  60521. this.uScale === this._cachedUScale &&
  60522. this.vScale === this._cachedVScale &&
  60523. this.coordinatesMode === this._cachedCoordinatesMode) {
  60524. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  60525. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  60526. return this._cachedTextureMatrix;
  60527. }
  60528. }
  60529. else {
  60530. return this._cachedTextureMatrix;
  60531. }
  60532. }
  60533. if (!this._cachedTextureMatrix) {
  60534. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  60535. }
  60536. if (!this._projectionModeMatrix) {
  60537. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  60538. }
  60539. this._cachedUOffset = this.uOffset;
  60540. this._cachedVOffset = this.vOffset;
  60541. this._cachedUScale = this.uScale;
  60542. this._cachedVScale = this.vScale;
  60543. this._cachedCoordinatesMode = this.coordinatesMode;
  60544. switch (this.coordinatesMode) {
  60545. case Texture.PLANAR_MODE:
  60546. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  60547. this._cachedTextureMatrix[0] = this.uScale;
  60548. this._cachedTextureMatrix[5] = this.vScale;
  60549. this._cachedTextureMatrix[12] = this.uOffset;
  60550. this._cachedTextureMatrix[13] = this.vOffset;
  60551. break;
  60552. case Texture.PROJECTION_MODE:
  60553. _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);
  60554. var projectionMatrix = scene.getProjectionMatrix();
  60555. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  60556. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  60557. break;
  60558. default:
  60559. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  60560. break;
  60561. }
  60562. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  60563. return (mat.getActiveTextures().indexOf(_this) !== -1);
  60564. });
  60565. return this._cachedTextureMatrix;
  60566. };
  60567. /**
  60568. * Clones the texture.
  60569. * @returns the cloned texture
  60570. */
  60571. Texture.prototype.clone = function () {
  60572. var _this = this;
  60573. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  60574. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  60575. }, this);
  60576. };
  60577. /**
  60578. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  60579. * @returns The JSON representation of the texture
  60580. */
  60581. Texture.prototype.serialize = function () {
  60582. var serializationObject = _super.prototype.serialize.call(this);
  60583. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  60584. serializationObject.base64String = this._buffer;
  60585. serializationObject.name = serializationObject.name.replace("data:", "");
  60586. }
  60587. serializationObject.invertY = this._invertY;
  60588. serializationObject.samplingMode = this.samplingMode;
  60589. return serializationObject;
  60590. };
  60591. /**
  60592. * Get the current class name of the texture useful for serialization or dynamic coding.
  60593. * @returns "Texture"
  60594. */
  60595. Texture.prototype.getClassName = function () {
  60596. return "Texture";
  60597. };
  60598. /**
  60599. * Dispose the texture and release its associated resources.
  60600. */
  60601. Texture.prototype.dispose = function () {
  60602. _super.prototype.dispose.call(this);
  60603. this.onLoadObservable.clear();
  60604. this._delayedOnLoad = null;
  60605. this._delayedOnError = null;
  60606. };
  60607. /**
  60608. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  60609. * @param parsedTexture Define the JSON representation of the texture
  60610. * @param scene Define the scene the parsed texture should be instantiated in
  60611. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60612. * @returns The parsed texture if successful
  60613. */
  60614. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  60615. if (parsedTexture.customType) {
  60616. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  60617. // Update Sampling Mode
  60618. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  60619. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  60620. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  60621. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  60622. }
  60623. }
  60624. return parsedCustomTexture;
  60625. }
  60626. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  60627. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  60628. }
  60629. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  60630. return null;
  60631. }
  60632. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  60633. var generateMipMaps = true;
  60634. if (parsedTexture.noMipmap) {
  60635. generateMipMaps = false;
  60636. }
  60637. if (parsedTexture.mirrorPlane) {
  60638. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  60639. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  60640. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  60641. return mirrorTexture;
  60642. }
  60643. else if (parsedTexture.isRenderTarget) {
  60644. var renderTargetTexture = null;
  60645. if (parsedTexture.isCube) {
  60646. // Search for an existing reflection probe (which contains a cube render target texture)
  60647. if (scene.reflectionProbes) {
  60648. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  60649. var probe = scene.reflectionProbes[index];
  60650. if (probe.name === parsedTexture.name) {
  60651. return probe.cubeTexture;
  60652. }
  60653. }
  60654. }
  60655. }
  60656. else {
  60657. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  60658. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  60659. }
  60660. return renderTargetTexture;
  60661. }
  60662. else {
  60663. var texture;
  60664. if (parsedTexture.base64String) {
  60665. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  60666. }
  60667. else {
  60668. var url = rootUrl + parsedTexture.name;
  60669. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  60670. url = parsedTexture.url;
  60671. }
  60672. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  60673. }
  60674. return texture;
  60675. }
  60676. }, parsedTexture, scene);
  60677. // Update Sampling Mode
  60678. if (parsedTexture.samplingMode) {
  60679. var sampling = parsedTexture.samplingMode;
  60680. if (texture && texture.samplingMode !== sampling) {
  60681. texture.updateSamplingMode(sampling);
  60682. }
  60683. }
  60684. // Animations
  60685. if (texture && parsedTexture.animations) {
  60686. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  60687. var parsedAnimation = parsedTexture.animations[animationIndex];
  60688. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  60689. if (internalClass) {
  60690. texture.animations.push(internalClass.Parse(parsedAnimation));
  60691. }
  60692. }
  60693. }
  60694. return texture;
  60695. };
  60696. /**
  60697. * Creates a texture from its base 64 representation.
  60698. * @param data Define the base64 payload without the data: prefix
  60699. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  60700. * @param scene Define the scene the texture should belong to
  60701. * @param noMipmap Forces the texture to not create mip map information if true
  60702. * @param invertY define if the texture needs to be inverted on the y axis during loading
  60703. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  60704. * @param onLoad define a callback triggered when the texture has been loaded
  60705. * @param onError define a callback triggered when an error occurred during the loading session
  60706. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  60707. * @returns the created texture
  60708. */
  60709. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  60710. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  60711. if (onLoad === void 0) { onLoad = null; }
  60712. if (onError === void 0) { onError = null; }
  60713. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  60714. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  60715. };
  60716. /**
  60717. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  60718. * @param data Define the base64 payload without the data: prefix
  60719. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  60720. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  60721. * @param scene Define the scene the texture should belong to
  60722. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  60723. * @param noMipmap Forces the texture to not create mip map information if true
  60724. * @param invertY define if the texture needs to be inverted on the y axis during loading
  60725. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  60726. * @param onLoad define a callback triggered when the texture has been loaded
  60727. * @param onError define a callback triggered when an error occurred during the loading session
  60728. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  60729. * @returns the created texture
  60730. */
  60731. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  60732. if (deleteBuffer === void 0) { deleteBuffer = false; }
  60733. if (noMipmap === void 0) { noMipmap = false; }
  60734. if (invertY === void 0) { invertY = true; }
  60735. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  60736. if (onLoad === void 0) { onLoad = null; }
  60737. if (onError === void 0) { onError = null; }
  60738. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  60739. if (name.substr(0, 5) !== "data:") {
  60740. name = "data:" + name;
  60741. }
  60742. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  60743. };
  60744. /** @hidden */
  60745. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  60746. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  60747. };
  60748. /** @hidden */
  60749. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  60750. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  60751. };
  60752. /** @hidden */
  60753. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  60754. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  60755. };
  60756. /** nearest is mag = nearest and min = nearest and mip = linear */
  60757. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  60758. /** nearest is mag = nearest and min = nearest and mip = linear */
  60759. 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
  60760. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60761. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  60762. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60763. 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
  60764. /** Trilinear is mag = linear and min = linear and mip = linear */
  60765. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  60766. /** Trilinear is mag = linear and min = linear and mip = linear */
  60767. 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
  60768. /** mag = nearest and min = nearest and mip = nearest */
  60769. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  60770. /** mag = nearest and min = linear and mip = nearest */
  60771. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  60772. /** mag = nearest and min = linear and mip = linear */
  60773. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  60774. /** mag = nearest and min = linear and mip = none */
  60775. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  60776. /** mag = nearest and min = nearest and mip = none */
  60777. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  60778. /** mag = linear and min = nearest and mip = nearest */
  60779. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  60780. /** mag = linear and min = nearest and mip = linear */
  60781. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  60782. /** mag = linear and min = linear and mip = none */
  60783. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  60784. /** mag = linear and min = nearest and mip = none */
  60785. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  60786. /** Explicit coordinates mode */
  60787. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  60788. /** Spherical coordinates mode */
  60789. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  60790. /** Planar coordinates mode */
  60791. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  60792. /** Cubic coordinates mode */
  60793. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  60794. /** Projection coordinates mode */
  60795. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  60796. /** Inverse Cubic coordinates mode */
  60797. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  60798. /** Inverse Cubic coordinates mode */
  60799. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  60800. /** Equirectangular coordinates mode */
  60801. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  60802. /** Equirectangular Fixed coordinates mode */
  60803. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  60804. /** Equirectangular Fixed Mirrored coordinates mode */
  60805. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  60806. /** Texture is not repeating outside of 0..1 UVs */
  60807. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  60808. /** Texture is repeating outside of 0..1 UVs */
  60809. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  60810. /** Texture is repeating and mirrored */
  60811. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  60812. /**
  60813. * 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
  60814. */
  60815. Texture.UseSerializedUrlIfAny = false;
  60816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60818. ], Texture.prototype, "url", void 0);
  60819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60821. ], Texture.prototype, "uOffset", void 0);
  60822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60824. ], Texture.prototype, "vOffset", void 0);
  60825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60827. ], Texture.prototype, "uScale", void 0);
  60828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60830. ], Texture.prototype, "vScale", void 0);
  60831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60833. ], Texture.prototype, "uAng", void 0);
  60834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60836. ], Texture.prototype, "vAng", void 0);
  60837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60839. ], Texture.prototype, "wAng", void 0);
  60840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60842. ], Texture.prototype, "uRotationCenter", void 0);
  60843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60845. ], Texture.prototype, "vRotationCenter", void 0);
  60846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60848. ], Texture.prototype, "wRotationCenter", void 0);
  60849. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60851. ], Texture.prototype, "isBlocking", null);
  60852. return Texture;
  60853. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  60854. // References the dependencies.
  60855. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  60856. /***/ }),
  60857. /***/ "./Materials/Textures/videoTexture.ts":
  60858. /*!********************************************!*\
  60859. !*** ./Materials/Textures/videoTexture.ts ***!
  60860. \********************************************/
  60861. /*! exports provided: VideoTexture */
  60862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60863. "use strict";
  60864. __webpack_require__.r(__webpack_exports__);
  60865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  60866. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60867. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60868. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60869. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  60870. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60871. /**
  60872. * If you want to display a video in your scene, this is the special texture for that.
  60873. * This special texture works similar to other textures, with the exception of a few parameters.
  60874. * @see https://doc.babylonjs.com/how_to/video_texture
  60875. */
  60876. var VideoTexture = /** @class */ (function (_super) {
  60877. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  60878. /**
  60879. * Creates a video texture.
  60880. * If you want to display a video in your scene, this is the special texture for that.
  60881. * This special texture works similar to other textures, with the exception of a few parameters.
  60882. * @see https://doc.babylonjs.com/how_to/video_texture
  60883. * @param name optional name, will detect from video source, if not defined
  60884. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  60885. * @param scene is obviously the current scene.
  60886. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  60887. * @param invertY is false by default but can be used to invert video on Y axis
  60888. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  60889. * @param settings allows finer control over video usage
  60890. */
  60891. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  60892. if (generateMipMaps === void 0) { generateMipMaps = false; }
  60893. if (invertY === void 0) { invertY = false; }
  60894. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60895. if (settings === void 0) { settings = {
  60896. autoPlay: true,
  60897. loop: true,
  60898. autoUpdateTexture: true,
  60899. }; }
  60900. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  60901. _this._onUserActionRequestedObservable = null;
  60902. _this._stillImageCaptured = false;
  60903. _this._displayingPosterTexture = false;
  60904. _this._createInternalTexture = function () {
  60905. if (_this._texture != null) {
  60906. if (_this._displayingPosterTexture) {
  60907. _this._texture.dispose();
  60908. _this._displayingPosterTexture = false;
  60909. }
  60910. else {
  60911. return;
  60912. }
  60913. }
  60914. if (!_this._engine.needPOTTextures ||
  60915. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  60916. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  60917. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  60918. }
  60919. else {
  60920. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60921. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60922. _this._generateMipMaps = false;
  60923. }
  60924. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  60925. if (!_this.video.autoplay && !_this._settings.poster) {
  60926. var oldHandler_1 = _this.video.onplaying;
  60927. var error_1 = false;
  60928. var oldMuted_1 = _this.video.muted;
  60929. _this.video.muted = true;
  60930. _this.video.onplaying = function () {
  60931. _this.video.muted = oldMuted_1;
  60932. _this.video.onplaying = oldHandler_1;
  60933. _this._texture.isReady = true;
  60934. _this._updateInternalTexture();
  60935. if (!error_1) {
  60936. _this.video.pause();
  60937. }
  60938. if (_this.onLoadObservable.hasObservers()) {
  60939. _this.onLoadObservable.notifyObservers(_this);
  60940. }
  60941. };
  60942. var playing = _this.video.play();
  60943. if (playing) {
  60944. playing.then(function () {
  60945. // Everything is good.
  60946. })
  60947. .catch(function () {
  60948. error_1 = true;
  60949. // On Chrome for instance, new policies might prevent playing without user interaction.
  60950. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  60951. _this._onUserActionRequestedObservable.notifyObservers(_this);
  60952. }
  60953. });
  60954. }
  60955. else {
  60956. _this.video.onplaying = oldHandler_1;
  60957. _this._texture.isReady = true;
  60958. _this._updateInternalTexture();
  60959. if (_this.onLoadObservable.hasObservers()) {
  60960. _this.onLoadObservable.notifyObservers(_this);
  60961. }
  60962. }
  60963. }
  60964. else {
  60965. _this._texture.isReady = true;
  60966. _this._updateInternalTexture();
  60967. if (_this.onLoadObservable.hasObservers()) {
  60968. _this.onLoadObservable.notifyObservers(_this);
  60969. }
  60970. }
  60971. };
  60972. _this.reset = function () {
  60973. if (_this._texture == null) {
  60974. return;
  60975. }
  60976. if (!_this._displayingPosterTexture) {
  60977. _this._texture.dispose();
  60978. _this._texture = null;
  60979. }
  60980. };
  60981. _this._updateInternalTexture = function () {
  60982. if (_this._texture == null || !_this._texture.isReady) {
  60983. return;
  60984. }
  60985. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  60986. return;
  60987. }
  60988. if (_this._displayingPosterTexture) {
  60989. return;
  60990. }
  60991. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  60992. };
  60993. _this._engine = _this.getScene().getEngine();
  60994. _this._generateMipMaps = generateMipMaps;
  60995. _this._initialSamplingMode = samplingMode;
  60996. _this.autoUpdateTexture = settings.autoUpdateTexture;
  60997. _this.name = name || _this._getName(src);
  60998. _this.video = _this._getVideo(src);
  60999. _this._settings = settings;
  61000. if (settings.poster) {
  61001. _this.video.poster = settings.poster;
  61002. }
  61003. if (settings.autoPlay !== undefined) {
  61004. _this.video.autoplay = settings.autoPlay;
  61005. }
  61006. if (settings.loop !== undefined) {
  61007. _this.video.loop = settings.loop;
  61008. }
  61009. _this.video.setAttribute("playsinline", "");
  61010. _this.video.addEventListener("paused", _this._updateInternalTexture);
  61011. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  61012. _this.video.addEventListener("emptied", _this.reset);
  61013. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  61014. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  61015. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  61016. if (settings.poster &&
  61017. (!settings.autoPlay || !videoHasEnoughData)) {
  61018. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  61019. _this._displayingPosterTexture = true;
  61020. }
  61021. else if (videoHasEnoughData) {
  61022. _this._createInternalTexture();
  61023. }
  61024. return _this;
  61025. }
  61026. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  61027. /**
  61028. * Event triggerd when a dom action is required by the user to play the video.
  61029. * This happens due to recent changes in browser policies preventing video to auto start.
  61030. */
  61031. get: function () {
  61032. if (!this._onUserActionRequestedObservable) {
  61033. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  61034. }
  61035. return this._onUserActionRequestedObservable;
  61036. },
  61037. enumerable: true,
  61038. configurable: true
  61039. });
  61040. VideoTexture.prototype._getName = function (src) {
  61041. if (src instanceof HTMLVideoElement) {
  61042. return src.currentSrc;
  61043. }
  61044. if (typeof src === "object") {
  61045. return src.toString();
  61046. }
  61047. return src;
  61048. };
  61049. VideoTexture.prototype._getVideo = function (src) {
  61050. if (src instanceof HTMLVideoElement) {
  61051. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  61052. return src;
  61053. }
  61054. var video = document.createElement("video");
  61055. if (typeof src === "string") {
  61056. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  61057. video.src = src;
  61058. }
  61059. else {
  61060. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  61061. src.forEach(function (url) {
  61062. var source = document.createElement("source");
  61063. source.src = url;
  61064. video.appendChild(source);
  61065. });
  61066. }
  61067. return video;
  61068. };
  61069. /**
  61070. * @hidden Internal method to initiate `update`.
  61071. */
  61072. VideoTexture.prototype._rebuild = function () {
  61073. this.update();
  61074. };
  61075. /**
  61076. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  61077. */
  61078. VideoTexture.prototype.update = function () {
  61079. if (!this.autoUpdateTexture) {
  61080. // Expecting user to call `updateTexture` manually
  61081. return;
  61082. }
  61083. this.updateTexture(true);
  61084. };
  61085. /**
  61086. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  61087. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  61088. */
  61089. VideoTexture.prototype.updateTexture = function (isVisible) {
  61090. if (!isVisible) {
  61091. return;
  61092. }
  61093. if (this.video.paused && this._stillImageCaptured) {
  61094. return;
  61095. }
  61096. this._stillImageCaptured = true;
  61097. this._updateInternalTexture();
  61098. };
  61099. /**
  61100. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  61101. * @param url New url.
  61102. */
  61103. VideoTexture.prototype.updateURL = function (url) {
  61104. this.video.src = url;
  61105. };
  61106. /**
  61107. * Dispose the texture and release its associated resources.
  61108. */
  61109. VideoTexture.prototype.dispose = function () {
  61110. _super.prototype.dispose.call(this);
  61111. if (this._onUserActionRequestedObservable) {
  61112. this._onUserActionRequestedObservable.clear();
  61113. this._onUserActionRequestedObservable = null;
  61114. }
  61115. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  61116. this.video.removeEventListener("paused", this._updateInternalTexture);
  61117. this.video.removeEventListener("seeked", this._updateInternalTexture);
  61118. this.video.removeEventListener("emptied", this.reset);
  61119. this.video.pause();
  61120. };
  61121. /**
  61122. * Creates a video texture straight from a stream.
  61123. * @param scene Define the scene the texture should be created in
  61124. * @param stream Define the stream the texture should be created from
  61125. * @returns The created video texture as a promise
  61126. */
  61127. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  61128. var video = document.createElement("video");
  61129. video.setAttribute('autoplay', '');
  61130. video.setAttribute('muted', 'true');
  61131. video.setAttribute('playsinline', '');
  61132. video.muted = true;
  61133. if (video.mozSrcObject !== undefined) {
  61134. // hack for Firefox < 19
  61135. video.mozSrcObject = stream;
  61136. }
  61137. else {
  61138. if (typeof video.srcObject == "object") {
  61139. video.srcObject = stream;
  61140. }
  61141. else {
  61142. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  61143. video.src = (window.URL && window.URL.createObjectURL(stream));
  61144. }
  61145. }
  61146. return new Promise(function (resolve) {
  61147. var onPlaying = function () {
  61148. resolve(new VideoTexture("video", video, scene, true, true));
  61149. video.removeEventListener("playing", onPlaying);
  61150. };
  61151. video.addEventListener("playing", onPlaying);
  61152. video.play();
  61153. });
  61154. };
  61155. /**
  61156. * Creates a video texture straight from your WebCam video feed.
  61157. * @param scene Define the scene the texture should be created in
  61158. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  61159. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  61160. * @returns The created video texture as a promise
  61161. */
  61162. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  61163. var _this = this;
  61164. if (audioConstaints === void 0) { audioConstaints = false; }
  61165. var constraintsDeviceId;
  61166. if (constraints && constraints.deviceId) {
  61167. constraintsDeviceId = {
  61168. exact: constraints.deviceId,
  61169. };
  61170. }
  61171. if (navigator.mediaDevices) {
  61172. return navigator.mediaDevices.getUserMedia({
  61173. video: constraints,
  61174. audio: audioConstaints
  61175. })
  61176. .then(function (stream) {
  61177. return _this.CreateFromStreamAsync(scene, stream);
  61178. });
  61179. }
  61180. else {
  61181. navigator.getUserMedia =
  61182. navigator.getUserMedia ||
  61183. navigator.webkitGetUserMedia ||
  61184. navigator.mozGetUserMedia ||
  61185. navigator.msGetUserMedia;
  61186. if (navigator.getUserMedia) {
  61187. navigator.getUserMedia({
  61188. video: {
  61189. deviceId: constraintsDeviceId,
  61190. width: {
  61191. min: (constraints && constraints.minWidth) || 256,
  61192. max: (constraints && constraints.maxWidth) || 640,
  61193. },
  61194. height: {
  61195. min: (constraints && constraints.minHeight) || 256,
  61196. max: (constraints && constraints.maxHeight) || 480,
  61197. },
  61198. },
  61199. audio: audioConstaints
  61200. }, function (stream) {
  61201. return _this.CreateFromStreamAsync(scene, stream);
  61202. }, function (e) {
  61203. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  61204. });
  61205. }
  61206. }
  61207. return Promise.reject("No support for userMedia on this device");
  61208. };
  61209. /**
  61210. * Creates a video texture straight from your WebCam video feed.
  61211. * @param scene Define the scene the texture should be created in
  61212. * @param onReady Define a callback to triggered once the texture will be ready
  61213. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  61214. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  61215. */
  61216. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  61217. if (audioConstaints === void 0) { audioConstaints = false; }
  61218. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  61219. .then(function (videoTexture) {
  61220. if (onReady) {
  61221. onReady(videoTexture);
  61222. }
  61223. })
  61224. .catch(function (err) {
  61225. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  61226. });
  61227. };
  61228. return VideoTexture;
  61229. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  61230. /***/ }),
  61231. /***/ "./Materials/colorCurves.ts":
  61232. /*!**********************************!*\
  61233. !*** ./Materials/colorCurves.ts ***!
  61234. \**********************************/
  61235. /*! exports provided: ColorCurves */
  61236. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61237. "use strict";
  61238. __webpack_require__.r(__webpack_exports__);
  61239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  61240. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61241. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61242. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61243. /**
  61244. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61245. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61246. * 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;
  61247. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61248. */
  61249. var ColorCurves = /** @class */ (function () {
  61250. function ColorCurves() {
  61251. this._dirty = true;
  61252. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61253. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61254. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61255. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61256. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61257. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61258. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  61259. this._globalHue = 30;
  61260. this._globalDensity = 0;
  61261. this._globalSaturation = 0;
  61262. this._globalExposure = 0;
  61263. this._highlightsHue = 30;
  61264. this._highlightsDensity = 0;
  61265. this._highlightsSaturation = 0;
  61266. this._highlightsExposure = 0;
  61267. this._midtonesHue = 30;
  61268. this._midtonesDensity = 0;
  61269. this._midtonesSaturation = 0;
  61270. this._midtonesExposure = 0;
  61271. this._shadowsHue = 30;
  61272. this._shadowsDensity = 0;
  61273. this._shadowsSaturation = 0;
  61274. this._shadowsExposure = 0;
  61275. }
  61276. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  61277. /**
  61278. * Gets the global Hue value.
  61279. * 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).
  61280. */
  61281. get: function () {
  61282. return this._globalHue;
  61283. },
  61284. /**
  61285. * Sets the global Hue value.
  61286. * 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).
  61287. */
  61288. set: function (value) {
  61289. this._globalHue = value;
  61290. this._dirty = true;
  61291. },
  61292. enumerable: true,
  61293. configurable: true
  61294. });
  61295. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  61296. /**
  61297. * Gets the global Density value.
  61298. * 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.
  61299. * Values less than zero provide a filter of opposite hue.
  61300. */
  61301. get: function () {
  61302. return this._globalDensity;
  61303. },
  61304. /**
  61305. * Sets the global Density value.
  61306. * 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.
  61307. * Values less than zero provide a filter of opposite hue.
  61308. */
  61309. set: function (value) {
  61310. this._globalDensity = value;
  61311. this._dirty = true;
  61312. },
  61313. enumerable: true,
  61314. configurable: true
  61315. });
  61316. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  61317. /**
  61318. * Gets the global Saturation value.
  61319. * 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.
  61320. */
  61321. get: function () {
  61322. return this._globalSaturation;
  61323. },
  61324. /**
  61325. * Sets the global Saturation value.
  61326. * 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.
  61327. */
  61328. set: function (value) {
  61329. this._globalSaturation = value;
  61330. this._dirty = true;
  61331. },
  61332. enumerable: true,
  61333. configurable: true
  61334. });
  61335. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  61336. /**
  61337. * Gets the global Exposure value.
  61338. * 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.
  61339. */
  61340. get: function () {
  61341. return this._globalExposure;
  61342. },
  61343. /**
  61344. * Sets the global Exposure value.
  61345. * 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.
  61346. */
  61347. set: function (value) {
  61348. this._globalExposure = value;
  61349. this._dirty = true;
  61350. },
  61351. enumerable: true,
  61352. configurable: true
  61353. });
  61354. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  61355. /**
  61356. * Gets the highlights Hue value.
  61357. * 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).
  61358. */
  61359. get: function () {
  61360. return this._highlightsHue;
  61361. },
  61362. /**
  61363. * Sets the highlights Hue value.
  61364. * 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).
  61365. */
  61366. set: function (value) {
  61367. this._highlightsHue = value;
  61368. this._dirty = true;
  61369. },
  61370. enumerable: true,
  61371. configurable: true
  61372. });
  61373. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  61374. /**
  61375. * Gets the highlights Density value.
  61376. * 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.
  61377. * Values less than zero provide a filter of opposite hue.
  61378. */
  61379. get: function () {
  61380. return this._highlightsDensity;
  61381. },
  61382. /**
  61383. * Sets the highlights Density value.
  61384. * 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.
  61385. * Values less than zero provide a filter of opposite hue.
  61386. */
  61387. set: function (value) {
  61388. this._highlightsDensity = value;
  61389. this._dirty = true;
  61390. },
  61391. enumerable: true,
  61392. configurable: true
  61393. });
  61394. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  61395. /**
  61396. * Gets the highlights Saturation value.
  61397. * 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.
  61398. */
  61399. get: function () {
  61400. return this._highlightsSaturation;
  61401. },
  61402. /**
  61403. * Sets the highlights Saturation value.
  61404. * 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.
  61405. */
  61406. set: function (value) {
  61407. this._highlightsSaturation = value;
  61408. this._dirty = true;
  61409. },
  61410. enumerable: true,
  61411. configurable: true
  61412. });
  61413. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  61414. /**
  61415. * Gets the highlights Exposure value.
  61416. * 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.
  61417. */
  61418. get: function () {
  61419. return this._highlightsExposure;
  61420. },
  61421. /**
  61422. * Sets the highlights Exposure value.
  61423. * 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.
  61424. */
  61425. set: function (value) {
  61426. this._highlightsExposure = value;
  61427. this._dirty = true;
  61428. },
  61429. enumerable: true,
  61430. configurable: true
  61431. });
  61432. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  61433. /**
  61434. * Gets the midtones Hue value.
  61435. * 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).
  61436. */
  61437. get: function () {
  61438. return this._midtonesHue;
  61439. },
  61440. /**
  61441. * Sets the midtones Hue value.
  61442. * 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).
  61443. */
  61444. set: function (value) {
  61445. this._midtonesHue = value;
  61446. this._dirty = true;
  61447. },
  61448. enumerable: true,
  61449. configurable: true
  61450. });
  61451. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  61452. /**
  61453. * Gets the midtones Density value.
  61454. * 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.
  61455. * Values less than zero provide a filter of opposite hue.
  61456. */
  61457. get: function () {
  61458. return this._midtonesDensity;
  61459. },
  61460. /**
  61461. * Sets the midtones Density value.
  61462. * 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.
  61463. * Values less than zero provide a filter of opposite hue.
  61464. */
  61465. set: function (value) {
  61466. this._midtonesDensity = value;
  61467. this._dirty = true;
  61468. },
  61469. enumerable: true,
  61470. configurable: true
  61471. });
  61472. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  61473. /**
  61474. * Gets the midtones Saturation value.
  61475. * 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.
  61476. */
  61477. get: function () {
  61478. return this._midtonesSaturation;
  61479. },
  61480. /**
  61481. * Sets the midtones Saturation value.
  61482. * 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.
  61483. */
  61484. set: function (value) {
  61485. this._midtonesSaturation = value;
  61486. this._dirty = true;
  61487. },
  61488. enumerable: true,
  61489. configurable: true
  61490. });
  61491. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  61492. /**
  61493. * Gets the midtones Exposure value.
  61494. * 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.
  61495. */
  61496. get: function () {
  61497. return this._midtonesExposure;
  61498. },
  61499. /**
  61500. * Sets the midtones Exposure value.
  61501. * 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.
  61502. */
  61503. set: function (value) {
  61504. this._midtonesExposure = value;
  61505. this._dirty = true;
  61506. },
  61507. enumerable: true,
  61508. configurable: true
  61509. });
  61510. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  61511. /**
  61512. * Gets the shadows Hue value.
  61513. * 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).
  61514. */
  61515. get: function () {
  61516. return this._shadowsHue;
  61517. },
  61518. /**
  61519. * Sets the shadows Hue value.
  61520. * 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).
  61521. */
  61522. set: function (value) {
  61523. this._shadowsHue = value;
  61524. this._dirty = true;
  61525. },
  61526. enumerable: true,
  61527. configurable: true
  61528. });
  61529. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  61530. /**
  61531. * Gets the shadows Density value.
  61532. * 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.
  61533. * Values less than zero provide a filter of opposite hue.
  61534. */
  61535. get: function () {
  61536. return this._shadowsDensity;
  61537. },
  61538. /**
  61539. * Sets the shadows Density value.
  61540. * 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.
  61541. * Values less than zero provide a filter of opposite hue.
  61542. */
  61543. set: function (value) {
  61544. this._shadowsDensity = value;
  61545. this._dirty = true;
  61546. },
  61547. enumerable: true,
  61548. configurable: true
  61549. });
  61550. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  61551. /**
  61552. * Gets the shadows Saturation value.
  61553. * 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.
  61554. */
  61555. get: function () {
  61556. return this._shadowsSaturation;
  61557. },
  61558. /**
  61559. * Sets the shadows Saturation value.
  61560. * 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.
  61561. */
  61562. set: function (value) {
  61563. this._shadowsSaturation = value;
  61564. this._dirty = true;
  61565. },
  61566. enumerable: true,
  61567. configurable: true
  61568. });
  61569. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  61570. /**
  61571. * Gets the shadows Exposure value.
  61572. * 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.
  61573. */
  61574. get: function () {
  61575. return this._shadowsExposure;
  61576. },
  61577. /**
  61578. * Sets the shadows Exposure value.
  61579. * 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.
  61580. */
  61581. set: function (value) {
  61582. this._shadowsExposure = value;
  61583. this._dirty = true;
  61584. },
  61585. enumerable: true,
  61586. configurable: true
  61587. });
  61588. /**
  61589. * Returns the class name
  61590. * @returns The class name
  61591. */
  61592. ColorCurves.prototype.getClassName = function () {
  61593. return "ColorCurves";
  61594. };
  61595. /**
  61596. * Binds the color curves to the shader.
  61597. * @param colorCurves The color curve to bind
  61598. * @param effect The effect to bind to
  61599. * @param positiveUniform The positive uniform shader parameter
  61600. * @param neutralUniform The neutral uniform shader parameter
  61601. * @param negativeUniform The negative uniform shader parameter
  61602. */
  61603. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  61604. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  61605. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  61606. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  61607. if (colorCurves._dirty) {
  61608. colorCurves._dirty = false;
  61609. // Fill in global info.
  61610. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  61611. // Compute highlights info.
  61612. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  61613. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  61614. // Compute midtones info.
  61615. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  61616. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  61617. // Compute shadows info.
  61618. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  61619. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  61620. // Compute deltas (neutral is midtones).
  61621. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  61622. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  61623. }
  61624. if (effect) {
  61625. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  61626. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  61627. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  61628. }
  61629. };
  61630. /**
  61631. * Prepare the list of uniforms associated with the ColorCurves effects.
  61632. * @param uniformsList The list of uniforms used in the effect
  61633. */
  61634. ColorCurves.PrepareUniforms = function (uniformsList) {
  61635. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  61636. };
  61637. /**
  61638. * Returns color grading data based on a hue, density, saturation and exposure value.
  61639. * @param filterHue The hue of the color filter.
  61640. * @param filterDensity The density of the color filter.
  61641. * @param saturation The saturation.
  61642. * @param exposure The exposure.
  61643. * @param result The result data container.
  61644. */
  61645. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  61646. if (hue == null) {
  61647. return;
  61648. }
  61649. hue = ColorCurves.clamp(hue, 0, 360);
  61650. density = ColorCurves.clamp(density, -100, 100);
  61651. saturation = ColorCurves.clamp(saturation, -100, 100);
  61652. exposure = ColorCurves.clamp(exposure, -100, 100);
  61653. // Remap the slider/config filter density with non-linear mapping and also scale by half
  61654. // so that the maximum filter density is only 50% control. This provides fine control
  61655. // for small values and reasonable range.
  61656. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  61657. density *= 0.5;
  61658. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  61659. if (density < 0) {
  61660. density *= -1;
  61661. hue = (hue + 180) % 360;
  61662. }
  61663. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  61664. result.scaleToRef(2, result);
  61665. result.a = 1 + 0.01 * saturation;
  61666. };
  61667. /**
  61668. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  61669. * @param value The input slider value in range [-100,100].
  61670. * @returns Adjusted value.
  61671. */
  61672. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  61673. value /= 100;
  61674. var x = Math.abs(value);
  61675. x = Math.pow(x, 2);
  61676. if (value < 0) {
  61677. x *= -1;
  61678. }
  61679. x *= 100;
  61680. return x;
  61681. };
  61682. /**
  61683. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  61684. * @param hue The hue (H) input.
  61685. * @param saturation The saturation (S) input.
  61686. * @param brightness The brightness (B) input.
  61687. * @result An RGBA color represented as Vector4.
  61688. */
  61689. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  61690. var h = ColorCurves.clamp(hue, 0, 360);
  61691. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  61692. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  61693. if (s === 0) {
  61694. result.r = v;
  61695. result.g = v;
  61696. result.b = v;
  61697. }
  61698. else {
  61699. // sector 0 to 5
  61700. h /= 60;
  61701. var i = Math.floor(h);
  61702. // fractional part of h
  61703. var f = h - i;
  61704. var p = v * (1 - s);
  61705. var q = v * (1 - s * f);
  61706. var t = v * (1 - s * (1 - f));
  61707. switch (i) {
  61708. case 0:
  61709. result.r = v;
  61710. result.g = t;
  61711. result.b = p;
  61712. break;
  61713. case 1:
  61714. result.r = q;
  61715. result.g = v;
  61716. result.b = p;
  61717. break;
  61718. case 2:
  61719. result.r = p;
  61720. result.g = v;
  61721. result.b = t;
  61722. break;
  61723. case 3:
  61724. result.r = p;
  61725. result.g = q;
  61726. result.b = v;
  61727. break;
  61728. case 4:
  61729. result.r = t;
  61730. result.g = p;
  61731. result.b = v;
  61732. break;
  61733. default: // case 5:
  61734. result.r = v;
  61735. result.g = p;
  61736. result.b = q;
  61737. break;
  61738. }
  61739. }
  61740. result.a = 1;
  61741. };
  61742. /**
  61743. * Returns a value clamped between min and max
  61744. * @param value The value to clamp
  61745. * @param min The minimum of value
  61746. * @param max The maximum of value
  61747. * @returns The clamped value.
  61748. */
  61749. ColorCurves.clamp = function (value, min, max) {
  61750. return Math.min(Math.max(value, min), max);
  61751. };
  61752. /**
  61753. * Clones the current color curve instance.
  61754. * @return The cloned curves
  61755. */
  61756. ColorCurves.prototype.clone = function () {
  61757. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  61758. };
  61759. /**
  61760. * Serializes the current color curve instance to a json representation.
  61761. * @return a JSON representation
  61762. */
  61763. ColorCurves.prototype.serialize = function () {
  61764. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  61765. };
  61766. /**
  61767. * Parses the color curve from a json representation.
  61768. * @param source the JSON source to parse
  61769. * @return The parsed curves
  61770. */
  61771. ColorCurves.Parse = function (source) {
  61772. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  61773. };
  61774. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61775. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61776. ], ColorCurves.prototype, "_globalHue", void 0);
  61777. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61778. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61779. ], ColorCurves.prototype, "_globalDensity", void 0);
  61780. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61781. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61782. ], ColorCurves.prototype, "_globalSaturation", void 0);
  61783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61785. ], ColorCurves.prototype, "_globalExposure", void 0);
  61786. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61787. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61788. ], ColorCurves.prototype, "_highlightsHue", void 0);
  61789. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61790. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61791. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  61792. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61793. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61794. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  61795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61797. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  61798. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61799. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61800. ], ColorCurves.prototype, "_midtonesHue", void 0);
  61801. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61802. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61803. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  61804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61806. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  61807. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61808. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61809. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  61810. return ColorCurves;
  61811. }());
  61812. // References the dependencies.
  61813. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  61814. /***/ }),
  61815. /***/ "./Materials/effect.ts":
  61816. /*!*****************************!*\
  61817. !*** ./Materials/effect.ts ***!
  61818. \*****************************/
  61819. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  61820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61821. "use strict";
  61822. __webpack_require__.r(__webpack_exports__);
  61823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  61824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  61825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  61826. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61827. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61828. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  61829. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  61830. /**
  61831. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  61832. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  61833. */
  61834. var EffectFallbacks = /** @class */ (function () {
  61835. function EffectFallbacks() {
  61836. this._defines = {};
  61837. this._currentRank = 32;
  61838. this._maxRank = -1;
  61839. }
  61840. /**
  61841. * Removes the fallback from the bound mesh.
  61842. */
  61843. EffectFallbacks.prototype.unBindMesh = function () {
  61844. this._mesh = null;
  61845. };
  61846. /**
  61847. * Adds a fallback on the specified property.
  61848. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  61849. * @param define The name of the define in the shader
  61850. */
  61851. EffectFallbacks.prototype.addFallback = function (rank, define) {
  61852. if (!this._defines[rank]) {
  61853. if (rank < this._currentRank) {
  61854. this._currentRank = rank;
  61855. }
  61856. if (rank > this._maxRank) {
  61857. this._maxRank = rank;
  61858. }
  61859. this._defines[rank] = new Array();
  61860. }
  61861. this._defines[rank].push(define);
  61862. };
  61863. /**
  61864. * Sets the mesh to use CPU skinning when needing to fallback.
  61865. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  61866. * @param mesh The mesh to use the fallbacks.
  61867. */
  61868. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  61869. this._mesh = mesh;
  61870. if (rank < this._currentRank) {
  61871. this._currentRank = rank;
  61872. }
  61873. if (rank > this._maxRank) {
  61874. this._maxRank = rank;
  61875. }
  61876. };
  61877. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  61878. /**
  61879. * Checks to see if more fallbacks are still availible.
  61880. */
  61881. get: function () {
  61882. return this._currentRank <= this._maxRank;
  61883. },
  61884. enumerable: true,
  61885. configurable: true
  61886. });
  61887. /**
  61888. * Removes the defines that shoould be removed when falling back.
  61889. * @param currentDefines defines the current define statements for the shader.
  61890. * @param effect defines the current effect we try to compile
  61891. * @returns The resulting defines with defines of the current rank removed.
  61892. */
  61893. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  61894. // First we try to switch to CPU skinning
  61895. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  61896. this._mesh.computeBonesUsingShaders = false;
  61897. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  61898. effect._bonesComputationForcedToCPU = true;
  61899. var scene = this._mesh.getScene();
  61900. for (var index = 0; index < scene.meshes.length; index++) {
  61901. var otherMesh = scene.meshes[index];
  61902. if (!otherMesh.material) {
  61903. continue;
  61904. }
  61905. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  61906. continue;
  61907. }
  61908. if (otherMesh.material.getEffect() === effect) {
  61909. otherMesh.computeBonesUsingShaders = false;
  61910. }
  61911. else if (otherMesh.subMeshes) {
  61912. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  61913. var subMesh = _a[_i];
  61914. var subMeshEffect = subMesh.effect;
  61915. if (subMeshEffect === effect) {
  61916. otherMesh.computeBonesUsingShaders = false;
  61917. break;
  61918. }
  61919. }
  61920. }
  61921. }
  61922. }
  61923. else {
  61924. var currentFallbacks = this._defines[this._currentRank];
  61925. if (currentFallbacks) {
  61926. for (var index = 0; index < currentFallbacks.length; index++) {
  61927. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  61928. }
  61929. }
  61930. this._currentRank++;
  61931. }
  61932. return currentDefines;
  61933. };
  61934. return EffectFallbacks;
  61935. }());
  61936. /**
  61937. * Options to be used when creating an effect.
  61938. */
  61939. var EffectCreationOptions = /** @class */ (function () {
  61940. function EffectCreationOptions() {
  61941. }
  61942. return EffectCreationOptions;
  61943. }());
  61944. /**
  61945. * Effect containing vertex and fragment shader that can be executed on an object.
  61946. */
  61947. var Effect = /** @class */ (function () {
  61948. /**
  61949. * Instantiates an effect.
  61950. * An effect can be used to create/manage/execute vertex and fragment shaders.
  61951. * @param baseName Name of the effect.
  61952. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  61953. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  61954. * @param samplers List of sampler variables that will be passed to the shader.
  61955. * @param engine Engine to be used to render the effect
  61956. * @param defines Define statements to be added to the shader.
  61957. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  61958. * @param onCompiled Callback that will be called when the shader is compiled.
  61959. * @param onError Callback that will be called if an error occurs during shader compilation.
  61960. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  61961. */
  61962. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  61963. if (samplers === void 0) { samplers = null; }
  61964. if (defines === void 0) { defines = null; }
  61965. if (fallbacks === void 0) { fallbacks = null; }
  61966. if (onCompiled === void 0) { onCompiled = null; }
  61967. if (onError === void 0) { onError = null; }
  61968. var _this = this;
  61969. /**
  61970. * Unique ID of the effect.
  61971. */
  61972. this.uniqueId = 0;
  61973. /**
  61974. * Observable that will be called when the shader is compiled.
  61975. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  61976. */
  61977. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  61978. /**
  61979. * Observable that will be called if an error occurs during shader compilation.
  61980. */
  61981. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  61982. /** @hidden */
  61983. this._bonesComputationForcedToCPU = false;
  61984. this._uniformBuffersNames = {};
  61985. this._isReady = false;
  61986. this._compilationError = "";
  61987. this.name = baseName;
  61988. if (attributesNamesOrOptions.attributes) {
  61989. var options = attributesNamesOrOptions;
  61990. this._engine = uniformsNamesOrEngine;
  61991. this._attributesNames = options.attributes;
  61992. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  61993. this._samplers = options.samplers.slice();
  61994. this.defines = options.defines;
  61995. this.onError = options.onError;
  61996. this.onCompiled = options.onCompiled;
  61997. this._fallbacks = options.fallbacks;
  61998. this._indexParameters = options.indexParameters;
  61999. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  62000. if (options.uniformBuffersNames) {
  62001. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  62002. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  62003. }
  62004. }
  62005. }
  62006. else {
  62007. this._engine = engine;
  62008. this.defines = defines;
  62009. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  62010. this._samplers = samplers ? samplers.slice() : [];
  62011. this._attributesNames = attributesNamesOrOptions;
  62012. this.onError = onError;
  62013. this.onCompiled = onCompiled;
  62014. this._indexParameters = indexParameters;
  62015. this._fallbacks = fallbacks;
  62016. }
  62017. this.uniqueId = Effect._uniqueIdSeed++;
  62018. var vertexSource;
  62019. var fragmentSource;
  62020. if (baseName.vertexElement) {
  62021. vertexSource = document.getElementById(baseName.vertexElement);
  62022. if (!vertexSource) {
  62023. vertexSource = baseName.vertexElement;
  62024. }
  62025. }
  62026. else {
  62027. vertexSource = baseName.vertex || baseName;
  62028. }
  62029. if (baseName.fragmentElement) {
  62030. fragmentSource = document.getElementById(baseName.fragmentElement);
  62031. if (!fragmentSource) {
  62032. fragmentSource = baseName.fragmentElement;
  62033. }
  62034. }
  62035. else {
  62036. fragmentSource = baseName.fragment || baseName;
  62037. }
  62038. this._loadVertexShader(vertexSource, function (vertexCode) {
  62039. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  62040. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  62041. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  62042. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  62043. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  62044. if (baseName) {
  62045. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  62046. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  62047. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  62048. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  62049. }
  62050. else {
  62051. _this._vertexSourceCode = migratedVertexCode;
  62052. _this._fragmentSourceCode = migratedFragmentCode;
  62053. }
  62054. _this._prepareEffect();
  62055. });
  62056. });
  62057. });
  62058. });
  62059. });
  62060. });
  62061. }
  62062. Object.defineProperty(Effect.prototype, "onBindObservable", {
  62063. /**
  62064. * Observable that will be called when effect is bound.
  62065. */
  62066. get: function () {
  62067. if (!this._onBindObservable) {
  62068. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62069. }
  62070. return this._onBindObservable;
  62071. },
  62072. enumerable: true,
  62073. configurable: true
  62074. });
  62075. Object.defineProperty(Effect.prototype, "key", {
  62076. /**
  62077. * Unique key for this effect
  62078. */
  62079. get: function () {
  62080. return this._key;
  62081. },
  62082. enumerable: true,
  62083. configurable: true
  62084. });
  62085. /**
  62086. * If the effect has been compiled and prepared.
  62087. * @returns if the effect is compiled and prepared.
  62088. */
  62089. Effect.prototype.isReady = function () {
  62090. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  62091. return this._engine._isProgramCompiled(this._program);
  62092. }
  62093. return this._isReady;
  62094. };
  62095. /**
  62096. * The engine the effect was initialized with.
  62097. * @returns the engine.
  62098. */
  62099. Effect.prototype.getEngine = function () {
  62100. return this._engine;
  62101. };
  62102. /**
  62103. * The compiled webGL program for the effect
  62104. * @returns the webGL program.
  62105. */
  62106. Effect.prototype.getProgram = function () {
  62107. return this._program;
  62108. };
  62109. /**
  62110. * The set of names of attribute variables for the shader.
  62111. * @returns An array of attribute names.
  62112. */
  62113. Effect.prototype.getAttributesNames = function () {
  62114. return this._attributesNames;
  62115. };
  62116. /**
  62117. * Returns the attribute at the given index.
  62118. * @param index The index of the attribute.
  62119. * @returns The location of the attribute.
  62120. */
  62121. Effect.prototype.getAttributeLocation = function (index) {
  62122. return this._attributes[index];
  62123. };
  62124. /**
  62125. * Returns the attribute based on the name of the variable.
  62126. * @param name of the attribute to look up.
  62127. * @returns the attribute location.
  62128. */
  62129. Effect.prototype.getAttributeLocationByName = function (name) {
  62130. var index = this._attributesNames.indexOf(name);
  62131. return this._attributes[index];
  62132. };
  62133. /**
  62134. * The number of attributes.
  62135. * @returns the numnber of attributes.
  62136. */
  62137. Effect.prototype.getAttributesCount = function () {
  62138. return this._attributes.length;
  62139. };
  62140. /**
  62141. * Gets the index of a uniform variable.
  62142. * @param uniformName of the uniform to look up.
  62143. * @returns the index.
  62144. */
  62145. Effect.prototype.getUniformIndex = function (uniformName) {
  62146. return this._uniformsNames.indexOf(uniformName);
  62147. };
  62148. /**
  62149. * Returns the attribute based on the name of the variable.
  62150. * @param uniformName of the uniform to look up.
  62151. * @returns the location of the uniform.
  62152. */
  62153. Effect.prototype.getUniform = function (uniformName) {
  62154. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  62155. };
  62156. /**
  62157. * Returns an array of sampler variable names
  62158. * @returns The array of sampler variable neames.
  62159. */
  62160. Effect.prototype.getSamplers = function () {
  62161. return this._samplers;
  62162. };
  62163. /**
  62164. * The error from the last compilation.
  62165. * @returns the error string.
  62166. */
  62167. Effect.prototype.getCompilationError = function () {
  62168. return this._compilationError;
  62169. };
  62170. /**
  62171. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  62172. * @param func The callback to be used.
  62173. */
  62174. Effect.prototype.executeWhenCompiled = function (func) {
  62175. var _this = this;
  62176. if (this.isReady()) {
  62177. func(this);
  62178. return;
  62179. }
  62180. this.onCompileObservable.add(function (effect) {
  62181. func(effect);
  62182. });
  62183. if (!this._program || this._program.isParallelCompiled) {
  62184. setTimeout(function () {
  62185. _this._checkIsReady();
  62186. }, 16);
  62187. }
  62188. };
  62189. Effect.prototype._checkIsReady = function () {
  62190. var _this = this;
  62191. if (this.isReady()) {
  62192. return;
  62193. }
  62194. setTimeout(function () {
  62195. _this._checkIsReady();
  62196. }, 16);
  62197. };
  62198. /** @hidden */
  62199. Effect.prototype._loadVertexShader = function (vertex, callback) {
  62200. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  62201. // DOM element ?
  62202. if (vertex instanceof HTMLElement) {
  62203. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  62204. callback(vertexCode);
  62205. return;
  62206. }
  62207. }
  62208. // Base64 encoded ?
  62209. if (vertex.substr(0, 7) === "base64:") {
  62210. var vertexBinary = window.atob(vertex.substr(7));
  62211. callback(vertexBinary);
  62212. return;
  62213. }
  62214. // Is in local store ?
  62215. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  62216. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  62217. return;
  62218. }
  62219. var vertexShaderUrl;
  62220. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  62221. vertexShaderUrl = vertex;
  62222. }
  62223. else {
  62224. vertexShaderUrl = Effect.ShadersRepository + vertex;
  62225. }
  62226. // Vertex shader
  62227. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  62228. };
  62229. /** @hidden */
  62230. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  62231. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  62232. // DOM element ?
  62233. if (fragment instanceof HTMLElement) {
  62234. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  62235. callback(fragmentCode);
  62236. return;
  62237. }
  62238. }
  62239. // Base64 encoded ?
  62240. if (fragment.substr(0, 7) === "base64:") {
  62241. var fragmentBinary = window.atob(fragment.substr(7));
  62242. callback(fragmentBinary);
  62243. return;
  62244. }
  62245. // Is in local store ?
  62246. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  62247. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  62248. return;
  62249. }
  62250. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  62251. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  62252. return;
  62253. }
  62254. var fragmentShaderUrl;
  62255. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  62256. fragmentShaderUrl = fragment;
  62257. }
  62258. else {
  62259. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  62260. }
  62261. // Fragment shader
  62262. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  62263. };
  62264. /** @hidden */
  62265. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  62266. // Rebuild shaders source code
  62267. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  62268. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  62269. vertexCode = prefix + vertexCode;
  62270. fragmentCode = prefix + fragmentCode;
  62271. // Number lines of shaders source code
  62272. var i = 2;
  62273. var regex = /\n/gm;
  62274. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  62275. i = 2;
  62276. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  62277. // Dump shaders name and formatted source code
  62278. if (this.name.vertexElement) {
  62279. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  62280. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  62281. }
  62282. else if (this.name.vertex) {
  62283. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  62284. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  62285. }
  62286. else {
  62287. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  62288. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  62289. }
  62290. };
  62291. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  62292. var preparedSourceCode = this._processPrecision(sourceCode);
  62293. if (this._engine.webGLVersion == 1) {
  62294. callback(preparedSourceCode);
  62295. return;
  62296. }
  62297. // Already converted
  62298. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  62299. callback(preparedSourceCode.replace("#version 300 es", ""));
  62300. return;
  62301. }
  62302. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  62303. // Remove extensions
  62304. // #extension GL_OES_standard_derivatives : enable
  62305. // #extension GL_EXT_shader_texture_lod : enable
  62306. // #extension GL_EXT_frag_depth : enable
  62307. // #extension GL_EXT_draw_buffers : require
  62308. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  62309. var result = preparedSourceCode.replace(regex, "");
  62310. // Migrate to GLSL v300
  62311. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  62312. result = result.replace(/attribute[ \t]/g, "in ");
  62313. result = result.replace(/[ \t]attribute/g, " in");
  62314. result = result.replace(/texture2D\s*\(/g, "texture(");
  62315. if (isFragment) {
  62316. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  62317. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  62318. result = result.replace(/textureCube\s*\(/g, "texture(");
  62319. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  62320. result = result.replace(/gl_FragColor/g, "glFragColor");
  62321. result = result.replace(/gl_FragData/g, "glFragData");
  62322. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  62323. }
  62324. callback(result);
  62325. };
  62326. Effect.prototype._processIncludes = function (sourceCode, callback) {
  62327. var _this = this;
  62328. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  62329. var match = regex.exec(sourceCode);
  62330. var returnValue = new String(sourceCode);
  62331. while (match != null) {
  62332. var includeFile = match[1];
  62333. // Uniform declaration
  62334. if (includeFile.indexOf("__decl__") !== -1) {
  62335. includeFile = includeFile.replace(/__decl__/, "");
  62336. if (this._engine.supportsUniformBuffers) {
  62337. includeFile = includeFile.replace(/Vertex/, "Ubo");
  62338. includeFile = includeFile.replace(/Fragment/, "Ubo");
  62339. }
  62340. includeFile = includeFile + "Declaration";
  62341. }
  62342. if (Effect.IncludesShadersStore[includeFile]) {
  62343. // Substitution
  62344. var includeContent = Effect.IncludesShadersStore[includeFile];
  62345. if (match[2]) {
  62346. var splits = match[3].split(",");
  62347. for (var index = 0; index < splits.length; index += 2) {
  62348. var source = new RegExp(splits[index], "g");
  62349. var dest = splits[index + 1];
  62350. includeContent = includeContent.replace(source, dest);
  62351. }
  62352. }
  62353. if (match[4]) {
  62354. var indexString = match[5];
  62355. if (indexString.indexOf("..") !== -1) {
  62356. var indexSplits = indexString.split("..");
  62357. var minIndex = parseInt(indexSplits[0]);
  62358. var maxIndex = parseInt(indexSplits[1]);
  62359. var sourceIncludeContent = includeContent.slice(0);
  62360. includeContent = "";
  62361. if (isNaN(maxIndex)) {
  62362. maxIndex = this._indexParameters[indexSplits[1]];
  62363. }
  62364. for (var i = minIndex; i < maxIndex; i++) {
  62365. if (!this._engine.supportsUniformBuffers) {
  62366. // Ubo replacement
  62367. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  62368. return p1 + "{X}";
  62369. });
  62370. }
  62371. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  62372. }
  62373. }
  62374. else {
  62375. if (!this._engine.supportsUniformBuffers) {
  62376. // Ubo replacement
  62377. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  62378. return p1 + "{X}";
  62379. });
  62380. }
  62381. includeContent = includeContent.replace(/\{X\}/g, indexString);
  62382. }
  62383. }
  62384. // Replace
  62385. returnValue = returnValue.replace(match[0], includeContent);
  62386. }
  62387. else {
  62388. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  62389. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  62390. Effect.IncludesShadersStore[includeFile] = fileContent;
  62391. _this._processIncludes(returnValue, callback);
  62392. });
  62393. return;
  62394. }
  62395. match = regex.exec(sourceCode);
  62396. }
  62397. callback(returnValue);
  62398. };
  62399. Effect.prototype._processPrecision = function (source) {
  62400. if (source.indexOf("precision highp float") === -1) {
  62401. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  62402. source = "precision mediump float;\n" + source;
  62403. }
  62404. else {
  62405. source = "precision highp float;\n" + source;
  62406. }
  62407. }
  62408. else {
  62409. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  62410. source = source.replace("precision highp float", "precision mediump float");
  62411. }
  62412. }
  62413. return source;
  62414. };
  62415. /**
  62416. * Recompiles the webGL program
  62417. * @param vertexSourceCode The source code for the vertex shader.
  62418. * @param fragmentSourceCode The source code for the fragment shader.
  62419. * @param onCompiled Callback called when completed.
  62420. * @param onError Callback called on error.
  62421. * @hidden
  62422. */
  62423. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  62424. var _this = this;
  62425. this._isReady = false;
  62426. this._vertexSourceCodeOverride = vertexSourceCode;
  62427. this._fragmentSourceCodeOverride = fragmentSourceCode;
  62428. this.onError = function (effect, error) {
  62429. if (onError) {
  62430. onError(error);
  62431. }
  62432. };
  62433. this.onCompiled = function () {
  62434. var scenes = _this.getEngine().scenes;
  62435. for (var i = 0; i < scenes.length; i++) {
  62436. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  62437. }
  62438. if (onCompiled) {
  62439. onCompiled(_this._program);
  62440. }
  62441. };
  62442. this._fallbacks = null;
  62443. this._prepareEffect();
  62444. };
  62445. /**
  62446. * Gets the uniform locations of the the specified variable names
  62447. * @param names THe names of the variables to lookup.
  62448. * @returns Array of locations in the same order as variable names.
  62449. */
  62450. Effect.prototype.getSpecificUniformLocations = function (names) {
  62451. var engine = this._engine;
  62452. return engine.getUniforms(this._program, names);
  62453. };
  62454. /**
  62455. * Prepares the effect
  62456. * @hidden
  62457. */
  62458. Effect.prototype._prepareEffect = function () {
  62459. var _this = this;
  62460. var attributesNames = this._attributesNames;
  62461. var defines = this.defines;
  62462. var fallbacks = this._fallbacks;
  62463. this._valueCache = {};
  62464. var previousProgram = this._program;
  62465. try {
  62466. var engine_1 = this._engine;
  62467. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  62468. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  62469. }
  62470. else {
  62471. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  62472. }
  62473. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  62474. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  62475. if (engine_1.supportsUniformBuffers) {
  62476. for (var name in _this._uniformBuffersNames) {
  62477. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  62478. }
  62479. }
  62480. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  62481. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  62482. var index;
  62483. for (index = 0; index < _this._samplers.length; index++) {
  62484. var sampler = _this.getUniform(_this._samplers[index]);
  62485. if (sampler == null) {
  62486. _this._samplers.splice(index, 1);
  62487. index--;
  62488. }
  62489. }
  62490. engine_1.bindSamplers(_this);
  62491. _this._compilationError = "";
  62492. _this._isReady = true;
  62493. if (_this.onCompiled) {
  62494. _this.onCompiled(_this);
  62495. }
  62496. _this.onCompileObservable.notifyObservers(_this);
  62497. _this.onCompileObservable.clear();
  62498. // Unbind mesh reference in fallbacks
  62499. if (_this._fallbacks) {
  62500. _this._fallbacks.unBindMesh();
  62501. }
  62502. if (previousProgram) {
  62503. _this.getEngine()._deleteProgram(previousProgram);
  62504. }
  62505. });
  62506. if (this._program.isParallelCompiled) {
  62507. this._checkIsReady();
  62508. }
  62509. }
  62510. catch (e) {
  62511. this._compilationError = e.message;
  62512. // Let's go through fallbacks then
  62513. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  62514. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  62515. return " " + uniform;
  62516. }));
  62517. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  62518. return " " + attribute;
  62519. }));
  62520. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  62521. if (previousProgram) {
  62522. this._program = previousProgram;
  62523. this._isReady = true;
  62524. if (this.onError) {
  62525. this.onError(this, this._compilationError);
  62526. }
  62527. this.onErrorObservable.notifyObservers(this);
  62528. }
  62529. if (fallbacks && fallbacks.isMoreFallbacks) {
  62530. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  62531. this.defines = fallbacks.reduce(this.defines, this);
  62532. this._prepareEffect();
  62533. }
  62534. else { // Sorry we did everything we can
  62535. if (this.onError) {
  62536. this.onError(this, this._compilationError);
  62537. }
  62538. this.onErrorObservable.notifyObservers(this);
  62539. this.onErrorObservable.clear();
  62540. // Unbind mesh reference in fallbacks
  62541. if (this._fallbacks) {
  62542. this._fallbacks.unBindMesh();
  62543. }
  62544. }
  62545. }
  62546. };
  62547. Object.defineProperty(Effect.prototype, "isSupported", {
  62548. /**
  62549. * Checks if the effect is supported. (Must be called after compilation)
  62550. */
  62551. get: function () {
  62552. return this._compilationError === "";
  62553. },
  62554. enumerable: true,
  62555. configurable: true
  62556. });
  62557. /**
  62558. * Binds a texture to the engine to be used as output of the shader.
  62559. * @param channel Name of the output variable.
  62560. * @param texture Texture to bind.
  62561. * @hidden
  62562. */
  62563. Effect.prototype._bindTexture = function (channel, texture) {
  62564. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  62565. };
  62566. /**
  62567. * Sets a texture on the engine to be used in the shader.
  62568. * @param channel Name of the sampler variable.
  62569. * @param texture Texture to set.
  62570. */
  62571. Effect.prototype.setTexture = function (channel, texture) {
  62572. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  62573. };
  62574. /**
  62575. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  62576. * @param channel Name of the sampler variable.
  62577. * @param texture Texture to set.
  62578. */
  62579. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  62580. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  62581. };
  62582. /**
  62583. * Sets an array of textures on the engine to be used in the shader.
  62584. * @param channel Name of the variable.
  62585. * @param textures Textures to set.
  62586. */
  62587. Effect.prototype.setTextureArray = function (channel, textures) {
  62588. if (this._samplers.indexOf(channel + "Ex") === -1) {
  62589. var initialPos = this._samplers.indexOf(channel);
  62590. for (var index = 1; index < textures.length; index++) {
  62591. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  62592. }
  62593. }
  62594. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  62595. };
  62596. /**
  62597. * 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)
  62598. * @param channel Name of the sampler variable.
  62599. * @param postProcess Post process to get the input texture from.
  62600. */
  62601. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  62602. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  62603. };
  62604. /**
  62605. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  62606. * 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)
  62607. * @param channel Name of the sampler variable.
  62608. * @param postProcess Post process to get the output texture from.
  62609. */
  62610. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  62611. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  62612. };
  62613. /** @hidden */
  62614. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  62615. var cache = this._valueCache[uniformName];
  62616. var flag = matrix.updateFlag;
  62617. if (cache !== undefined && cache === flag) {
  62618. return false;
  62619. }
  62620. this._valueCache[uniformName] = flag;
  62621. return true;
  62622. };
  62623. /** @hidden */
  62624. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  62625. var cache = this._valueCache[uniformName];
  62626. if (!cache) {
  62627. cache = [x, y];
  62628. this._valueCache[uniformName] = cache;
  62629. return true;
  62630. }
  62631. var changed = false;
  62632. if (cache[0] !== x) {
  62633. cache[0] = x;
  62634. changed = true;
  62635. }
  62636. if (cache[1] !== y) {
  62637. cache[1] = y;
  62638. changed = true;
  62639. }
  62640. return changed;
  62641. };
  62642. /** @hidden */
  62643. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  62644. var cache = this._valueCache[uniformName];
  62645. if (!cache) {
  62646. cache = [x, y, z];
  62647. this._valueCache[uniformName] = cache;
  62648. return true;
  62649. }
  62650. var changed = false;
  62651. if (cache[0] !== x) {
  62652. cache[0] = x;
  62653. changed = true;
  62654. }
  62655. if (cache[1] !== y) {
  62656. cache[1] = y;
  62657. changed = true;
  62658. }
  62659. if (cache[2] !== z) {
  62660. cache[2] = z;
  62661. changed = true;
  62662. }
  62663. return changed;
  62664. };
  62665. /** @hidden */
  62666. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  62667. var cache = this._valueCache[uniformName];
  62668. if (!cache) {
  62669. cache = [x, y, z, w];
  62670. this._valueCache[uniformName] = cache;
  62671. return true;
  62672. }
  62673. var changed = false;
  62674. if (cache[0] !== x) {
  62675. cache[0] = x;
  62676. changed = true;
  62677. }
  62678. if (cache[1] !== y) {
  62679. cache[1] = y;
  62680. changed = true;
  62681. }
  62682. if (cache[2] !== z) {
  62683. cache[2] = z;
  62684. changed = true;
  62685. }
  62686. if (cache[3] !== w) {
  62687. cache[3] = w;
  62688. changed = true;
  62689. }
  62690. return changed;
  62691. };
  62692. /**
  62693. * Binds a buffer to a uniform.
  62694. * @param buffer Buffer to bind.
  62695. * @param name Name of the uniform variable to bind to.
  62696. */
  62697. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  62698. var bufferName = this._uniformBuffersNames[name];
  62699. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  62700. return;
  62701. }
  62702. Effect._baseCache[bufferName] = buffer;
  62703. this._engine.bindUniformBufferBase(buffer, bufferName);
  62704. };
  62705. /**
  62706. * Binds block to a uniform.
  62707. * @param blockName Name of the block to bind.
  62708. * @param index Index to bind.
  62709. */
  62710. Effect.prototype.bindUniformBlock = function (blockName, index) {
  62711. this._engine.bindUniformBlock(this._program, blockName, index);
  62712. };
  62713. /**
  62714. * Sets an interger value on a uniform variable.
  62715. * @param uniformName Name of the variable.
  62716. * @param value Value to be set.
  62717. * @returns this effect.
  62718. */
  62719. Effect.prototype.setInt = function (uniformName, value) {
  62720. var cache = this._valueCache[uniformName];
  62721. if (cache !== undefined && cache === value) {
  62722. return this;
  62723. }
  62724. this._valueCache[uniformName] = value;
  62725. this._engine.setInt(this.getUniform(uniformName), value);
  62726. return this;
  62727. };
  62728. /**
  62729. * Sets an int array on a uniform variable.
  62730. * @param uniformName Name of the variable.
  62731. * @param array array to be set.
  62732. * @returns this effect.
  62733. */
  62734. Effect.prototype.setIntArray = function (uniformName, array) {
  62735. this._valueCache[uniformName] = null;
  62736. this._engine.setIntArray(this.getUniform(uniformName), array);
  62737. return this;
  62738. };
  62739. /**
  62740. * 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)
  62741. * @param uniformName Name of the variable.
  62742. * @param array array to be set.
  62743. * @returns this effect.
  62744. */
  62745. Effect.prototype.setIntArray2 = function (uniformName, array) {
  62746. this._valueCache[uniformName] = null;
  62747. this._engine.setIntArray2(this.getUniform(uniformName), array);
  62748. return this;
  62749. };
  62750. /**
  62751. * 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)
  62752. * @param uniformName Name of the variable.
  62753. * @param array array to be set.
  62754. * @returns this effect.
  62755. */
  62756. Effect.prototype.setIntArray3 = function (uniformName, array) {
  62757. this._valueCache[uniformName] = null;
  62758. this._engine.setIntArray3(this.getUniform(uniformName), array);
  62759. return this;
  62760. };
  62761. /**
  62762. * 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)
  62763. * @param uniformName Name of the variable.
  62764. * @param array array to be set.
  62765. * @returns this effect.
  62766. */
  62767. Effect.prototype.setIntArray4 = function (uniformName, array) {
  62768. this._valueCache[uniformName] = null;
  62769. this._engine.setIntArray4(this.getUniform(uniformName), array);
  62770. return this;
  62771. };
  62772. /**
  62773. * Sets an float array on a uniform variable.
  62774. * @param uniformName Name of the variable.
  62775. * @param array array to be set.
  62776. * @returns this effect.
  62777. */
  62778. Effect.prototype.setFloatArray = function (uniformName, array) {
  62779. this._valueCache[uniformName] = null;
  62780. this._engine.setFloatArray(this.getUniform(uniformName), array);
  62781. return this;
  62782. };
  62783. /**
  62784. * 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)
  62785. * @param uniformName Name of the variable.
  62786. * @param array array to be set.
  62787. * @returns this effect.
  62788. */
  62789. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  62790. this._valueCache[uniformName] = null;
  62791. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  62792. return this;
  62793. };
  62794. /**
  62795. * 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)
  62796. * @param uniformName Name of the variable.
  62797. * @param array array to be set.
  62798. * @returns this effect.
  62799. */
  62800. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  62801. this._valueCache[uniformName] = null;
  62802. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  62803. return this;
  62804. };
  62805. /**
  62806. * 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)
  62807. * @param uniformName Name of the variable.
  62808. * @param array array to be set.
  62809. * @returns this effect.
  62810. */
  62811. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  62812. this._valueCache[uniformName] = null;
  62813. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  62814. return this;
  62815. };
  62816. /**
  62817. * Sets an array on a uniform variable.
  62818. * @param uniformName Name of the variable.
  62819. * @param array array to be set.
  62820. * @returns this effect.
  62821. */
  62822. Effect.prototype.setArray = function (uniformName, array) {
  62823. this._valueCache[uniformName] = null;
  62824. this._engine.setArray(this.getUniform(uniformName), array);
  62825. return this;
  62826. };
  62827. /**
  62828. * 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)
  62829. * @param uniformName Name of the variable.
  62830. * @param array array to be set.
  62831. * @returns this effect.
  62832. */
  62833. Effect.prototype.setArray2 = function (uniformName, array) {
  62834. this._valueCache[uniformName] = null;
  62835. this._engine.setArray2(this.getUniform(uniformName), array);
  62836. return this;
  62837. };
  62838. /**
  62839. * 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)
  62840. * @param uniformName Name of the variable.
  62841. * @param array array to be set.
  62842. * @returns this effect.
  62843. */
  62844. Effect.prototype.setArray3 = function (uniformName, array) {
  62845. this._valueCache[uniformName] = null;
  62846. this._engine.setArray3(this.getUniform(uniformName), array);
  62847. return this;
  62848. };
  62849. /**
  62850. * 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)
  62851. * @param uniformName Name of the variable.
  62852. * @param array array to be set.
  62853. * @returns this effect.
  62854. */
  62855. Effect.prototype.setArray4 = function (uniformName, array) {
  62856. this._valueCache[uniformName] = null;
  62857. this._engine.setArray4(this.getUniform(uniformName), array);
  62858. return this;
  62859. };
  62860. /**
  62861. * Sets matrices on a uniform variable.
  62862. * @param uniformName Name of the variable.
  62863. * @param matrices matrices to be set.
  62864. * @returns this effect.
  62865. */
  62866. Effect.prototype.setMatrices = function (uniformName, matrices) {
  62867. if (!matrices) {
  62868. return this;
  62869. }
  62870. this._valueCache[uniformName] = null;
  62871. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  62872. return this;
  62873. };
  62874. /**
  62875. * Sets matrix on a uniform variable.
  62876. * @param uniformName Name of the variable.
  62877. * @param matrix matrix to be set.
  62878. * @returns this effect.
  62879. */
  62880. Effect.prototype.setMatrix = function (uniformName, matrix) {
  62881. if (this._cacheMatrix(uniformName, matrix)) {
  62882. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  62883. }
  62884. return this;
  62885. };
  62886. /**
  62887. * 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)
  62888. * @param uniformName Name of the variable.
  62889. * @param matrix matrix to be set.
  62890. * @returns this effect.
  62891. */
  62892. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  62893. this._valueCache[uniformName] = null;
  62894. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  62895. return this;
  62896. };
  62897. /**
  62898. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  62899. * @param uniformName Name of the variable.
  62900. * @param matrix matrix to be set.
  62901. * @returns this effect.
  62902. */
  62903. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  62904. this._valueCache[uniformName] = null;
  62905. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  62906. return this;
  62907. };
  62908. /**
  62909. * Sets a float on a uniform variable.
  62910. * @param uniformName Name of the variable.
  62911. * @param value value to be set.
  62912. * @returns this effect.
  62913. */
  62914. Effect.prototype.setFloat = function (uniformName, value) {
  62915. var cache = this._valueCache[uniformName];
  62916. if (cache !== undefined && cache === value) {
  62917. return this;
  62918. }
  62919. this._valueCache[uniformName] = value;
  62920. this._engine.setFloat(this.getUniform(uniformName), value);
  62921. return this;
  62922. };
  62923. /**
  62924. * Sets a boolean on a uniform variable.
  62925. * @param uniformName Name of the variable.
  62926. * @param bool value to be set.
  62927. * @returns this effect.
  62928. */
  62929. Effect.prototype.setBool = function (uniformName, bool) {
  62930. var cache = this._valueCache[uniformName];
  62931. if (cache !== undefined && cache === bool) {
  62932. return this;
  62933. }
  62934. this._valueCache[uniformName] = bool;
  62935. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  62936. return this;
  62937. };
  62938. /**
  62939. * Sets a Vector2 on a uniform variable.
  62940. * @param uniformName Name of the variable.
  62941. * @param vector2 vector2 to be set.
  62942. * @returns this effect.
  62943. */
  62944. Effect.prototype.setVector2 = function (uniformName, vector2) {
  62945. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  62946. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  62947. }
  62948. return this;
  62949. };
  62950. /**
  62951. * Sets a float2 on a uniform variable.
  62952. * @param uniformName Name of the variable.
  62953. * @param x First float in float2.
  62954. * @param y Second float in float2.
  62955. * @returns this effect.
  62956. */
  62957. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  62958. if (this._cacheFloat2(uniformName, x, y)) {
  62959. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  62960. }
  62961. return this;
  62962. };
  62963. /**
  62964. * Sets a Vector3 on a uniform variable.
  62965. * @param uniformName Name of the variable.
  62966. * @param vector3 Value to be set.
  62967. * @returns this effect.
  62968. */
  62969. Effect.prototype.setVector3 = function (uniformName, vector3) {
  62970. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  62971. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  62972. }
  62973. return this;
  62974. };
  62975. /**
  62976. * Sets a float3 on a uniform variable.
  62977. * @param uniformName Name of the variable.
  62978. * @param x First float in float3.
  62979. * @param y Second float in float3.
  62980. * @param z Third float in float3.
  62981. * @returns this effect.
  62982. */
  62983. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  62984. if (this._cacheFloat3(uniformName, x, y, z)) {
  62985. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  62986. }
  62987. return this;
  62988. };
  62989. /**
  62990. * Sets a Vector4 on a uniform variable.
  62991. * @param uniformName Name of the variable.
  62992. * @param vector4 Value to be set.
  62993. * @returns this effect.
  62994. */
  62995. Effect.prototype.setVector4 = function (uniformName, vector4) {
  62996. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  62997. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  62998. }
  62999. return this;
  63000. };
  63001. /**
  63002. * Sets a float4 on a uniform variable.
  63003. * @param uniformName Name of the variable.
  63004. * @param x First float in float4.
  63005. * @param y Second float in float4.
  63006. * @param z Third float in float4.
  63007. * @param w Fourth float in float4.
  63008. * @returns this effect.
  63009. */
  63010. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  63011. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  63012. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  63013. }
  63014. return this;
  63015. };
  63016. /**
  63017. * Sets a Color3 on a uniform variable.
  63018. * @param uniformName Name of the variable.
  63019. * @param color3 Value to be set.
  63020. * @returns this effect.
  63021. */
  63022. Effect.prototype.setColor3 = function (uniformName, color3) {
  63023. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  63024. this._engine.setColor3(this.getUniform(uniformName), color3);
  63025. }
  63026. return this;
  63027. };
  63028. /**
  63029. * Sets a Color4 on a uniform variable.
  63030. * @param uniformName Name of the variable.
  63031. * @param color3 Value to be set.
  63032. * @param alpha Alpha value to be set.
  63033. * @returns this effect.
  63034. */
  63035. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  63036. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  63037. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  63038. }
  63039. return this;
  63040. };
  63041. /**
  63042. * Sets a Color4 on a uniform variable
  63043. * @param uniformName defines the name of the variable
  63044. * @param color4 defines the value to be set
  63045. * @returns this effect.
  63046. */
  63047. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  63048. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  63049. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  63050. }
  63051. return this;
  63052. };
  63053. /**
  63054. * This function will add a new shader to the shader store
  63055. * @param name the name of the shader
  63056. * @param pixelShader optional pixel shader content
  63057. * @param vertexShader optional vertex shader content
  63058. */
  63059. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  63060. if (pixelShader) {
  63061. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  63062. }
  63063. if (vertexShader) {
  63064. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  63065. }
  63066. };
  63067. /**
  63068. * Resets the cache of effects.
  63069. */
  63070. Effect.ResetCache = function () {
  63071. Effect._baseCache = {};
  63072. };
  63073. /**
  63074. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  63075. */
  63076. Effect.ShadersRepository = "src/Shaders/";
  63077. Effect._uniqueIdSeed = 0;
  63078. Effect._baseCache = {};
  63079. /**
  63080. * Store of each shader (The can be looked up using effect.key)
  63081. */
  63082. Effect.ShadersStore = {};
  63083. /**
  63084. * Store of each included file for a shader (The can be looked up using effect.key)
  63085. */
  63086. Effect.IncludesShadersStore = {};
  63087. return Effect;
  63088. }());
  63089. /***/ }),
  63090. /***/ "./Materials/fresnelParameters.ts":
  63091. /*!****************************************!*\
  63092. !*** ./Materials/fresnelParameters.ts ***!
  63093. \****************************************/
  63094. /*! exports provided: FresnelParameters */
  63095. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63096. "use strict";
  63097. __webpack_require__.r(__webpack_exports__);
  63098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  63099. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  63100. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63101. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63102. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63103. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63104. /**
  63105. * This represents all the required information to add a fresnel effect on a material:
  63106. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  63107. */
  63108. var FresnelParameters = /** @class */ (function () {
  63109. function FresnelParameters() {
  63110. this._isEnabled = true;
  63111. /**
  63112. * Define the color used on edges (grazing angle)
  63113. */
  63114. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  63115. /**
  63116. * Define the color used on center
  63117. */
  63118. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  63119. /**
  63120. * Define bias applied to computed fresnel term
  63121. */
  63122. this.bias = 0;
  63123. /**
  63124. * Defined the power exponent applied to fresnel term
  63125. */
  63126. this.power = 1;
  63127. }
  63128. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  63129. /**
  63130. * Define if the fresnel effect is enable or not.
  63131. */
  63132. get: function () {
  63133. return this._isEnabled;
  63134. },
  63135. set: function (value) {
  63136. if (this._isEnabled === value) {
  63137. return;
  63138. }
  63139. this._isEnabled = value;
  63140. _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);
  63141. },
  63142. enumerable: true,
  63143. configurable: true
  63144. });
  63145. /**
  63146. * Clones the current fresnel and its valuues
  63147. * @returns a clone fresnel configuration
  63148. */
  63149. FresnelParameters.prototype.clone = function () {
  63150. var newFresnelParameters = new FresnelParameters();
  63151. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  63152. return newFresnelParameters;
  63153. };
  63154. /**
  63155. * Serializes the current fresnel parameters to a JSON representation.
  63156. * @return the JSON serialization
  63157. */
  63158. FresnelParameters.prototype.serialize = function () {
  63159. var serializationObject = {};
  63160. serializationObject.isEnabled = this.isEnabled;
  63161. serializationObject.leftColor = this.leftColor.asArray();
  63162. serializationObject.rightColor = this.rightColor.asArray();
  63163. serializationObject.bias = this.bias;
  63164. serializationObject.power = this.power;
  63165. return serializationObject;
  63166. };
  63167. /**
  63168. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  63169. * @param parsedFresnelParameters Define the JSON representation
  63170. * @returns the parsed parameters
  63171. */
  63172. FresnelParameters.Parse = function (parsedFresnelParameters) {
  63173. var fresnelParameters = new FresnelParameters();
  63174. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  63175. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  63176. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  63177. fresnelParameters.bias = parsedFresnelParameters.bias;
  63178. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  63179. return fresnelParameters;
  63180. };
  63181. return FresnelParameters;
  63182. }());
  63183. // References the dependencies.
  63184. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  63185. /***/ }),
  63186. /***/ "./Materials/imageProcessingConfiguration.ts":
  63187. /*!***************************************************!*\
  63188. !*** ./Materials/imageProcessingConfiguration.ts ***!
  63189. \***************************************************/
  63190. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  63191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63192. "use strict";
  63193. __webpack_require__.r(__webpack_exports__);
  63194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  63195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  63196. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63197. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63198. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  63199. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  63200. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63201. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  63202. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  63203. /**
  63204. * @hidden
  63205. */
  63206. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  63207. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  63208. function ImageProcessingConfigurationDefines() {
  63209. var _this = _super.call(this) || this;
  63210. _this.IMAGEPROCESSING = false;
  63211. _this.VIGNETTE = false;
  63212. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  63213. _this.VIGNETTEBLENDMODEOPAQUE = false;
  63214. _this.TONEMAPPING = false;
  63215. _this.TONEMAPPING_ACES = false;
  63216. _this.CONTRAST = false;
  63217. _this.COLORCURVES = false;
  63218. _this.COLORGRADING = false;
  63219. _this.COLORGRADING3D = false;
  63220. _this.SAMPLER3DGREENDEPTH = false;
  63221. _this.SAMPLER3DBGRMAP = false;
  63222. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  63223. _this.EXPOSURE = false;
  63224. _this.rebuild();
  63225. return _this;
  63226. }
  63227. return ImageProcessingConfigurationDefines;
  63228. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  63229. /**
  63230. * This groups together the common properties used for image processing either in direct forward pass
  63231. * or through post processing effect depending on the use of the image processing pipeline in your scene
  63232. * or not.
  63233. */
  63234. var ImageProcessingConfiguration = /** @class */ (function () {
  63235. function ImageProcessingConfiguration() {
  63236. /**
  63237. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  63238. */
  63239. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  63240. this._colorCurvesEnabled = false;
  63241. this._colorGradingEnabled = false;
  63242. this._colorGradingWithGreenDepth = true;
  63243. this._colorGradingBGR = true;
  63244. /** @hidden */
  63245. this._exposure = 1.0;
  63246. this._toneMappingEnabled = false;
  63247. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  63248. this._contrast = 1.0;
  63249. /**
  63250. * Vignette stretch size.
  63251. */
  63252. this.vignetteStretch = 0;
  63253. /**
  63254. * Vignette centre X Offset.
  63255. */
  63256. this.vignetteCentreX = 0;
  63257. /**
  63258. * Vignette centre Y Offset.
  63259. */
  63260. this.vignetteCentreY = 0;
  63261. /**
  63262. * Vignette weight or intensity of the vignette effect.
  63263. */
  63264. this.vignetteWeight = 1.5;
  63265. /**
  63266. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  63267. * if vignetteEnabled is set to true.
  63268. */
  63269. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  63270. /**
  63271. * Camera field of view used by the Vignette effect.
  63272. */
  63273. this.vignetteCameraFov = 0.5;
  63274. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  63275. this._vignetteEnabled = false;
  63276. this._applyByPostProcess = false;
  63277. this._isEnabled = true;
  63278. /**
  63279. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  63280. */
  63281. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  63282. }
  63283. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  63284. /**
  63285. * Gets wether the color curves effect is enabled.
  63286. */
  63287. get: function () {
  63288. return this._colorCurvesEnabled;
  63289. },
  63290. /**
  63291. * Sets wether the color curves effect is enabled.
  63292. */
  63293. set: function (value) {
  63294. if (this._colorCurvesEnabled === value) {
  63295. return;
  63296. }
  63297. this._colorCurvesEnabled = value;
  63298. this._updateParameters();
  63299. },
  63300. enumerable: true,
  63301. configurable: true
  63302. });
  63303. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  63304. /**
  63305. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  63306. */
  63307. get: function () {
  63308. return this._colorGradingTexture;
  63309. },
  63310. /**
  63311. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  63312. */
  63313. set: function (value) {
  63314. if (this._colorGradingTexture === value) {
  63315. return;
  63316. }
  63317. this._colorGradingTexture = value;
  63318. this._updateParameters();
  63319. },
  63320. enumerable: true,
  63321. configurable: true
  63322. });
  63323. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  63324. /**
  63325. * Gets wether the color grading effect is enabled.
  63326. */
  63327. get: function () {
  63328. return this._colorGradingEnabled;
  63329. },
  63330. /**
  63331. * Sets wether the color grading effect is enabled.
  63332. */
  63333. set: function (value) {
  63334. if (this._colorGradingEnabled === value) {
  63335. return;
  63336. }
  63337. this._colorGradingEnabled = value;
  63338. this._updateParameters();
  63339. },
  63340. enumerable: true,
  63341. configurable: true
  63342. });
  63343. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  63344. /**
  63345. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  63346. */
  63347. get: function () {
  63348. return this._colorGradingWithGreenDepth;
  63349. },
  63350. /**
  63351. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  63352. */
  63353. set: function (value) {
  63354. if (this._colorGradingWithGreenDepth === value) {
  63355. return;
  63356. }
  63357. this._colorGradingWithGreenDepth = value;
  63358. this._updateParameters();
  63359. },
  63360. enumerable: true,
  63361. configurable: true
  63362. });
  63363. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  63364. /**
  63365. * Gets wether the color grading texture contains BGR values.
  63366. */
  63367. get: function () {
  63368. return this._colorGradingBGR;
  63369. },
  63370. /**
  63371. * Sets wether the color grading texture contains BGR values.
  63372. */
  63373. set: function (value) {
  63374. if (this._colorGradingBGR === value) {
  63375. return;
  63376. }
  63377. this._colorGradingBGR = value;
  63378. this._updateParameters();
  63379. },
  63380. enumerable: true,
  63381. configurable: true
  63382. });
  63383. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  63384. /**
  63385. * Gets the Exposure used in the effect.
  63386. */
  63387. get: function () {
  63388. return this._exposure;
  63389. },
  63390. /**
  63391. * Sets the Exposure used in the effect.
  63392. */
  63393. set: function (value) {
  63394. if (this._exposure === value) {
  63395. return;
  63396. }
  63397. this._exposure = value;
  63398. this._updateParameters();
  63399. },
  63400. enumerable: true,
  63401. configurable: true
  63402. });
  63403. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  63404. /**
  63405. * Gets wether the tone mapping effect is enabled.
  63406. */
  63407. get: function () {
  63408. return this._toneMappingEnabled;
  63409. },
  63410. /**
  63411. * Sets wether the tone mapping effect is enabled.
  63412. */
  63413. set: function (value) {
  63414. if (this._toneMappingEnabled === value) {
  63415. return;
  63416. }
  63417. this._toneMappingEnabled = value;
  63418. this._updateParameters();
  63419. },
  63420. enumerable: true,
  63421. configurable: true
  63422. });
  63423. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  63424. /**
  63425. * Gets the type of tone mapping effect.
  63426. */
  63427. get: function () {
  63428. return this._toneMappingType;
  63429. },
  63430. /**
  63431. * Sets the type of tone mapping effect used in BabylonJS.
  63432. */
  63433. set: function (value) {
  63434. if (this._toneMappingType === value) {
  63435. return;
  63436. }
  63437. this._toneMappingType = value;
  63438. this._updateParameters();
  63439. },
  63440. enumerable: true,
  63441. configurable: true
  63442. });
  63443. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  63444. /**
  63445. * Gets the contrast used in the effect.
  63446. */
  63447. get: function () {
  63448. return this._contrast;
  63449. },
  63450. /**
  63451. * Sets the contrast used in the effect.
  63452. */
  63453. set: function (value) {
  63454. if (this._contrast === value) {
  63455. return;
  63456. }
  63457. this._contrast = value;
  63458. this._updateParameters();
  63459. },
  63460. enumerable: true,
  63461. configurable: true
  63462. });
  63463. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  63464. /**
  63465. * Gets the vignette blend mode allowing different kind of effect.
  63466. */
  63467. get: function () {
  63468. return this._vignetteBlendMode;
  63469. },
  63470. /**
  63471. * Sets the vignette blend mode allowing different kind of effect.
  63472. */
  63473. set: function (value) {
  63474. if (this._vignetteBlendMode === value) {
  63475. return;
  63476. }
  63477. this._vignetteBlendMode = value;
  63478. this._updateParameters();
  63479. },
  63480. enumerable: true,
  63481. configurable: true
  63482. });
  63483. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  63484. /**
  63485. * Gets wether the vignette effect is enabled.
  63486. */
  63487. get: function () {
  63488. return this._vignetteEnabled;
  63489. },
  63490. /**
  63491. * Sets wether the vignette effect is enabled.
  63492. */
  63493. set: function (value) {
  63494. if (this._vignetteEnabled === value) {
  63495. return;
  63496. }
  63497. this._vignetteEnabled = value;
  63498. this._updateParameters();
  63499. },
  63500. enumerable: true,
  63501. configurable: true
  63502. });
  63503. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  63504. /**
  63505. * Gets wether the image processing is applied through a post process or not.
  63506. */
  63507. get: function () {
  63508. return this._applyByPostProcess;
  63509. },
  63510. /**
  63511. * Sets wether the image processing is applied through a post process or not.
  63512. */
  63513. set: function (value) {
  63514. if (this._applyByPostProcess === value) {
  63515. return;
  63516. }
  63517. this._applyByPostProcess = value;
  63518. this._updateParameters();
  63519. },
  63520. enumerable: true,
  63521. configurable: true
  63522. });
  63523. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  63524. /**
  63525. * Gets wether the image processing is enabled or not.
  63526. */
  63527. get: function () {
  63528. return this._isEnabled;
  63529. },
  63530. /**
  63531. * Sets wether the image processing is enabled or not.
  63532. */
  63533. set: function (value) {
  63534. if (this._isEnabled === value) {
  63535. return;
  63536. }
  63537. this._isEnabled = value;
  63538. this._updateParameters();
  63539. },
  63540. enumerable: true,
  63541. configurable: true
  63542. });
  63543. /**
  63544. * Method called each time the image processing information changes requires to recompile the effect.
  63545. */
  63546. ImageProcessingConfiguration.prototype._updateParameters = function () {
  63547. this.onUpdateParameters.notifyObservers(this);
  63548. };
  63549. /**
  63550. * Gets the current class name.
  63551. * @return "ImageProcessingConfiguration"
  63552. */
  63553. ImageProcessingConfiguration.prototype.getClassName = function () {
  63554. return "ImageProcessingConfiguration";
  63555. };
  63556. /**
  63557. * Prepare the list of uniforms associated with the Image Processing effects.
  63558. * @param uniforms The list of uniforms used in the effect
  63559. * @param defines the list of defines currently in use
  63560. */
  63561. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  63562. if (defines.EXPOSURE) {
  63563. uniforms.push("exposureLinear");
  63564. }
  63565. if (defines.CONTRAST) {
  63566. uniforms.push("contrast");
  63567. }
  63568. if (defines.COLORGRADING) {
  63569. uniforms.push("colorTransformSettings");
  63570. }
  63571. if (defines.VIGNETTE) {
  63572. uniforms.push("vInverseScreenSize");
  63573. uniforms.push("vignetteSettings1");
  63574. uniforms.push("vignetteSettings2");
  63575. }
  63576. if (defines.COLORCURVES) {
  63577. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  63578. }
  63579. };
  63580. /**
  63581. * Prepare the list of samplers associated with the Image Processing effects.
  63582. * @param samplersList The list of uniforms used in the effect
  63583. * @param defines the list of defines currently in use
  63584. */
  63585. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  63586. if (defines.COLORGRADING) {
  63587. samplersList.push("txColorTransform");
  63588. }
  63589. };
  63590. /**
  63591. * Prepare the list of defines associated to the shader.
  63592. * @param defines the list of defines to complete
  63593. * @param forPostProcess Define if we are currently in post process mode or not
  63594. */
  63595. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  63596. if (forPostProcess === void 0) { forPostProcess = false; }
  63597. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  63598. defines.VIGNETTE = false;
  63599. defines.TONEMAPPING = false;
  63600. defines.TONEMAPPING_ACES = false;
  63601. defines.CONTRAST = false;
  63602. defines.EXPOSURE = false;
  63603. defines.COLORCURVES = false;
  63604. defines.COLORGRADING = false;
  63605. defines.COLORGRADING3D = false;
  63606. defines.IMAGEPROCESSING = false;
  63607. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  63608. return;
  63609. }
  63610. defines.VIGNETTE = this.vignetteEnabled;
  63611. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  63612. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  63613. defines.TONEMAPPING = this.toneMappingEnabled;
  63614. switch (this._toneMappingType) {
  63615. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  63616. defines.TONEMAPPING_ACES = true;
  63617. break;
  63618. default:
  63619. defines.TONEMAPPING_ACES = false;
  63620. break;
  63621. }
  63622. defines.CONTRAST = (this.contrast !== 1.0);
  63623. defines.EXPOSURE = (this.exposure !== 1.0);
  63624. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  63625. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  63626. if (defines.COLORGRADING) {
  63627. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  63628. }
  63629. else {
  63630. defines.COLORGRADING3D = false;
  63631. }
  63632. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  63633. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  63634. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  63635. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  63636. };
  63637. /**
  63638. * Returns true if all the image processing information are ready.
  63639. * @returns True if ready, otherwise, false
  63640. */
  63641. ImageProcessingConfiguration.prototype.isReady = function () {
  63642. // Color Grading texure can not be none blocking.
  63643. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  63644. };
  63645. /**
  63646. * Binds the image processing to the shader.
  63647. * @param effect The effect to bind to
  63648. * @param aspectRatio Define the current aspect ratio of the effect
  63649. */
  63650. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  63651. if (aspectRatio === void 0) { aspectRatio = 1; }
  63652. // Color Curves
  63653. if (this._colorCurvesEnabled && this.colorCurves) {
  63654. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  63655. }
  63656. // Vignette
  63657. if (this._vignetteEnabled) {
  63658. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  63659. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  63660. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  63661. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  63662. var vignetteScaleX = vignetteScaleY * aspectRatio;
  63663. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  63664. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  63665. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  63666. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  63667. var vignettePower = -2.0 * this.vignetteWeight;
  63668. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  63669. }
  63670. // Exposure
  63671. effect.setFloat("exposureLinear", this.exposure);
  63672. // Contrast
  63673. effect.setFloat("contrast", this.contrast);
  63674. // Color transform settings
  63675. if (this.colorGradingTexture) {
  63676. effect.setTexture("txColorTransform", this.colorGradingTexture);
  63677. var textureSize = this.colorGradingTexture.getSize().height;
  63678. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  63679. 0.5 / textureSize, // textureOffset
  63680. textureSize, // textureSize
  63681. this.colorGradingTexture.level // weight
  63682. );
  63683. }
  63684. };
  63685. /**
  63686. * Clones the current image processing instance.
  63687. * @return The cloned image processing
  63688. */
  63689. ImageProcessingConfiguration.prototype.clone = function () {
  63690. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  63691. };
  63692. /**
  63693. * Serializes the current image processing instance to a json representation.
  63694. * @return a JSON representation
  63695. */
  63696. ImageProcessingConfiguration.prototype.serialize = function () {
  63697. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63698. };
  63699. /**
  63700. * Parses the image processing from a json representation.
  63701. * @param source the JSON source to parse
  63702. * @return The parsed image processing
  63703. */
  63704. ImageProcessingConfiguration.Parse = function (source) {
  63705. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  63706. };
  63707. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  63708. /**
  63709. * Used to apply the vignette as a mix with the pixel color.
  63710. */
  63711. get: function () {
  63712. return this._VIGNETTEMODE_MULTIPLY;
  63713. },
  63714. enumerable: true,
  63715. configurable: true
  63716. });
  63717. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  63718. /**
  63719. * Used to apply the vignette as a replacement of the pixel color.
  63720. */
  63721. get: function () {
  63722. return this._VIGNETTEMODE_OPAQUE;
  63723. },
  63724. enumerable: true,
  63725. configurable: true
  63726. });
  63727. /**
  63728. * Default tone mapping applied in BabylonJS.
  63729. */
  63730. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  63731. /**
  63732. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  63733. * to other engines rendering to increase portability.
  63734. */
  63735. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  63736. // Static constants associated to the image processing.
  63737. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  63738. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  63739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  63741. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  63742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63744. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  63745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  63747. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  63748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63750. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  63751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63753. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  63754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63755. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63756. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  63757. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63758. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63759. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  63760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63762. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  63763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63765. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  63766. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63767. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63768. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  63769. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63770. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63771. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  63772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63774. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  63775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63777. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  63778. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63779. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63780. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  63781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  63783. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  63784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63786. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  63787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63789. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  63790. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63791. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63792. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  63793. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63794. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63795. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  63796. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63797. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63798. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  63799. return ImageProcessingConfiguration;
  63800. }());
  63801. // References the dependencies.
  63802. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  63803. /***/ }),
  63804. /***/ "./Materials/index.ts":
  63805. /*!****************************!*\
  63806. !*** ./Materials/index.ts ***!
  63807. \****************************/
  63808. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  63809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63810. "use strict";
  63811. __webpack_require__.r(__webpack_exports__);
  63812. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  63813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  63814. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  63815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  63816. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  63817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  63818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  63819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  63820. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  63821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  63822. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  63823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  63824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  63825. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  63826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  63827. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  63828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  63829. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  63830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  63831. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  63832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  63833. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  63834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  63835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  63836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  63837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  63838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  63839. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  63840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  63841. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  63842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  63843. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  63844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  63845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  63846. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  63847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  63848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  63849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  63850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  63851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  63852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  63853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  63854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  63855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  63856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  63857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  63858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  63859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  63860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  63861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  63862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  63863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  63864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  63865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  63866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  63867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  63868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  63869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  63870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  63871. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  63872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  63873. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  63874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  63875. /***/ }),
  63876. /***/ "./Materials/material.ts":
  63877. /*!*******************************!*\
  63878. !*** ./Materials/material.ts ***!
  63879. \*******************************/
  63880. /*! exports provided: Material */
  63881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63882. "use strict";
  63883. __webpack_require__.r(__webpack_exports__);
  63884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  63885. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63886. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63887. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  63888. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  63889. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63890. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  63891. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  63892. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  63893. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63894. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63895. /**
  63896. * Base class for the main features of a material in Babylon.js
  63897. */
  63898. var Material = /** @class */ (function () {
  63899. /**
  63900. * Creates a material instance
  63901. * @param name defines the name of the material
  63902. * @param scene defines the scene to reference
  63903. * @param doNotAdd specifies if the material should be added to the scene
  63904. */
  63905. function Material(name, scene, doNotAdd) {
  63906. /**
  63907. * Gets or sets user defined metadata
  63908. */
  63909. this.metadata = null;
  63910. /**
  63911. * For internal use only. Please do not use.
  63912. */
  63913. this.reservedDataStore = null;
  63914. /**
  63915. * Specifies if the ready state should be checked on each call
  63916. */
  63917. this.checkReadyOnEveryCall = false;
  63918. /**
  63919. * Specifies if the ready state should be checked once
  63920. */
  63921. this.checkReadyOnlyOnce = false;
  63922. /**
  63923. * The state of the material
  63924. */
  63925. this.state = "";
  63926. /**
  63927. * The alpha value of the material
  63928. */
  63929. this._alpha = 1.0;
  63930. /**
  63931. * Specifies if back face culling is enabled
  63932. */
  63933. this._backFaceCulling = true;
  63934. /**
  63935. * Specifies if the material should be serialized
  63936. */
  63937. this.doNotSerialize = false;
  63938. /**
  63939. * @hidden
  63940. */
  63941. this._storeEffectOnSubMeshes = false;
  63942. /**
  63943. * An event triggered when the material is disposed
  63944. */
  63945. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  63946. /**
  63947. * Stores the value of the alpha mode
  63948. */
  63949. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  63950. /**
  63951. * Stores the state of the need depth pre-pass value
  63952. */
  63953. this._needDepthPrePass = false;
  63954. /**
  63955. * Specifies if depth writing should be disabled
  63956. */
  63957. this.disableDepthWrite = false;
  63958. /**
  63959. * Specifies if depth writing should be forced
  63960. */
  63961. this.forceDepthWrite = false;
  63962. /**
  63963. * Specifies if there should be a separate pass for culling
  63964. */
  63965. this.separateCullingPass = false;
  63966. /**
  63967. * Stores the state specifing if fog should be enabled
  63968. */
  63969. this._fogEnabled = true;
  63970. /**
  63971. * Stores the size of points
  63972. */
  63973. this.pointSize = 1.0;
  63974. /**
  63975. * Stores the z offset value
  63976. */
  63977. this.zOffset = 0;
  63978. /**
  63979. * @hidden
  63980. * Specifies if the material was previously ready
  63981. */
  63982. this._wasPreviouslyReady = false;
  63983. /**
  63984. * Stores the fill mode state
  63985. */
  63986. this._fillMode = Material.TriangleFillMode;
  63987. /** @hidden */
  63988. this._indexInSceneMaterialArray = -1;
  63989. this.name = name;
  63990. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  63991. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  63992. this.uniqueId = this._scene.getUniqueId();
  63993. if (this._scene.useRightHandedSystem) {
  63994. this.sideOrientation = Material.ClockWiseSideOrientation;
  63995. }
  63996. else {
  63997. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  63998. }
  63999. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  64000. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  64001. if (!doNotAdd) {
  64002. this._scene.addMaterial(this);
  64003. }
  64004. if (this._scene.useMaterialMeshMap) {
  64005. this.meshMap = {};
  64006. }
  64007. }
  64008. Object.defineProperty(Material.prototype, "alpha", {
  64009. /**
  64010. * Gets the alpha value of the material
  64011. */
  64012. get: function () {
  64013. return this._alpha;
  64014. },
  64015. /**
  64016. * Sets the alpha value of the material
  64017. */
  64018. set: function (value) {
  64019. if (this._alpha === value) {
  64020. return;
  64021. }
  64022. this._alpha = value;
  64023. this.markAsDirty(Material.MiscDirtyFlag);
  64024. },
  64025. enumerable: true,
  64026. configurable: true
  64027. });
  64028. Object.defineProperty(Material.prototype, "backFaceCulling", {
  64029. /**
  64030. * Gets the back-face culling state
  64031. */
  64032. get: function () {
  64033. return this._backFaceCulling;
  64034. },
  64035. /**
  64036. * Sets the back-face culling state
  64037. */
  64038. set: function (value) {
  64039. if (this._backFaceCulling === value) {
  64040. return;
  64041. }
  64042. this._backFaceCulling = value;
  64043. this.markAsDirty(Material.TextureDirtyFlag);
  64044. },
  64045. enumerable: true,
  64046. configurable: true
  64047. });
  64048. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  64049. /**
  64050. * Gets a boolean indicating that current material needs to register RTT
  64051. */
  64052. get: function () {
  64053. return false;
  64054. },
  64055. enumerable: true,
  64056. configurable: true
  64057. });
  64058. Object.defineProperty(Material.prototype, "onDispose", {
  64059. /**
  64060. * Called during a dispose event
  64061. */
  64062. set: function (callback) {
  64063. if (this._onDisposeObserver) {
  64064. this.onDisposeObservable.remove(this._onDisposeObserver);
  64065. }
  64066. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  64067. },
  64068. enumerable: true,
  64069. configurable: true
  64070. });
  64071. Object.defineProperty(Material.prototype, "onBindObservable", {
  64072. /**
  64073. * An event triggered when the material is bound
  64074. */
  64075. get: function () {
  64076. if (!this._onBindObservable) {
  64077. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64078. }
  64079. return this._onBindObservable;
  64080. },
  64081. enumerable: true,
  64082. configurable: true
  64083. });
  64084. Object.defineProperty(Material.prototype, "onBind", {
  64085. /**
  64086. * Called during a bind event
  64087. */
  64088. set: function (callback) {
  64089. if (this._onBindObserver) {
  64090. this.onBindObservable.remove(this._onBindObserver);
  64091. }
  64092. this._onBindObserver = this.onBindObservable.add(callback);
  64093. },
  64094. enumerable: true,
  64095. configurable: true
  64096. });
  64097. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  64098. /**
  64099. * An event triggered when the material is unbound
  64100. */
  64101. get: function () {
  64102. if (!this._onUnBindObservable) {
  64103. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64104. }
  64105. return this._onUnBindObservable;
  64106. },
  64107. enumerable: true,
  64108. configurable: true
  64109. });
  64110. Object.defineProperty(Material.prototype, "alphaMode", {
  64111. /**
  64112. * Gets the value of the alpha mode
  64113. */
  64114. get: function () {
  64115. return this._alphaMode;
  64116. },
  64117. /**
  64118. * Sets the value of the alpha mode.
  64119. *
  64120. * | Value | Type | Description |
  64121. * | --- | --- | --- |
  64122. * | 0 | ALPHA_DISABLE | |
  64123. * | 1 | ALPHA_ADD | |
  64124. * | 2 | ALPHA_COMBINE | |
  64125. * | 3 | ALPHA_SUBTRACT | |
  64126. * | 4 | ALPHA_MULTIPLY | |
  64127. * | 5 | ALPHA_MAXIMIZED | |
  64128. * | 6 | ALPHA_ONEONE | |
  64129. * | 7 | ALPHA_PREMULTIPLIED | |
  64130. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  64131. * | 9 | ALPHA_INTERPOLATE | |
  64132. * | 10 | ALPHA_SCREENMODE | |
  64133. *
  64134. */
  64135. set: function (value) {
  64136. if (this._alphaMode === value) {
  64137. return;
  64138. }
  64139. this._alphaMode = value;
  64140. this.markAsDirty(Material.TextureDirtyFlag);
  64141. },
  64142. enumerable: true,
  64143. configurable: true
  64144. });
  64145. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  64146. /**
  64147. * Gets the depth pre-pass value
  64148. */
  64149. get: function () {
  64150. return this._needDepthPrePass;
  64151. },
  64152. /**
  64153. * Sets the need depth pre-pass value
  64154. */
  64155. set: function (value) {
  64156. if (this._needDepthPrePass === value) {
  64157. return;
  64158. }
  64159. this._needDepthPrePass = value;
  64160. if (this._needDepthPrePass) {
  64161. this.checkReadyOnEveryCall = true;
  64162. }
  64163. },
  64164. enumerable: true,
  64165. configurable: true
  64166. });
  64167. Object.defineProperty(Material.prototype, "fogEnabled", {
  64168. /**
  64169. * Gets the value of the fog enabled state
  64170. */
  64171. get: function () {
  64172. return this._fogEnabled;
  64173. },
  64174. /**
  64175. * Sets the state for enabling fog
  64176. */
  64177. set: function (value) {
  64178. if (this._fogEnabled === value) {
  64179. return;
  64180. }
  64181. this._fogEnabled = value;
  64182. this.markAsDirty(Material.MiscDirtyFlag);
  64183. },
  64184. enumerable: true,
  64185. configurable: true
  64186. });
  64187. Object.defineProperty(Material.prototype, "wireframe", {
  64188. /**
  64189. * Gets a value specifying if wireframe mode is enabled
  64190. */
  64191. get: function () {
  64192. switch (this._fillMode) {
  64193. case Material.WireFrameFillMode:
  64194. case Material.LineListDrawMode:
  64195. case Material.LineLoopDrawMode:
  64196. case Material.LineStripDrawMode:
  64197. return true;
  64198. }
  64199. return this._scene.forceWireframe;
  64200. },
  64201. /**
  64202. * Sets the state of wireframe mode
  64203. */
  64204. set: function (value) {
  64205. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  64206. },
  64207. enumerable: true,
  64208. configurable: true
  64209. });
  64210. Object.defineProperty(Material.prototype, "pointsCloud", {
  64211. /**
  64212. * Gets the value specifying if point clouds are enabled
  64213. */
  64214. get: function () {
  64215. switch (this._fillMode) {
  64216. case Material.PointFillMode:
  64217. case Material.PointListDrawMode:
  64218. return true;
  64219. }
  64220. return this._scene.forcePointsCloud;
  64221. },
  64222. /**
  64223. * Sets the state of point cloud mode
  64224. */
  64225. set: function (value) {
  64226. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  64227. },
  64228. enumerable: true,
  64229. configurable: true
  64230. });
  64231. Object.defineProperty(Material.prototype, "fillMode", {
  64232. /**
  64233. * Gets the material fill mode
  64234. */
  64235. get: function () {
  64236. return this._fillMode;
  64237. },
  64238. /**
  64239. * Sets the material fill mode
  64240. */
  64241. set: function (value) {
  64242. if (this._fillMode === value) {
  64243. return;
  64244. }
  64245. this._fillMode = value;
  64246. this.markAsDirty(Material.MiscDirtyFlag);
  64247. },
  64248. enumerable: true,
  64249. configurable: true
  64250. });
  64251. /**
  64252. * Returns a string representation of the current material
  64253. * @param fullDetails defines a boolean indicating which levels of logging is desired
  64254. * @returns a string with material information
  64255. */
  64256. Material.prototype.toString = function (fullDetails) {
  64257. var ret = "Name: " + this.name;
  64258. if (fullDetails) {
  64259. }
  64260. return ret;
  64261. };
  64262. /**
  64263. * Gets the class name of the material
  64264. * @returns a string with the class name of the material
  64265. */
  64266. Material.prototype.getClassName = function () {
  64267. return "Material";
  64268. };
  64269. Object.defineProperty(Material.prototype, "isFrozen", {
  64270. /**
  64271. * Specifies if updates for the material been locked
  64272. */
  64273. get: function () {
  64274. return this.checkReadyOnlyOnce;
  64275. },
  64276. enumerable: true,
  64277. configurable: true
  64278. });
  64279. /**
  64280. * Locks updates for the material
  64281. */
  64282. Material.prototype.freeze = function () {
  64283. this.checkReadyOnlyOnce = true;
  64284. };
  64285. /**
  64286. * Unlocks updates for the material
  64287. */
  64288. Material.prototype.unfreeze = function () {
  64289. this.checkReadyOnlyOnce = false;
  64290. };
  64291. /**
  64292. * Specifies if the material is ready to be used
  64293. * @param mesh defines the mesh to check
  64294. * @param useInstances specifies if instances should be used
  64295. * @returns a boolean indicating if the material is ready to be used
  64296. */
  64297. Material.prototype.isReady = function (mesh, useInstances) {
  64298. return true;
  64299. };
  64300. /**
  64301. * Specifies that the submesh is ready to be used
  64302. * @param mesh defines the mesh to check
  64303. * @param subMesh defines which submesh to check
  64304. * @param useInstances specifies that instances should be used
  64305. * @returns a boolean indicating that the submesh is ready or not
  64306. */
  64307. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64308. return false;
  64309. };
  64310. /**
  64311. * Returns the material effect
  64312. * @returns the effect associated with the material
  64313. */
  64314. Material.prototype.getEffect = function () {
  64315. return this._effect;
  64316. };
  64317. /**
  64318. * Returns the current scene
  64319. * @returns a Scene
  64320. */
  64321. Material.prototype.getScene = function () {
  64322. return this._scene;
  64323. };
  64324. /**
  64325. * Specifies if the material will require alpha blending
  64326. * @returns a boolean specifying if alpha blending is needed
  64327. */
  64328. Material.prototype.needAlphaBlending = function () {
  64329. return (this.alpha < 1.0);
  64330. };
  64331. /**
  64332. * Specifies if the mesh will require alpha blending
  64333. * @param mesh defines the mesh to check
  64334. * @returns a boolean specifying if alpha blending is needed for the mesh
  64335. */
  64336. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  64337. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  64338. };
  64339. /**
  64340. * Specifies if this material should be rendered in alpha test mode
  64341. * @returns a boolean specifying if an alpha test is needed.
  64342. */
  64343. Material.prototype.needAlphaTesting = function () {
  64344. return false;
  64345. };
  64346. /**
  64347. * Gets the texture used for the alpha test
  64348. * @returns the texture to use for alpha testing
  64349. */
  64350. Material.prototype.getAlphaTestTexture = function () {
  64351. return null;
  64352. };
  64353. /**
  64354. * Marks the material to indicate that it needs to be re-calculated
  64355. */
  64356. Material.prototype.markDirty = function () {
  64357. this._wasPreviouslyReady = false;
  64358. };
  64359. /** @hidden */
  64360. Material.prototype._preBind = function (effect, overrideOrientation) {
  64361. if (overrideOrientation === void 0) { overrideOrientation = null; }
  64362. var engine = this._scene.getEngine();
  64363. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  64364. var reverse = orientation === Material.ClockWiseSideOrientation;
  64365. engine.enableEffect(effect ? effect : this._effect);
  64366. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  64367. return reverse;
  64368. };
  64369. /**
  64370. * Binds the material to the mesh
  64371. * @param world defines the world transformation matrix
  64372. * @param mesh defines the mesh to bind the material to
  64373. */
  64374. Material.prototype.bind = function (world, mesh) {
  64375. };
  64376. /**
  64377. * Binds the submesh to the material
  64378. * @param world defines the world transformation matrix
  64379. * @param mesh defines the mesh containing the submesh
  64380. * @param subMesh defines the submesh to bind the material to
  64381. */
  64382. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  64383. };
  64384. /**
  64385. * Binds the world matrix to the material
  64386. * @param world defines the world transformation matrix
  64387. */
  64388. Material.prototype.bindOnlyWorldMatrix = function (world) {
  64389. };
  64390. /**
  64391. * Binds the scene's uniform buffer to the effect.
  64392. * @param effect defines the effect to bind to the scene uniform buffer
  64393. * @param sceneUbo defines the uniform buffer storing scene data
  64394. */
  64395. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  64396. sceneUbo.bindToEffect(effect, "Scene");
  64397. };
  64398. /**
  64399. * Binds the view matrix to the effect
  64400. * @param effect defines the effect to bind the view matrix to
  64401. */
  64402. Material.prototype.bindView = function (effect) {
  64403. if (!this._useUBO) {
  64404. effect.setMatrix("view", this.getScene().getViewMatrix());
  64405. }
  64406. else {
  64407. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  64408. }
  64409. };
  64410. /**
  64411. * Binds the view projection matrix to the effect
  64412. * @param effect defines the effect to bind the view projection matrix to
  64413. */
  64414. Material.prototype.bindViewProjection = function (effect) {
  64415. if (!this._useUBO) {
  64416. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64417. }
  64418. else {
  64419. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  64420. }
  64421. };
  64422. /**
  64423. * Specifies if material alpha testing should be turned on for the mesh
  64424. * @param mesh defines the mesh to check
  64425. */
  64426. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  64427. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  64428. };
  64429. /**
  64430. * Processes to execute after binding the material to a mesh
  64431. * @param mesh defines the rendered mesh
  64432. */
  64433. Material.prototype._afterBind = function (mesh) {
  64434. this._scene._cachedMaterial = this;
  64435. if (mesh) {
  64436. this._scene._cachedVisibility = mesh.visibility;
  64437. }
  64438. else {
  64439. this._scene._cachedVisibility = 1;
  64440. }
  64441. if (this._onBindObservable && mesh) {
  64442. this._onBindObservable.notifyObservers(mesh);
  64443. }
  64444. if (this.disableDepthWrite) {
  64445. var engine = this._scene.getEngine();
  64446. this._cachedDepthWriteState = engine.getDepthWrite();
  64447. engine.setDepthWrite(false);
  64448. }
  64449. };
  64450. /**
  64451. * Unbinds the material from the mesh
  64452. */
  64453. Material.prototype.unbind = function () {
  64454. if (this._onUnBindObservable) {
  64455. this._onUnBindObservable.notifyObservers(this);
  64456. }
  64457. if (this.disableDepthWrite) {
  64458. var engine = this._scene.getEngine();
  64459. engine.setDepthWrite(this._cachedDepthWriteState);
  64460. }
  64461. };
  64462. /**
  64463. * Gets the active textures from the material
  64464. * @returns an array of textures
  64465. */
  64466. Material.prototype.getActiveTextures = function () {
  64467. return [];
  64468. };
  64469. /**
  64470. * Specifies if the material uses a texture
  64471. * @param texture defines the texture to check against the material
  64472. * @returns a boolean specifying if the material uses the texture
  64473. */
  64474. Material.prototype.hasTexture = function (texture) {
  64475. return false;
  64476. };
  64477. /**
  64478. * Makes a duplicate of the material, and gives it a new name
  64479. * @param name defines the new name for the duplicated material
  64480. * @returns the cloned material
  64481. */
  64482. Material.prototype.clone = function (name) {
  64483. return null;
  64484. };
  64485. /**
  64486. * Gets the meshes bound to the material
  64487. * @returns an array of meshes bound to the material
  64488. */
  64489. Material.prototype.getBindedMeshes = function () {
  64490. var _this = this;
  64491. if (this.meshMap) {
  64492. var result = new Array();
  64493. for (var meshId in this.meshMap) {
  64494. var mesh = this.meshMap[meshId];
  64495. if (mesh) {
  64496. result.push(mesh);
  64497. }
  64498. }
  64499. return result;
  64500. }
  64501. else {
  64502. var meshes = this._scene.meshes;
  64503. return meshes.filter(function (mesh) { return mesh.material === _this; });
  64504. }
  64505. };
  64506. /**
  64507. * Force shader compilation
  64508. * @param mesh defines the mesh associated with this material
  64509. * @param onCompiled defines a function to execute once the material is compiled
  64510. * @param options defines the options to configure the compilation
  64511. */
  64512. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  64513. var _this = this;
  64514. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  64515. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  64516. var scene = this.getScene();
  64517. var checkReady = function () {
  64518. if (!_this._scene || !_this._scene.getEngine()) {
  64519. return;
  64520. }
  64521. if (subMesh._materialDefines) {
  64522. subMesh._materialDefines._renderId = -1;
  64523. }
  64524. var clipPlaneState = scene.clipPlane;
  64525. if (localOptions.clipPlane) {
  64526. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  64527. }
  64528. if (_this._storeEffectOnSubMeshes) {
  64529. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  64530. if (onCompiled) {
  64531. onCompiled(_this);
  64532. }
  64533. }
  64534. else {
  64535. setTimeout(checkReady, 16);
  64536. }
  64537. }
  64538. else {
  64539. if (_this.isReady()) {
  64540. if (onCompiled) {
  64541. onCompiled(_this);
  64542. }
  64543. }
  64544. else {
  64545. setTimeout(checkReady, 16);
  64546. }
  64547. }
  64548. if (localOptions.clipPlane) {
  64549. scene.clipPlane = clipPlaneState;
  64550. }
  64551. };
  64552. checkReady();
  64553. };
  64554. /**
  64555. * Force shader compilation
  64556. * @param mesh defines the mesh that will use this material
  64557. * @param options defines additional options for compiling the shaders
  64558. * @returns a promise that resolves when the compilation completes
  64559. */
  64560. Material.prototype.forceCompilationAsync = function (mesh, options) {
  64561. var _this = this;
  64562. return new Promise(function (resolve) {
  64563. _this.forceCompilation(mesh, function () {
  64564. resolve();
  64565. }, options);
  64566. });
  64567. };
  64568. /**
  64569. * Marks a define in the material to indicate that it needs to be re-computed
  64570. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  64571. */
  64572. Material.prototype.markAsDirty = function (flag) {
  64573. if (this.getScene().blockMaterialDirtyMechanism) {
  64574. return;
  64575. }
  64576. Material._DirtyCallbackArray.length = 0;
  64577. if (flag & Material.TextureDirtyFlag) {
  64578. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  64579. }
  64580. if (flag & Material.LightDirtyFlag) {
  64581. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  64582. }
  64583. if (flag & Material.FresnelDirtyFlag) {
  64584. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  64585. }
  64586. if (flag & Material.AttributesDirtyFlag) {
  64587. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  64588. }
  64589. if (flag & Material.MiscDirtyFlag) {
  64590. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  64591. }
  64592. if (Material._DirtyCallbackArray.length) {
  64593. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  64594. }
  64595. this.getScene().resetCachedMaterial();
  64596. };
  64597. /**
  64598. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  64599. * @param func defines a function which checks material defines against the submeshes
  64600. */
  64601. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  64602. if (this.getScene().blockMaterialDirtyMechanism) {
  64603. return;
  64604. }
  64605. var meshes = this.getScene().meshes;
  64606. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  64607. var mesh = meshes_1[_i];
  64608. if (!mesh.subMeshes) {
  64609. continue;
  64610. }
  64611. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  64612. var subMesh = _b[_a];
  64613. if (subMesh.getMaterial() !== this) {
  64614. continue;
  64615. }
  64616. if (!subMesh._materialDefines) {
  64617. continue;
  64618. }
  64619. func(subMesh._materialDefines);
  64620. }
  64621. }
  64622. };
  64623. /**
  64624. * Indicates that image processing needs to be re-calculated for all submeshes
  64625. */
  64626. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  64627. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  64628. };
  64629. /**
  64630. * Indicates that textures need to be re-calculated for all submeshes
  64631. */
  64632. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  64633. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  64634. };
  64635. /**
  64636. * Indicates that fresnel needs to be re-calculated for all submeshes
  64637. */
  64638. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  64639. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  64640. };
  64641. /**
  64642. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  64643. */
  64644. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  64645. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  64646. };
  64647. /**
  64648. * Indicates that lights need to be re-calculated for all submeshes
  64649. */
  64650. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  64651. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  64652. };
  64653. /**
  64654. * Indicates that attributes need to be re-calculated for all submeshes
  64655. */
  64656. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  64657. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  64658. };
  64659. /**
  64660. * Indicates that misc needs to be re-calculated for all submeshes
  64661. */
  64662. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  64663. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  64664. };
  64665. /**
  64666. * Indicates that textures and misc need to be re-calculated for all submeshes
  64667. */
  64668. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  64669. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  64670. };
  64671. /**
  64672. * Disposes the material
  64673. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64674. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  64675. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  64676. */
  64677. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  64678. var scene = this.getScene();
  64679. // Animations
  64680. scene.stopAnimation(this);
  64681. scene.freeProcessedMaterials();
  64682. // Remove from scene
  64683. scene.removeMaterial(this);
  64684. if (notBoundToMesh !== true) {
  64685. // Remove from meshes
  64686. if (this.meshMap) {
  64687. for (var meshId in this.meshMap) {
  64688. var mesh = this.meshMap[meshId];
  64689. if (mesh) {
  64690. mesh.material = null; // will set the entry in the map to undefined
  64691. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  64692. }
  64693. }
  64694. }
  64695. else {
  64696. var meshes = scene.meshes;
  64697. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  64698. var mesh = meshes_2[_i];
  64699. if (mesh.material === this) {
  64700. mesh.material = null;
  64701. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  64702. }
  64703. }
  64704. }
  64705. }
  64706. this._uniformBuffer.dispose();
  64707. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  64708. if (forceDisposeEffect && this._effect) {
  64709. if (!this._storeEffectOnSubMeshes) {
  64710. scene.getEngine()._releaseEffect(this._effect);
  64711. }
  64712. this._effect = null;
  64713. }
  64714. // Callback
  64715. this.onDisposeObservable.notifyObservers(this);
  64716. this.onDisposeObservable.clear();
  64717. if (this._onBindObservable) {
  64718. this._onBindObservable.clear();
  64719. }
  64720. if (this._onUnBindObservable) {
  64721. this._onUnBindObservable.clear();
  64722. }
  64723. };
  64724. /** @hidden */
  64725. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  64726. if (mesh.geometry) {
  64727. var geometry = (mesh.geometry);
  64728. var scene = this.getScene();
  64729. if (this._storeEffectOnSubMeshes) {
  64730. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  64731. var subMesh = _a[_i];
  64732. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  64733. if (forceDisposeEffect && subMesh._materialEffect) {
  64734. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  64735. }
  64736. }
  64737. }
  64738. else {
  64739. geometry._releaseVertexArrayObject(this._effect);
  64740. }
  64741. }
  64742. };
  64743. /**
  64744. * Serializes this material
  64745. * @returns the serialized material object
  64746. */
  64747. Material.prototype.serialize = function () {
  64748. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64749. };
  64750. /**
  64751. * Creates a material from parsed material data
  64752. * @param parsedMaterial defines parsed material data
  64753. * @param scene defines the hosting scene
  64754. * @param rootUrl defines the root URL to use to load textures
  64755. * @returns a new material
  64756. */
  64757. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  64758. if (!parsedMaterial.customType) {
  64759. parsedMaterial.customType = "BABYLON.StandardMaterial";
  64760. }
  64761. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  64762. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  64763. if (!BABYLON.LegacyPBRMaterial) {
  64764. _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.");
  64765. return;
  64766. }
  64767. }
  64768. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  64769. return materialType.Parse(parsedMaterial, scene, rootUrl);
  64770. };
  64771. /**
  64772. * Returns the triangle fill mode
  64773. */
  64774. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  64775. /**
  64776. * Returns the wireframe mode
  64777. */
  64778. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  64779. /**
  64780. * Returns the point fill mode
  64781. */
  64782. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  64783. /**
  64784. * Returns the point list draw mode
  64785. */
  64786. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  64787. /**
  64788. * Returns the line list draw mode
  64789. */
  64790. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  64791. /**
  64792. * Returns the line loop draw mode
  64793. */
  64794. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  64795. /**
  64796. * Returns the line strip draw mode
  64797. */
  64798. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  64799. /**
  64800. * Returns the triangle strip draw mode
  64801. */
  64802. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  64803. /**
  64804. * Returns the triangle fan draw mode
  64805. */
  64806. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  64807. /**
  64808. * Stores the clock-wise side orientation
  64809. */
  64810. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  64811. /**
  64812. * Stores the counter clock-wise side orientation
  64813. */
  64814. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  64815. /**
  64816. * The dirty texture flag value
  64817. */
  64818. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  64819. /**
  64820. * The dirty light flag value
  64821. */
  64822. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  64823. /**
  64824. * The dirty fresnel flag value
  64825. */
  64826. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  64827. /**
  64828. * The dirty attribute flag value
  64829. */
  64830. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  64831. /**
  64832. * The dirty misc flag value
  64833. */
  64834. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  64835. /**
  64836. * The all dirty flag value
  64837. */
  64838. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  64839. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  64840. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  64841. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  64842. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  64843. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  64844. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  64845. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  64846. Material._FresnelDirtyCallBack(defines);
  64847. Material._MiscDirtyCallBack(defines);
  64848. };
  64849. Material._TextureAndMiscDirtyCallBack = function (defines) {
  64850. Material._TextureDirtyCallBack(defines);
  64851. Material._MiscDirtyCallBack(defines);
  64852. };
  64853. Material._DirtyCallbackArray = [];
  64854. Material._RunDirtyCallBacks = function (defines) {
  64855. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  64856. var cb = _a[_i];
  64857. cb(defines);
  64858. }
  64859. };
  64860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64862. ], Material.prototype, "id", void 0);
  64863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64865. ], Material.prototype, "uniqueId", void 0);
  64866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64868. ], Material.prototype, "name", void 0);
  64869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64871. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  64872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64874. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  64875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64877. ], Material.prototype, "state", void 0);
  64878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  64880. ], Material.prototype, "_alpha", void 0);
  64881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  64883. ], Material.prototype, "_backFaceCulling", void 0);
  64884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64886. ], Material.prototype, "sideOrientation", void 0);
  64887. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  64889. ], Material.prototype, "_alphaMode", void 0);
  64890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64892. ], Material.prototype, "_needDepthPrePass", void 0);
  64893. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64895. ], Material.prototype, "disableDepthWrite", void 0);
  64896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64898. ], Material.prototype, "forceDepthWrite", void 0);
  64899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64901. ], Material.prototype, "separateCullingPass", void 0);
  64902. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  64904. ], Material.prototype, "_fogEnabled", void 0);
  64905. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64907. ], Material.prototype, "pointSize", void 0);
  64908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64910. ], Material.prototype, "zOffset", void 0);
  64911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64913. ], Material.prototype, "wireframe", null);
  64914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64916. ], Material.prototype, "pointsCloud", null);
  64917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64919. ], Material.prototype, "fillMode", null);
  64920. return Material;
  64921. }());
  64922. /***/ }),
  64923. /***/ "./Materials/materialDefines.ts":
  64924. /*!**************************************!*\
  64925. !*** ./Materials/materialDefines.ts ***!
  64926. \**************************************/
  64927. /*! exports provided: MaterialDefines */
  64928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64929. "use strict";
  64930. __webpack_require__.r(__webpack_exports__);
  64931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  64932. /**
  64933. * Manages the defines for the Material
  64934. */
  64935. var MaterialDefines = /** @class */ (function () {
  64936. function MaterialDefines() {
  64937. this._isDirty = true;
  64938. /** @hidden */
  64939. this._areLightsDirty = true;
  64940. /** @hidden */
  64941. this._areAttributesDirty = true;
  64942. /** @hidden */
  64943. this._areTexturesDirty = true;
  64944. /** @hidden */
  64945. this._areFresnelDirty = true;
  64946. /** @hidden */
  64947. this._areMiscDirty = true;
  64948. /** @hidden */
  64949. this._areImageProcessingDirty = true;
  64950. /** @hidden */
  64951. this._normals = false;
  64952. /** @hidden */
  64953. this._uvs = false;
  64954. /** @hidden */
  64955. this._needNormals = false;
  64956. /** @hidden */
  64957. this._needUVs = false;
  64958. }
  64959. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  64960. /**
  64961. * Specifies if the material needs to be re-calculated
  64962. */
  64963. get: function () {
  64964. return this._isDirty;
  64965. },
  64966. enumerable: true,
  64967. configurable: true
  64968. });
  64969. /**
  64970. * Marks the material to indicate that it has been re-calculated
  64971. */
  64972. MaterialDefines.prototype.markAsProcessed = function () {
  64973. this._isDirty = false;
  64974. this._areAttributesDirty = false;
  64975. this._areTexturesDirty = false;
  64976. this._areFresnelDirty = false;
  64977. this._areLightsDirty = false;
  64978. this._areMiscDirty = false;
  64979. this._areImageProcessingDirty = false;
  64980. };
  64981. /**
  64982. * Marks the material to indicate that it needs to be re-calculated
  64983. */
  64984. MaterialDefines.prototype.markAsUnprocessed = function () {
  64985. this._isDirty = true;
  64986. };
  64987. /**
  64988. * Marks the material to indicate all of its defines need to be re-calculated
  64989. */
  64990. MaterialDefines.prototype.markAllAsDirty = function () {
  64991. this._areTexturesDirty = true;
  64992. this._areAttributesDirty = true;
  64993. this._areLightsDirty = true;
  64994. this._areFresnelDirty = true;
  64995. this._areMiscDirty = true;
  64996. this._areImageProcessingDirty = true;
  64997. this._isDirty = true;
  64998. };
  64999. /**
  65000. * Marks the material to indicate that image processing needs to be re-calculated
  65001. */
  65002. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  65003. this._areImageProcessingDirty = true;
  65004. this._isDirty = true;
  65005. };
  65006. /**
  65007. * Marks the material to indicate the lights need to be re-calculated
  65008. */
  65009. MaterialDefines.prototype.markAsLightDirty = function () {
  65010. this._areLightsDirty = true;
  65011. this._isDirty = true;
  65012. };
  65013. /**
  65014. * Marks the attribute state as changed
  65015. */
  65016. MaterialDefines.prototype.markAsAttributesDirty = function () {
  65017. this._areAttributesDirty = true;
  65018. this._isDirty = true;
  65019. };
  65020. /**
  65021. * Marks the texture state as changed
  65022. */
  65023. MaterialDefines.prototype.markAsTexturesDirty = function () {
  65024. this._areTexturesDirty = true;
  65025. this._isDirty = true;
  65026. };
  65027. /**
  65028. * Marks the fresnel state as changed
  65029. */
  65030. MaterialDefines.prototype.markAsFresnelDirty = function () {
  65031. this._areFresnelDirty = true;
  65032. this._isDirty = true;
  65033. };
  65034. /**
  65035. * Marks the misc state as changed
  65036. */
  65037. MaterialDefines.prototype.markAsMiscDirty = function () {
  65038. this._areMiscDirty = true;
  65039. this._isDirty = true;
  65040. };
  65041. /**
  65042. * Rebuilds the material defines
  65043. */
  65044. MaterialDefines.prototype.rebuild = function () {
  65045. if (this._keys) {
  65046. delete this._keys;
  65047. }
  65048. this._keys = [];
  65049. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  65050. var key = _a[_i];
  65051. if (key[0] === "_") {
  65052. continue;
  65053. }
  65054. this._keys.push(key);
  65055. }
  65056. };
  65057. /**
  65058. * Specifies if two material defines are equal
  65059. * @param other - A material define instance to compare to
  65060. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65061. */
  65062. MaterialDefines.prototype.isEqual = function (other) {
  65063. if (this._keys.length !== other._keys.length) {
  65064. return false;
  65065. }
  65066. for (var index = 0; index < this._keys.length; index++) {
  65067. var prop = this._keys[index];
  65068. if (this[prop] !== other[prop]) {
  65069. return false;
  65070. }
  65071. }
  65072. return true;
  65073. };
  65074. /**
  65075. * Clones this instance's defines to another instance
  65076. * @param other - material defines to clone values to
  65077. */
  65078. MaterialDefines.prototype.cloneTo = function (other) {
  65079. if (this._keys.length !== other._keys.length) {
  65080. other._keys = this._keys.slice(0);
  65081. }
  65082. for (var index = 0; index < this._keys.length; index++) {
  65083. var prop = this._keys[index];
  65084. other[prop] = this[prop];
  65085. }
  65086. };
  65087. /**
  65088. * Resets the material define values
  65089. */
  65090. MaterialDefines.prototype.reset = function () {
  65091. for (var index = 0; index < this._keys.length; index++) {
  65092. var prop = this._keys[index];
  65093. var type = typeof this[prop];
  65094. switch (type) {
  65095. case "number":
  65096. this[prop] = 0;
  65097. break;
  65098. case "string":
  65099. this[prop] = "";
  65100. break;
  65101. default:
  65102. this[prop] = false;
  65103. break;
  65104. }
  65105. }
  65106. };
  65107. /**
  65108. * Converts the material define values to a string
  65109. * @returns - String of material define information
  65110. */
  65111. MaterialDefines.prototype.toString = function () {
  65112. var result = "";
  65113. for (var index = 0; index < this._keys.length; index++) {
  65114. var prop = this._keys[index];
  65115. var value = this[prop];
  65116. var type = typeof value;
  65117. switch (type) {
  65118. case "number":
  65119. case "string":
  65120. result += "#define " + prop + " " + value + "\n";
  65121. break;
  65122. default:
  65123. if (value) {
  65124. result += "#define " + prop + "\n";
  65125. }
  65126. break;
  65127. }
  65128. }
  65129. return result;
  65130. };
  65131. return MaterialDefines;
  65132. }());
  65133. /***/ }),
  65134. /***/ "./Materials/materialFlags.ts":
  65135. /*!************************************!*\
  65136. !*** ./Materials/materialFlags.ts ***!
  65137. \************************************/
  65138. /*! exports provided: MaterialFlags */
  65139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65140. "use strict";
  65141. __webpack_require__.r(__webpack_exports__);
  65142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  65143. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  65144. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65145. /**
  65146. * This groups all the flags used to control the materials channel.
  65147. */
  65148. var MaterialFlags = /** @class */ (function () {
  65149. function MaterialFlags() {
  65150. }
  65151. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  65152. /**
  65153. * Are diffuse textures enabled in the application.
  65154. */
  65155. get: function () {
  65156. return this._DiffuseTextureEnabled;
  65157. },
  65158. set: function (value) {
  65159. if (this._DiffuseTextureEnabled === value) {
  65160. return;
  65161. }
  65162. this._DiffuseTextureEnabled = value;
  65163. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65164. },
  65165. enumerable: true,
  65166. configurable: true
  65167. });
  65168. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  65169. /**
  65170. * Are ambient textures enabled in the application.
  65171. */
  65172. get: function () {
  65173. return this._AmbientTextureEnabled;
  65174. },
  65175. set: function (value) {
  65176. if (this._AmbientTextureEnabled === value) {
  65177. return;
  65178. }
  65179. this._AmbientTextureEnabled = value;
  65180. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65181. },
  65182. enumerable: true,
  65183. configurable: true
  65184. });
  65185. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  65186. /**
  65187. * Are opacity textures enabled in the application.
  65188. */
  65189. get: function () {
  65190. return this._OpacityTextureEnabled;
  65191. },
  65192. set: function (value) {
  65193. if (this._OpacityTextureEnabled === value) {
  65194. return;
  65195. }
  65196. this._OpacityTextureEnabled = value;
  65197. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65198. },
  65199. enumerable: true,
  65200. configurable: true
  65201. });
  65202. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  65203. /**
  65204. * Are reflection textures enabled in the application.
  65205. */
  65206. get: function () {
  65207. return this._ReflectionTextureEnabled;
  65208. },
  65209. set: function (value) {
  65210. if (this._ReflectionTextureEnabled === value) {
  65211. return;
  65212. }
  65213. this._ReflectionTextureEnabled = value;
  65214. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65215. },
  65216. enumerable: true,
  65217. configurable: true
  65218. });
  65219. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  65220. /**
  65221. * Are emissive textures enabled in the application.
  65222. */
  65223. get: function () {
  65224. return this._EmissiveTextureEnabled;
  65225. },
  65226. set: function (value) {
  65227. if (this._EmissiveTextureEnabled === value) {
  65228. return;
  65229. }
  65230. this._EmissiveTextureEnabled = value;
  65231. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65232. },
  65233. enumerable: true,
  65234. configurable: true
  65235. });
  65236. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  65237. /**
  65238. * Are specular textures enabled in the application.
  65239. */
  65240. get: function () {
  65241. return this._SpecularTextureEnabled;
  65242. },
  65243. set: function (value) {
  65244. if (this._SpecularTextureEnabled === value) {
  65245. return;
  65246. }
  65247. this._SpecularTextureEnabled = value;
  65248. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65249. },
  65250. enumerable: true,
  65251. configurable: true
  65252. });
  65253. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  65254. /**
  65255. * Are bump textures enabled in the application.
  65256. */
  65257. get: function () {
  65258. return this._BumpTextureEnabled;
  65259. },
  65260. set: function (value) {
  65261. if (this._BumpTextureEnabled === value) {
  65262. return;
  65263. }
  65264. this._BumpTextureEnabled = value;
  65265. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65266. },
  65267. enumerable: true,
  65268. configurable: true
  65269. });
  65270. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  65271. /**
  65272. * Are lightmap textures enabled in the application.
  65273. */
  65274. get: function () {
  65275. return this._LightmapTextureEnabled;
  65276. },
  65277. set: function (value) {
  65278. if (this._LightmapTextureEnabled === value) {
  65279. return;
  65280. }
  65281. this._LightmapTextureEnabled = value;
  65282. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65283. },
  65284. enumerable: true,
  65285. configurable: true
  65286. });
  65287. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  65288. /**
  65289. * Are refraction textures enabled in the application.
  65290. */
  65291. get: function () {
  65292. return this._RefractionTextureEnabled;
  65293. },
  65294. set: function (value) {
  65295. if (this._RefractionTextureEnabled === value) {
  65296. return;
  65297. }
  65298. this._RefractionTextureEnabled = value;
  65299. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65300. },
  65301. enumerable: true,
  65302. configurable: true
  65303. });
  65304. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  65305. /**
  65306. * Are color grading textures enabled in the application.
  65307. */
  65308. get: function () {
  65309. return this._ColorGradingTextureEnabled;
  65310. },
  65311. set: function (value) {
  65312. if (this._ColorGradingTextureEnabled === value) {
  65313. return;
  65314. }
  65315. this._ColorGradingTextureEnabled = value;
  65316. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65317. },
  65318. enumerable: true,
  65319. configurable: true
  65320. });
  65321. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  65322. /**
  65323. * Are fresnels enabled in the application.
  65324. */
  65325. get: function () {
  65326. return this._FresnelEnabled;
  65327. },
  65328. set: function (value) {
  65329. if (this._FresnelEnabled === value) {
  65330. return;
  65331. }
  65332. this._FresnelEnabled = value;
  65333. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  65334. },
  65335. enumerable: true,
  65336. configurable: true
  65337. });
  65338. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  65339. /**
  65340. * Are clear coat textures enabled in the application.
  65341. */
  65342. get: function () {
  65343. return this._ClearCoatTextureEnabled;
  65344. },
  65345. set: function (value) {
  65346. if (this._ClearCoatTextureEnabled === value) {
  65347. return;
  65348. }
  65349. this._ClearCoatTextureEnabled = value;
  65350. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65351. },
  65352. enumerable: true,
  65353. configurable: true
  65354. });
  65355. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  65356. /**
  65357. * Are clear coat bump textures enabled in the application.
  65358. */
  65359. get: function () {
  65360. return this._ClearCoatBumpTextureEnabled;
  65361. },
  65362. set: function (value) {
  65363. if (this._ClearCoatBumpTextureEnabled === value) {
  65364. return;
  65365. }
  65366. this._ClearCoatBumpTextureEnabled = value;
  65367. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65368. },
  65369. enumerable: true,
  65370. configurable: true
  65371. });
  65372. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  65373. /**
  65374. * Are clear coat tint textures enabled in the application.
  65375. */
  65376. get: function () {
  65377. return this._ClearCoatTintTextureEnabled;
  65378. },
  65379. set: function (value) {
  65380. if (this._ClearCoatTintTextureEnabled === value) {
  65381. return;
  65382. }
  65383. this._ClearCoatTintTextureEnabled = value;
  65384. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65385. },
  65386. enumerable: true,
  65387. configurable: true
  65388. });
  65389. Object.defineProperty(MaterialFlags, "SheenTextureEnabled", {
  65390. /**
  65391. * Are sheen textures enabled in the application.
  65392. */
  65393. get: function () {
  65394. return this._SheenTextureEnabled;
  65395. },
  65396. set: function (value) {
  65397. if (this._SheenTextureEnabled === value) {
  65398. return;
  65399. }
  65400. this._SheenTextureEnabled = value;
  65401. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65402. },
  65403. enumerable: true,
  65404. configurable: true
  65405. });
  65406. Object.defineProperty(MaterialFlags, "AnisotropicTextureEnabled", {
  65407. /**
  65408. * Are anisotropic textures enabled in the application.
  65409. */
  65410. get: function () {
  65411. return this._AnisotropicTextureEnabled;
  65412. },
  65413. set: function (value) {
  65414. if (this._AnisotropicTextureEnabled === value) {
  65415. return;
  65416. }
  65417. this._AnisotropicTextureEnabled = value;
  65418. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  65419. },
  65420. enumerable: true,
  65421. configurable: true
  65422. });
  65423. // Flags used to enable or disable a type of texture for all Standard Materials
  65424. MaterialFlags._DiffuseTextureEnabled = true;
  65425. MaterialFlags._AmbientTextureEnabled = true;
  65426. MaterialFlags._OpacityTextureEnabled = true;
  65427. MaterialFlags._ReflectionTextureEnabled = true;
  65428. MaterialFlags._EmissiveTextureEnabled = true;
  65429. MaterialFlags._SpecularTextureEnabled = true;
  65430. MaterialFlags._BumpTextureEnabled = true;
  65431. MaterialFlags._LightmapTextureEnabled = true;
  65432. MaterialFlags._RefractionTextureEnabled = true;
  65433. MaterialFlags._ColorGradingTextureEnabled = true;
  65434. MaterialFlags._FresnelEnabled = true;
  65435. MaterialFlags._ClearCoatTextureEnabled = true;
  65436. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  65437. MaterialFlags._ClearCoatTintTextureEnabled = true;
  65438. MaterialFlags._SheenTextureEnabled = true;
  65439. MaterialFlags._AnisotropicTextureEnabled = true;
  65440. return MaterialFlags;
  65441. }());
  65442. /***/ }),
  65443. /***/ "./Materials/materialHelper.ts":
  65444. /*!*************************************!*\
  65445. !*** ./Materials/materialHelper.ts ***!
  65446. \*************************************/
  65447. /*! exports provided: MaterialHelper */
  65448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65449. "use strict";
  65450. __webpack_require__.r(__webpack_exports__);
  65451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  65452. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  65453. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  65454. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65455. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  65456. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65457. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  65458. /**
  65459. * "Static Class" containing the most commonly used helper while dealing with material for
  65460. * rendering purpose.
  65461. *
  65462. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  65463. *
  65464. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  65465. */
  65466. var MaterialHelper = /** @class */ (function () {
  65467. function MaterialHelper() {
  65468. }
  65469. /**
  65470. * Bind the current view position to an effect.
  65471. * @param effect The effect to be bound
  65472. * @param scene The scene the eyes position is used from
  65473. */
  65474. MaterialHelper.BindEyePosition = function (effect, scene) {
  65475. if (scene._forcedViewPosition) {
  65476. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  65477. return;
  65478. }
  65479. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  65480. };
  65481. /**
  65482. * Helps preparing the defines values about the UVs in used in the effect.
  65483. * UVs are shared as much as we can accross channels in the shaders.
  65484. * @param texture The texture we are preparing the UVs for
  65485. * @param defines The defines to update
  65486. * @param key The channel key "diffuse", "specular"... used in the shader
  65487. */
  65488. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  65489. defines._needUVs = true;
  65490. defines[key] = true;
  65491. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  65492. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  65493. if (texture.coordinatesIndex === 0) {
  65494. defines["MAINUV1"] = true;
  65495. }
  65496. else {
  65497. defines["MAINUV2"] = true;
  65498. }
  65499. }
  65500. else {
  65501. defines[key + "DIRECTUV"] = 0;
  65502. }
  65503. };
  65504. /**
  65505. * Binds a texture matrix value to its corrsponding uniform
  65506. * @param texture The texture to bind the matrix for
  65507. * @param uniformBuffer The uniform buffer receivin the data
  65508. * @param key The channel key "diffuse", "specular"... used in the shader
  65509. */
  65510. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  65511. var matrix = texture.getTextureMatrix();
  65512. if (!matrix.isIdentityAs3x2()) {
  65513. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  65514. }
  65515. };
  65516. /**
  65517. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65518. * @param mesh defines the current mesh
  65519. * @param scene defines the current scene
  65520. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65521. * @param pointsCloud defines if point cloud rendering has to be turned on
  65522. * @param fogEnabled defines if fog has to be turned on
  65523. * @param alphaTest defines if alpha testing has to be turned on
  65524. * @param defines defines the current list of defines
  65525. */
  65526. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  65527. if (defines._areMiscDirty) {
  65528. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  65529. defines["POINTSIZE"] = pointsCloud;
  65530. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  65531. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  65532. defines["ALPHATEST"] = alphaTest;
  65533. }
  65534. };
  65535. /**
  65536. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65537. * @param scene defines the current scene
  65538. * @param engine defines the current engine
  65539. * @param defines specifies the list of active defines
  65540. * @param useInstances defines if instances have to be turned on
  65541. * @param useClipPlane defines if clip plane have to be turned on
  65542. */
  65543. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  65544. if (useClipPlane === void 0) { useClipPlane = null; }
  65545. var changed = false;
  65546. var useClipPlane1 = false;
  65547. var useClipPlane2 = false;
  65548. var useClipPlane3 = false;
  65549. var useClipPlane4 = false;
  65550. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  65551. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  65552. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  65553. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  65554. if (defines["CLIPPLANE"] !== useClipPlane1) {
  65555. defines["CLIPPLANE"] = useClipPlane1;
  65556. changed = true;
  65557. }
  65558. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  65559. defines["CLIPPLANE2"] = useClipPlane2;
  65560. changed = true;
  65561. }
  65562. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  65563. defines["CLIPPLANE3"] = useClipPlane3;
  65564. changed = true;
  65565. }
  65566. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  65567. defines["CLIPPLANE4"] = useClipPlane4;
  65568. changed = true;
  65569. }
  65570. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  65571. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  65572. changed = true;
  65573. }
  65574. if (defines["INSTANCES"] !== useInstances) {
  65575. defines["INSTANCES"] = useInstances;
  65576. changed = true;
  65577. }
  65578. if (changed) {
  65579. defines.markAsUnprocessed();
  65580. }
  65581. };
  65582. /**
  65583. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65584. * @param mesh The mesh containing the geometry data we will draw
  65585. * @param defines The defines to update
  65586. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65587. * @param useBones Precise whether bones should be used or not (override mesh info)
  65588. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65589. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65590. * @returns false if defines are considered not dirty and have not been checked
  65591. */
  65592. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  65593. if (useMorphTargets === void 0) { useMorphTargets = false; }
  65594. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  65595. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  65596. return false;
  65597. }
  65598. defines._normals = defines._needNormals;
  65599. defines._uvs = defines._needUVs;
  65600. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  65601. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  65602. defines["TANGENT"] = true;
  65603. }
  65604. if (defines._needUVs) {
  65605. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  65606. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  65607. }
  65608. else {
  65609. defines["UV1"] = false;
  65610. defines["UV2"] = false;
  65611. }
  65612. if (useVertexColor) {
  65613. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  65614. defines["VERTEXCOLOR"] = hasVertexColors;
  65615. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  65616. }
  65617. if (useBones) {
  65618. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  65619. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  65620. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  65621. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  65622. defines["BONETEXTURE"] = true;
  65623. }
  65624. else {
  65625. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  65626. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  65627. }
  65628. }
  65629. else {
  65630. defines["NUM_BONE_INFLUENCERS"] = 0;
  65631. defines["BonesPerMesh"] = 0;
  65632. }
  65633. }
  65634. if (useMorphTargets) {
  65635. var manager = mesh.morphTargetManager;
  65636. if (manager) {
  65637. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  65638. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  65639. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  65640. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  65641. }
  65642. else {
  65643. defines["MORPHTARGETS_TANGENT"] = false;
  65644. defines["MORPHTARGETS_NORMAL"] = false;
  65645. defines["MORPHTARGETS"] = false;
  65646. defines["NUM_MORPH_INFLUENCERS"] = 0;
  65647. }
  65648. }
  65649. return true;
  65650. };
  65651. /**
  65652. * Prepares the defines related to the light information passed in parameter
  65653. * @param scene The scene we are intending to draw
  65654. * @param mesh The mesh the effect is compiling for
  65655. * @param defines The defines to update
  65656. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65657. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65658. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65659. * @returns true if normals will be required for the rest of the effect
  65660. */
  65661. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  65662. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  65663. if (disableLighting === void 0) { disableLighting = false; }
  65664. if (!defines._areLightsDirty) {
  65665. return defines._needNormals;
  65666. }
  65667. var lightIndex = 0;
  65668. var needNormals = false;
  65669. var needRebuild = false;
  65670. var lightmapMode = false;
  65671. var shadowEnabled = false;
  65672. var specularEnabled = false;
  65673. if (scene.lightsEnabled && !disableLighting) {
  65674. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  65675. var light = _a[_i];
  65676. needNormals = true;
  65677. if (defines["LIGHT" + lightIndex] === undefined) {
  65678. needRebuild = true;
  65679. }
  65680. defines["LIGHT" + lightIndex] = true;
  65681. defines["SPOTLIGHT" + lightIndex] = false;
  65682. defines["HEMILIGHT" + lightIndex] = false;
  65683. defines["POINTLIGHT" + lightIndex] = false;
  65684. defines["DIRLIGHT" + lightIndex] = false;
  65685. light.prepareLightSpecificDefines(defines, lightIndex);
  65686. // FallOff.
  65687. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  65688. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  65689. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  65690. switch (light.falloffType) {
  65691. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  65692. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  65693. break;
  65694. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  65695. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  65696. break;
  65697. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  65698. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  65699. break;
  65700. }
  65701. // Specular
  65702. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  65703. specularEnabled = true;
  65704. }
  65705. // Shadows
  65706. defines["SHADOW" + lightIndex] = false;
  65707. defines["SHADOWPCF" + lightIndex] = false;
  65708. defines["SHADOWPCSS" + lightIndex] = false;
  65709. defines["SHADOWPOISSON" + lightIndex] = false;
  65710. defines["SHADOWESM" + lightIndex] = false;
  65711. defines["SHADOWCUBE" + lightIndex] = false;
  65712. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  65713. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  65714. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  65715. var shadowGenerator = light.getShadowGenerator();
  65716. if (shadowGenerator) {
  65717. var shadowMap = shadowGenerator.getShadowMap();
  65718. if (shadowMap) {
  65719. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  65720. shadowEnabled = true;
  65721. shadowGenerator.prepareDefines(defines, lightIndex);
  65722. }
  65723. }
  65724. }
  65725. }
  65726. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  65727. lightmapMode = true;
  65728. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  65729. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  65730. }
  65731. else {
  65732. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  65733. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  65734. }
  65735. lightIndex++;
  65736. if (lightIndex === maxSimultaneousLights) {
  65737. break;
  65738. }
  65739. }
  65740. }
  65741. defines["SPECULARTERM"] = specularEnabled;
  65742. defines["SHADOWS"] = shadowEnabled;
  65743. // Resetting all other lights if any
  65744. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  65745. if (defines["LIGHT" + index] !== undefined) {
  65746. defines["LIGHT" + index] = false;
  65747. defines["HEMILIGHT" + index] = false;
  65748. defines["POINTLIGHT" + index] = false;
  65749. defines["DIRLIGHT" + index] = false;
  65750. defines["SPOTLIGHT" + index] = false;
  65751. defines["SHADOW" + index] = false;
  65752. defines["SHADOWPCF" + index] = false;
  65753. defines["SHADOWPCSS" + index] = false;
  65754. defines["SHADOWPOISSON" + index] = false;
  65755. defines["SHADOWESM" + index] = false;
  65756. defines["SHADOWCUBE" + index] = false;
  65757. defines["SHADOWLOWQUALITY" + index] = false;
  65758. defines["SHADOWMEDIUMQUALITY" + index] = false;
  65759. }
  65760. }
  65761. var caps = scene.getEngine().getCaps();
  65762. if (defines["SHADOWFLOAT"] === undefined) {
  65763. needRebuild = true;
  65764. }
  65765. defines["SHADOWFLOAT"] = shadowEnabled &&
  65766. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  65767. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  65768. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  65769. if (needRebuild) {
  65770. defines.rebuild();
  65771. }
  65772. return needNormals;
  65773. };
  65774. /**
  65775. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  65776. * that won t be acctive due to defines being turned off.
  65777. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  65778. * @param samplersList The samplers list
  65779. * @param defines The defines helping in the list generation
  65780. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  65781. */
  65782. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  65783. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  65784. var uniformsList;
  65785. var uniformBuffersList = null;
  65786. if (uniformsListOrOptions.uniformsNames) {
  65787. var options = uniformsListOrOptions;
  65788. uniformsList = options.uniformsNames;
  65789. uniformBuffersList = options.uniformBuffersNames;
  65790. samplersList = options.samplers;
  65791. defines = options.defines;
  65792. maxSimultaneousLights = options.maxSimultaneousLights;
  65793. }
  65794. else {
  65795. uniformsList = uniformsListOrOptions;
  65796. if (!samplersList) {
  65797. samplersList = [];
  65798. }
  65799. }
  65800. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  65801. if (!defines["LIGHT" + lightIndex]) {
  65802. break;
  65803. }
  65804. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  65805. if (uniformBuffersList) {
  65806. uniformBuffersList.push("Light" + lightIndex);
  65807. }
  65808. samplersList.push("shadowSampler" + lightIndex);
  65809. samplersList.push("depthSampler" + lightIndex);
  65810. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  65811. samplersList.push("projectionLightSampler" + lightIndex);
  65812. uniformsList.push("textureProjectionMatrix" + lightIndex);
  65813. }
  65814. }
  65815. if (defines["NUM_MORPH_INFLUENCERS"]) {
  65816. uniformsList.push("morphTargetInfluences");
  65817. }
  65818. };
  65819. /**
  65820. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  65821. * @param defines The defines to update while falling back
  65822. * @param fallbacks The authorized effect fallbacks
  65823. * @param maxSimultaneousLights The maximum number of lights allowed
  65824. * @param rank the current rank of the Effect
  65825. * @returns The newly affected rank
  65826. */
  65827. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  65828. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  65829. if (rank === void 0) { rank = 0; }
  65830. var lightFallbackRank = 0;
  65831. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  65832. if (!defines["LIGHT" + lightIndex]) {
  65833. break;
  65834. }
  65835. if (lightIndex > 0) {
  65836. lightFallbackRank = rank + lightIndex;
  65837. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  65838. }
  65839. if (!defines["SHADOWS"]) {
  65840. if (defines["SHADOW" + lightIndex]) {
  65841. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  65842. }
  65843. if (defines["SHADOWPCF" + lightIndex]) {
  65844. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  65845. }
  65846. if (defines["SHADOWPCSS" + lightIndex]) {
  65847. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  65848. }
  65849. if (defines["SHADOWPOISSON" + lightIndex]) {
  65850. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  65851. }
  65852. if (defines["SHADOWESM" + lightIndex]) {
  65853. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  65854. }
  65855. }
  65856. }
  65857. return lightFallbackRank++;
  65858. };
  65859. /**
  65860. * Prepares the list of attributes required for morph targets according to the effect defines.
  65861. * @param attribs The current list of supported attribs
  65862. * @param mesh The mesh to prepare the morph targets attributes for
  65863. * @param defines The current Defines of the effect
  65864. */
  65865. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  65866. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  65867. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  65868. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  65869. var manager = mesh.morphTargetManager;
  65870. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  65871. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  65872. for (var index = 0; index < influencers; index++) {
  65873. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  65874. if (normal) {
  65875. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  65876. }
  65877. if (tangent) {
  65878. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  65879. }
  65880. if (attribs.length > maxAttributesCount) {
  65881. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  65882. }
  65883. }
  65884. }
  65885. };
  65886. /**
  65887. * Prepares the list of attributes required for bones according to the effect defines.
  65888. * @param attribs The current list of supported attribs
  65889. * @param mesh The mesh to prepare the bones attributes for
  65890. * @param defines The current Defines of the effect
  65891. * @param fallbacks The current efffect fallback strategy
  65892. */
  65893. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  65894. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  65895. fallbacks.addCPUSkinningFallback(0, mesh);
  65896. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  65897. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  65898. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  65899. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  65900. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  65901. }
  65902. }
  65903. };
  65904. /**
  65905. * Prepares the list of attributes required for instances according to the effect defines.
  65906. * @param attribs The current list of supported attribs
  65907. * @param defines The current Defines of the effect
  65908. */
  65909. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  65910. if (defines["INSTANCES"]) {
  65911. attribs.push("world0");
  65912. attribs.push("world1");
  65913. attribs.push("world2");
  65914. attribs.push("world3");
  65915. }
  65916. };
  65917. /**
  65918. * Binds the light shadow information to the effect for the given mesh.
  65919. * @param light The light containing the generator
  65920. * @param scene The scene the lights belongs to
  65921. * @param mesh The mesh we are binding the information to render
  65922. * @param lightIndex The light index in the effect used to render the mesh
  65923. * @param effect The effect we are binding the data to
  65924. */
  65925. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  65926. if (light.shadowEnabled && mesh.receiveShadows) {
  65927. var shadowGenerator = light.getShadowGenerator();
  65928. if (shadowGenerator) {
  65929. shadowGenerator.bindShadowLight(lightIndex, effect);
  65930. }
  65931. }
  65932. };
  65933. /**
  65934. * Binds the light information to the effect.
  65935. * @param light The light containing the generator
  65936. * @param effect The effect we are binding the data to
  65937. * @param lightIndex The light index in the effect used to render
  65938. */
  65939. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  65940. light.transferToEffect(effect, lightIndex + "");
  65941. };
  65942. /**
  65943. * Binds the lights information from the scene to the effect for the given mesh.
  65944. * @param scene The scene the lights belongs to
  65945. * @param mesh The mesh we are binding the information to render
  65946. * @param effect The effect we are binding the data to
  65947. * @param defines The generated defines for the effect
  65948. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  65949. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  65950. */
  65951. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  65952. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  65953. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  65954. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  65955. for (var i = 0; i < len; i++) {
  65956. var light = mesh._lightSources[i];
  65957. var iAsString = i.toString();
  65958. var scaledIntensity = light.getScaledIntensity();
  65959. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  65960. MaterialHelper.BindLightProperties(light, effect, i);
  65961. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  65962. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  65963. if (defines["SPECULARTERM"]) {
  65964. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  65965. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  65966. }
  65967. // Shadows
  65968. if (scene.shadowsEnabled) {
  65969. this.BindLightShadow(light, mesh, iAsString, effect);
  65970. }
  65971. light._uniformBuffer.update();
  65972. }
  65973. };
  65974. /**
  65975. * Binds the fog information from the scene to the effect for the given mesh.
  65976. * @param scene The scene the lights belongs to
  65977. * @param mesh The mesh we are binding the information to render
  65978. * @param effect The effect we are binding the data to
  65979. * @param linearSpace Defines if the fog effect is applied in linear space
  65980. */
  65981. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  65982. if (linearSpace === void 0) { linearSpace = false; }
  65983. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  65984. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  65985. // Convert fog color to linear space if used in a linear space computed shader.
  65986. if (linearSpace) {
  65987. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  65988. effect.setColor3("vFogColor", this._tempFogColor);
  65989. }
  65990. else {
  65991. effect.setColor3("vFogColor", scene.fogColor);
  65992. }
  65993. }
  65994. };
  65995. /**
  65996. * Binds the bones information from the mesh to the effect.
  65997. * @param mesh The mesh we are binding the information to render
  65998. * @param effect The effect we are binding the data to
  65999. */
  66000. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  66001. if (!effect || !mesh) {
  66002. return;
  66003. }
  66004. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  66005. mesh.computeBonesUsingShaders = false;
  66006. }
  66007. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66008. var skeleton = mesh.skeleton;
  66009. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  66010. var boneTexture = skeleton.getTransformMatrixTexture();
  66011. effect.setTexture("boneSampler", boneTexture);
  66012. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  66013. }
  66014. else {
  66015. var matrices = skeleton.getTransformMatrices(mesh);
  66016. if (matrices) {
  66017. effect.setMatrices("mBones", matrices);
  66018. }
  66019. }
  66020. }
  66021. };
  66022. /**
  66023. * Binds the morph targets information from the mesh to the effect.
  66024. * @param abstractMesh The mesh we are binding the information to render
  66025. * @param effect The effect we are binding the data to
  66026. */
  66027. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  66028. var manager = abstractMesh.morphTargetManager;
  66029. if (!abstractMesh || !manager) {
  66030. return;
  66031. }
  66032. effect.setFloatArray("morphTargetInfluences", manager.influences);
  66033. };
  66034. /**
  66035. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66036. * @param defines The generated defines used in the effect
  66037. * @param effect The effect we are binding the data to
  66038. * @param scene The scene we are willing to render with logarithmic scale for
  66039. */
  66040. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  66041. if (defines["LOGARITHMICDEPTH"]) {
  66042. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  66043. }
  66044. };
  66045. /**
  66046. * Binds the clip plane information from the scene to the effect.
  66047. * @param scene The scene the clip plane information are extracted from
  66048. * @param effect The effect we are binding the data to
  66049. */
  66050. MaterialHelper.BindClipPlane = function (effect, scene) {
  66051. if (scene.clipPlane) {
  66052. var clipPlane = scene.clipPlane;
  66053. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66054. }
  66055. if (scene.clipPlane2) {
  66056. var clipPlane = scene.clipPlane2;
  66057. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66058. }
  66059. if (scene.clipPlane3) {
  66060. var clipPlane = scene.clipPlane3;
  66061. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66062. }
  66063. if (scene.clipPlane4) {
  66064. var clipPlane = scene.clipPlane4;
  66065. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66066. }
  66067. };
  66068. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  66069. return MaterialHelper;
  66070. }());
  66071. /***/ }),
  66072. /***/ "./Materials/multiMaterial.ts":
  66073. /*!************************************!*\
  66074. !*** ./Materials/multiMaterial.ts ***!
  66075. \************************************/
  66076. /*! exports provided: MultiMaterial */
  66077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66078. "use strict";
  66079. __webpack_require__.r(__webpack_exports__);
  66080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  66081. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66082. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  66083. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  66084. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  66085. /**
  66086. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66087. * separate meshes. This can be use to improve performances.
  66088. * @see http://doc.babylonjs.com/how_to/multi_materials
  66089. */
  66090. var MultiMaterial = /** @class */ (function (_super) {
  66091. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  66092. /**
  66093. * Instantiates a new Multi Material
  66094. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66095. * separate meshes. This can be use to improve performances.
  66096. * @see http://doc.babylonjs.com/how_to/multi_materials
  66097. * @param name Define the name in the scene
  66098. * @param scene Define the scene the material belongs to
  66099. */
  66100. function MultiMaterial(name, scene) {
  66101. var _this = _super.call(this, name, scene, true) || this;
  66102. scene.multiMaterials.push(_this);
  66103. _this.subMaterials = new Array();
  66104. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  66105. return _this;
  66106. }
  66107. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  66108. /**
  66109. * Gets or Sets the list of Materials used within the multi material.
  66110. * They need to be ordered according to the submeshes order in the associated mesh
  66111. */
  66112. get: function () {
  66113. return this._subMaterials;
  66114. },
  66115. set: function (value) {
  66116. this._subMaterials = value;
  66117. this._hookArray(value);
  66118. },
  66119. enumerable: true,
  66120. configurable: true
  66121. });
  66122. /**
  66123. * Function used to align with Node.getChildren()
  66124. * @returns the list of Materials used within the multi material
  66125. */
  66126. MultiMaterial.prototype.getChildren = function () {
  66127. return this.subMaterials;
  66128. };
  66129. MultiMaterial.prototype._hookArray = function (array) {
  66130. var _this = this;
  66131. var oldPush = array.push;
  66132. array.push = function () {
  66133. var items = [];
  66134. for (var _i = 0; _i < arguments.length; _i++) {
  66135. items[_i] = arguments[_i];
  66136. }
  66137. var result = oldPush.apply(array, items);
  66138. _this._markAllSubMeshesAsTexturesDirty();
  66139. return result;
  66140. };
  66141. var oldSplice = array.splice;
  66142. array.splice = function (index, deleteCount) {
  66143. var deleted = oldSplice.apply(array, [index, deleteCount]);
  66144. _this._markAllSubMeshesAsTexturesDirty();
  66145. return deleted;
  66146. };
  66147. };
  66148. /**
  66149. * Get one of the submaterial by its index in the submaterials array
  66150. * @param index The index to look the sub material at
  66151. * @returns The Material if the index has been defined
  66152. */
  66153. MultiMaterial.prototype.getSubMaterial = function (index) {
  66154. if (index < 0 || index >= this.subMaterials.length) {
  66155. return this.getScene().defaultMaterial;
  66156. }
  66157. return this.subMaterials[index];
  66158. };
  66159. /**
  66160. * Get the list of active textures for the whole sub materials list.
  66161. * @returns All the textures that will be used during the rendering
  66162. */
  66163. MultiMaterial.prototype.getActiveTextures = function () {
  66164. var _a;
  66165. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  66166. if (subMaterial) {
  66167. return subMaterial.getActiveTextures();
  66168. }
  66169. else {
  66170. return [];
  66171. }
  66172. }));
  66173. };
  66174. /**
  66175. * Gets the current class name of the material e.g. "MultiMaterial"
  66176. * Mainly use in serialization.
  66177. * @returns the class name
  66178. */
  66179. MultiMaterial.prototype.getClassName = function () {
  66180. return "MultiMaterial";
  66181. };
  66182. /**
  66183. * Checks if the material is ready to render the requested sub mesh
  66184. * @param mesh Define the mesh the submesh belongs to
  66185. * @param subMesh Define the sub mesh to look readyness for
  66186. * @param useInstances Define whether or not the material is used with instances
  66187. * @returns true if ready, otherwise false
  66188. */
  66189. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  66190. for (var index = 0; index < this.subMaterials.length; index++) {
  66191. var subMaterial = this.subMaterials[index];
  66192. if (subMaterial) {
  66193. if (subMaterial._storeEffectOnSubMeshes) {
  66194. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  66195. return false;
  66196. }
  66197. continue;
  66198. }
  66199. if (!subMaterial.isReady(mesh)) {
  66200. return false;
  66201. }
  66202. }
  66203. }
  66204. return true;
  66205. };
  66206. /**
  66207. * Clones the current material and its related sub materials
  66208. * @param name Define the name of the newly cloned material
  66209. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66210. * @returns the cloned material
  66211. */
  66212. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  66213. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  66214. for (var index = 0; index < this.subMaterials.length; index++) {
  66215. var subMaterial = null;
  66216. var current = this.subMaterials[index];
  66217. if (cloneChildren && current) {
  66218. subMaterial = current.clone(name + "-" + current.name);
  66219. }
  66220. else {
  66221. subMaterial = this.subMaterials[index];
  66222. }
  66223. newMultiMaterial.subMaterials.push(subMaterial);
  66224. }
  66225. return newMultiMaterial;
  66226. };
  66227. /**
  66228. * Serializes the materials into a JSON representation.
  66229. * @returns the JSON representation
  66230. */
  66231. MultiMaterial.prototype.serialize = function () {
  66232. var serializationObject = {};
  66233. serializationObject.name = this.name;
  66234. serializationObject.id = this.id;
  66235. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  66236. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  66237. }
  66238. serializationObject.materials = [];
  66239. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  66240. var subMat = this.subMaterials[matIndex];
  66241. if (subMat) {
  66242. serializationObject.materials.push(subMat.id);
  66243. }
  66244. else {
  66245. serializationObject.materials.push(null);
  66246. }
  66247. }
  66248. return serializationObject;
  66249. };
  66250. /**
  66251. * Dispose the material and release its associated resources
  66252. * @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)
  66253. * @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)
  66254. * @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)
  66255. */
  66256. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  66257. var scene = this.getScene();
  66258. if (!scene) {
  66259. return;
  66260. }
  66261. if (forceDisposeChildren) {
  66262. for (var index = 0; index < this.subMaterials.length; index++) {
  66263. var subMaterial = this.subMaterials[index];
  66264. if (subMaterial) {
  66265. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  66266. }
  66267. }
  66268. }
  66269. var index = scene.multiMaterials.indexOf(this);
  66270. if (index >= 0) {
  66271. scene.multiMaterials.splice(index, 1);
  66272. }
  66273. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  66274. };
  66275. /**
  66276. * Creates a MultiMaterial from parsed MultiMaterial data.
  66277. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66278. * @param scene defines the hosting scene
  66279. * @returns a new MultiMaterial
  66280. */
  66281. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  66282. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  66283. multiMaterial.id = parsedMultiMaterial.id;
  66284. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  66285. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  66286. }
  66287. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  66288. var subMatId = parsedMultiMaterial.materials[matIndex];
  66289. if (subMatId) {
  66290. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  66291. }
  66292. else {
  66293. multiMaterial.subMaterials.push(null);
  66294. }
  66295. }
  66296. return multiMaterial;
  66297. };
  66298. return MultiMaterial;
  66299. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  66300. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  66301. /***/ }),
  66302. /***/ "./Materials/pushMaterial.ts":
  66303. /*!***********************************!*\
  66304. !*** ./Materials/pushMaterial.ts ***!
  66305. \***********************************/
  66306. /*! exports provided: PushMaterial */
  66307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66308. "use strict";
  66309. __webpack_require__.r(__webpack_exports__);
  66310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  66311. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66312. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66313. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  66314. /**
  66315. * Base class of materials working in push mode in babylon JS
  66316. * @hidden
  66317. */
  66318. var PushMaterial = /** @class */ (function (_super) {
  66319. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  66320. function PushMaterial(name, scene) {
  66321. var _this = _super.call(this, name, scene) || this;
  66322. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  66323. /**
  66324. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  66325. * This means that the material can keep using a previous shader while a new one is being compiled.
  66326. * This is mostly used when shader parallel compilation is supported (true by default)
  66327. */
  66328. _this.allowShaderHotSwapping = true;
  66329. _this._storeEffectOnSubMeshes = true;
  66330. return _this;
  66331. }
  66332. PushMaterial.prototype.getEffect = function () {
  66333. return this._activeEffect;
  66334. };
  66335. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  66336. if (!mesh) {
  66337. return false;
  66338. }
  66339. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  66340. return true;
  66341. }
  66342. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  66343. };
  66344. /**
  66345. * Binds the given world matrix to the active effect
  66346. *
  66347. * @param world the matrix to bind
  66348. */
  66349. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  66350. this._activeEffect.setMatrix("world", world);
  66351. };
  66352. /**
  66353. * Binds the given normal matrix to the active effect
  66354. *
  66355. * @param normalMatrix the matrix to bind
  66356. */
  66357. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  66358. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  66359. };
  66360. PushMaterial.prototype.bind = function (world, mesh) {
  66361. if (!mesh) {
  66362. return;
  66363. }
  66364. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  66365. };
  66366. PushMaterial.prototype._afterBind = function (mesh, effect) {
  66367. if (effect === void 0) { effect = null; }
  66368. _super.prototype._afterBind.call(this, mesh);
  66369. this.getScene()._cachedEffect = effect;
  66370. };
  66371. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  66372. if (visibility === void 0) { visibility = 1; }
  66373. return scene.isCachedMaterialInvalid(this, effect, visibility);
  66374. };
  66375. return PushMaterial;
  66376. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  66377. /***/ }),
  66378. /***/ "./Materials/shaderMaterial.ts":
  66379. /*!*************************************!*\
  66380. !*** ./Materials/shaderMaterial.ts ***!
  66381. \*************************************/
  66382. /*! exports provided: ShaderMaterial */
  66383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66384. "use strict";
  66385. __webpack_require__.r(__webpack_exports__);
  66386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  66387. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66388. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  66389. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66390. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  66391. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  66392. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  66393. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  66394. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  66395. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  66396. /**
  66397. * 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.
  66398. *
  66399. * This returned material effects how the mesh will look based on the code in the shaders.
  66400. *
  66401. * @see http://doc.babylonjs.com/how_to/shader_material
  66402. */
  66403. var ShaderMaterial = /** @class */ (function (_super) {
  66404. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  66405. /**
  66406. * Instantiate a new shader material.
  66407. * 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.
  66408. * This returned material effects how the mesh will look based on the code in the shaders.
  66409. * @see http://doc.babylonjs.com/how_to/shader_material
  66410. * @param name Define the name of the material in the scene
  66411. * @param scene Define the scene the material belongs to
  66412. * @param shaderPath Defines the route to the shader code in one of three ways:
  66413. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  66414. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  66415. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  66416. * @param options Define the options used to create the shader
  66417. */
  66418. function ShaderMaterial(name, scene, shaderPath, options) {
  66419. if (options === void 0) { options = {}; }
  66420. var _this = _super.call(this, name, scene) || this;
  66421. _this._textures = {};
  66422. _this._textureArrays = {};
  66423. _this._floats = {};
  66424. _this._ints = {};
  66425. _this._floatsArrays = {};
  66426. _this._colors3 = {};
  66427. _this._colors3Arrays = {};
  66428. _this._colors4 = {};
  66429. _this._vectors2 = {};
  66430. _this._vectors3 = {};
  66431. _this._vectors4 = {};
  66432. _this._matrices = {};
  66433. _this._matrices3x3 = {};
  66434. _this._matrices2x2 = {};
  66435. _this._vectors2Arrays = {};
  66436. _this._vectors3Arrays = {};
  66437. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  66438. _this._shaderPath = shaderPath;
  66439. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  66440. return _this;
  66441. }
  66442. /**
  66443. * Gets the current class name of the material e.g. "ShaderMaterial"
  66444. * Mainly use in serialization.
  66445. * @returns the class name
  66446. */
  66447. ShaderMaterial.prototype.getClassName = function () {
  66448. return "ShaderMaterial";
  66449. };
  66450. /**
  66451. * Specifies if the material will require alpha blending
  66452. * @returns a boolean specifying if alpha blending is needed
  66453. */
  66454. ShaderMaterial.prototype.needAlphaBlending = function () {
  66455. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  66456. };
  66457. /**
  66458. * Specifies if this material should be rendered in alpha test mode
  66459. * @returns a boolean specifying if an alpha test is needed.
  66460. */
  66461. ShaderMaterial.prototype.needAlphaTesting = function () {
  66462. return this._options.needAlphaTesting;
  66463. };
  66464. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  66465. if (this._options.uniforms.indexOf(uniformName) === -1) {
  66466. this._options.uniforms.push(uniformName);
  66467. }
  66468. };
  66469. /**
  66470. * Set a texture in the shader.
  66471. * @param name Define the name of the uniform samplers as defined in the shader
  66472. * @param texture Define the texture to bind to this sampler
  66473. * @return the material itself allowing "fluent" like uniform updates
  66474. */
  66475. ShaderMaterial.prototype.setTexture = function (name, texture) {
  66476. if (this._options.samplers.indexOf(name) === -1) {
  66477. this._options.samplers.push(name);
  66478. }
  66479. this._textures[name] = texture;
  66480. return this;
  66481. };
  66482. /**
  66483. * Set a texture array in the shader.
  66484. * @param name Define the name of the uniform sampler array as defined in the shader
  66485. * @param textures Define the list of textures to bind to this sampler
  66486. * @return the material itself allowing "fluent" like uniform updates
  66487. */
  66488. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  66489. if (this._options.samplers.indexOf(name) === -1) {
  66490. this._options.samplers.push(name);
  66491. }
  66492. this._checkUniform(name);
  66493. this._textureArrays[name] = textures;
  66494. return this;
  66495. };
  66496. /**
  66497. * Set a float in the shader.
  66498. * @param name Define the name of the uniform as defined in the shader
  66499. * @param value Define the value to give to the uniform
  66500. * @return the material itself allowing "fluent" like uniform updates
  66501. */
  66502. ShaderMaterial.prototype.setFloat = function (name, value) {
  66503. this._checkUniform(name);
  66504. this._floats[name] = value;
  66505. return this;
  66506. };
  66507. /**
  66508. * Set a int in the shader.
  66509. * @param name Define the name of the uniform as defined in the shader
  66510. * @param value Define the value to give to the uniform
  66511. * @return the material itself allowing "fluent" like uniform updates
  66512. */
  66513. ShaderMaterial.prototype.setInt = function (name, value) {
  66514. this._checkUniform(name);
  66515. this._ints[name] = value;
  66516. return this;
  66517. };
  66518. /**
  66519. * Set an array of floats in the shader.
  66520. * @param name Define the name of the uniform as defined in the shader
  66521. * @param value Define the value to give to the uniform
  66522. * @return the material itself allowing "fluent" like uniform updates
  66523. */
  66524. ShaderMaterial.prototype.setFloats = function (name, value) {
  66525. this._checkUniform(name);
  66526. this._floatsArrays[name] = value;
  66527. return this;
  66528. };
  66529. /**
  66530. * Set a vec3 in the shader from a Color3.
  66531. * @param name Define the name of the uniform as defined in the shader
  66532. * @param value Define the value to give to the uniform
  66533. * @return the material itself allowing "fluent" like uniform updates
  66534. */
  66535. ShaderMaterial.prototype.setColor3 = function (name, value) {
  66536. this._checkUniform(name);
  66537. this._colors3[name] = value;
  66538. return this;
  66539. };
  66540. /**
  66541. * Set a vec3 array in the shader from a Color3 array.
  66542. * @param name Define the name of the uniform as defined in the shader
  66543. * @param value Define the value to give to the uniform
  66544. * @return the material itself allowing "fluent" like uniform updates
  66545. */
  66546. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  66547. this._checkUniform(name);
  66548. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  66549. color.toArray(arr, arr.length);
  66550. return arr;
  66551. }, []);
  66552. return this;
  66553. };
  66554. /**
  66555. * Set a vec4 in the shader from a Color4.
  66556. * @param name Define the name of the uniform as defined in the shader
  66557. * @param value Define the value to give to the uniform
  66558. * @return the material itself allowing "fluent" like uniform updates
  66559. */
  66560. ShaderMaterial.prototype.setColor4 = function (name, value) {
  66561. this._checkUniform(name);
  66562. this._colors4[name] = value;
  66563. return this;
  66564. };
  66565. /**
  66566. * Set a vec2 in the shader from a Vector2.
  66567. * @param name Define the name of the uniform as defined in the shader
  66568. * @param value Define the value to give to the uniform
  66569. * @return the material itself allowing "fluent" like uniform updates
  66570. */
  66571. ShaderMaterial.prototype.setVector2 = function (name, value) {
  66572. this._checkUniform(name);
  66573. this._vectors2[name] = value;
  66574. return this;
  66575. };
  66576. /**
  66577. * Set a vec3 in the shader from a Vector3.
  66578. * @param name Define the name of the uniform as defined in the shader
  66579. * @param value Define the value to give to the uniform
  66580. * @return the material itself allowing "fluent" like uniform updates
  66581. */
  66582. ShaderMaterial.prototype.setVector3 = function (name, value) {
  66583. this._checkUniform(name);
  66584. this._vectors3[name] = value;
  66585. return this;
  66586. };
  66587. /**
  66588. * Set a vec4 in the shader from a Vector4.
  66589. * @param name Define the name of the uniform as defined in the shader
  66590. * @param value Define the value to give to the uniform
  66591. * @return the material itself allowing "fluent" like uniform updates
  66592. */
  66593. ShaderMaterial.prototype.setVector4 = function (name, value) {
  66594. this._checkUniform(name);
  66595. this._vectors4[name] = value;
  66596. return this;
  66597. };
  66598. /**
  66599. * Set a mat4 in the shader from a Matrix.
  66600. * @param name Define the name of the uniform as defined in the shader
  66601. * @param value Define the value to give to the uniform
  66602. * @return the material itself allowing "fluent" like uniform updates
  66603. */
  66604. ShaderMaterial.prototype.setMatrix = function (name, value) {
  66605. this._checkUniform(name);
  66606. this._matrices[name] = value;
  66607. return this;
  66608. };
  66609. /**
  66610. * Set a mat3 in the shader from a Float32Array.
  66611. * @param name Define the name of the uniform as defined in the shader
  66612. * @param value Define the value to give to the uniform
  66613. * @return the material itself allowing "fluent" like uniform updates
  66614. */
  66615. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  66616. this._checkUniform(name);
  66617. this._matrices3x3[name] = value;
  66618. return this;
  66619. };
  66620. /**
  66621. * Set a mat2 in the shader from a Float32Array.
  66622. * @param name Define the name of the uniform as defined in the shader
  66623. * @param value Define the value to give to the uniform
  66624. * @return the material itself allowing "fluent" like uniform updates
  66625. */
  66626. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  66627. this._checkUniform(name);
  66628. this._matrices2x2[name] = value;
  66629. return this;
  66630. };
  66631. /**
  66632. * Set a vec2 array in the shader from a number array.
  66633. * @param name Define the name of the uniform as defined in the shader
  66634. * @param value Define the value to give to the uniform
  66635. * @return the material itself allowing "fluent" like uniform updates
  66636. */
  66637. ShaderMaterial.prototype.setArray2 = function (name, value) {
  66638. this._checkUniform(name);
  66639. this._vectors2Arrays[name] = value;
  66640. return this;
  66641. };
  66642. /**
  66643. * Set a vec3 array in the shader from a number array.
  66644. * @param name Define the name of the uniform as defined in the shader
  66645. * @param value Define the value to give to the uniform
  66646. * @return the material itself allowing "fluent" like uniform updates
  66647. */
  66648. ShaderMaterial.prototype.setArray3 = function (name, value) {
  66649. this._checkUniform(name);
  66650. this._vectors3Arrays[name] = value;
  66651. return this;
  66652. };
  66653. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  66654. if (!mesh) {
  66655. return true;
  66656. }
  66657. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  66658. return false;
  66659. }
  66660. return false;
  66661. };
  66662. /**
  66663. * Checks if the material is ready to render the requested mesh
  66664. * @param mesh Define the mesh to render
  66665. * @param useInstances Define whether or not the material is used with instances
  66666. * @returns true if ready, otherwise false
  66667. */
  66668. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  66669. var scene = this.getScene();
  66670. var engine = scene.getEngine();
  66671. if (!this.checkReadyOnEveryCall) {
  66672. if (this._renderId === scene.getRenderId()) {
  66673. if (this._checkCache(mesh, useInstances)) {
  66674. return true;
  66675. }
  66676. }
  66677. }
  66678. // Instances
  66679. var defines = [];
  66680. var attribs = [];
  66681. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  66682. for (var index = 0; index < this._options.defines.length; index++) {
  66683. defines.push(this._options.defines[index]);
  66684. }
  66685. for (var index = 0; index < this._options.attributes.length; index++) {
  66686. attribs.push(this._options.attributes[index]);
  66687. }
  66688. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  66689. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  66690. defines.push("#define VERTEXCOLOR");
  66691. }
  66692. if (useInstances) {
  66693. defines.push("#define INSTANCES");
  66694. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  66695. }
  66696. // Bones
  66697. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66698. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  66699. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  66700. if (mesh.numBoneInfluencers > 4) {
  66701. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  66702. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  66703. }
  66704. var skeleton = mesh.skeleton;
  66705. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  66706. fallbacks.addCPUSkinningFallback(0, mesh);
  66707. if (skeleton.isUsingTextureForMatrices) {
  66708. defines.push("#define BONETEXTURE");
  66709. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  66710. this._options.uniforms.push("boneTextureWidth");
  66711. }
  66712. if (this._options.samplers.indexOf("boneSampler") === -1) {
  66713. this._options.samplers.push("boneSampler");
  66714. }
  66715. }
  66716. else {
  66717. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  66718. if (this._options.uniforms.indexOf("mBones") === -1) {
  66719. this._options.uniforms.push("mBones");
  66720. }
  66721. }
  66722. }
  66723. else {
  66724. defines.push("#define NUM_BONE_INFLUENCERS 0");
  66725. }
  66726. // Textures
  66727. for (var name in this._textures) {
  66728. if (!this._textures[name].isReady()) {
  66729. return false;
  66730. }
  66731. }
  66732. // Alpha test
  66733. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  66734. defines.push("#define ALPHATEST");
  66735. }
  66736. var previousEffect = this._effect;
  66737. var join = defines.join("\n");
  66738. this._effect = engine.createEffect(this._shaderPath, {
  66739. attributes: attribs,
  66740. uniformsNames: this._options.uniforms,
  66741. uniformBuffersNames: this._options.uniformBuffers,
  66742. samplers: this._options.samplers,
  66743. defines: join,
  66744. fallbacks: fallbacks,
  66745. onCompiled: this.onCompiled,
  66746. onError: this.onError
  66747. }, engine);
  66748. if (!this._effect.isReady()) {
  66749. return false;
  66750. }
  66751. if (previousEffect !== this._effect) {
  66752. scene.resetCachedMaterial();
  66753. }
  66754. this._renderId = scene.getRenderId();
  66755. return true;
  66756. };
  66757. /**
  66758. * Binds the world matrix to the material
  66759. * @param world defines the world transformation matrix
  66760. */
  66761. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  66762. var scene = this.getScene();
  66763. if (!this._effect) {
  66764. return;
  66765. }
  66766. if (this._options.uniforms.indexOf("world") !== -1) {
  66767. this._effect.setMatrix("world", world);
  66768. }
  66769. if (this._options.uniforms.indexOf("worldView") !== -1) {
  66770. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  66771. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  66772. }
  66773. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  66774. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  66775. }
  66776. };
  66777. /**
  66778. * Binds the material to the mesh
  66779. * @param world defines the world transformation matrix
  66780. * @param mesh defines the mesh to bind the material to
  66781. */
  66782. ShaderMaterial.prototype.bind = function (world, mesh) {
  66783. // Std values
  66784. this.bindOnlyWorldMatrix(world);
  66785. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  66786. if (this._options.uniforms.indexOf("view") !== -1) {
  66787. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  66788. }
  66789. if (this._options.uniforms.indexOf("projection") !== -1) {
  66790. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  66791. }
  66792. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  66793. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  66794. }
  66795. // Bones
  66796. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  66797. var name;
  66798. // Texture
  66799. for (name in this._textures) {
  66800. this._effect.setTexture(name, this._textures[name]);
  66801. }
  66802. // Texture arrays
  66803. for (name in this._textureArrays) {
  66804. this._effect.setTextureArray(name, this._textureArrays[name]);
  66805. }
  66806. // Int
  66807. for (name in this._ints) {
  66808. this._effect.setInt(name, this._ints[name]);
  66809. }
  66810. // Float
  66811. for (name in this._floats) {
  66812. this._effect.setFloat(name, this._floats[name]);
  66813. }
  66814. // Floats
  66815. for (name in this._floatsArrays) {
  66816. this._effect.setArray(name, this._floatsArrays[name]);
  66817. }
  66818. // Color3
  66819. for (name in this._colors3) {
  66820. this._effect.setColor3(name, this._colors3[name]);
  66821. }
  66822. for (name in this._colors3Arrays) {
  66823. this._effect.setArray3(name, this._colors3Arrays[name]);
  66824. }
  66825. // Color4
  66826. for (name in this._colors4) {
  66827. var color = this._colors4[name];
  66828. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  66829. }
  66830. // Vector2
  66831. for (name in this._vectors2) {
  66832. this._effect.setVector2(name, this._vectors2[name]);
  66833. }
  66834. // Vector3
  66835. for (name in this._vectors3) {
  66836. this._effect.setVector3(name, this._vectors3[name]);
  66837. }
  66838. // Vector4
  66839. for (name in this._vectors4) {
  66840. this._effect.setVector4(name, this._vectors4[name]);
  66841. }
  66842. // Matrix
  66843. for (name in this._matrices) {
  66844. this._effect.setMatrix(name, this._matrices[name]);
  66845. }
  66846. // Matrix 3x3
  66847. for (name in this._matrices3x3) {
  66848. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  66849. }
  66850. // Matrix 2x2
  66851. for (name in this._matrices2x2) {
  66852. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  66853. }
  66854. // Vector2Array
  66855. for (name in this._vectors2Arrays) {
  66856. this._effect.setArray2(name, this._vectors2Arrays[name]);
  66857. }
  66858. // Vector3Array
  66859. for (name in this._vectors3Arrays) {
  66860. this._effect.setArray3(name, this._vectors3Arrays[name]);
  66861. }
  66862. }
  66863. this._afterBind(mesh);
  66864. };
  66865. /**
  66866. * Gets the active textures from the material
  66867. * @returns an array of textures
  66868. */
  66869. ShaderMaterial.prototype.getActiveTextures = function () {
  66870. var activeTextures = _super.prototype.getActiveTextures.call(this);
  66871. for (var name in this._textures) {
  66872. activeTextures.push(this._textures[name]);
  66873. }
  66874. for (var name in this._textureArrays) {
  66875. var array = this._textureArrays[name];
  66876. for (var index = 0; index < array.length; index++) {
  66877. activeTextures.push(array[index]);
  66878. }
  66879. }
  66880. return activeTextures;
  66881. };
  66882. /**
  66883. * Specifies if the material uses a texture
  66884. * @param texture defines the texture to check against the material
  66885. * @returns a boolean specifying if the material uses the texture
  66886. */
  66887. ShaderMaterial.prototype.hasTexture = function (texture) {
  66888. if (_super.prototype.hasTexture.call(this, texture)) {
  66889. return true;
  66890. }
  66891. for (var name in this._textures) {
  66892. if (this._textures[name] === texture) {
  66893. return true;
  66894. }
  66895. }
  66896. for (var name in this._textureArrays) {
  66897. var array = this._textureArrays[name];
  66898. for (var index = 0; index < array.length; index++) {
  66899. if (array[index] === texture) {
  66900. return true;
  66901. }
  66902. }
  66903. }
  66904. return false;
  66905. };
  66906. /**
  66907. * Makes a duplicate of the material, and gives it a new name
  66908. * @param name defines the new name for the duplicated material
  66909. * @returns the cloned material
  66910. */
  66911. ShaderMaterial.prototype.clone = function (name) {
  66912. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  66913. return newShaderMaterial;
  66914. };
  66915. /**
  66916. * Disposes the material
  66917. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66918. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66919. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  66920. */
  66921. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  66922. if (forceDisposeTextures) {
  66923. var name;
  66924. for (name in this._textures) {
  66925. this._textures[name].dispose();
  66926. }
  66927. for (name in this._textureArrays) {
  66928. var array = this._textureArrays[name];
  66929. for (var index = 0; index < array.length; index++) {
  66930. array[index].dispose();
  66931. }
  66932. }
  66933. }
  66934. this._textures = {};
  66935. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  66936. };
  66937. /**
  66938. * Serializes this material in a JSON representation
  66939. * @returns the serialized material object
  66940. */
  66941. ShaderMaterial.prototype.serialize = function () {
  66942. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66943. serializationObject.customType = "ShaderMaterial";
  66944. serializationObject.options = this._options;
  66945. serializationObject.shaderPath = this._shaderPath;
  66946. var name;
  66947. // Texture
  66948. serializationObject.textures = {};
  66949. for (name in this._textures) {
  66950. serializationObject.textures[name] = this._textures[name].serialize();
  66951. }
  66952. // Texture arrays
  66953. serializationObject.textureArrays = {};
  66954. for (name in this._textureArrays) {
  66955. serializationObject.textureArrays[name] = [];
  66956. var array = this._textureArrays[name];
  66957. for (var index = 0; index < array.length; index++) {
  66958. serializationObject.textureArrays[name].push(array[index].serialize());
  66959. }
  66960. }
  66961. // Float
  66962. serializationObject.floats = {};
  66963. for (name in this._floats) {
  66964. serializationObject.floats[name] = this._floats[name];
  66965. }
  66966. // Float s
  66967. serializationObject.FloatArrays = {};
  66968. for (name in this._floatsArrays) {
  66969. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  66970. }
  66971. // Color3
  66972. serializationObject.colors3 = {};
  66973. for (name in this._colors3) {
  66974. serializationObject.colors3[name] = this._colors3[name].asArray();
  66975. }
  66976. // Color3 array
  66977. serializationObject.colors3Arrays = {};
  66978. for (name in this._colors3Arrays) {
  66979. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  66980. }
  66981. // Color4
  66982. serializationObject.colors4 = {};
  66983. for (name in this._colors4) {
  66984. serializationObject.colors4[name] = this._colors4[name].asArray();
  66985. }
  66986. // Vector2
  66987. serializationObject.vectors2 = {};
  66988. for (name in this._vectors2) {
  66989. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  66990. }
  66991. // Vector3
  66992. serializationObject.vectors3 = {};
  66993. for (name in this._vectors3) {
  66994. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  66995. }
  66996. // Vector4
  66997. serializationObject.vectors4 = {};
  66998. for (name in this._vectors4) {
  66999. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  67000. }
  67001. // Matrix
  67002. serializationObject.matrices = {};
  67003. for (name in this._matrices) {
  67004. serializationObject.matrices[name] = this._matrices[name].asArray();
  67005. }
  67006. // Matrix 3x3
  67007. serializationObject.matrices3x3 = {};
  67008. for (name in this._matrices3x3) {
  67009. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  67010. }
  67011. // Matrix 2x2
  67012. serializationObject.matrices2x2 = {};
  67013. for (name in this._matrices2x2) {
  67014. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  67015. }
  67016. // Vector2Array
  67017. serializationObject.vectors2Arrays = {};
  67018. for (name in this._vectors2Arrays) {
  67019. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  67020. }
  67021. // Vector3Array
  67022. serializationObject.vectors3Arrays = {};
  67023. for (name in this._vectors3Arrays) {
  67024. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  67025. }
  67026. return serializationObject;
  67027. };
  67028. /**
  67029. * Creates a shader material from parsed shader material data
  67030. * @param source defines the JSON represnetation of the material
  67031. * @param scene defines the hosting scene
  67032. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67033. * @returns a new material
  67034. */
  67035. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  67036. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  67037. var name;
  67038. // Texture
  67039. for (name in source.textures) {
  67040. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  67041. }
  67042. // Texture arrays
  67043. for (name in source.textureArrays) {
  67044. var array = source.textureArrays[name];
  67045. var textureArray = new Array();
  67046. for (var index = 0; index < array.length; index++) {
  67047. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  67048. }
  67049. material.setTextureArray(name, textureArray);
  67050. }
  67051. // Float
  67052. for (name in source.floats) {
  67053. material.setFloat(name, source.floats[name]);
  67054. }
  67055. // Float s
  67056. for (name in source.floatsArrays) {
  67057. material.setFloats(name, source.floatsArrays[name]);
  67058. }
  67059. // Color3
  67060. for (name in source.colors3) {
  67061. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  67062. }
  67063. // Color3 arrays
  67064. for (name in source.colors3Arrays) {
  67065. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  67066. if (i % 3 === 0) {
  67067. arr.push([num]);
  67068. }
  67069. else {
  67070. arr[arr.length - 1].push(num);
  67071. }
  67072. return arr;
  67073. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  67074. material.setColor3Array(name, colors);
  67075. }
  67076. // Color4
  67077. for (name in source.colors4) {
  67078. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  67079. }
  67080. // Vector2
  67081. for (name in source.vectors2) {
  67082. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  67083. }
  67084. // Vector3
  67085. for (name in source.vectors3) {
  67086. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  67087. }
  67088. // Vector4
  67089. for (name in source.vectors4) {
  67090. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  67091. }
  67092. // Matrix
  67093. for (name in source.matrices) {
  67094. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  67095. }
  67096. // Matrix 3x3
  67097. for (name in source.matrices3x3) {
  67098. material.setMatrix3x3(name, source.matrices3x3[name]);
  67099. }
  67100. // Matrix 2x2
  67101. for (name in source.matrices2x2) {
  67102. material.setMatrix2x2(name, source.matrices2x2[name]);
  67103. }
  67104. // Vector2Array
  67105. for (name in source.vectors2Arrays) {
  67106. material.setArray2(name, source.vectors2Arrays[name]);
  67107. }
  67108. // Vector3Array
  67109. for (name in source.vectors3Arrays) {
  67110. material.setArray3(name, source.vectors3Arrays[name]);
  67111. }
  67112. return material;
  67113. };
  67114. return ShaderMaterial;
  67115. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  67116. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  67117. /***/ }),
  67118. /***/ "./Materials/standardMaterial.ts":
  67119. /*!***************************************!*\
  67120. !*** ./Materials/standardMaterial.ts ***!
  67121. \***************************************/
  67122. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  67123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67124. "use strict";
  67125. __webpack_require__.r(__webpack_exports__);
  67126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  67127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  67128. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67129. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  67130. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  67131. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  67132. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67133. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  67134. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  67135. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  67136. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  67137. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  67138. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  67139. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  67140. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  67141. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  67142. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  67143. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  67144. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  67145. /** @hidden */
  67146. var StandardMaterialDefines = /** @class */ (function (_super) {
  67147. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  67148. function StandardMaterialDefines() {
  67149. var _this = _super.call(this) || this;
  67150. _this.MAINUV1 = false;
  67151. _this.MAINUV2 = false;
  67152. _this.DIFFUSE = false;
  67153. _this.DIFFUSEDIRECTUV = 0;
  67154. _this.AMBIENT = false;
  67155. _this.AMBIENTDIRECTUV = 0;
  67156. _this.OPACITY = false;
  67157. _this.OPACITYDIRECTUV = 0;
  67158. _this.OPACITYRGB = false;
  67159. _this.REFLECTION = false;
  67160. _this.EMISSIVE = false;
  67161. _this.EMISSIVEDIRECTUV = 0;
  67162. _this.SPECULAR = false;
  67163. _this.SPECULARDIRECTUV = 0;
  67164. _this.BUMP = false;
  67165. _this.BUMPDIRECTUV = 0;
  67166. _this.PARALLAX = false;
  67167. _this.PARALLAXOCCLUSION = false;
  67168. _this.SPECULAROVERALPHA = false;
  67169. _this.CLIPPLANE = false;
  67170. _this.CLIPPLANE2 = false;
  67171. _this.CLIPPLANE3 = false;
  67172. _this.CLIPPLANE4 = false;
  67173. _this.ALPHATEST = false;
  67174. _this.DEPTHPREPASS = false;
  67175. _this.ALPHAFROMDIFFUSE = false;
  67176. _this.POINTSIZE = false;
  67177. _this.FOG = false;
  67178. _this.SPECULARTERM = false;
  67179. _this.DIFFUSEFRESNEL = false;
  67180. _this.OPACITYFRESNEL = false;
  67181. _this.REFLECTIONFRESNEL = false;
  67182. _this.REFRACTIONFRESNEL = false;
  67183. _this.EMISSIVEFRESNEL = false;
  67184. _this.FRESNEL = false;
  67185. _this.NORMAL = false;
  67186. _this.UV1 = false;
  67187. _this.UV2 = false;
  67188. _this.VERTEXCOLOR = false;
  67189. _this.VERTEXALPHA = false;
  67190. _this.NUM_BONE_INFLUENCERS = 0;
  67191. _this.BonesPerMesh = 0;
  67192. _this.BONETEXTURE = false;
  67193. _this.INSTANCES = false;
  67194. _this.GLOSSINESS = false;
  67195. _this.ROUGHNESS = false;
  67196. _this.EMISSIVEASILLUMINATION = false;
  67197. _this.LINKEMISSIVEWITHDIFFUSE = false;
  67198. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  67199. _this.LIGHTMAP = false;
  67200. _this.LIGHTMAPDIRECTUV = 0;
  67201. _this.OBJECTSPACE_NORMALMAP = false;
  67202. _this.USELIGHTMAPASSHADOWMAP = false;
  67203. _this.REFLECTIONMAP_3D = false;
  67204. _this.REFLECTIONMAP_SPHERICAL = false;
  67205. _this.REFLECTIONMAP_PLANAR = false;
  67206. _this.REFLECTIONMAP_CUBIC = false;
  67207. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  67208. _this.REFLECTIONMAP_PROJECTION = false;
  67209. _this.REFLECTIONMAP_SKYBOX = false;
  67210. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  67211. _this.REFLECTIONMAP_EXPLICIT = false;
  67212. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  67213. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  67214. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  67215. _this.INVERTCUBICMAP = false;
  67216. _this.LOGARITHMICDEPTH = false;
  67217. _this.REFRACTION = false;
  67218. _this.REFRACTIONMAP_3D = false;
  67219. _this.REFLECTIONOVERALPHA = false;
  67220. _this.TWOSIDEDLIGHTING = false;
  67221. _this.SHADOWFLOAT = false;
  67222. _this.MORPHTARGETS = false;
  67223. _this.MORPHTARGETS_NORMAL = false;
  67224. _this.MORPHTARGETS_TANGENT = false;
  67225. _this.NUM_MORPH_INFLUENCERS = 0;
  67226. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  67227. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  67228. _this.IMAGEPROCESSING = false;
  67229. _this.VIGNETTE = false;
  67230. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  67231. _this.VIGNETTEBLENDMODEOPAQUE = false;
  67232. _this.TONEMAPPING = false;
  67233. _this.TONEMAPPING_ACES = false;
  67234. _this.CONTRAST = false;
  67235. _this.COLORCURVES = false;
  67236. _this.COLORGRADING = false;
  67237. _this.COLORGRADING3D = false;
  67238. _this.SAMPLER3DGREENDEPTH = false;
  67239. _this.SAMPLER3DBGRMAP = false;
  67240. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  67241. /**
  67242. * If the reflection texture on this material is in linear color space
  67243. * @hidden
  67244. */
  67245. _this.IS_REFLECTION_LINEAR = false;
  67246. /**
  67247. * If the refraction texture on this material is in linear color space
  67248. * @hidden
  67249. */
  67250. _this.IS_REFRACTION_LINEAR = false;
  67251. _this.EXPOSURE = false;
  67252. _this.rebuild();
  67253. return _this;
  67254. }
  67255. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  67256. var modes = [
  67257. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  67258. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  67259. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  67260. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  67261. ];
  67262. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  67263. var mode = modes_1[_i];
  67264. this[mode] = (mode === modeToEnable);
  67265. }
  67266. };
  67267. return StandardMaterialDefines;
  67268. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  67269. /**
  67270. * This is the default material used in Babylon. It is the best trade off between quality
  67271. * and performances.
  67272. * @see http://doc.babylonjs.com/babylon101/materials
  67273. */
  67274. var StandardMaterial = /** @class */ (function (_super) {
  67275. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  67276. /**
  67277. * Instantiates a new standard material.
  67278. * This is the default material used in Babylon. It is the best trade off between quality
  67279. * and performances.
  67280. * @see http://doc.babylonjs.com/babylon101/materials
  67281. * @param name Define the name of the material in the scene
  67282. * @param scene Define the scene the material belong to
  67283. */
  67284. function StandardMaterial(name, scene) {
  67285. var _this = _super.call(this, name, scene) || this;
  67286. /**
  67287. * The color of the material lit by the environmental background lighting.
  67288. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  67289. */
  67290. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  67291. /**
  67292. * The basic color of the material as viewed under a light.
  67293. */
  67294. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  67295. /**
  67296. * Define how the color and intensity of the highlight given by the light in the material.
  67297. */
  67298. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  67299. /**
  67300. * Define the color of the material as if self lit.
  67301. * This will be mixed in the final result even in the absence of light.
  67302. */
  67303. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  67304. /**
  67305. * Defines how sharp are the highlights in the material.
  67306. * The bigger the value the sharper giving a more glossy feeling to the result.
  67307. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  67308. */
  67309. _this.specularPower = 64;
  67310. _this._useAlphaFromDiffuseTexture = false;
  67311. _this._useEmissiveAsIllumination = false;
  67312. _this._linkEmissiveWithDiffuse = false;
  67313. _this._useSpecularOverAlpha = false;
  67314. _this._useReflectionOverAlpha = false;
  67315. _this._disableLighting = false;
  67316. _this._useObjectSpaceNormalMap = false;
  67317. _this._useParallax = false;
  67318. _this._useParallaxOcclusion = false;
  67319. /**
  67320. * 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.
  67321. */
  67322. _this.parallaxScaleBias = 0.05;
  67323. _this._roughness = 0;
  67324. /**
  67325. * In case of refraction, define the value of the indice of refraction.
  67326. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  67327. */
  67328. _this.indexOfRefraction = 0.98;
  67329. /**
  67330. * Invert the refraction texture alongside the y axis.
  67331. * It can be useful with procedural textures or probe for instance.
  67332. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  67333. */
  67334. _this.invertRefractionY = true;
  67335. /**
  67336. * Defines the alpha limits in alpha test mode.
  67337. */
  67338. _this.alphaCutOff = 0.4;
  67339. _this._useLightmapAsShadowmap = false;
  67340. _this._useReflectionFresnelFromSpecular = false;
  67341. _this._useGlossinessFromSpecularMapAlpha = false;
  67342. _this._maxSimultaneousLights = 4;
  67343. _this._invertNormalMapX = false;
  67344. _this._invertNormalMapY = false;
  67345. _this._twoSidedLighting = false;
  67346. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  67347. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  67348. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  67349. // Setup the default processing configuration to the scene.
  67350. _this._attachImageProcessingConfiguration(null);
  67351. _this.getRenderTargetTextures = function () {
  67352. _this._renderTargets.reset();
  67353. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  67354. _this._renderTargets.push(_this._reflectionTexture);
  67355. }
  67356. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  67357. _this._renderTargets.push(_this._refractionTexture);
  67358. }
  67359. return _this._renderTargets;
  67360. };
  67361. return _this;
  67362. }
  67363. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  67364. /**
  67365. * Gets the image processing configuration used either in this material.
  67366. */
  67367. get: function () {
  67368. return this._imageProcessingConfiguration;
  67369. },
  67370. /**
  67371. * Sets the Default image processing configuration used either in the this material.
  67372. *
  67373. * If sets to null, the scene one is in use.
  67374. */
  67375. set: function (value) {
  67376. this._attachImageProcessingConfiguration(value);
  67377. // Ensure the effect will be rebuilt.
  67378. this._markAllSubMeshesAsTexturesDirty();
  67379. },
  67380. enumerable: true,
  67381. configurable: true
  67382. });
  67383. /**
  67384. * Attaches a new image processing configuration to the Standard Material.
  67385. * @param configuration
  67386. */
  67387. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  67388. var _this = this;
  67389. if (configuration === this._imageProcessingConfiguration) {
  67390. return;
  67391. }
  67392. // Detaches observer.
  67393. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  67394. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  67395. }
  67396. // Pick the scene configuration if needed.
  67397. if (!configuration) {
  67398. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  67399. }
  67400. else {
  67401. this._imageProcessingConfiguration = configuration;
  67402. }
  67403. // Attaches observer.
  67404. if (this._imageProcessingConfiguration) {
  67405. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  67406. _this._markAllSubMeshesAsImageProcessingDirty();
  67407. });
  67408. }
  67409. };
  67410. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  67411. /**
  67412. * Gets wether the color curves effect is enabled.
  67413. */
  67414. get: function () {
  67415. return this.imageProcessingConfiguration.colorCurvesEnabled;
  67416. },
  67417. /**
  67418. * Sets wether the color curves effect is enabled.
  67419. */
  67420. set: function (value) {
  67421. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  67422. },
  67423. enumerable: true,
  67424. configurable: true
  67425. });
  67426. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  67427. /**
  67428. * Gets wether the color grading effect is enabled.
  67429. */
  67430. get: function () {
  67431. return this.imageProcessingConfiguration.colorGradingEnabled;
  67432. },
  67433. /**
  67434. * Gets wether the color grading effect is enabled.
  67435. */
  67436. set: function (value) {
  67437. this.imageProcessingConfiguration.colorGradingEnabled = value;
  67438. },
  67439. enumerable: true,
  67440. configurable: true
  67441. });
  67442. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  67443. /**
  67444. * Gets wether tonemapping is enabled or not.
  67445. */
  67446. get: function () {
  67447. return this._imageProcessingConfiguration.toneMappingEnabled;
  67448. },
  67449. /**
  67450. * Sets wether tonemapping is enabled or not
  67451. */
  67452. set: function (value) {
  67453. this._imageProcessingConfiguration.toneMappingEnabled = value;
  67454. },
  67455. enumerable: true,
  67456. configurable: true
  67457. });
  67458. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  67459. /**
  67460. * The camera exposure used on this material.
  67461. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  67462. * This corresponds to a photographic exposure.
  67463. */
  67464. get: function () {
  67465. return this._imageProcessingConfiguration.exposure;
  67466. },
  67467. /**
  67468. * The camera exposure used on this material.
  67469. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  67470. * This corresponds to a photographic exposure.
  67471. */
  67472. set: function (value) {
  67473. this._imageProcessingConfiguration.exposure = value;
  67474. },
  67475. enumerable: true,
  67476. configurable: true
  67477. });
  67478. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  67479. /**
  67480. * Gets The camera contrast used on this material.
  67481. */
  67482. get: function () {
  67483. return this._imageProcessingConfiguration.contrast;
  67484. },
  67485. /**
  67486. * Sets The camera contrast used on this material.
  67487. */
  67488. set: function (value) {
  67489. this._imageProcessingConfiguration.contrast = value;
  67490. },
  67491. enumerable: true,
  67492. configurable: true
  67493. });
  67494. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  67495. /**
  67496. * Gets the Color Grading 2D Lookup Texture.
  67497. */
  67498. get: function () {
  67499. return this._imageProcessingConfiguration.colorGradingTexture;
  67500. },
  67501. /**
  67502. * Sets the Color Grading 2D Lookup Texture.
  67503. */
  67504. set: function (value) {
  67505. this._imageProcessingConfiguration.colorGradingTexture = value;
  67506. },
  67507. enumerable: true,
  67508. configurable: true
  67509. });
  67510. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  67511. /**
  67512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  67513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  67514. * 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;
  67515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  67516. */
  67517. get: function () {
  67518. return this._imageProcessingConfiguration.colorCurves;
  67519. },
  67520. /**
  67521. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  67522. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  67523. * 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;
  67524. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  67525. */
  67526. set: function (value) {
  67527. this._imageProcessingConfiguration.colorCurves = value;
  67528. },
  67529. enumerable: true,
  67530. configurable: true
  67531. });
  67532. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  67533. /**
  67534. * Gets a boolean indicating that current material needs to register RTT
  67535. */
  67536. get: function () {
  67537. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  67538. return true;
  67539. }
  67540. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  67541. return true;
  67542. }
  67543. return false;
  67544. },
  67545. enumerable: true,
  67546. configurable: true
  67547. });
  67548. /**
  67549. * Gets the current class name of the material e.g. "StandardMaterial"
  67550. * Mainly use in serialization.
  67551. * @returns the class name
  67552. */
  67553. StandardMaterial.prototype.getClassName = function () {
  67554. return "StandardMaterial";
  67555. };
  67556. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  67557. /**
  67558. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  67559. * You can try switching to logarithmic depth.
  67560. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  67561. */
  67562. get: function () {
  67563. return this._useLogarithmicDepth;
  67564. },
  67565. set: function (value) {
  67566. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  67567. this._markAllSubMeshesAsMiscDirty();
  67568. },
  67569. enumerable: true,
  67570. configurable: true
  67571. });
  67572. /**
  67573. * Specifies if the material will require alpha blending
  67574. * @returns a boolean specifying if alpha blending is needed
  67575. */
  67576. StandardMaterial.prototype.needAlphaBlending = function () {
  67577. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  67578. };
  67579. /**
  67580. * Specifies if this material should be rendered in alpha test mode
  67581. * @returns a boolean specifying if an alpha test is needed.
  67582. */
  67583. StandardMaterial.prototype.needAlphaTesting = function () {
  67584. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  67585. };
  67586. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  67587. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  67588. };
  67589. /**
  67590. * Get the texture used for alpha test purpose.
  67591. * @returns the diffuse texture in case of the standard material.
  67592. */
  67593. StandardMaterial.prototype.getAlphaTestTexture = function () {
  67594. return this._diffuseTexture;
  67595. };
  67596. /**
  67597. * Get if the submesh is ready to be used and all its information available.
  67598. * Child classes can use it to update shaders
  67599. * @param mesh defines the mesh to check
  67600. * @param subMesh defines which submesh to check
  67601. * @param useInstances specifies that instances should be used
  67602. * @returns a boolean indicating that the submesh is ready or not
  67603. */
  67604. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67605. if (useInstances === void 0) { useInstances = false; }
  67606. if (subMesh.effect && this.isFrozen) {
  67607. if (this._wasPreviouslyReady) {
  67608. return true;
  67609. }
  67610. }
  67611. if (!subMesh._materialDefines) {
  67612. subMesh._materialDefines = new StandardMaterialDefines();
  67613. }
  67614. var scene = this.getScene();
  67615. var defines = subMesh._materialDefines;
  67616. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  67617. if (defines._renderId === scene.getRenderId()) {
  67618. return true;
  67619. }
  67620. }
  67621. var engine = scene.getEngine();
  67622. // Lights
  67623. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  67624. // Textures
  67625. if (defines._areTexturesDirty) {
  67626. defines._needUVs = false;
  67627. defines.MAINUV1 = false;
  67628. defines.MAINUV2 = false;
  67629. if (scene.texturesEnabled) {
  67630. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  67631. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  67632. return false;
  67633. }
  67634. else {
  67635. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  67636. }
  67637. }
  67638. else {
  67639. defines.DIFFUSE = false;
  67640. }
  67641. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  67642. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  67643. return false;
  67644. }
  67645. else {
  67646. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  67647. }
  67648. }
  67649. else {
  67650. defines.AMBIENT = false;
  67651. }
  67652. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  67653. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  67654. return false;
  67655. }
  67656. else {
  67657. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  67658. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  67659. }
  67660. }
  67661. else {
  67662. defines.OPACITY = false;
  67663. }
  67664. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  67665. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  67666. return false;
  67667. }
  67668. else {
  67669. defines._needNormals = true;
  67670. defines.REFLECTION = true;
  67671. defines.ROUGHNESS = (this._roughness > 0);
  67672. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  67673. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  67674. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  67675. switch (this._reflectionTexture.coordinatesMode) {
  67676. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  67677. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  67678. break;
  67679. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  67680. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  67681. break;
  67682. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  67683. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  67684. break;
  67685. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  67686. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  67687. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  67688. break;
  67689. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  67690. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  67691. break;
  67692. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  67693. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  67694. break;
  67695. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  67696. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  67697. break;
  67698. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  67699. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  67700. break;
  67701. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  67702. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  67703. default:
  67704. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  67705. break;
  67706. }
  67707. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  67708. }
  67709. }
  67710. else {
  67711. defines.REFLECTION = false;
  67712. }
  67713. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  67714. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  67715. return false;
  67716. }
  67717. else {
  67718. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  67719. }
  67720. }
  67721. else {
  67722. defines.EMISSIVE = false;
  67723. }
  67724. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  67725. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  67726. return false;
  67727. }
  67728. else {
  67729. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  67730. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  67731. }
  67732. }
  67733. else {
  67734. defines.LIGHTMAP = false;
  67735. }
  67736. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  67737. if (!this._specularTexture.isReadyOrNotBlocking()) {
  67738. return false;
  67739. }
  67740. else {
  67741. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  67742. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  67743. }
  67744. }
  67745. else {
  67746. defines.SPECULAR = false;
  67747. }
  67748. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  67749. // Bump texure can not be not blocking.
  67750. if (!this._bumpTexture.isReady()) {
  67751. return false;
  67752. }
  67753. else {
  67754. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  67755. defines.PARALLAX = this._useParallax;
  67756. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  67757. }
  67758. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  67759. }
  67760. else {
  67761. defines.BUMP = false;
  67762. }
  67763. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  67764. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  67765. return false;
  67766. }
  67767. else {
  67768. defines._needUVs = true;
  67769. defines.REFRACTION = true;
  67770. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  67771. }
  67772. }
  67773. else {
  67774. defines.REFRACTION = false;
  67775. }
  67776. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  67777. }
  67778. else {
  67779. defines.DIFFUSE = false;
  67780. defines.AMBIENT = false;
  67781. defines.OPACITY = false;
  67782. defines.REFLECTION = false;
  67783. defines.EMISSIVE = false;
  67784. defines.LIGHTMAP = false;
  67785. defines.BUMP = false;
  67786. defines.REFRACTION = false;
  67787. }
  67788. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  67789. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  67790. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  67791. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  67792. 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);
  67793. }
  67794. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  67795. if (!this._imageProcessingConfiguration.isReady()) {
  67796. return false;
  67797. }
  67798. this._imageProcessingConfiguration.prepareDefines(defines);
  67799. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  67800. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  67801. }
  67802. if (defines._areFresnelDirty) {
  67803. if (StandardMaterial.FresnelEnabled) {
  67804. // Fresnel
  67805. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  67806. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  67807. this._reflectionFresnelParameters) {
  67808. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  67809. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  67810. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  67811. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  67812. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  67813. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  67814. defines._needNormals = true;
  67815. defines.FRESNEL = true;
  67816. }
  67817. }
  67818. else {
  67819. defines.FRESNEL = false;
  67820. }
  67821. }
  67822. // Misc.
  67823. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  67824. // Attribs
  67825. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  67826. // Values that need to be evaluated on every frame
  67827. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  67828. // Get correct effect
  67829. if (defines.isDirty) {
  67830. defines.markAsProcessed();
  67831. // Fallbacks
  67832. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  67833. if (defines.REFLECTION) {
  67834. fallbacks.addFallback(0, "REFLECTION");
  67835. }
  67836. if (defines.SPECULAR) {
  67837. fallbacks.addFallback(0, "SPECULAR");
  67838. }
  67839. if (defines.BUMP) {
  67840. fallbacks.addFallback(0, "BUMP");
  67841. }
  67842. if (defines.PARALLAX) {
  67843. fallbacks.addFallback(1, "PARALLAX");
  67844. }
  67845. if (defines.PARALLAXOCCLUSION) {
  67846. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  67847. }
  67848. if (defines.SPECULAROVERALPHA) {
  67849. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  67850. }
  67851. if (defines.FOG) {
  67852. fallbacks.addFallback(1, "FOG");
  67853. }
  67854. if (defines.POINTSIZE) {
  67855. fallbacks.addFallback(0, "POINTSIZE");
  67856. }
  67857. if (defines.LOGARITHMICDEPTH) {
  67858. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  67859. }
  67860. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  67861. if (defines.SPECULARTERM) {
  67862. fallbacks.addFallback(0, "SPECULARTERM");
  67863. }
  67864. if (defines.DIFFUSEFRESNEL) {
  67865. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  67866. }
  67867. if (defines.OPACITYFRESNEL) {
  67868. fallbacks.addFallback(2, "OPACITYFRESNEL");
  67869. }
  67870. if (defines.REFLECTIONFRESNEL) {
  67871. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  67872. }
  67873. if (defines.EMISSIVEFRESNEL) {
  67874. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  67875. }
  67876. if (defines.FRESNEL) {
  67877. fallbacks.addFallback(4, "FRESNEL");
  67878. }
  67879. //Attributes
  67880. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  67881. if (defines.NORMAL) {
  67882. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  67883. }
  67884. if (defines.UV1) {
  67885. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  67886. }
  67887. if (defines.UV2) {
  67888. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  67889. }
  67890. if (defines.VERTEXCOLOR) {
  67891. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  67892. }
  67893. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  67894. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  67895. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  67896. var shaderName = "default";
  67897. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  67898. "vFogInfos", "vFogColor", "pointSize",
  67899. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  67900. "mBones",
  67901. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  67902. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  67903. "vReflectionPosition", "vReflectionSize",
  67904. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  67905. ];
  67906. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  67907. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  67908. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  67909. var uniformBuffers = ["Material", "Scene"];
  67910. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  67911. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  67912. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  67913. }
  67914. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  67915. uniformsNames: uniforms,
  67916. uniformBuffersNames: uniformBuffers,
  67917. samplers: samplers,
  67918. defines: defines,
  67919. maxSimultaneousLights: this._maxSimultaneousLights
  67920. });
  67921. if (this.customShaderNameResolve) {
  67922. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  67923. }
  67924. var join = defines.toString();
  67925. var previousEffect = subMesh.effect;
  67926. var effect = scene.getEngine().createEffect(shaderName, {
  67927. attributes: attribs,
  67928. uniformsNames: uniforms,
  67929. uniformBuffersNames: uniformBuffers,
  67930. samplers: samplers,
  67931. defines: join,
  67932. fallbacks: fallbacks,
  67933. onCompiled: this.onCompiled,
  67934. onError: this.onError,
  67935. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  67936. }, engine);
  67937. if (effect) {
  67938. // Use previous effect while new one is compiling
  67939. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  67940. effect = previousEffect;
  67941. defines.markAsUnprocessed();
  67942. }
  67943. else {
  67944. scene.resetCachedMaterial();
  67945. subMesh.setEffect(effect, defines);
  67946. this.buildUniformLayout();
  67947. }
  67948. }
  67949. }
  67950. if (!subMesh.effect || !subMesh.effect.isReady()) {
  67951. return false;
  67952. }
  67953. defines._renderId = scene.getRenderId();
  67954. this._wasPreviouslyReady = true;
  67955. return true;
  67956. };
  67957. /**
  67958. * Builds the material UBO layouts.
  67959. * Used internally during the effect preparation.
  67960. */
  67961. StandardMaterial.prototype.buildUniformLayout = function () {
  67962. // Order is important !
  67963. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  67964. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  67965. this._uniformBuffer.addUniform("opacityParts", 4);
  67966. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  67967. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  67968. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  67969. this._uniformBuffer.addUniform("refractionRightColor", 4);
  67970. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  67971. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  67972. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  67973. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  67974. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  67975. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  67976. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  67977. this._uniformBuffer.addUniform("vReflectionSize", 3);
  67978. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  67979. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  67980. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  67981. this._uniformBuffer.addUniform("vBumpInfos", 3);
  67982. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  67983. this._uniformBuffer.addUniform("ambientMatrix", 16);
  67984. this._uniformBuffer.addUniform("opacityMatrix", 16);
  67985. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  67986. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  67987. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  67988. this._uniformBuffer.addUniform("specularMatrix", 16);
  67989. this._uniformBuffer.addUniform("bumpMatrix", 16);
  67990. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  67991. this._uniformBuffer.addUniform("refractionMatrix", 16);
  67992. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  67993. this._uniformBuffer.addUniform("vSpecularColor", 4);
  67994. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  67995. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  67996. this._uniformBuffer.addUniform("pointSize", 1);
  67997. this._uniformBuffer.create();
  67998. };
  67999. /**
  68000. * Unbinds the material from the mesh
  68001. */
  68002. StandardMaterial.prototype.unbind = function () {
  68003. if (this._activeEffect) {
  68004. var needFlag = false;
  68005. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  68006. this._activeEffect.setTexture("reflection2DSampler", null);
  68007. needFlag = true;
  68008. }
  68009. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  68010. this._activeEffect.setTexture("refraction2DSampler", null);
  68011. needFlag = true;
  68012. }
  68013. if (needFlag) {
  68014. this._markAllSubMeshesAsTexturesDirty();
  68015. }
  68016. }
  68017. _super.prototype.unbind.call(this);
  68018. };
  68019. /**
  68020. * Binds the submesh to this material by preparing the effect and shader to draw
  68021. * @param world defines the world transformation matrix
  68022. * @param mesh defines the mesh containing the submesh
  68023. * @param subMesh defines the submesh to bind the material to
  68024. */
  68025. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  68026. var scene = this.getScene();
  68027. var defines = subMesh._materialDefines;
  68028. if (!defines) {
  68029. return;
  68030. }
  68031. var effect = subMesh.effect;
  68032. if (!effect) {
  68033. return;
  68034. }
  68035. this._activeEffect = effect;
  68036. // Matrices
  68037. this.bindOnlyWorldMatrix(world);
  68038. // Normal Matrix
  68039. if (defines.OBJECTSPACE_NORMALMAP) {
  68040. world.toNormalMatrix(this._normalMatrix);
  68041. this.bindOnlyNormalMatrix(this._normalMatrix);
  68042. }
  68043. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  68044. // Bones
  68045. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  68046. if (mustRebind) {
  68047. this._uniformBuffer.bindToEffect(effect, "Material");
  68048. this.bindViewProjection(effect);
  68049. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  68050. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  68051. // Fresnel
  68052. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  68053. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  68054. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  68055. }
  68056. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  68057. 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);
  68058. }
  68059. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  68060. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  68061. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  68062. }
  68063. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  68064. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  68065. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  68066. }
  68067. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  68068. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  68069. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  68070. }
  68071. }
  68072. // Textures
  68073. if (scene.texturesEnabled) {
  68074. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  68075. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  68076. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  68077. if (this._diffuseTexture.hasAlpha) {
  68078. effect.setFloat("alphaCutOff", this.alphaCutOff);
  68079. }
  68080. }
  68081. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  68082. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  68083. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  68084. }
  68085. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  68086. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  68087. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  68088. }
  68089. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  68090. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  68091. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  68092. if (this._reflectionTexture.boundingBoxSize) {
  68093. var cubeTexture = this._reflectionTexture;
  68094. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  68095. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  68096. }
  68097. }
  68098. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  68099. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  68100. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  68101. }
  68102. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  68103. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  68104. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  68105. }
  68106. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  68107. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  68108. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  68109. }
  68110. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  68111. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  68112. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  68113. if (scene._mirroredCameraPosition) {
  68114. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  68115. }
  68116. else {
  68117. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  68118. }
  68119. }
  68120. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  68121. var depth = 1.0;
  68122. if (!this._refractionTexture.isCube) {
  68123. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  68124. if (this._refractionTexture.depth) {
  68125. depth = this._refractionTexture.depth;
  68126. }
  68127. }
  68128. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  68129. }
  68130. }
  68131. // Point size
  68132. if (this.pointsCloud) {
  68133. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  68134. }
  68135. if (defines.SPECULARTERM) {
  68136. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  68137. }
  68138. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  68139. // Diffuse
  68140. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  68141. }
  68142. // Textures
  68143. if (scene.texturesEnabled) {
  68144. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  68145. effect.setTexture("diffuseSampler", this._diffuseTexture);
  68146. }
  68147. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  68148. effect.setTexture("ambientSampler", this._ambientTexture);
  68149. }
  68150. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  68151. effect.setTexture("opacitySampler", this._opacityTexture);
  68152. }
  68153. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  68154. if (this._reflectionTexture.isCube) {
  68155. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  68156. }
  68157. else {
  68158. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  68159. }
  68160. }
  68161. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  68162. effect.setTexture("emissiveSampler", this._emissiveTexture);
  68163. }
  68164. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  68165. effect.setTexture("lightmapSampler", this._lightmapTexture);
  68166. }
  68167. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  68168. effect.setTexture("specularSampler", this._specularTexture);
  68169. }
  68170. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  68171. effect.setTexture("bumpSampler", this._bumpTexture);
  68172. }
  68173. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  68174. var depth = 1.0;
  68175. if (this._refractionTexture.isCube) {
  68176. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  68177. }
  68178. else {
  68179. effect.setTexture("refraction2DSampler", this._refractionTexture);
  68180. }
  68181. }
  68182. }
  68183. // Clip plane
  68184. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  68185. // Colors
  68186. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  68187. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  68188. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  68189. }
  68190. if (mustRebind || !this.isFrozen) {
  68191. // Lights
  68192. if (scene.lightsEnabled && !this._disableLighting) {
  68193. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  68194. }
  68195. // View
  68196. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  68197. this.bindView(effect);
  68198. }
  68199. // Fog
  68200. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  68201. // Morph targets
  68202. if (defines.NUM_MORPH_INFLUENCERS) {
  68203. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  68204. }
  68205. // Log. depth
  68206. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  68207. // image processing
  68208. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  68209. this._imageProcessingConfiguration.bind(this._activeEffect);
  68210. }
  68211. }
  68212. this._uniformBuffer.update();
  68213. this._afterBind(mesh, this._activeEffect);
  68214. };
  68215. /**
  68216. * Get the list of animatables in the material.
  68217. * @returns the list of animatables object used in the material
  68218. */
  68219. StandardMaterial.prototype.getAnimatables = function () {
  68220. var results = [];
  68221. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  68222. results.push(this._diffuseTexture);
  68223. }
  68224. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  68225. results.push(this._ambientTexture);
  68226. }
  68227. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  68228. results.push(this._opacityTexture);
  68229. }
  68230. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  68231. results.push(this._reflectionTexture);
  68232. }
  68233. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  68234. results.push(this._emissiveTexture);
  68235. }
  68236. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  68237. results.push(this._specularTexture);
  68238. }
  68239. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  68240. results.push(this._bumpTexture);
  68241. }
  68242. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  68243. results.push(this._lightmapTexture);
  68244. }
  68245. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  68246. results.push(this._refractionTexture);
  68247. }
  68248. return results;
  68249. };
  68250. /**
  68251. * Gets the active textures from the material
  68252. * @returns an array of textures
  68253. */
  68254. StandardMaterial.prototype.getActiveTextures = function () {
  68255. var activeTextures = _super.prototype.getActiveTextures.call(this);
  68256. if (this._diffuseTexture) {
  68257. activeTextures.push(this._diffuseTexture);
  68258. }
  68259. if (this._ambientTexture) {
  68260. activeTextures.push(this._ambientTexture);
  68261. }
  68262. if (this._opacityTexture) {
  68263. activeTextures.push(this._opacityTexture);
  68264. }
  68265. if (this._reflectionTexture) {
  68266. activeTextures.push(this._reflectionTexture);
  68267. }
  68268. if (this._emissiveTexture) {
  68269. activeTextures.push(this._emissiveTexture);
  68270. }
  68271. if (this._specularTexture) {
  68272. activeTextures.push(this._specularTexture);
  68273. }
  68274. if (this._bumpTexture) {
  68275. activeTextures.push(this._bumpTexture);
  68276. }
  68277. if (this._lightmapTexture) {
  68278. activeTextures.push(this._lightmapTexture);
  68279. }
  68280. if (this._refractionTexture) {
  68281. activeTextures.push(this._refractionTexture);
  68282. }
  68283. return activeTextures;
  68284. };
  68285. /**
  68286. * Specifies if the material uses a texture
  68287. * @param texture defines the texture to check against the material
  68288. * @returns a boolean specifying if the material uses the texture
  68289. */
  68290. StandardMaterial.prototype.hasTexture = function (texture) {
  68291. if (_super.prototype.hasTexture.call(this, texture)) {
  68292. return true;
  68293. }
  68294. if (this._diffuseTexture === texture) {
  68295. return true;
  68296. }
  68297. if (this._ambientTexture === texture) {
  68298. return true;
  68299. }
  68300. if (this._opacityTexture === texture) {
  68301. return true;
  68302. }
  68303. if (this._reflectionTexture === texture) {
  68304. return true;
  68305. }
  68306. if (this._emissiveTexture === texture) {
  68307. return true;
  68308. }
  68309. if (this._specularTexture === texture) {
  68310. return true;
  68311. }
  68312. if (this._bumpTexture === texture) {
  68313. return true;
  68314. }
  68315. if (this._lightmapTexture === texture) {
  68316. return true;
  68317. }
  68318. if (this._refractionTexture === texture) {
  68319. return true;
  68320. }
  68321. return false;
  68322. };
  68323. /**
  68324. * Disposes the material
  68325. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68326. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  68327. */
  68328. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  68329. if (forceDisposeTextures) {
  68330. if (this._diffuseTexture) {
  68331. this._diffuseTexture.dispose();
  68332. }
  68333. if (this._ambientTexture) {
  68334. this._ambientTexture.dispose();
  68335. }
  68336. if (this._opacityTexture) {
  68337. this._opacityTexture.dispose();
  68338. }
  68339. if (this._reflectionTexture) {
  68340. this._reflectionTexture.dispose();
  68341. }
  68342. if (this._emissiveTexture) {
  68343. this._emissiveTexture.dispose();
  68344. }
  68345. if (this._specularTexture) {
  68346. this._specularTexture.dispose();
  68347. }
  68348. if (this._bumpTexture) {
  68349. this._bumpTexture.dispose();
  68350. }
  68351. if (this._lightmapTexture) {
  68352. this._lightmapTexture.dispose();
  68353. }
  68354. if (this._refractionTexture) {
  68355. this._refractionTexture.dispose();
  68356. }
  68357. }
  68358. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  68359. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  68360. }
  68361. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  68362. };
  68363. /**
  68364. * Makes a duplicate of the material, and gives it a new name
  68365. * @param name defines the new name for the duplicated material
  68366. * @returns the cloned material
  68367. */
  68368. StandardMaterial.prototype.clone = function (name) {
  68369. var _this = this;
  68370. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  68371. result.name = name;
  68372. result.id = name;
  68373. return result;
  68374. };
  68375. /**
  68376. * Serializes this material in a JSON representation
  68377. * @returns the serialized material object
  68378. */
  68379. StandardMaterial.prototype.serialize = function () {
  68380. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  68381. };
  68382. /**
  68383. * Creates a standard material from parsed material data
  68384. * @param source defines the JSON representation of the material
  68385. * @param scene defines the hosting scene
  68386. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68387. * @returns a new standard material
  68388. */
  68389. StandardMaterial.Parse = function (source, scene, rootUrl) {
  68390. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  68391. };
  68392. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  68393. // Flags used to enable or disable a type of texture for all Standard Materials
  68394. /**
  68395. * Are diffuse textures enabled in the application.
  68396. */
  68397. get: function () {
  68398. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  68399. },
  68400. set: function (value) {
  68401. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  68402. },
  68403. enumerable: true,
  68404. configurable: true
  68405. });
  68406. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  68407. /**
  68408. * Are ambient textures enabled in the application.
  68409. */
  68410. get: function () {
  68411. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  68412. },
  68413. set: function (value) {
  68414. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  68415. },
  68416. enumerable: true,
  68417. configurable: true
  68418. });
  68419. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  68420. /**
  68421. * Are opacity textures enabled in the application.
  68422. */
  68423. get: function () {
  68424. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  68425. },
  68426. set: function (value) {
  68427. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  68428. },
  68429. enumerable: true,
  68430. configurable: true
  68431. });
  68432. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  68433. /**
  68434. * Are reflection textures enabled in the application.
  68435. */
  68436. get: function () {
  68437. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  68438. },
  68439. set: function (value) {
  68440. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  68441. },
  68442. enumerable: true,
  68443. configurable: true
  68444. });
  68445. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  68446. /**
  68447. * Are emissive textures enabled in the application.
  68448. */
  68449. get: function () {
  68450. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  68451. },
  68452. set: function (value) {
  68453. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  68454. },
  68455. enumerable: true,
  68456. configurable: true
  68457. });
  68458. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  68459. /**
  68460. * Are specular textures enabled in the application.
  68461. */
  68462. get: function () {
  68463. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  68464. },
  68465. set: function (value) {
  68466. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  68467. },
  68468. enumerable: true,
  68469. configurable: true
  68470. });
  68471. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  68472. /**
  68473. * Are bump textures enabled in the application.
  68474. */
  68475. get: function () {
  68476. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  68477. },
  68478. set: function (value) {
  68479. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  68480. },
  68481. enumerable: true,
  68482. configurable: true
  68483. });
  68484. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  68485. /**
  68486. * Are lightmap textures enabled in the application.
  68487. */
  68488. get: function () {
  68489. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  68490. },
  68491. set: function (value) {
  68492. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  68493. },
  68494. enumerable: true,
  68495. configurable: true
  68496. });
  68497. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  68498. /**
  68499. * Are refraction textures enabled in the application.
  68500. */
  68501. get: function () {
  68502. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  68503. },
  68504. set: function (value) {
  68505. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  68506. },
  68507. enumerable: true,
  68508. configurable: true
  68509. });
  68510. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  68511. /**
  68512. * Are color grading textures enabled in the application.
  68513. */
  68514. get: function () {
  68515. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  68516. },
  68517. set: function (value) {
  68518. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  68519. },
  68520. enumerable: true,
  68521. configurable: true
  68522. });
  68523. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  68524. /**
  68525. * Are fresnels enabled in the application.
  68526. */
  68527. get: function () {
  68528. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  68529. },
  68530. set: function (value) {
  68531. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  68532. },
  68533. enumerable: true,
  68534. configurable: true
  68535. });
  68536. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68537. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  68538. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  68539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  68541. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  68542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  68544. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  68545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68547. ], StandardMaterial.prototype, "ambientTexture", void 0);
  68548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  68550. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  68551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  68553. ], StandardMaterial.prototype, "opacityTexture", void 0);
  68554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  68556. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  68557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68559. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  68560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  68562. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  68563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68565. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  68566. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  68568. ], StandardMaterial.prototype, "_specularTexture", void 0);
  68569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68571. ], StandardMaterial.prototype, "specularTexture", void 0);
  68572. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68573. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  68574. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  68575. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68576. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68577. ], StandardMaterial.prototype, "bumpTexture", void 0);
  68578. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68579. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  68580. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  68581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68583. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  68584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68585. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  68586. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  68587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68589. ], StandardMaterial.prototype, "refractionTexture", void 0);
  68590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  68592. ], StandardMaterial.prototype, "ambientColor", void 0);
  68593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  68595. ], StandardMaterial.prototype, "diffuseColor", void 0);
  68596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  68598. ], StandardMaterial.prototype, "specularColor", void 0);
  68599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  68601. ], StandardMaterial.prototype, "emissiveColor", void 0);
  68602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68604. ], StandardMaterial.prototype, "specularPower", void 0);
  68605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  68607. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  68608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68610. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  68611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  68613. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  68614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68616. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  68617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  68619. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  68620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68621. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68622. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  68623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  68625. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  68626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68628. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  68629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  68631. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  68632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68634. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  68635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  68637. ], StandardMaterial.prototype, "_disableLighting", void 0);
  68638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  68640. ], StandardMaterial.prototype, "disableLighting", void 0);
  68641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  68643. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  68644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68646. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  68647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  68649. ], StandardMaterial.prototype, "_useParallax", void 0);
  68650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68652. ], StandardMaterial.prototype, "useParallax", void 0);
  68653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  68655. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  68656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68658. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  68659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68661. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  68662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  68664. ], StandardMaterial.prototype, "_roughness", void 0);
  68665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68667. ], StandardMaterial.prototype, "roughness", void 0);
  68668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68670. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  68671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68673. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  68674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68676. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  68677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  68679. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  68680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68682. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  68683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  68685. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  68686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68688. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  68689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  68691. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  68692. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  68694. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  68695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  68697. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  68698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68700. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  68701. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68702. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  68703. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  68704. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68706. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  68707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  68709. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  68710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68711. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68712. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  68713. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68714. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  68715. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  68716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68718. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  68719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  68721. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  68722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68724. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  68725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  68727. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  68728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  68730. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  68731. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  68733. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  68734. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68735. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68736. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  68737. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68738. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  68739. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  68740. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68742. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  68743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  68745. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  68746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68748. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  68749. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68750. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68751. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  68752. return StandardMaterial;
  68753. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  68754. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  68755. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  68756. return new StandardMaterial("default material", scene);
  68757. };
  68758. /***/ }),
  68759. /***/ "./Materials/uniformBuffer.ts":
  68760. /*!************************************!*\
  68761. !*** ./Materials/uniformBuffer.ts ***!
  68762. \************************************/
  68763. /*! exports provided: UniformBuffer */
  68764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68765. "use strict";
  68766. __webpack_require__.r(__webpack_exports__);
  68767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  68768. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  68769. /**
  68770. * Uniform buffer objects.
  68771. *
  68772. * Handles blocks of uniform on the GPU.
  68773. *
  68774. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  68775. *
  68776. * For more information, please refer to :
  68777. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  68778. */
  68779. var UniformBuffer = /** @class */ (function () {
  68780. /**
  68781. * Instantiates a new Uniform buffer objects.
  68782. *
  68783. * Handles blocks of uniform on the GPU.
  68784. *
  68785. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  68786. *
  68787. * For more information, please refer to :
  68788. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  68789. * @param engine Define the engine the buffer is associated with
  68790. * @param data Define the data contained in the buffer
  68791. * @param dynamic Define if the buffer is updatable
  68792. */
  68793. function UniformBuffer(engine, data, dynamic) {
  68794. this._engine = engine;
  68795. this._noUBO = !engine.supportsUniformBuffers;
  68796. this._dynamic = dynamic;
  68797. this._data = data || [];
  68798. this._uniformLocations = {};
  68799. this._uniformSizes = {};
  68800. this._uniformLocationPointer = 0;
  68801. this._needSync = false;
  68802. if (this._noUBO) {
  68803. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  68804. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  68805. this.updateFloat = this._updateFloatForEffect;
  68806. this.updateFloat2 = this._updateFloat2ForEffect;
  68807. this.updateFloat3 = this._updateFloat3ForEffect;
  68808. this.updateFloat4 = this._updateFloat4ForEffect;
  68809. this.updateMatrix = this._updateMatrixForEffect;
  68810. this.updateVector3 = this._updateVector3ForEffect;
  68811. this.updateVector4 = this._updateVector4ForEffect;
  68812. this.updateColor3 = this._updateColor3ForEffect;
  68813. this.updateColor4 = this._updateColor4ForEffect;
  68814. }
  68815. else {
  68816. this._engine._uniformBuffers.push(this);
  68817. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  68818. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  68819. this.updateFloat = this._updateFloatForUniform;
  68820. this.updateFloat2 = this._updateFloat2ForUniform;
  68821. this.updateFloat3 = this._updateFloat3ForUniform;
  68822. this.updateFloat4 = this._updateFloat4ForUniform;
  68823. this.updateMatrix = this._updateMatrixForUniform;
  68824. this.updateVector3 = this._updateVector3ForUniform;
  68825. this.updateVector4 = this._updateVector4ForUniform;
  68826. this.updateColor3 = this._updateColor3ForUniform;
  68827. this.updateColor4 = this._updateColor4ForUniform;
  68828. }
  68829. }
  68830. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  68831. /**
  68832. * Indicates if the buffer is using the WebGL2 UBO implementation,
  68833. * or just falling back on setUniformXXX calls.
  68834. */
  68835. get: function () {
  68836. return !this._noUBO;
  68837. },
  68838. enumerable: true,
  68839. configurable: true
  68840. });
  68841. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  68842. /**
  68843. * Indicates if the WebGL underlying uniform buffer is in sync
  68844. * with the javascript cache data.
  68845. */
  68846. get: function () {
  68847. return !this._needSync;
  68848. },
  68849. enumerable: true,
  68850. configurable: true
  68851. });
  68852. /**
  68853. * Indicates if the WebGL underlying uniform buffer is dynamic.
  68854. * Also, a dynamic UniformBuffer will disable cache verification and always
  68855. * update the underlying WebGL uniform buffer to the GPU.
  68856. * @returns if Dynamic, otherwise false
  68857. */
  68858. UniformBuffer.prototype.isDynamic = function () {
  68859. return this._dynamic !== undefined;
  68860. };
  68861. /**
  68862. * The data cache on JS side.
  68863. * @returns the underlying data as a float array
  68864. */
  68865. UniformBuffer.prototype.getData = function () {
  68866. return this._bufferData;
  68867. };
  68868. /**
  68869. * The underlying WebGL Uniform buffer.
  68870. * @returns the webgl buffer
  68871. */
  68872. UniformBuffer.prototype.getBuffer = function () {
  68873. return this._buffer;
  68874. };
  68875. /**
  68876. * std140 layout specifies how to align data within an UBO structure.
  68877. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  68878. * for specs.
  68879. */
  68880. UniformBuffer.prototype._fillAlignment = function (size) {
  68881. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  68882. // and 4x4 matrices
  68883. // TODO : change if other types are used
  68884. var alignment;
  68885. if (size <= 2) {
  68886. alignment = size;
  68887. }
  68888. else {
  68889. alignment = 4;
  68890. }
  68891. if ((this._uniformLocationPointer % alignment) !== 0) {
  68892. var oldPointer = this._uniformLocationPointer;
  68893. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  68894. var diff = this._uniformLocationPointer - oldPointer;
  68895. for (var i = 0; i < diff; i++) {
  68896. this._data.push(0);
  68897. }
  68898. }
  68899. };
  68900. /**
  68901. * Adds an uniform in the buffer.
  68902. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  68903. * for the layout to be correct !
  68904. * @param name Name of the uniform, as used in the uniform block in the shader.
  68905. * @param size Data size, or data directly.
  68906. */
  68907. UniformBuffer.prototype.addUniform = function (name, size) {
  68908. if (this._noUBO) {
  68909. return;
  68910. }
  68911. if (this._uniformLocations[name] !== undefined) {
  68912. // Already existing uniform
  68913. return;
  68914. }
  68915. // This function must be called in the order of the shader layout !
  68916. // size can be the size of the uniform, or data directly
  68917. var data;
  68918. if (size instanceof Array) {
  68919. data = size;
  68920. size = data.length;
  68921. }
  68922. else {
  68923. size = size;
  68924. data = [];
  68925. // Fill with zeros
  68926. for (var i = 0; i < size; i++) {
  68927. data.push(0);
  68928. }
  68929. }
  68930. this._fillAlignment(size);
  68931. this._uniformSizes[name] = size;
  68932. this._uniformLocations[name] = this._uniformLocationPointer;
  68933. this._uniformLocationPointer += size;
  68934. for (var i = 0; i < size; i++) {
  68935. this._data.push(data[i]);
  68936. }
  68937. this._needSync = true;
  68938. };
  68939. /**
  68940. * Adds a Matrix 4x4 to the uniform buffer.
  68941. * @param name Name of the uniform, as used in the uniform block in the shader.
  68942. * @param mat A 4x4 matrix.
  68943. */
  68944. UniformBuffer.prototype.addMatrix = function (name, mat) {
  68945. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  68946. };
  68947. /**
  68948. * Adds a vec2 to the uniform buffer.
  68949. * @param name Name of the uniform, as used in the uniform block in the shader.
  68950. * @param x Define the x component value of the vec2
  68951. * @param y Define the y component value of the vec2
  68952. */
  68953. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  68954. var temp = [x, y];
  68955. this.addUniform(name, temp);
  68956. };
  68957. /**
  68958. * Adds a vec3 to the uniform buffer.
  68959. * @param name Name of the uniform, as used in the uniform block in the shader.
  68960. * @param x Define the x component value of the vec3
  68961. * @param y Define the y component value of the vec3
  68962. * @param z Define the z component value of the vec3
  68963. */
  68964. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  68965. var temp = [x, y, z];
  68966. this.addUniform(name, temp);
  68967. };
  68968. /**
  68969. * Adds a vec3 to the uniform buffer.
  68970. * @param name Name of the uniform, as used in the uniform block in the shader.
  68971. * @param color Define the vec3 from a Color
  68972. */
  68973. UniformBuffer.prototype.addColor3 = function (name, color) {
  68974. var temp = new Array();
  68975. color.toArray(temp);
  68976. this.addUniform(name, temp);
  68977. };
  68978. /**
  68979. * Adds a vec4 to the uniform buffer.
  68980. * @param name Name of the uniform, as used in the uniform block in the shader.
  68981. * @param color Define the rgb components from a Color
  68982. * @param alpha Define the a component of the vec4
  68983. */
  68984. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  68985. var temp = new Array();
  68986. color.toArray(temp);
  68987. temp.push(alpha);
  68988. this.addUniform(name, temp);
  68989. };
  68990. /**
  68991. * Adds a vec3 to the uniform buffer.
  68992. * @param name Name of the uniform, as used in the uniform block in the shader.
  68993. * @param vector Define the vec3 components from a Vector
  68994. */
  68995. UniformBuffer.prototype.addVector3 = function (name, vector) {
  68996. var temp = new Array();
  68997. vector.toArray(temp);
  68998. this.addUniform(name, temp);
  68999. };
  69000. /**
  69001. * Adds a Matrix 3x3 to the uniform buffer.
  69002. * @param name Name of the uniform, as used in the uniform block in the shader.
  69003. */
  69004. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  69005. this.addUniform(name, 12);
  69006. };
  69007. /**
  69008. * Adds a Matrix 2x2 to the uniform buffer.
  69009. * @param name Name of the uniform, as used in the uniform block in the shader.
  69010. */
  69011. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  69012. this.addUniform(name, 8);
  69013. };
  69014. /**
  69015. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  69016. */
  69017. UniformBuffer.prototype.create = function () {
  69018. if (this._noUBO) {
  69019. return;
  69020. }
  69021. if (this._buffer) {
  69022. return; // nothing to do
  69023. }
  69024. // See spec, alignment must be filled as a vec4
  69025. this._fillAlignment(4);
  69026. this._bufferData = new Float32Array(this._data);
  69027. this._rebuild();
  69028. this._needSync = true;
  69029. };
  69030. /** @hidden */
  69031. UniformBuffer.prototype._rebuild = function () {
  69032. if (this._noUBO) {
  69033. return;
  69034. }
  69035. if (this._dynamic) {
  69036. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  69037. }
  69038. else {
  69039. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  69040. }
  69041. };
  69042. /**
  69043. * Updates the WebGL Uniform Buffer on the GPU.
  69044. * If the `dynamic` flag is set to true, no cache comparison is done.
  69045. * Otherwise, the buffer will be updated only if the cache differs.
  69046. */
  69047. UniformBuffer.prototype.update = function () {
  69048. if (!this._buffer) {
  69049. this.create();
  69050. return;
  69051. }
  69052. if (!this._dynamic && !this._needSync) {
  69053. return;
  69054. }
  69055. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  69056. this._needSync = false;
  69057. };
  69058. /**
  69059. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  69060. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  69061. * @param data Define the flattened data
  69062. * @param size Define the size of the data.
  69063. */
  69064. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  69065. var location = this._uniformLocations[uniformName];
  69066. if (location === undefined) {
  69067. if (this._buffer) {
  69068. // Cannot add an uniform if the buffer is already created
  69069. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  69070. return;
  69071. }
  69072. this.addUniform(uniformName, size);
  69073. location = this._uniformLocations[uniformName];
  69074. }
  69075. if (!this._buffer) {
  69076. this.create();
  69077. }
  69078. if (!this._dynamic) {
  69079. // Cache for static uniform buffers
  69080. var changed = false;
  69081. for (var i = 0; i < size; i++) {
  69082. if (this._bufferData[location + i] !== data[i]) {
  69083. changed = true;
  69084. this._bufferData[location + i] = data[i];
  69085. }
  69086. }
  69087. this._needSync = this._needSync || changed;
  69088. }
  69089. else {
  69090. // No cache for dynamic
  69091. for (var i = 0; i < size; i++) {
  69092. this._bufferData[location + i] = data[i];
  69093. }
  69094. }
  69095. };
  69096. // Update methods
  69097. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  69098. // To match std140, matrix must be realigned
  69099. for (var i = 0; i < 3; i++) {
  69100. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  69101. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  69102. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  69103. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  69104. }
  69105. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  69106. };
  69107. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  69108. this._currentEffect.setMatrix3x3(name, matrix);
  69109. };
  69110. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  69111. this._currentEffect.setMatrix2x2(name, matrix);
  69112. };
  69113. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  69114. // To match std140, matrix must be realigned
  69115. for (var i = 0; i < 2; i++) {
  69116. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  69117. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  69118. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  69119. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  69120. }
  69121. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  69122. };
  69123. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  69124. this._currentEffect.setFloat(name, x);
  69125. };
  69126. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  69127. UniformBuffer._tempBuffer[0] = x;
  69128. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  69129. };
  69130. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  69131. if (suffix === void 0) { suffix = ""; }
  69132. this._currentEffect.setFloat2(name + suffix, x, y);
  69133. };
  69134. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  69135. UniformBuffer._tempBuffer[0] = x;
  69136. UniformBuffer._tempBuffer[1] = y;
  69137. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  69138. };
  69139. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  69140. if (suffix === void 0) { suffix = ""; }
  69141. this._currentEffect.setFloat3(name + suffix, x, y, z);
  69142. };
  69143. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  69144. UniformBuffer._tempBuffer[0] = x;
  69145. UniformBuffer._tempBuffer[1] = y;
  69146. UniformBuffer._tempBuffer[2] = z;
  69147. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  69148. };
  69149. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  69150. if (suffix === void 0) { suffix = ""; }
  69151. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  69152. };
  69153. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  69154. UniformBuffer._tempBuffer[0] = x;
  69155. UniformBuffer._tempBuffer[1] = y;
  69156. UniformBuffer._tempBuffer[2] = z;
  69157. UniformBuffer._tempBuffer[3] = w;
  69158. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  69159. };
  69160. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  69161. this._currentEffect.setMatrix(name, mat);
  69162. };
  69163. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  69164. this.updateUniform(name, mat.toArray(), 16);
  69165. };
  69166. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  69167. this._currentEffect.setVector3(name, vector);
  69168. };
  69169. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  69170. vector.toArray(UniformBuffer._tempBuffer);
  69171. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  69172. };
  69173. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  69174. this._currentEffect.setVector4(name, vector);
  69175. };
  69176. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  69177. vector.toArray(UniformBuffer._tempBuffer);
  69178. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  69179. };
  69180. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  69181. if (suffix === void 0) { suffix = ""; }
  69182. this._currentEffect.setColor3(name + suffix, color);
  69183. };
  69184. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  69185. color.toArray(UniformBuffer._tempBuffer);
  69186. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  69187. };
  69188. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  69189. if (suffix === void 0) { suffix = ""; }
  69190. this._currentEffect.setColor4(name + suffix, color, alpha);
  69191. };
  69192. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  69193. color.toArray(UniformBuffer._tempBuffer);
  69194. UniformBuffer._tempBuffer[3] = alpha;
  69195. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  69196. };
  69197. /**
  69198. * Sets a sampler uniform on the effect.
  69199. * @param name Define the name of the sampler.
  69200. * @param texture Define the texture to set in the sampler
  69201. */
  69202. UniformBuffer.prototype.setTexture = function (name, texture) {
  69203. this._currentEffect.setTexture(name, texture);
  69204. };
  69205. /**
  69206. * Directly updates the value of the uniform in the cache AND on the GPU.
  69207. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  69208. * @param data Define the flattened data
  69209. */
  69210. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  69211. this.updateUniform(uniformName, data, data.length);
  69212. this.update();
  69213. };
  69214. /**
  69215. * Binds this uniform buffer to an effect.
  69216. * @param effect Define the effect to bind the buffer to
  69217. * @param name Name of the uniform block in the shader.
  69218. */
  69219. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  69220. this._currentEffect = effect;
  69221. if (this._noUBO || !this._buffer) {
  69222. return;
  69223. }
  69224. effect.bindUniformBuffer(this._buffer, name);
  69225. };
  69226. /**
  69227. * Disposes the uniform buffer.
  69228. */
  69229. UniformBuffer.prototype.dispose = function () {
  69230. if (this._noUBO) {
  69231. return;
  69232. }
  69233. var uniformBuffers = this._engine._uniformBuffers;
  69234. var index = uniformBuffers.indexOf(this);
  69235. if (index !== -1) {
  69236. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  69237. uniformBuffers.pop();
  69238. }
  69239. if (!this._buffer) {
  69240. return;
  69241. }
  69242. if (this._engine._releaseBuffer(this._buffer)) {
  69243. this._buffer = null;
  69244. }
  69245. };
  69246. // Pool for avoiding memory leaks
  69247. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  69248. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  69249. return UniformBuffer;
  69250. }());
  69251. /***/ }),
  69252. /***/ "./Maths/index.ts":
  69253. /*!************************!*\
  69254. !*** ./Maths/index.ts ***!
  69255. \************************/
  69256. /*! 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 */
  69257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69258. "use strict";
  69259. __webpack_require__.r(__webpack_exports__);
  69260. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  69261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  69262. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  69263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  69264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  69265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  69266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  69267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  69268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  69269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  69270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  69271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  69272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  69273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  69274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  69275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  69276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  69277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  69278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  69279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  69280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  69281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  69282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  69283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  69284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  69285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  69286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  69287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  69288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  69289. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  69290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  69291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  69292. /***/ }),
  69293. /***/ "./Maths/math.scalar.ts":
  69294. /*!******************************!*\
  69295. !*** ./Maths/math.scalar.ts ***!
  69296. \******************************/
  69297. /*! exports provided: Scalar */
  69298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69299. "use strict";
  69300. __webpack_require__.r(__webpack_exports__);
  69301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  69302. /**
  69303. * Scalar computation library
  69304. */
  69305. var Scalar = /** @class */ (function () {
  69306. function Scalar() {
  69307. }
  69308. /**
  69309. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69310. * @param a number
  69311. * @param b number
  69312. * @param epsilon (default = 1.401298E-45)
  69313. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69314. */
  69315. Scalar.WithinEpsilon = function (a, b, epsilon) {
  69316. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  69317. var num = a - b;
  69318. return -epsilon <= num && num <= epsilon;
  69319. };
  69320. /**
  69321. * Returns a string : the upper case translation of the number i to hexadecimal.
  69322. * @param i number
  69323. * @returns the upper case translation of the number i to hexadecimal.
  69324. */
  69325. Scalar.ToHex = function (i) {
  69326. var str = i.toString(16);
  69327. if (i <= 15) {
  69328. return ("0" + str).toUpperCase();
  69329. }
  69330. return str.toUpperCase();
  69331. };
  69332. /**
  69333. * Returns -1 if value is negative and +1 is value is positive.
  69334. * @param value the value
  69335. * @returns the value itself if it's equal to zero.
  69336. */
  69337. Scalar.Sign = function (value) {
  69338. value = +value; // convert to a number
  69339. if (value === 0 || isNaN(value)) {
  69340. return value;
  69341. }
  69342. return value > 0 ? 1 : -1;
  69343. };
  69344. /**
  69345. * Returns the value itself if it's between min and max.
  69346. * Returns min if the value is lower than min.
  69347. * Returns max if the value is greater than max.
  69348. * @param value the value to clmap
  69349. * @param min the min value to clamp to (default: 0)
  69350. * @param max the max value to clamp to (default: 1)
  69351. * @returns the clamped value
  69352. */
  69353. Scalar.Clamp = function (value, min, max) {
  69354. if (min === void 0) { min = 0; }
  69355. if (max === void 0) { max = 1; }
  69356. return Math.min(max, Math.max(min, value));
  69357. };
  69358. /**
  69359. * the log2 of value.
  69360. * @param value the value to compute log2 of
  69361. * @returns the log2 of value.
  69362. */
  69363. Scalar.Log2 = function (value) {
  69364. return Math.log(value) * Math.LOG2E;
  69365. };
  69366. /**
  69367. * Loops the value, so that it is never larger than length and never smaller than 0.
  69368. *
  69369. * This is similar to the modulo operator but it works with floating point numbers.
  69370. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69371. * With t = 5 and length = 2.5, the result would be 0.0.
  69372. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69373. * @param value the value
  69374. * @param length the length
  69375. * @returns the looped value
  69376. */
  69377. Scalar.Repeat = function (value, length) {
  69378. return value - Math.floor(value / length) * length;
  69379. };
  69380. /**
  69381. * Normalize the value between 0.0 and 1.0 using min and max values
  69382. * @param value value to normalize
  69383. * @param min max to normalize between
  69384. * @param max min to normalize between
  69385. * @returns the normalized value
  69386. */
  69387. Scalar.Normalize = function (value, min, max) {
  69388. return (value - min) / (max - min);
  69389. };
  69390. /**
  69391. * Denormalize the value from 0.0 and 1.0 using min and max values
  69392. * @param normalized value to denormalize
  69393. * @param min max to denormalize between
  69394. * @param max min to denormalize between
  69395. * @returns the denormalized value
  69396. */
  69397. Scalar.Denormalize = function (normalized, min, max) {
  69398. return (normalized * (max - min) + min);
  69399. };
  69400. /**
  69401. * Calculates the shortest difference between two given angles given in degrees.
  69402. * @param current current angle in degrees
  69403. * @param target target angle in degrees
  69404. * @returns the delta
  69405. */
  69406. Scalar.DeltaAngle = function (current, target) {
  69407. var num = Scalar.Repeat(target - current, 360.0);
  69408. if (num > 180.0) {
  69409. num -= 360.0;
  69410. }
  69411. return num;
  69412. };
  69413. /**
  69414. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69415. * @param tx value
  69416. * @param length length
  69417. * @returns The returned value will move back and forth between 0 and length
  69418. */
  69419. Scalar.PingPong = function (tx, length) {
  69420. var t = Scalar.Repeat(tx, length * 2.0);
  69421. return length - Math.abs(t - length);
  69422. };
  69423. /**
  69424. * Interpolates between min and max with smoothing at the limits.
  69425. *
  69426. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69427. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69428. * @param from from
  69429. * @param to to
  69430. * @param tx value
  69431. * @returns the smooth stepped value
  69432. */
  69433. Scalar.SmoothStep = function (from, to, tx) {
  69434. var t = Scalar.Clamp(tx);
  69435. t = -2.0 * t * t * t + 3.0 * t * t;
  69436. return to * t + from * (1.0 - t);
  69437. };
  69438. /**
  69439. * Moves a value current towards target.
  69440. *
  69441. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69442. * Negative values of maxDelta pushes the value away from target.
  69443. * @param current current value
  69444. * @param target target value
  69445. * @param maxDelta max distance to move
  69446. * @returns resulting value
  69447. */
  69448. Scalar.MoveTowards = function (current, target, maxDelta) {
  69449. var result = 0;
  69450. if (Math.abs(target - current) <= maxDelta) {
  69451. result = target;
  69452. }
  69453. else {
  69454. result = current + Scalar.Sign(target - current) * maxDelta;
  69455. }
  69456. return result;
  69457. };
  69458. /**
  69459. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69460. *
  69461. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69462. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69463. * @param current current value
  69464. * @param target target value
  69465. * @param maxDelta max distance to move
  69466. * @returns resulting angle
  69467. */
  69468. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  69469. var num = Scalar.DeltaAngle(current, target);
  69470. var result = 0;
  69471. if (-maxDelta < num && num < maxDelta) {
  69472. result = target;
  69473. }
  69474. else {
  69475. target = current + num;
  69476. result = Scalar.MoveTowards(current, target, maxDelta);
  69477. }
  69478. return result;
  69479. };
  69480. /**
  69481. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69482. * @param start start value
  69483. * @param end target value
  69484. * @param amount amount to lerp between
  69485. * @returns the lerped value
  69486. */
  69487. Scalar.Lerp = function (start, end, amount) {
  69488. return start + ((end - start) * amount);
  69489. };
  69490. /**
  69491. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69492. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69493. * @param start start value
  69494. * @param end target value
  69495. * @param amount amount to lerp between
  69496. * @returns the lerped value
  69497. */
  69498. Scalar.LerpAngle = function (start, end, amount) {
  69499. var num = Scalar.Repeat(end - start, 360.0);
  69500. if (num > 180.0) {
  69501. num -= 360.0;
  69502. }
  69503. return start + num * Scalar.Clamp(amount);
  69504. };
  69505. /**
  69506. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69507. * @param a start value
  69508. * @param b target value
  69509. * @param value value between a and b
  69510. * @returns the inverseLerp value
  69511. */
  69512. Scalar.InverseLerp = function (a, b, value) {
  69513. var result = 0;
  69514. if (a != b) {
  69515. result = Scalar.Clamp((value - a) / (b - a));
  69516. }
  69517. else {
  69518. result = 0.0;
  69519. }
  69520. return result;
  69521. };
  69522. /**
  69523. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69524. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69525. * @param value1 spline value
  69526. * @param tangent1 spline value
  69527. * @param value2 spline value
  69528. * @param tangent2 spline value
  69529. * @param amount input value
  69530. * @returns hermite result
  69531. */
  69532. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69533. var squared = amount * amount;
  69534. var cubed = amount * squared;
  69535. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69536. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69537. var part3 = (cubed - (2.0 * squared)) + amount;
  69538. var part4 = cubed - squared;
  69539. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  69540. };
  69541. /**
  69542. * Returns a random float number between and min and max values
  69543. * @param min min value of random
  69544. * @param max max value of random
  69545. * @returns random value
  69546. */
  69547. Scalar.RandomRange = function (min, max) {
  69548. if (min === max) {
  69549. return min;
  69550. }
  69551. return ((Math.random() * (max - min)) + min);
  69552. };
  69553. /**
  69554. * This function returns percentage of a number in a given range.
  69555. *
  69556. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69557. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69558. * @param number to convert to percentage
  69559. * @param min min range
  69560. * @param max max range
  69561. * @returns the percentage
  69562. */
  69563. Scalar.RangeToPercent = function (number, min, max) {
  69564. return ((number - min) / (max - min));
  69565. };
  69566. /**
  69567. * This function returns number that corresponds to the percentage in a given range.
  69568. *
  69569. * PercentToRange(0.34,0,100) will return 34.
  69570. * @param percent to convert to number
  69571. * @param min min range
  69572. * @param max max range
  69573. * @returns the number
  69574. */
  69575. Scalar.PercentToRange = function (percent, min, max) {
  69576. return ((max - min) * percent + min);
  69577. };
  69578. /**
  69579. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69580. * @param angle The angle to normalize in radian.
  69581. * @return The converted angle.
  69582. */
  69583. Scalar.NormalizeRadians = function (angle) {
  69584. // More precise but slower version kept for reference.
  69585. // angle = angle % Tools.TwoPi;
  69586. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  69587. //if (angle > Math.PI) {
  69588. // angle -= Tools.TwoPi;
  69589. //}
  69590. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  69591. return angle;
  69592. };
  69593. /**
  69594. * Two pi constants convenient for computation.
  69595. */
  69596. Scalar.TwoPi = Math.PI * 2;
  69597. return Scalar;
  69598. }());
  69599. /***/ }),
  69600. /***/ "./Maths/math.ts":
  69601. /*!***********************!*\
  69602. !*** ./Maths/math.ts ***!
  69603. \***********************/
  69604. /*! 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 */
  69605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69606. "use strict";
  69607. __webpack_require__.r(__webpack_exports__);
  69608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  69609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  69610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  69611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  69612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  69613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  69614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  69615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  69616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  69617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  69618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  69619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  69620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  69621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  69622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  69623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  69624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  69625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  69626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  69627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  69628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  69629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  69630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  69631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  69632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  69633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  69634. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  69635. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  69636. /**
  69637. * Constant used to convert a value to gamma space
  69638. * @ignorenaming
  69639. */
  69640. var ToGammaSpace = 1 / 2.2;
  69641. /**
  69642. * Constant used to convert a value to linear space
  69643. * @ignorenaming
  69644. */
  69645. var ToLinearSpace = 2.2;
  69646. /**
  69647. * Constant used to define the minimal number value in Babylon.js
  69648. * @ignorenaming
  69649. */
  69650. var Epsilon = 0.001;
  69651. /**
  69652. * Class used to hold a RBG color
  69653. */
  69654. var Color3 = /** @class */ (function () {
  69655. /**
  69656. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69657. * @param r defines the red component (between 0 and 1, default is 0)
  69658. * @param g defines the green component (between 0 and 1, default is 0)
  69659. * @param b defines the blue component (between 0 and 1, default is 0)
  69660. */
  69661. function Color3(
  69662. /**
  69663. * Defines the red component (between 0 and 1, default is 0)
  69664. */
  69665. r,
  69666. /**
  69667. * Defines the green component (between 0 and 1, default is 0)
  69668. */
  69669. g,
  69670. /**
  69671. * Defines the blue component (between 0 and 1, default is 0)
  69672. */
  69673. b) {
  69674. if (r === void 0) { r = 0; }
  69675. if (g === void 0) { g = 0; }
  69676. if (b === void 0) { b = 0; }
  69677. this.r = r;
  69678. this.g = g;
  69679. this.b = b;
  69680. }
  69681. /**
  69682. * Creates a string with the Color3 current values
  69683. * @returns the string representation of the Color3 object
  69684. */
  69685. Color3.prototype.toString = function () {
  69686. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  69687. };
  69688. /**
  69689. * Returns the string "Color3"
  69690. * @returns "Color3"
  69691. */
  69692. Color3.prototype.getClassName = function () {
  69693. return "Color3";
  69694. };
  69695. /**
  69696. * Compute the Color3 hash code
  69697. * @returns an unique number that can be used to hash Color3 objects
  69698. */
  69699. Color3.prototype.getHashCode = function () {
  69700. var hash = this.r || 0;
  69701. hash = (hash * 397) ^ (this.g || 0);
  69702. hash = (hash * 397) ^ (this.b || 0);
  69703. return hash;
  69704. };
  69705. // Operators
  69706. /**
  69707. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69708. * @param array defines the array where to store the r,g,b components
  69709. * @param index defines an optional index in the target array to define where to start storing values
  69710. * @returns the current Color3 object
  69711. */
  69712. Color3.prototype.toArray = function (array, index) {
  69713. if (index === void 0) { index = 0; }
  69714. array[index] = this.r;
  69715. array[index + 1] = this.g;
  69716. array[index + 2] = this.b;
  69717. return this;
  69718. };
  69719. /**
  69720. * Returns a new Color4 object from the current Color3 and the given alpha
  69721. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69722. * @returns a new Color4 object
  69723. */
  69724. Color3.prototype.toColor4 = function (alpha) {
  69725. if (alpha === void 0) { alpha = 1; }
  69726. return new Color4(this.r, this.g, this.b, alpha);
  69727. };
  69728. /**
  69729. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69730. * @returns the new array
  69731. */
  69732. Color3.prototype.asArray = function () {
  69733. var result = new Array();
  69734. this.toArray(result, 0);
  69735. return result;
  69736. };
  69737. /**
  69738. * Returns the luminance value
  69739. * @returns a float value
  69740. */
  69741. Color3.prototype.toLuminance = function () {
  69742. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  69743. };
  69744. /**
  69745. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69746. * @param otherColor defines the second operand
  69747. * @returns the new Color3 object
  69748. */
  69749. Color3.prototype.multiply = function (otherColor) {
  69750. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  69751. };
  69752. /**
  69753. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69754. * @param otherColor defines the second operand
  69755. * @param result defines the Color3 object where to store the result
  69756. * @returns the current Color3
  69757. */
  69758. Color3.prototype.multiplyToRef = function (otherColor, result) {
  69759. result.r = this.r * otherColor.r;
  69760. result.g = this.g * otherColor.g;
  69761. result.b = this.b * otherColor.b;
  69762. return this;
  69763. };
  69764. /**
  69765. * Determines equality between Color3 objects
  69766. * @param otherColor defines the second operand
  69767. * @returns true if the rgb values are equal to the given ones
  69768. */
  69769. Color3.prototype.equals = function (otherColor) {
  69770. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  69771. };
  69772. /**
  69773. * Determines equality between the current Color3 object and a set of r,b,g values
  69774. * @param r defines the red component to check
  69775. * @param g defines the green component to check
  69776. * @param b defines the blue component to check
  69777. * @returns true if the rgb values are equal to the given ones
  69778. */
  69779. Color3.prototype.equalsFloats = function (r, g, b) {
  69780. return this.r === r && this.g === g && this.b === b;
  69781. };
  69782. /**
  69783. * Multiplies in place each rgb value by scale
  69784. * @param scale defines the scaling factor
  69785. * @returns the updated Color3
  69786. */
  69787. Color3.prototype.scale = function (scale) {
  69788. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  69789. };
  69790. /**
  69791. * Multiplies the rgb values by scale and stores the result into "result"
  69792. * @param scale defines the scaling factor
  69793. * @param result defines the Color3 object where to store the result
  69794. * @returns the unmodified current Color3
  69795. */
  69796. Color3.prototype.scaleToRef = function (scale, result) {
  69797. result.r = this.r * scale;
  69798. result.g = this.g * scale;
  69799. result.b = this.b * scale;
  69800. return this;
  69801. };
  69802. /**
  69803. * Scale the current Color3 values by a factor and add the result to a given Color3
  69804. * @param scale defines the scale factor
  69805. * @param result defines color to store the result into
  69806. * @returns the unmodified current Color3
  69807. */
  69808. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  69809. result.r += this.r * scale;
  69810. result.g += this.g * scale;
  69811. result.b += this.b * scale;
  69812. return this;
  69813. };
  69814. /**
  69815. * Clamps the rgb values by the min and max values and stores the result into "result"
  69816. * @param min defines minimum clamping value (default is 0)
  69817. * @param max defines maximum clamping value (default is 1)
  69818. * @param result defines color to store the result into
  69819. * @returns the original Color3
  69820. */
  69821. Color3.prototype.clampToRef = function (min, max, result) {
  69822. if (min === void 0) { min = 0; }
  69823. if (max === void 0) { max = 1; }
  69824. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  69825. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  69826. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  69827. return this;
  69828. };
  69829. /**
  69830. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69831. * @param otherColor defines the second operand
  69832. * @returns the new Color3
  69833. */
  69834. Color3.prototype.add = function (otherColor) {
  69835. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  69836. };
  69837. /**
  69838. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69839. * @param otherColor defines the second operand
  69840. * @param result defines Color3 object to store the result into
  69841. * @returns the unmodified current Color3
  69842. */
  69843. Color3.prototype.addToRef = function (otherColor, result) {
  69844. result.r = this.r + otherColor.r;
  69845. result.g = this.g + otherColor.g;
  69846. result.b = this.b + otherColor.b;
  69847. return this;
  69848. };
  69849. /**
  69850. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69851. * @param otherColor defines the second operand
  69852. * @returns the new Color3
  69853. */
  69854. Color3.prototype.subtract = function (otherColor) {
  69855. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  69856. };
  69857. /**
  69858. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69859. * @param otherColor defines the second operand
  69860. * @param result defines Color3 object to store the result into
  69861. * @returns the unmodified current Color3
  69862. */
  69863. Color3.prototype.subtractToRef = function (otherColor, result) {
  69864. result.r = this.r - otherColor.r;
  69865. result.g = this.g - otherColor.g;
  69866. result.b = this.b - otherColor.b;
  69867. return this;
  69868. };
  69869. /**
  69870. * Copy the current object
  69871. * @returns a new Color3 copied the current one
  69872. */
  69873. Color3.prototype.clone = function () {
  69874. return new Color3(this.r, this.g, this.b);
  69875. };
  69876. /**
  69877. * Copies the rgb values from the source in the current Color3
  69878. * @param source defines the source Color3 object
  69879. * @returns the updated Color3 object
  69880. */
  69881. Color3.prototype.copyFrom = function (source) {
  69882. this.r = source.r;
  69883. this.g = source.g;
  69884. this.b = source.b;
  69885. return this;
  69886. };
  69887. /**
  69888. * Updates the Color3 rgb values from the given floats
  69889. * @param r defines the red component to read from
  69890. * @param g defines the green component to read from
  69891. * @param b defines the blue component to read from
  69892. * @returns the current Color3 object
  69893. */
  69894. Color3.prototype.copyFromFloats = function (r, g, b) {
  69895. this.r = r;
  69896. this.g = g;
  69897. this.b = b;
  69898. return this;
  69899. };
  69900. /**
  69901. * Updates the Color3 rgb values from the given floats
  69902. * @param r defines the red component to read from
  69903. * @param g defines the green component to read from
  69904. * @param b defines the blue component to read from
  69905. * @returns the current Color3 object
  69906. */
  69907. Color3.prototype.set = function (r, g, b) {
  69908. return this.copyFromFloats(r, g, b);
  69909. };
  69910. /**
  69911. * Compute the Color3 hexadecimal code as a string
  69912. * @returns a string containing the hexadecimal representation of the Color3 object
  69913. */
  69914. Color3.prototype.toHexString = function () {
  69915. var intR = (this.r * 255) | 0;
  69916. var intG = (this.g * 255) | 0;
  69917. var intB = (this.b * 255) | 0;
  69918. 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);
  69919. };
  69920. /**
  69921. * Computes a new Color3 converted from the current one to linear space
  69922. * @returns a new Color3 object
  69923. */
  69924. Color3.prototype.toLinearSpace = function () {
  69925. var convertedColor = new Color3();
  69926. this.toLinearSpaceToRef(convertedColor);
  69927. return convertedColor;
  69928. };
  69929. /**
  69930. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69931. * @param convertedColor defines the Color3 object where to store the linear space version
  69932. * @returns the unmodified Color3
  69933. */
  69934. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  69935. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  69936. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  69937. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  69938. return this;
  69939. };
  69940. /**
  69941. * Computes a new Color3 converted from the current one to gamma space
  69942. * @returns a new Color3 object
  69943. */
  69944. Color3.prototype.toGammaSpace = function () {
  69945. var convertedColor = new Color3();
  69946. this.toGammaSpaceToRef(convertedColor);
  69947. return convertedColor;
  69948. };
  69949. /**
  69950. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69951. * @param convertedColor defines the Color3 object where to store the gamma space version
  69952. * @returns the unmodified Color3
  69953. */
  69954. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  69955. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  69956. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  69957. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  69958. return this;
  69959. };
  69960. /**
  69961. * Creates a new Color3 from the string containing valid hexadecimal values
  69962. * @param hex defines a string containing valid hexadecimal values
  69963. * @returns a new Color3 object
  69964. */
  69965. Color3.FromHexString = function (hex) {
  69966. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  69967. return new Color3(0, 0, 0);
  69968. }
  69969. var r = parseInt(hex.substring(1, 3), 16);
  69970. var g = parseInt(hex.substring(3, 5), 16);
  69971. var b = parseInt(hex.substring(5, 7), 16);
  69972. return Color3.FromInts(r, g, b);
  69973. };
  69974. /**
  69975. * Creates a new Vector3 from the starting index of the given array
  69976. * @param array defines the source array
  69977. * @param offset defines an offset in the source array
  69978. * @returns a new Color3 object
  69979. */
  69980. Color3.FromArray = function (array, offset) {
  69981. if (offset === void 0) { offset = 0; }
  69982. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  69983. };
  69984. /**
  69985. * Creates a new Color3 from integer values (< 256)
  69986. * @param r defines the red component to read from (value between 0 and 255)
  69987. * @param g defines the green component to read from (value between 0 and 255)
  69988. * @param b defines the blue component to read from (value between 0 and 255)
  69989. * @returns a new Color3 object
  69990. */
  69991. Color3.FromInts = function (r, g, b) {
  69992. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  69993. };
  69994. /**
  69995. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69996. * @param start defines the start Color3 value
  69997. * @param end defines the end Color3 value
  69998. * @param amount defines the gradient value between start and end
  69999. * @returns a new Color3 object
  70000. */
  70001. Color3.Lerp = function (start, end, amount) {
  70002. var result = new Color3(0.0, 0.0, 0.0);
  70003. Color3.LerpToRef(start, end, amount, result);
  70004. return result;
  70005. };
  70006. /**
  70007. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70008. * @param left defines the start value
  70009. * @param right defines the end value
  70010. * @param amount defines the gradient factor
  70011. * @param result defines the Color3 object where to store the result
  70012. */
  70013. Color3.LerpToRef = function (left, right, amount, result) {
  70014. result.r = left.r + ((right.r - left.r) * amount);
  70015. result.g = left.g + ((right.g - left.g) * amount);
  70016. result.b = left.b + ((right.b - left.b) * amount);
  70017. };
  70018. /**
  70019. * Returns a Color3 value containing a red color
  70020. * @returns a new Color3 object
  70021. */
  70022. Color3.Red = function () { return new Color3(1, 0, 0); };
  70023. /**
  70024. * Returns a Color3 value containing a green color
  70025. * @returns a new Color3 object
  70026. */
  70027. Color3.Green = function () { return new Color3(0, 1, 0); };
  70028. /**
  70029. * Returns a Color3 value containing a blue color
  70030. * @returns a new Color3 object
  70031. */
  70032. Color3.Blue = function () { return new Color3(0, 0, 1); };
  70033. /**
  70034. * Returns a Color3 value containing a black color
  70035. * @returns a new Color3 object
  70036. */
  70037. Color3.Black = function () { return new Color3(0, 0, 0); };
  70038. Object.defineProperty(Color3, "BlackReadOnly", {
  70039. /**
  70040. * Gets a Color3 value containing a black color that must not be updated
  70041. */
  70042. get: function () {
  70043. return Color3._BlackReadOnly;
  70044. },
  70045. enumerable: true,
  70046. configurable: true
  70047. });
  70048. /**
  70049. * Returns a Color3 value containing a white color
  70050. * @returns a new Color3 object
  70051. */
  70052. Color3.White = function () { return new Color3(1, 1, 1); };
  70053. /**
  70054. * Returns a Color3 value containing a purple color
  70055. * @returns a new Color3 object
  70056. */
  70057. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  70058. /**
  70059. * Returns a Color3 value containing a magenta color
  70060. * @returns a new Color3 object
  70061. */
  70062. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  70063. /**
  70064. * Returns a Color3 value containing a yellow color
  70065. * @returns a new Color3 object
  70066. */
  70067. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  70068. /**
  70069. * Returns a Color3 value containing a gray color
  70070. * @returns a new Color3 object
  70071. */
  70072. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  70073. /**
  70074. * Returns a Color3 value containing a teal color
  70075. * @returns a new Color3 object
  70076. */
  70077. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  70078. /**
  70079. * Returns a Color3 value containing a random color
  70080. * @returns a new Color3 object
  70081. */
  70082. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  70083. // Statics
  70084. Color3._BlackReadOnly = Color3.Black();
  70085. return Color3;
  70086. }());
  70087. /**
  70088. * Class used to hold a RBGA color
  70089. */
  70090. var Color4 = /** @class */ (function () {
  70091. /**
  70092. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70093. * @param r defines the red component (between 0 and 1, default is 0)
  70094. * @param g defines the green component (between 0 and 1, default is 0)
  70095. * @param b defines the blue component (between 0 and 1, default is 0)
  70096. * @param a defines the alpha component (between 0 and 1, default is 1)
  70097. */
  70098. function Color4(
  70099. /**
  70100. * Defines the red component (between 0 and 1, default is 0)
  70101. */
  70102. r,
  70103. /**
  70104. * Defines the green component (between 0 and 1, default is 0)
  70105. */
  70106. g,
  70107. /**
  70108. * Defines the blue component (between 0 and 1, default is 0)
  70109. */
  70110. b,
  70111. /**
  70112. * Defines the alpha component (between 0 and 1, default is 1)
  70113. */
  70114. a) {
  70115. if (r === void 0) { r = 0; }
  70116. if (g === void 0) { g = 0; }
  70117. if (b === void 0) { b = 0; }
  70118. if (a === void 0) { a = 1; }
  70119. this.r = r;
  70120. this.g = g;
  70121. this.b = b;
  70122. this.a = a;
  70123. }
  70124. // Operators
  70125. /**
  70126. * Adds in place the given Color4 values to the current Color4 object
  70127. * @param right defines the second operand
  70128. * @returns the current updated Color4 object
  70129. */
  70130. Color4.prototype.addInPlace = function (right) {
  70131. this.r += right.r;
  70132. this.g += right.g;
  70133. this.b += right.b;
  70134. this.a += right.a;
  70135. return this;
  70136. };
  70137. /**
  70138. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70139. * @returns the new array
  70140. */
  70141. Color4.prototype.asArray = function () {
  70142. var result = new Array();
  70143. this.toArray(result, 0);
  70144. return result;
  70145. };
  70146. /**
  70147. * Stores from the starting index in the given array the Color4 successive values
  70148. * @param array defines the array where to store the r,g,b components
  70149. * @param index defines an optional index in the target array to define where to start storing values
  70150. * @returns the current Color4 object
  70151. */
  70152. Color4.prototype.toArray = function (array, index) {
  70153. if (index === void 0) { index = 0; }
  70154. array[index] = this.r;
  70155. array[index + 1] = this.g;
  70156. array[index + 2] = this.b;
  70157. array[index + 3] = this.a;
  70158. return this;
  70159. };
  70160. /**
  70161. * Determines equality between Color4 objects
  70162. * @param otherColor defines the second operand
  70163. * @returns true if the rgba values are equal to the given ones
  70164. */
  70165. Color4.prototype.equals = function (otherColor) {
  70166. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  70167. };
  70168. /**
  70169. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70170. * @param right defines the second operand
  70171. * @returns a new Color4 object
  70172. */
  70173. Color4.prototype.add = function (right) {
  70174. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  70175. };
  70176. /**
  70177. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70178. * @param right defines the second operand
  70179. * @returns a new Color4 object
  70180. */
  70181. Color4.prototype.subtract = function (right) {
  70182. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  70183. };
  70184. /**
  70185. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70186. * @param right defines the second operand
  70187. * @param result defines the Color4 object where to store the result
  70188. * @returns the current Color4 object
  70189. */
  70190. Color4.prototype.subtractToRef = function (right, result) {
  70191. result.r = this.r - right.r;
  70192. result.g = this.g - right.g;
  70193. result.b = this.b - right.b;
  70194. result.a = this.a - right.a;
  70195. return this;
  70196. };
  70197. /**
  70198. * Creates a new Color4 with the current Color4 values multiplied by scale
  70199. * @param scale defines the scaling factor to apply
  70200. * @returns a new Color4 object
  70201. */
  70202. Color4.prototype.scale = function (scale) {
  70203. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  70204. };
  70205. /**
  70206. * Multiplies the current Color4 values by scale and stores the result in "result"
  70207. * @param scale defines the scaling factor to apply
  70208. * @param result defines the Color4 object where to store the result
  70209. * @returns the current unmodified Color4
  70210. */
  70211. Color4.prototype.scaleToRef = function (scale, result) {
  70212. result.r = this.r * scale;
  70213. result.g = this.g * scale;
  70214. result.b = this.b * scale;
  70215. result.a = this.a * scale;
  70216. return this;
  70217. };
  70218. /**
  70219. * Scale the current Color4 values by a factor and add the result to a given Color4
  70220. * @param scale defines the scale factor
  70221. * @param result defines the Color4 object where to store the result
  70222. * @returns the unmodified current Color4
  70223. */
  70224. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  70225. result.r += this.r * scale;
  70226. result.g += this.g * scale;
  70227. result.b += this.b * scale;
  70228. result.a += this.a * scale;
  70229. return this;
  70230. };
  70231. /**
  70232. * Clamps the rgb values by the min and max values and stores the result into "result"
  70233. * @param min defines minimum clamping value (default is 0)
  70234. * @param max defines maximum clamping value (default is 1)
  70235. * @param result defines color to store the result into.
  70236. * @returns the cuurent Color4
  70237. */
  70238. Color4.prototype.clampToRef = function (min, max, result) {
  70239. if (min === void 0) { min = 0; }
  70240. if (max === void 0) { max = 1; }
  70241. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  70242. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  70243. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  70244. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  70245. return this;
  70246. };
  70247. /**
  70248. * Multipy an Color4 value by another and return a new Color4 object
  70249. * @param color defines the Color4 value to multiply by
  70250. * @returns a new Color4 object
  70251. */
  70252. Color4.prototype.multiply = function (color) {
  70253. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  70254. };
  70255. /**
  70256. * Multipy a Color4 value by another and push the result in a reference value
  70257. * @param color defines the Color4 value to multiply by
  70258. * @param result defines the Color4 to fill the result in
  70259. * @returns the result Color4
  70260. */
  70261. Color4.prototype.multiplyToRef = function (color, result) {
  70262. result.r = this.r * color.r;
  70263. result.g = this.g * color.g;
  70264. result.b = this.b * color.b;
  70265. result.a = this.a * color.a;
  70266. return result;
  70267. };
  70268. /**
  70269. * Creates a string with the Color4 current values
  70270. * @returns the string representation of the Color4 object
  70271. */
  70272. Color4.prototype.toString = function () {
  70273. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  70274. };
  70275. /**
  70276. * Returns the string "Color4"
  70277. * @returns "Color4"
  70278. */
  70279. Color4.prototype.getClassName = function () {
  70280. return "Color4";
  70281. };
  70282. /**
  70283. * Compute the Color4 hash code
  70284. * @returns an unique number that can be used to hash Color4 objects
  70285. */
  70286. Color4.prototype.getHashCode = function () {
  70287. var hash = this.r || 0;
  70288. hash = (hash * 397) ^ (this.g || 0);
  70289. hash = (hash * 397) ^ (this.b || 0);
  70290. hash = (hash * 397) ^ (this.a || 0);
  70291. return hash;
  70292. };
  70293. /**
  70294. * Creates a new Color4 copied from the current one
  70295. * @returns a new Color4 object
  70296. */
  70297. Color4.prototype.clone = function () {
  70298. return new Color4(this.r, this.g, this.b, this.a);
  70299. };
  70300. /**
  70301. * Copies the given Color4 values into the current one
  70302. * @param source defines the source Color4 object
  70303. * @returns the current updated Color4 object
  70304. */
  70305. Color4.prototype.copyFrom = function (source) {
  70306. this.r = source.r;
  70307. this.g = source.g;
  70308. this.b = source.b;
  70309. this.a = source.a;
  70310. return this;
  70311. };
  70312. /**
  70313. * Copies the given float values into the current one
  70314. * @param r defines the red component to read from
  70315. * @param g defines the green component to read from
  70316. * @param b defines the blue component to read from
  70317. * @param a defines the alpha component to read from
  70318. * @returns the current updated Color4 object
  70319. */
  70320. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  70321. this.r = r;
  70322. this.g = g;
  70323. this.b = b;
  70324. this.a = a;
  70325. return this;
  70326. };
  70327. /**
  70328. * Copies the given float values into the current one
  70329. * @param r defines the red component to read from
  70330. * @param g defines the green component to read from
  70331. * @param b defines the blue component to read from
  70332. * @param a defines the alpha component to read from
  70333. * @returns the current updated Color4 object
  70334. */
  70335. Color4.prototype.set = function (r, g, b, a) {
  70336. return this.copyFromFloats(r, g, b, a);
  70337. };
  70338. /**
  70339. * Compute the Color4 hexadecimal code as a string
  70340. * @returns a string containing the hexadecimal representation of the Color4 object
  70341. */
  70342. Color4.prototype.toHexString = function () {
  70343. var intR = (this.r * 255) | 0;
  70344. var intG = (this.g * 255) | 0;
  70345. var intB = (this.b * 255) | 0;
  70346. var intA = (this.a * 255) | 0;
  70347. 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);
  70348. };
  70349. /**
  70350. * Computes a new Color4 converted from the current one to linear space
  70351. * @returns a new Color4 object
  70352. */
  70353. Color4.prototype.toLinearSpace = function () {
  70354. var convertedColor = new Color4();
  70355. this.toLinearSpaceToRef(convertedColor);
  70356. return convertedColor;
  70357. };
  70358. /**
  70359. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70360. * @param convertedColor defines the Color4 object where to store the linear space version
  70361. * @returns the unmodified Color4
  70362. */
  70363. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  70364. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  70365. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  70366. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  70367. convertedColor.a = this.a;
  70368. return this;
  70369. };
  70370. /**
  70371. * Computes a new Color4 converted from the current one to gamma space
  70372. * @returns a new Color4 object
  70373. */
  70374. Color4.prototype.toGammaSpace = function () {
  70375. var convertedColor = new Color4();
  70376. this.toGammaSpaceToRef(convertedColor);
  70377. return convertedColor;
  70378. };
  70379. /**
  70380. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70381. * @param convertedColor defines the Color4 object where to store the gamma space version
  70382. * @returns the unmodified Color4
  70383. */
  70384. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  70385. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  70386. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  70387. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  70388. convertedColor.a = this.a;
  70389. return this;
  70390. };
  70391. // Statics
  70392. /**
  70393. * Creates a new Color4 from the string containing valid hexadecimal values
  70394. * @param hex defines a string containing valid hexadecimal values
  70395. * @returns a new Color4 object
  70396. */
  70397. Color4.FromHexString = function (hex) {
  70398. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  70399. return new Color4(0.0, 0.0, 0.0, 0.0);
  70400. }
  70401. var r = parseInt(hex.substring(1, 3), 16);
  70402. var g = parseInt(hex.substring(3, 5), 16);
  70403. var b = parseInt(hex.substring(5, 7), 16);
  70404. var a = parseInt(hex.substring(7, 9), 16);
  70405. return Color4.FromInts(r, g, b, a);
  70406. };
  70407. /**
  70408. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70409. * @param left defines the start value
  70410. * @param right defines the end value
  70411. * @param amount defines the gradient factor
  70412. * @returns a new Color4 object
  70413. */
  70414. Color4.Lerp = function (left, right, amount) {
  70415. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  70416. Color4.LerpToRef(left, right, amount, result);
  70417. return result;
  70418. };
  70419. /**
  70420. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70421. * @param left defines the start value
  70422. * @param right defines the end value
  70423. * @param amount defines the gradient factor
  70424. * @param result defines the Color4 object where to store data
  70425. */
  70426. Color4.LerpToRef = function (left, right, amount, result) {
  70427. result.r = left.r + (right.r - left.r) * amount;
  70428. result.g = left.g + (right.g - left.g) * amount;
  70429. result.b = left.b + (right.b - left.b) * amount;
  70430. result.a = left.a + (right.a - left.a) * amount;
  70431. };
  70432. /**
  70433. * Creates a new Color4 from a Color3 and an alpha value
  70434. * @param color3 defines the source Color3 to read from
  70435. * @param alpha defines the alpha component (1.0 by default)
  70436. * @returns a new Color4 object
  70437. */
  70438. Color4.FromColor3 = function (color3, alpha) {
  70439. if (alpha === void 0) { alpha = 1.0; }
  70440. return new Color4(color3.r, color3.g, color3.b, alpha);
  70441. };
  70442. /**
  70443. * Creates a new Color4 from the starting index element of the given array
  70444. * @param array defines the source array to read from
  70445. * @param offset defines the offset in the source array
  70446. * @returns a new Color4 object
  70447. */
  70448. Color4.FromArray = function (array, offset) {
  70449. if (offset === void 0) { offset = 0; }
  70450. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70451. };
  70452. /**
  70453. * Creates a new Color3 from integer values (< 256)
  70454. * @param r defines the red component to read from (value between 0 and 255)
  70455. * @param g defines the green component to read from (value between 0 and 255)
  70456. * @param b defines the blue component to read from (value between 0 and 255)
  70457. * @param a defines the alpha component to read from (value between 0 and 255)
  70458. * @returns a new Color3 object
  70459. */
  70460. Color4.FromInts = function (r, g, b, a) {
  70461. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  70462. };
  70463. /**
  70464. * Check the content of a given array and convert it to an array containing RGBA data
  70465. * If the original array was already containing count * 4 values then it is returned directly
  70466. * @param colors defines the array to check
  70467. * @param count defines the number of RGBA data to expect
  70468. * @returns an array containing count * 4 values (RGBA)
  70469. */
  70470. Color4.CheckColors4 = function (colors, count) {
  70471. // Check if color3 was used
  70472. if (colors.length === count * 3) {
  70473. var colors4 = [];
  70474. for (var index = 0; index < colors.length; index += 3) {
  70475. var newIndex = (index / 3) * 4;
  70476. colors4[newIndex] = colors[index];
  70477. colors4[newIndex + 1] = colors[index + 1];
  70478. colors4[newIndex + 2] = colors[index + 2];
  70479. colors4[newIndex + 3] = 1.0;
  70480. }
  70481. return colors4;
  70482. }
  70483. return colors;
  70484. };
  70485. return Color4;
  70486. }());
  70487. /**
  70488. * Class representing a vector containing 2 coordinates
  70489. */
  70490. var Vector2 = /** @class */ (function () {
  70491. /**
  70492. * Creates a new Vector2 from the given x and y coordinates
  70493. * @param x defines the first coordinate
  70494. * @param y defines the second coordinate
  70495. */
  70496. function Vector2(
  70497. /** defines the first coordinate */
  70498. x,
  70499. /** defines the second coordinate */
  70500. y) {
  70501. if (x === void 0) { x = 0; }
  70502. if (y === void 0) { y = 0; }
  70503. this.x = x;
  70504. this.y = y;
  70505. }
  70506. /**
  70507. * Gets a string with the Vector2 coordinates
  70508. * @returns a string with the Vector2 coordinates
  70509. */
  70510. Vector2.prototype.toString = function () {
  70511. return "{X: " + this.x + " Y:" + this.y + "}";
  70512. };
  70513. /**
  70514. * Gets class name
  70515. * @returns the string "Vector2"
  70516. */
  70517. Vector2.prototype.getClassName = function () {
  70518. return "Vector2";
  70519. };
  70520. /**
  70521. * Gets current vector hash code
  70522. * @returns the Vector2 hash code as a number
  70523. */
  70524. Vector2.prototype.getHashCode = function () {
  70525. var hash = this.x || 0;
  70526. hash = (hash * 397) ^ (this.y || 0);
  70527. return hash;
  70528. };
  70529. // Operators
  70530. /**
  70531. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70532. * @param array defines the source array
  70533. * @param index defines the offset in source array
  70534. * @returns the current Vector2
  70535. */
  70536. Vector2.prototype.toArray = function (array, index) {
  70537. if (index === void 0) { index = 0; }
  70538. array[index] = this.x;
  70539. array[index + 1] = this.y;
  70540. return this;
  70541. };
  70542. /**
  70543. * Copy the current vector to an array
  70544. * @returns a new array with 2 elements: the Vector2 coordinates.
  70545. */
  70546. Vector2.prototype.asArray = function () {
  70547. var result = new Array();
  70548. this.toArray(result, 0);
  70549. return result;
  70550. };
  70551. /**
  70552. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70553. * @param source defines the source Vector2
  70554. * @returns the current updated Vector2
  70555. */
  70556. Vector2.prototype.copyFrom = function (source) {
  70557. this.x = source.x;
  70558. this.y = source.y;
  70559. return this;
  70560. };
  70561. /**
  70562. * Sets the Vector2 coordinates with the given floats
  70563. * @param x defines the first coordinate
  70564. * @param y defines the second coordinate
  70565. * @returns the current updated Vector2
  70566. */
  70567. Vector2.prototype.copyFromFloats = function (x, y) {
  70568. this.x = x;
  70569. this.y = y;
  70570. return this;
  70571. };
  70572. /**
  70573. * Sets the Vector2 coordinates with the given floats
  70574. * @param x defines the first coordinate
  70575. * @param y defines the second coordinate
  70576. * @returns the current updated Vector2
  70577. */
  70578. Vector2.prototype.set = function (x, y) {
  70579. return this.copyFromFloats(x, y);
  70580. };
  70581. /**
  70582. * Add another vector with the current one
  70583. * @param otherVector defines the other vector
  70584. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70585. */
  70586. Vector2.prototype.add = function (otherVector) {
  70587. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  70588. };
  70589. /**
  70590. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70591. * @param otherVector defines the other vector
  70592. * @param result defines the target vector
  70593. * @returns the unmodified current Vector2
  70594. */
  70595. Vector2.prototype.addToRef = function (otherVector, result) {
  70596. result.x = this.x + otherVector.x;
  70597. result.y = this.y + otherVector.y;
  70598. return this;
  70599. };
  70600. /**
  70601. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70602. * @param otherVector defines the other vector
  70603. * @returns the current updated Vector2
  70604. */
  70605. Vector2.prototype.addInPlace = function (otherVector) {
  70606. this.x += otherVector.x;
  70607. this.y += otherVector.y;
  70608. return this;
  70609. };
  70610. /**
  70611. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70612. * @param otherVector defines the other vector
  70613. * @returns a new Vector2
  70614. */
  70615. Vector2.prototype.addVector3 = function (otherVector) {
  70616. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  70617. };
  70618. /**
  70619. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70620. * @param otherVector defines the other vector
  70621. * @returns a new Vector2
  70622. */
  70623. Vector2.prototype.subtract = function (otherVector) {
  70624. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  70625. };
  70626. /**
  70627. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70628. * @param otherVector defines the other vector
  70629. * @param result defines the target vector
  70630. * @returns the unmodified current Vector2
  70631. */
  70632. Vector2.prototype.subtractToRef = function (otherVector, result) {
  70633. result.x = this.x - otherVector.x;
  70634. result.y = this.y - otherVector.y;
  70635. return this;
  70636. };
  70637. /**
  70638. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70639. * @param otherVector defines the other vector
  70640. * @returns the current updated Vector2
  70641. */
  70642. Vector2.prototype.subtractInPlace = function (otherVector) {
  70643. this.x -= otherVector.x;
  70644. this.y -= otherVector.y;
  70645. return this;
  70646. };
  70647. /**
  70648. * Multiplies in place the current Vector2 coordinates by the given ones
  70649. * @param otherVector defines the other vector
  70650. * @returns the current updated Vector2
  70651. */
  70652. Vector2.prototype.multiplyInPlace = function (otherVector) {
  70653. this.x *= otherVector.x;
  70654. this.y *= otherVector.y;
  70655. return this;
  70656. };
  70657. /**
  70658. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70659. * @param otherVector defines the other vector
  70660. * @returns a new Vector2
  70661. */
  70662. Vector2.prototype.multiply = function (otherVector) {
  70663. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  70664. };
  70665. /**
  70666. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70667. * @param otherVector defines the other vector
  70668. * @param result defines the target vector
  70669. * @returns the unmodified current Vector2
  70670. */
  70671. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  70672. result.x = this.x * otherVector.x;
  70673. result.y = this.y * otherVector.y;
  70674. return this;
  70675. };
  70676. /**
  70677. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70678. * @param x defines the first coordinate
  70679. * @param y defines the second coordinate
  70680. * @returns a new Vector2
  70681. */
  70682. Vector2.prototype.multiplyByFloats = function (x, y) {
  70683. return new Vector2(this.x * x, this.y * y);
  70684. };
  70685. /**
  70686. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70687. * @param otherVector defines the other vector
  70688. * @returns a new Vector2
  70689. */
  70690. Vector2.prototype.divide = function (otherVector) {
  70691. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  70692. };
  70693. /**
  70694. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70695. * @param otherVector defines the other vector
  70696. * @param result defines the target vector
  70697. * @returns the unmodified current Vector2
  70698. */
  70699. Vector2.prototype.divideToRef = function (otherVector, result) {
  70700. result.x = this.x / otherVector.x;
  70701. result.y = this.y / otherVector.y;
  70702. return this;
  70703. };
  70704. /**
  70705. * Divides the current Vector2 coordinates by the given ones
  70706. * @param otherVector defines the other vector
  70707. * @returns the current updated Vector2
  70708. */
  70709. Vector2.prototype.divideInPlace = function (otherVector) {
  70710. return this.divideToRef(otherVector, this);
  70711. };
  70712. /**
  70713. * Gets a new Vector2 with current Vector2 negated coordinates
  70714. * @returns a new Vector2
  70715. */
  70716. Vector2.prototype.negate = function () {
  70717. return new Vector2(-this.x, -this.y);
  70718. };
  70719. /**
  70720. * Multiply the Vector2 coordinates by scale
  70721. * @param scale defines the scaling factor
  70722. * @returns the current updated Vector2
  70723. */
  70724. Vector2.prototype.scaleInPlace = function (scale) {
  70725. this.x *= scale;
  70726. this.y *= scale;
  70727. return this;
  70728. };
  70729. /**
  70730. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70731. * @param scale defines the scaling factor
  70732. * @returns a new Vector2
  70733. */
  70734. Vector2.prototype.scale = function (scale) {
  70735. var result = new Vector2(0, 0);
  70736. this.scaleToRef(scale, result);
  70737. return result;
  70738. };
  70739. /**
  70740. * Scale the current Vector2 values by a factor to a given Vector2
  70741. * @param scale defines the scale factor
  70742. * @param result defines the Vector2 object where to store the result
  70743. * @returns the unmodified current Vector2
  70744. */
  70745. Vector2.prototype.scaleToRef = function (scale, result) {
  70746. result.x = this.x * scale;
  70747. result.y = this.y * scale;
  70748. return this;
  70749. };
  70750. /**
  70751. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70752. * @param scale defines the scale factor
  70753. * @param result defines the Vector2 object where to store the result
  70754. * @returns the unmodified current Vector2
  70755. */
  70756. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  70757. result.x += this.x * scale;
  70758. result.y += this.y * scale;
  70759. return this;
  70760. };
  70761. /**
  70762. * Gets a boolean if two vectors are equals
  70763. * @param otherVector defines the other vector
  70764. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70765. */
  70766. Vector2.prototype.equals = function (otherVector) {
  70767. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  70768. };
  70769. /**
  70770. * Gets a boolean if two vectors are equals (using an epsilon value)
  70771. * @param otherVector defines the other vector
  70772. * @param epsilon defines the minimal distance to consider equality
  70773. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70774. */
  70775. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  70776. if (epsilon === void 0) { epsilon = Epsilon; }
  70777. 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);
  70778. };
  70779. /**
  70780. * Gets a new Vector2 from current Vector2 floored values
  70781. * @returns a new Vector2
  70782. */
  70783. Vector2.prototype.floor = function () {
  70784. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  70785. };
  70786. /**
  70787. * Gets a new Vector2 from current Vector2 floored values
  70788. * @returns a new Vector2
  70789. */
  70790. Vector2.prototype.fract = function () {
  70791. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  70792. };
  70793. // Properties
  70794. /**
  70795. * Gets the length of the vector
  70796. * @returns the vector length (float)
  70797. */
  70798. Vector2.prototype.length = function () {
  70799. return Math.sqrt(this.x * this.x + this.y * this.y);
  70800. };
  70801. /**
  70802. * Gets the vector squared length
  70803. * @returns the vector squared length (float)
  70804. */
  70805. Vector2.prototype.lengthSquared = function () {
  70806. return (this.x * this.x + this.y * this.y);
  70807. };
  70808. // Methods
  70809. /**
  70810. * Normalize the vector
  70811. * @returns the current updated Vector2
  70812. */
  70813. Vector2.prototype.normalize = function () {
  70814. var len = this.length();
  70815. if (len === 0) {
  70816. return this;
  70817. }
  70818. var num = 1.0 / len;
  70819. this.x *= num;
  70820. this.y *= num;
  70821. return this;
  70822. };
  70823. /**
  70824. * Gets a new Vector2 copied from the Vector2
  70825. * @returns a new Vector2
  70826. */
  70827. Vector2.prototype.clone = function () {
  70828. return new Vector2(this.x, this.y);
  70829. };
  70830. // Statics
  70831. /**
  70832. * Gets a new Vector2(0, 0)
  70833. * @returns a new Vector2
  70834. */
  70835. Vector2.Zero = function () {
  70836. return new Vector2(0, 0);
  70837. };
  70838. /**
  70839. * Gets a new Vector2(1, 1)
  70840. * @returns a new Vector2
  70841. */
  70842. Vector2.One = function () {
  70843. return new Vector2(1, 1);
  70844. };
  70845. /**
  70846. * Gets a new Vector2 set from the given index element of the given array
  70847. * @param array defines the data source
  70848. * @param offset defines the offset in the data source
  70849. * @returns a new Vector2
  70850. */
  70851. Vector2.FromArray = function (array, offset) {
  70852. if (offset === void 0) { offset = 0; }
  70853. return new Vector2(array[offset], array[offset + 1]);
  70854. };
  70855. /**
  70856. * Sets "result" from the given index element of the given array
  70857. * @param array defines the data source
  70858. * @param offset defines the offset in the data source
  70859. * @param result defines the target vector
  70860. */
  70861. Vector2.FromArrayToRef = function (array, offset, result) {
  70862. result.x = array[offset];
  70863. result.y = array[offset + 1];
  70864. };
  70865. /**
  70866. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70867. * @param value1 defines 1st point of control
  70868. * @param value2 defines 2nd point of control
  70869. * @param value3 defines 3rd point of control
  70870. * @param value4 defines 4th point of control
  70871. * @param amount defines the interpolation factor
  70872. * @returns a new Vector2
  70873. */
  70874. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  70875. var squared = amount * amount;
  70876. var cubed = amount * squared;
  70877. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  70878. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  70879. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  70880. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  70881. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  70882. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  70883. return new Vector2(x, y);
  70884. };
  70885. /**
  70886. * 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".
  70887. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70888. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70889. * @param value defines the value to clamp
  70890. * @param min defines the lower limit
  70891. * @param max defines the upper limit
  70892. * @returns a new Vector2
  70893. */
  70894. Vector2.Clamp = function (value, min, max) {
  70895. var x = value.x;
  70896. x = (x > max.x) ? max.x : x;
  70897. x = (x < min.x) ? min.x : x;
  70898. var y = value.y;
  70899. y = (y > max.y) ? max.y : y;
  70900. y = (y < min.y) ? min.y : y;
  70901. return new Vector2(x, y);
  70902. };
  70903. /**
  70904. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70905. * @param value1 defines the 1st control point
  70906. * @param tangent1 defines the outgoing tangent
  70907. * @param value2 defines the 2nd control point
  70908. * @param tangent2 defines the incoming tangent
  70909. * @param amount defines the interpolation factor
  70910. * @returns a new Vector2
  70911. */
  70912. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70913. var squared = amount * amount;
  70914. var cubed = amount * squared;
  70915. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70916. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70917. var part3 = (cubed - (2.0 * squared)) + amount;
  70918. var part4 = cubed - squared;
  70919. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  70920. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  70921. return new Vector2(x, y);
  70922. };
  70923. /**
  70924. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70925. * @param start defines the start vector
  70926. * @param end defines the end vector
  70927. * @param amount defines the interpolation factor
  70928. * @returns a new Vector2
  70929. */
  70930. Vector2.Lerp = function (start, end, amount) {
  70931. var x = start.x + ((end.x - start.x) * amount);
  70932. var y = start.y + ((end.y - start.y) * amount);
  70933. return new Vector2(x, y);
  70934. };
  70935. /**
  70936. * Gets the dot product of the vector "left" and the vector "right"
  70937. * @param left defines first vector
  70938. * @param right defines second vector
  70939. * @returns the dot product (float)
  70940. */
  70941. Vector2.Dot = function (left, right) {
  70942. return left.x * right.x + left.y * right.y;
  70943. };
  70944. /**
  70945. * Returns a new Vector2 equal to the normalized given vector
  70946. * @param vector defines the vector to normalize
  70947. * @returns a new Vector2
  70948. */
  70949. Vector2.Normalize = function (vector) {
  70950. var newVector = vector.clone();
  70951. newVector.normalize();
  70952. return newVector;
  70953. };
  70954. /**
  70955. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70956. * @param left defines 1st vector
  70957. * @param right defines 2nd vector
  70958. * @returns a new Vector2
  70959. */
  70960. Vector2.Minimize = function (left, right) {
  70961. var x = (left.x < right.x) ? left.x : right.x;
  70962. var y = (left.y < right.y) ? left.y : right.y;
  70963. return new Vector2(x, y);
  70964. };
  70965. /**
  70966. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70967. * @param left defines 1st vector
  70968. * @param right defines 2nd vector
  70969. * @returns a new Vector2
  70970. */
  70971. Vector2.Maximize = function (left, right) {
  70972. var x = (left.x > right.x) ? left.x : right.x;
  70973. var y = (left.y > right.y) ? left.y : right.y;
  70974. return new Vector2(x, y);
  70975. };
  70976. /**
  70977. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70978. * @param vector defines the vector to transform
  70979. * @param transformation defines the matrix to apply
  70980. * @returns a new Vector2
  70981. */
  70982. Vector2.Transform = function (vector, transformation) {
  70983. var r = Vector2.Zero();
  70984. Vector2.TransformToRef(vector, transformation, r);
  70985. return r;
  70986. };
  70987. /**
  70988. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70989. * @param vector defines the vector to transform
  70990. * @param transformation defines the matrix to apply
  70991. * @param result defines the target vector
  70992. */
  70993. Vector2.TransformToRef = function (vector, transformation, result) {
  70994. var m = transformation.m;
  70995. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  70996. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  70997. result.x = x;
  70998. result.y = y;
  70999. };
  71000. /**
  71001. * Determines if a given vector is included in a triangle
  71002. * @param p defines the vector to test
  71003. * @param p0 defines 1st triangle point
  71004. * @param p1 defines 2nd triangle point
  71005. * @param p2 defines 3rd triangle point
  71006. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71007. */
  71008. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  71009. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  71010. var sign = a < 0 ? -1 : 1;
  71011. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  71012. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  71013. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  71014. };
  71015. /**
  71016. * Gets the distance between the vectors "value1" and "value2"
  71017. * @param value1 defines first vector
  71018. * @param value2 defines second vector
  71019. * @returns the distance between vectors
  71020. */
  71021. Vector2.Distance = function (value1, value2) {
  71022. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  71023. };
  71024. /**
  71025. * Returns the squared distance between the vectors "value1" and "value2"
  71026. * @param value1 defines first vector
  71027. * @param value2 defines second vector
  71028. * @returns the squared distance between vectors
  71029. */
  71030. Vector2.DistanceSquared = function (value1, value2) {
  71031. var x = value1.x - value2.x;
  71032. var y = value1.y - value2.y;
  71033. return (x * x) + (y * y);
  71034. };
  71035. /**
  71036. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71037. * @param value1 defines first vector
  71038. * @param value2 defines second vector
  71039. * @returns a new Vector2
  71040. */
  71041. Vector2.Center = function (value1, value2) {
  71042. var center = value1.add(value2);
  71043. center.scaleInPlace(0.5);
  71044. return center;
  71045. };
  71046. /**
  71047. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71048. * @param p defines the middle point
  71049. * @param segA defines one point of the segment
  71050. * @param segB defines the other point of the segment
  71051. * @returns the shortest distance
  71052. */
  71053. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  71054. var l2 = Vector2.DistanceSquared(segA, segB);
  71055. if (l2 === 0.0) {
  71056. return Vector2.Distance(p, segA);
  71057. }
  71058. var v = segB.subtract(segA);
  71059. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  71060. var proj = segA.add(v.multiplyByFloats(t, t));
  71061. return Vector2.Distance(p, proj);
  71062. };
  71063. return Vector2;
  71064. }());
  71065. /**
  71066. * Classed used to store (x,y,z) vector representation
  71067. * A Vector3 is the main object used in 3D geometry
  71068. * It can represent etiher the coordinates of a point the space, either a direction
  71069. * Reminder: js uses a left handed forward facing system
  71070. */
  71071. var Vector3 = /** @class */ (function () {
  71072. /**
  71073. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71074. * @param x defines the first coordinates (on X axis)
  71075. * @param y defines the second coordinates (on Y axis)
  71076. * @param z defines the third coordinates (on Z axis)
  71077. */
  71078. function Vector3(
  71079. /**
  71080. * Defines the first coordinates (on X axis)
  71081. */
  71082. x,
  71083. /**
  71084. * Defines the second coordinates (on Y axis)
  71085. */
  71086. y,
  71087. /**
  71088. * Defines the third coordinates (on Z axis)
  71089. */
  71090. z) {
  71091. if (x === void 0) { x = 0; }
  71092. if (y === void 0) { y = 0; }
  71093. if (z === void 0) { z = 0; }
  71094. this.x = x;
  71095. this.y = y;
  71096. this.z = z;
  71097. }
  71098. /**
  71099. * Creates a string representation of the Vector3
  71100. * @returns a string with the Vector3 coordinates.
  71101. */
  71102. Vector3.prototype.toString = function () {
  71103. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  71104. };
  71105. /**
  71106. * Gets the class name
  71107. * @returns the string "Vector3"
  71108. */
  71109. Vector3.prototype.getClassName = function () {
  71110. return "Vector3";
  71111. };
  71112. /**
  71113. * Creates the Vector3 hash code
  71114. * @returns a number which tends to be unique between Vector3 instances
  71115. */
  71116. Vector3.prototype.getHashCode = function () {
  71117. var hash = this.x || 0;
  71118. hash = (hash * 397) ^ (this.y || 0);
  71119. hash = (hash * 397) ^ (this.z || 0);
  71120. return hash;
  71121. };
  71122. // Operators
  71123. /**
  71124. * Creates an array containing three elements : the coordinates of the Vector3
  71125. * @returns a new array of numbers
  71126. */
  71127. Vector3.prototype.asArray = function () {
  71128. var result = [];
  71129. this.toArray(result, 0);
  71130. return result;
  71131. };
  71132. /**
  71133. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71134. * @param array defines the destination array
  71135. * @param index defines the offset in the destination array
  71136. * @returns the current Vector3
  71137. */
  71138. Vector3.prototype.toArray = function (array, index) {
  71139. if (index === void 0) { index = 0; }
  71140. array[index] = this.x;
  71141. array[index + 1] = this.y;
  71142. array[index + 2] = this.z;
  71143. return this;
  71144. };
  71145. /**
  71146. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71147. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71148. */
  71149. Vector3.prototype.toQuaternion = function () {
  71150. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  71151. };
  71152. /**
  71153. * Adds the given vector to the current Vector3
  71154. * @param otherVector defines the second operand
  71155. * @returns the current updated Vector3
  71156. */
  71157. Vector3.prototype.addInPlace = function (otherVector) {
  71158. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  71159. };
  71160. /**
  71161. * Adds the given coordinates to the current Vector3
  71162. * @param x defines the x coordinate of the operand
  71163. * @param y defines the y coordinate of the operand
  71164. * @param z defines the z coordinate of the operand
  71165. * @returns the current updated Vector3
  71166. */
  71167. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  71168. this.x += x;
  71169. this.y += y;
  71170. this.z += z;
  71171. return this;
  71172. };
  71173. /**
  71174. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71175. * @param otherVector defines the second operand
  71176. * @returns the resulting Vector3
  71177. */
  71178. Vector3.prototype.add = function (otherVector) {
  71179. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  71180. };
  71181. /**
  71182. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71183. * @param otherVector defines the second operand
  71184. * @param result defines the Vector3 object where to store the result
  71185. * @returns the current Vector3
  71186. */
  71187. Vector3.prototype.addToRef = function (otherVector, result) {
  71188. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  71189. };
  71190. /**
  71191. * Subtract the given vector from the current Vector3
  71192. * @param otherVector defines the second operand
  71193. * @returns the current updated Vector3
  71194. */
  71195. Vector3.prototype.subtractInPlace = function (otherVector) {
  71196. this.x -= otherVector.x;
  71197. this.y -= otherVector.y;
  71198. this.z -= otherVector.z;
  71199. return this;
  71200. };
  71201. /**
  71202. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71203. * @param otherVector defines the second operand
  71204. * @returns the resulting Vector3
  71205. */
  71206. Vector3.prototype.subtract = function (otherVector) {
  71207. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  71208. };
  71209. /**
  71210. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71211. * @param otherVector defines the second operand
  71212. * @param result defines the Vector3 object where to store the result
  71213. * @returns the current Vector3
  71214. */
  71215. Vector3.prototype.subtractToRef = function (otherVector, result) {
  71216. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  71217. };
  71218. /**
  71219. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71220. * @param x defines the x coordinate of the operand
  71221. * @param y defines the y coordinate of the operand
  71222. * @param z defines the z coordinate of the operand
  71223. * @returns the resulting Vector3
  71224. */
  71225. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  71226. return new Vector3(this.x - x, this.y - y, this.z - z);
  71227. };
  71228. /**
  71229. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71230. * @param x defines the x coordinate of the operand
  71231. * @param y defines the y coordinate of the operand
  71232. * @param z defines the z coordinate of the operand
  71233. * @param result defines the Vector3 object where to store the result
  71234. * @returns the current Vector3
  71235. */
  71236. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  71237. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  71238. };
  71239. /**
  71240. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71241. * @returns a new Vector3
  71242. */
  71243. Vector3.prototype.negate = function () {
  71244. return new Vector3(-this.x, -this.y, -this.z);
  71245. };
  71246. /**
  71247. * Multiplies the Vector3 coordinates by the float "scale"
  71248. * @param scale defines the multiplier factor
  71249. * @returns the current updated Vector3
  71250. */
  71251. Vector3.prototype.scaleInPlace = function (scale) {
  71252. this.x *= scale;
  71253. this.y *= scale;
  71254. this.z *= scale;
  71255. return this;
  71256. };
  71257. /**
  71258. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71259. * @param scale defines the multiplier factor
  71260. * @returns a new Vector3
  71261. */
  71262. Vector3.prototype.scale = function (scale) {
  71263. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  71264. };
  71265. /**
  71266. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71267. * @param scale defines the multiplier factor
  71268. * @param result defines the Vector3 object where to store the result
  71269. * @returns the current Vector3
  71270. */
  71271. Vector3.prototype.scaleToRef = function (scale, result) {
  71272. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  71273. };
  71274. /**
  71275. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71276. * @param scale defines the scale factor
  71277. * @param result defines the Vector3 object where to store the result
  71278. * @returns the unmodified current Vector3
  71279. */
  71280. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  71281. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  71282. };
  71283. /**
  71284. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71285. * @param otherVector defines the second operand
  71286. * @returns true if both vectors are equals
  71287. */
  71288. Vector3.prototype.equals = function (otherVector) {
  71289. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  71290. };
  71291. /**
  71292. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71293. * @param otherVector defines the second operand
  71294. * @param epsilon defines the minimal distance to define values as equals
  71295. * @returns true if both vectors are distant less than epsilon
  71296. */
  71297. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  71298. if (epsilon === void 0) { epsilon = Epsilon; }
  71299. 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);
  71300. };
  71301. /**
  71302. * Returns true if the current Vector3 coordinates equals the given floats
  71303. * @param x defines the x coordinate of the operand
  71304. * @param y defines the y coordinate of the operand
  71305. * @param z defines the z coordinate of the operand
  71306. * @returns true if both vectors are equals
  71307. */
  71308. Vector3.prototype.equalsToFloats = function (x, y, z) {
  71309. return this.x === x && this.y === y && this.z === z;
  71310. };
  71311. /**
  71312. * Multiplies the current Vector3 coordinates by the given ones
  71313. * @param otherVector defines the second operand
  71314. * @returns the current updated Vector3
  71315. */
  71316. Vector3.prototype.multiplyInPlace = function (otherVector) {
  71317. this.x *= otherVector.x;
  71318. this.y *= otherVector.y;
  71319. this.z *= otherVector.z;
  71320. return this;
  71321. };
  71322. /**
  71323. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71324. * @param otherVector defines the second operand
  71325. * @returns the new Vector3
  71326. */
  71327. Vector3.prototype.multiply = function (otherVector) {
  71328. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  71329. };
  71330. /**
  71331. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71332. * @param otherVector defines the second operand
  71333. * @param result defines the Vector3 object where to store the result
  71334. * @returns the current Vector3
  71335. */
  71336. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  71337. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  71338. };
  71339. /**
  71340. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71341. * @param x defines the x coordinate of the operand
  71342. * @param y defines the y coordinate of the operand
  71343. * @param z defines the z coordinate of the operand
  71344. * @returns the new Vector3
  71345. */
  71346. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  71347. return new Vector3(this.x * x, this.y * y, this.z * z);
  71348. };
  71349. /**
  71350. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71351. * @param otherVector defines the second operand
  71352. * @returns the new Vector3
  71353. */
  71354. Vector3.prototype.divide = function (otherVector) {
  71355. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  71356. };
  71357. /**
  71358. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71359. * @param otherVector defines the second operand
  71360. * @param result defines the Vector3 object where to store the result
  71361. * @returns the current Vector3
  71362. */
  71363. Vector3.prototype.divideToRef = function (otherVector, result) {
  71364. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  71365. };
  71366. /**
  71367. * Divides the current Vector3 coordinates by the given ones.
  71368. * @param otherVector defines the second operand
  71369. * @returns the current updated Vector3
  71370. */
  71371. Vector3.prototype.divideInPlace = function (otherVector) {
  71372. return this.divideToRef(otherVector, this);
  71373. };
  71374. /**
  71375. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71376. * @param other defines the second operand
  71377. * @returns the current updated Vector3
  71378. */
  71379. Vector3.prototype.minimizeInPlace = function (other) {
  71380. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  71381. };
  71382. /**
  71383. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71384. * @param other defines the second operand
  71385. * @returns the current updated Vector3
  71386. */
  71387. Vector3.prototype.maximizeInPlace = function (other) {
  71388. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  71389. };
  71390. /**
  71391. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71392. * @param x defines the x coordinate of the operand
  71393. * @param y defines the y coordinate of the operand
  71394. * @param z defines the z coordinate of the operand
  71395. * @returns the current updated Vector3
  71396. */
  71397. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  71398. if (x < this.x) {
  71399. this.x = x;
  71400. }
  71401. if (y < this.y) {
  71402. this.y = y;
  71403. }
  71404. if (z < this.z) {
  71405. this.z = z;
  71406. }
  71407. return this;
  71408. };
  71409. /**
  71410. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71411. * @param x defines the x coordinate of the operand
  71412. * @param y defines the y coordinate of the operand
  71413. * @param z defines the z coordinate of the operand
  71414. * @returns the current updated Vector3
  71415. */
  71416. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  71417. if (x > this.x) {
  71418. this.x = x;
  71419. }
  71420. if (y > this.y) {
  71421. this.y = y;
  71422. }
  71423. if (z > this.z) {
  71424. this.z = z;
  71425. }
  71426. return this;
  71427. };
  71428. /**
  71429. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71430. * Check if is non uniform within a certain amount of decimal places to account for this
  71431. * @param epsilon the amount the values can differ
  71432. * @returns if the the vector is non uniform to a certain number of decimal places
  71433. */
  71434. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  71435. var absX = Math.abs(this.x);
  71436. var absY = Math.abs(this.y);
  71437. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  71438. return true;
  71439. }
  71440. var absZ = Math.abs(this.z);
  71441. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  71442. return true;
  71443. }
  71444. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  71445. return true;
  71446. }
  71447. return false;
  71448. };
  71449. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  71450. /**
  71451. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71452. */
  71453. get: function () {
  71454. var absX = Math.abs(this.x);
  71455. var absY = Math.abs(this.y);
  71456. if (absX !== absY) {
  71457. return true;
  71458. }
  71459. var absZ = Math.abs(this.z);
  71460. if (absX !== absZ) {
  71461. return true;
  71462. }
  71463. if (absY !== absZ) {
  71464. return true;
  71465. }
  71466. return false;
  71467. },
  71468. enumerable: true,
  71469. configurable: true
  71470. });
  71471. /**
  71472. * Gets a new Vector3 from current Vector3 floored values
  71473. * @returns a new Vector3
  71474. */
  71475. Vector3.prototype.floor = function () {
  71476. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  71477. };
  71478. /**
  71479. * Gets a new Vector3 from current Vector3 floored values
  71480. * @returns a new Vector3
  71481. */
  71482. Vector3.prototype.fract = function () {
  71483. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  71484. };
  71485. // Properties
  71486. /**
  71487. * Gets the length of the Vector3
  71488. * @returns the length of the Vecto3
  71489. */
  71490. Vector3.prototype.length = function () {
  71491. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  71492. };
  71493. /**
  71494. * Gets the squared length of the Vector3
  71495. * @returns squared length of the Vector3
  71496. */
  71497. Vector3.prototype.lengthSquared = function () {
  71498. return (this.x * this.x + this.y * this.y + this.z * this.z);
  71499. };
  71500. /**
  71501. * Normalize the current Vector3.
  71502. * Please note that this is an in place operation.
  71503. * @returns the current updated Vector3
  71504. */
  71505. Vector3.prototype.normalize = function () {
  71506. return this.normalizeFromLength(this.length());
  71507. };
  71508. /**
  71509. * Reorders the x y z properties of the vector in place
  71510. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71511. * @returns the current updated vector
  71512. */
  71513. Vector3.prototype.reorderInPlace = function (order) {
  71514. var _this = this;
  71515. order = order.toLowerCase();
  71516. if (order === "xyz") {
  71517. return this;
  71518. }
  71519. MathTmp.Vector3[0].copyFrom(this);
  71520. ["x", "y", "z"].forEach(function (val, i) {
  71521. _this[val] = MathTmp.Vector3[0][order[i]];
  71522. });
  71523. return this;
  71524. };
  71525. /**
  71526. * Rotates the vector around 0,0,0 by a quaternion
  71527. * @param quaternion the rotation quaternion
  71528. * @param result vector to store the result
  71529. * @returns the resulting vector
  71530. */
  71531. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  71532. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  71533. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  71534. return result;
  71535. };
  71536. /**
  71537. * Rotates a vector around a given point
  71538. * @param quaternion the rotation quaternion
  71539. * @param point the point to rotate around
  71540. * @param result vector to store the result
  71541. * @returns the resulting vector
  71542. */
  71543. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  71544. this.subtractToRef(point, MathTmp.Vector3[0]);
  71545. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  71546. point.addToRef(MathTmp.Vector3[0], result);
  71547. return result;
  71548. };
  71549. /**
  71550. * Normalize the current Vector3 with the given input length.
  71551. * Please note that this is an in place operation.
  71552. * @param len the length of the vector
  71553. * @returns the current updated Vector3
  71554. */
  71555. Vector3.prototype.normalizeFromLength = function (len) {
  71556. if (len === 0 || len === 1.0) {
  71557. return this;
  71558. }
  71559. return this.scaleInPlace(1.0 / len);
  71560. };
  71561. /**
  71562. * Normalize the current Vector3 to a new vector
  71563. * @returns the new Vector3
  71564. */
  71565. Vector3.prototype.normalizeToNew = function () {
  71566. var normalized = new Vector3(0, 0, 0);
  71567. this.normalizeToRef(normalized);
  71568. return normalized;
  71569. };
  71570. /**
  71571. * Normalize the current Vector3 to the reference
  71572. * @param reference define the Vector3 to update
  71573. * @returns the updated Vector3
  71574. */
  71575. Vector3.prototype.normalizeToRef = function (reference) {
  71576. var len = this.length();
  71577. if (len === 0 || len === 1.0) {
  71578. return reference.copyFromFloats(this.x, this.y, this.z);
  71579. }
  71580. return this.scaleToRef(1.0 / len, reference);
  71581. };
  71582. /**
  71583. * Creates a new Vector3 copied from the current Vector3
  71584. * @returns the new Vector3
  71585. */
  71586. Vector3.prototype.clone = function () {
  71587. return new Vector3(this.x, this.y, this.z);
  71588. };
  71589. /**
  71590. * Copies the given vector coordinates to the current Vector3 ones
  71591. * @param source defines the source Vector3
  71592. * @returns the current updated Vector3
  71593. */
  71594. Vector3.prototype.copyFrom = function (source) {
  71595. return this.copyFromFloats(source.x, source.y, source.z);
  71596. };
  71597. /**
  71598. * Copies the given floats to the current Vector3 coordinates
  71599. * @param x defines the x coordinate of the operand
  71600. * @param y defines the y coordinate of the operand
  71601. * @param z defines the z coordinate of the operand
  71602. * @returns the current updated Vector3
  71603. */
  71604. Vector3.prototype.copyFromFloats = function (x, y, z) {
  71605. this.x = x;
  71606. this.y = y;
  71607. this.z = z;
  71608. return this;
  71609. };
  71610. /**
  71611. * Copies the given floats to the current Vector3 coordinates
  71612. * @param x defines the x coordinate of the operand
  71613. * @param y defines the y coordinate of the operand
  71614. * @param z defines the z coordinate of the operand
  71615. * @returns the current updated Vector3
  71616. */
  71617. Vector3.prototype.set = function (x, y, z) {
  71618. return this.copyFromFloats(x, y, z);
  71619. };
  71620. /**
  71621. * Copies the given float to the current Vector3 coordinates
  71622. * @param v defines the x, y and z coordinates of the operand
  71623. * @returns the current updated Vector3
  71624. */
  71625. Vector3.prototype.setAll = function (v) {
  71626. this.x = this.y = this.z = v;
  71627. return this;
  71628. };
  71629. // Statics
  71630. /**
  71631. * Get the clip factor between two vectors
  71632. * @param vector0 defines the first operand
  71633. * @param vector1 defines the second operand
  71634. * @param axis defines the axis to use
  71635. * @param size defines the size along the axis
  71636. * @returns the clip factor
  71637. */
  71638. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  71639. var d0 = Vector3.Dot(vector0, axis) - size;
  71640. var d1 = Vector3.Dot(vector1, axis) - size;
  71641. var s = d0 / (d0 - d1);
  71642. return s;
  71643. };
  71644. /**
  71645. * Get angle between two vectors
  71646. * @param vector0 angle between vector0 and vector1
  71647. * @param vector1 angle between vector0 and vector1
  71648. * @param normal direction of the normal
  71649. * @return the angle between vector0 and vector1
  71650. */
  71651. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  71652. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  71653. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  71654. var dot = Vector3.Dot(v0, v1);
  71655. var n = MathTmp.Vector3[3];
  71656. Vector3.CrossToRef(v0, v1, n);
  71657. if (Vector3.Dot(n, normal) > 0) {
  71658. return Math.acos(dot);
  71659. }
  71660. return -Math.acos(dot);
  71661. };
  71662. /**
  71663. * Returns a new Vector3 set from the index "offset" of the given array
  71664. * @param array defines the source array
  71665. * @param offset defines the offset in the source array
  71666. * @returns the new Vector3
  71667. */
  71668. Vector3.FromArray = function (array, offset) {
  71669. if (offset === void 0) { offset = 0; }
  71670. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  71671. };
  71672. /**
  71673. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71674. * This function is deprecated. Use FromArray instead
  71675. * @param array defines the source array
  71676. * @param offset defines the offset in the source array
  71677. * @returns the new Vector3
  71678. */
  71679. Vector3.FromFloatArray = function (array, offset) {
  71680. return Vector3.FromArray(array, offset);
  71681. };
  71682. /**
  71683. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71684. * @param array defines the source array
  71685. * @param offset defines the offset in the source array
  71686. * @param result defines the Vector3 where to store the result
  71687. */
  71688. Vector3.FromArrayToRef = function (array, offset, result) {
  71689. result.x = array[offset];
  71690. result.y = array[offset + 1];
  71691. result.z = array[offset + 2];
  71692. };
  71693. /**
  71694. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71695. * This function is deprecated. Use FromArrayToRef instead.
  71696. * @param array defines the source array
  71697. * @param offset defines the offset in the source array
  71698. * @param result defines the Vector3 where to store the result
  71699. */
  71700. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  71701. return Vector3.FromArrayToRef(array, offset, result);
  71702. };
  71703. /**
  71704. * Sets the given vector "result" with the given floats.
  71705. * @param x defines the x coordinate of the source
  71706. * @param y defines the y coordinate of the source
  71707. * @param z defines the z coordinate of the source
  71708. * @param result defines the Vector3 where to store the result
  71709. */
  71710. Vector3.FromFloatsToRef = function (x, y, z, result) {
  71711. result.copyFromFloats(x, y, z);
  71712. };
  71713. /**
  71714. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71715. * @returns a new empty Vector3
  71716. */
  71717. Vector3.Zero = function () {
  71718. return new Vector3(0.0, 0.0, 0.0);
  71719. };
  71720. /**
  71721. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71722. * @returns a new unit Vector3
  71723. */
  71724. Vector3.One = function () {
  71725. return new Vector3(1.0, 1.0, 1.0);
  71726. };
  71727. /**
  71728. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71729. * @returns a new up Vector3
  71730. */
  71731. Vector3.Up = function () {
  71732. return new Vector3(0.0, 1.0, 0.0);
  71733. };
  71734. Object.defineProperty(Vector3, "UpReadOnly", {
  71735. /**
  71736. * Gets a up Vector3 that must not be updated
  71737. */
  71738. get: function () {
  71739. return Vector3._UpReadOnly;
  71740. },
  71741. enumerable: true,
  71742. configurable: true
  71743. });
  71744. /**
  71745. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71746. * @returns a new down Vector3
  71747. */
  71748. Vector3.Down = function () {
  71749. return new Vector3(0.0, -1.0, 0.0);
  71750. };
  71751. /**
  71752. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71753. * @returns a new forward Vector3
  71754. */
  71755. Vector3.Forward = function () {
  71756. return new Vector3(0.0, 0.0, 1.0);
  71757. };
  71758. /**
  71759. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71760. * @returns a new forward Vector3
  71761. */
  71762. Vector3.Backward = function () {
  71763. return new Vector3(0.0, 0.0, -1.0);
  71764. };
  71765. /**
  71766. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71767. * @returns a new right Vector3
  71768. */
  71769. Vector3.Right = function () {
  71770. return new Vector3(1.0, 0.0, 0.0);
  71771. };
  71772. /**
  71773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71774. * @returns a new left Vector3
  71775. */
  71776. Vector3.Left = function () {
  71777. return new Vector3(-1.0, 0.0, 0.0);
  71778. };
  71779. /**
  71780. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71782. * @param vector defines the Vector3 to transform
  71783. * @param transformation defines the transformation matrix
  71784. * @returns the transformed Vector3
  71785. */
  71786. Vector3.TransformCoordinates = function (vector, transformation) {
  71787. var result = Vector3.Zero();
  71788. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  71789. return result;
  71790. };
  71791. /**
  71792. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71793. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71794. * @param vector defines the Vector3 to transform
  71795. * @param transformation defines the transformation matrix
  71796. * @param result defines the Vector3 where to store the result
  71797. */
  71798. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  71799. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  71800. };
  71801. /**
  71802. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71803. * This method computes tranformed coordinates only, not transformed direction vectors
  71804. * @param x define the x coordinate of the source vector
  71805. * @param y define the y coordinate of the source vector
  71806. * @param z define the z coordinate of the source vector
  71807. * @param transformation defines the transformation matrix
  71808. * @param result defines the Vector3 where to store the result
  71809. */
  71810. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  71811. var m = transformation.m;
  71812. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  71813. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  71814. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  71815. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  71816. result.x = rx * rw;
  71817. result.y = ry * rw;
  71818. result.z = rz * rw;
  71819. };
  71820. /**
  71821. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71822. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71823. * @param vector defines the Vector3 to transform
  71824. * @param transformation defines the transformation matrix
  71825. * @returns the new Vector3
  71826. */
  71827. Vector3.TransformNormal = function (vector, transformation) {
  71828. var result = Vector3.Zero();
  71829. Vector3.TransformNormalToRef(vector, transformation, result);
  71830. return result;
  71831. };
  71832. /**
  71833. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71834. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71835. * @param vector defines the Vector3 to transform
  71836. * @param transformation defines the transformation matrix
  71837. * @param result defines the Vector3 where to store the result
  71838. */
  71839. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  71840. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  71841. };
  71842. /**
  71843. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71844. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71845. * @param x define the x coordinate of the source vector
  71846. * @param y define the y coordinate of the source vector
  71847. * @param z define the z coordinate of the source vector
  71848. * @param transformation defines the transformation matrix
  71849. * @param result defines the Vector3 where to store the result
  71850. */
  71851. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  71852. var m = transformation.m;
  71853. result.x = x * m[0] + y * m[4] + z * m[8];
  71854. result.y = x * m[1] + y * m[5] + z * m[9];
  71855. result.z = x * m[2] + y * m[6] + z * m[10];
  71856. };
  71857. /**
  71858. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71859. * @param value1 defines the first control point
  71860. * @param value2 defines the second control point
  71861. * @param value3 defines the third control point
  71862. * @param value4 defines the fourth control point
  71863. * @param amount defines the amount on the spline to use
  71864. * @returns the new Vector3
  71865. */
  71866. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  71867. var squared = amount * amount;
  71868. var cubed = amount * squared;
  71869. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  71870. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  71871. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  71872. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  71873. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  71874. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  71875. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  71876. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  71877. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  71878. return new Vector3(x, y, z);
  71879. };
  71880. /**
  71881. * 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"
  71882. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71883. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71884. * @param value defines the current value
  71885. * @param min defines the lower range value
  71886. * @param max defines the upper range value
  71887. * @returns the new Vector3
  71888. */
  71889. Vector3.Clamp = function (value, min, max) {
  71890. var v = new Vector3();
  71891. Vector3.ClampToRef(value, min, max, v);
  71892. return v;
  71893. };
  71894. /**
  71895. * 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"
  71896. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71897. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71898. * @param value defines the current value
  71899. * @param min defines the lower range value
  71900. * @param max defines the upper range value
  71901. * @param result defines the Vector3 where to store the result
  71902. */
  71903. Vector3.ClampToRef = function (value, min, max, result) {
  71904. var x = value.x;
  71905. x = (x > max.x) ? max.x : x;
  71906. x = (x < min.x) ? min.x : x;
  71907. var y = value.y;
  71908. y = (y > max.y) ? max.y : y;
  71909. y = (y < min.y) ? min.y : y;
  71910. var z = value.z;
  71911. z = (z > max.z) ? max.z : z;
  71912. z = (z < min.z) ? min.z : z;
  71913. result.copyFromFloats(x, y, z);
  71914. };
  71915. /**
  71916. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71917. * @param value1 defines the first control point
  71918. * @param tangent1 defines the first tangent vector
  71919. * @param value2 defines the second control point
  71920. * @param tangent2 defines the second tangent vector
  71921. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71922. * @returns the new Vector3
  71923. */
  71924. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71925. var squared = amount * amount;
  71926. var cubed = amount * squared;
  71927. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71928. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71929. var part3 = (cubed - (2.0 * squared)) + amount;
  71930. var part4 = cubed - squared;
  71931. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71932. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71933. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  71934. return new Vector3(x, y, z);
  71935. };
  71936. /**
  71937. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71938. * @param start defines the start value
  71939. * @param end defines the end value
  71940. * @param amount max defines amount between both (between 0 and 1)
  71941. * @returns the new Vector3
  71942. */
  71943. Vector3.Lerp = function (start, end, amount) {
  71944. var result = new Vector3(0, 0, 0);
  71945. Vector3.LerpToRef(start, end, amount, result);
  71946. return result;
  71947. };
  71948. /**
  71949. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71950. * @param start defines the start value
  71951. * @param end defines the end value
  71952. * @param amount max defines amount between both (between 0 and 1)
  71953. * @param result defines the Vector3 where to store the result
  71954. */
  71955. Vector3.LerpToRef = function (start, end, amount, result) {
  71956. result.x = start.x + ((end.x - start.x) * amount);
  71957. result.y = start.y + ((end.y - start.y) * amount);
  71958. result.z = start.z + ((end.z - start.z) * amount);
  71959. };
  71960. /**
  71961. * Returns the dot product (float) between the vectors "left" and "right"
  71962. * @param left defines the left operand
  71963. * @param right defines the right operand
  71964. * @returns the dot product
  71965. */
  71966. Vector3.Dot = function (left, right) {
  71967. return (left.x * right.x + left.y * right.y + left.z * right.z);
  71968. };
  71969. /**
  71970. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71971. * The cross product is then orthogonal to both "left" and "right"
  71972. * @param left defines the left operand
  71973. * @param right defines the right operand
  71974. * @returns the cross product
  71975. */
  71976. Vector3.Cross = function (left, right) {
  71977. var result = Vector3.Zero();
  71978. Vector3.CrossToRef(left, right, result);
  71979. return result;
  71980. };
  71981. /**
  71982. * Sets the given vector "result" with the cross product of "left" and "right"
  71983. * The cross product is then orthogonal to both "left" and "right"
  71984. * @param left defines the left operand
  71985. * @param right defines the right operand
  71986. * @param result defines the Vector3 where to store the result
  71987. */
  71988. Vector3.CrossToRef = function (left, right, result) {
  71989. var x = left.y * right.z - left.z * right.y;
  71990. var y = left.z * right.x - left.x * right.z;
  71991. var z = left.x * right.y - left.y * right.x;
  71992. result.copyFromFloats(x, y, z);
  71993. };
  71994. /**
  71995. * Returns a new Vector3 as the normalization of the given vector
  71996. * @param vector defines the Vector3 to normalize
  71997. * @returns the new Vector3
  71998. */
  71999. Vector3.Normalize = function (vector) {
  72000. var result = Vector3.Zero();
  72001. Vector3.NormalizeToRef(vector, result);
  72002. return result;
  72003. };
  72004. /**
  72005. * Sets the given vector "result" with the normalization of the given first vector
  72006. * @param vector defines the Vector3 to normalize
  72007. * @param result defines the Vector3 where to store the result
  72008. */
  72009. Vector3.NormalizeToRef = function (vector, result) {
  72010. vector.normalizeToRef(result);
  72011. };
  72012. /**
  72013. * Project a Vector3 onto screen space
  72014. * @param vector defines the Vector3 to project
  72015. * @param world defines the world matrix to use
  72016. * @param transform defines the transform (view x projection) matrix to use
  72017. * @param viewport defines the screen viewport to use
  72018. * @returns the new Vector3
  72019. */
  72020. Vector3.Project = function (vector, world, transform, viewport) {
  72021. var cw = viewport.width;
  72022. var ch = viewport.height;
  72023. var cx = viewport.x;
  72024. var cy = viewport.y;
  72025. var viewportMatrix = MathTmp.Matrix[1];
  72026. 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);
  72027. var matrix = MathTmp.Matrix[0];
  72028. world.multiplyToRef(transform, matrix);
  72029. matrix.multiplyToRef(viewportMatrix, matrix);
  72030. return Vector3.TransformCoordinates(vector, matrix);
  72031. };
  72032. /** @hidden */
  72033. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  72034. Vector3.TransformCoordinatesToRef(source, matrix, result);
  72035. var m = matrix.m;
  72036. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  72037. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  72038. result.scaleInPlace(1.0 / num);
  72039. }
  72040. };
  72041. /**
  72042. * Unproject from screen space to object space
  72043. * @param source defines the screen space Vector3 to use
  72044. * @param viewportWidth defines the current width of the viewport
  72045. * @param viewportHeight defines the current height of the viewport
  72046. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72047. * @param transform defines the transform (view x projection) matrix to use
  72048. * @returns the new Vector3
  72049. */
  72050. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  72051. var matrix = MathTmp.Matrix[0];
  72052. world.multiplyToRef(transform, matrix);
  72053. matrix.invert();
  72054. source.x = source.x / viewportWidth * 2 - 1;
  72055. source.y = -(source.y / viewportHeight * 2 - 1);
  72056. var vector = new Vector3();
  72057. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  72058. return vector;
  72059. };
  72060. /**
  72061. * Unproject from screen space to object space
  72062. * @param source defines the screen space Vector3 to use
  72063. * @param viewportWidth defines the current width of the viewport
  72064. * @param viewportHeight defines the current height of the viewport
  72065. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72066. * @param view defines the view matrix to use
  72067. * @param projection defines the projection matrix to use
  72068. * @returns the new Vector3
  72069. */
  72070. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  72071. var result = Vector3.Zero();
  72072. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  72073. return result;
  72074. };
  72075. /**
  72076. * Unproject from screen space to object space
  72077. * @param source defines the screen space Vector3 to use
  72078. * @param viewportWidth defines the current width of the viewport
  72079. * @param viewportHeight defines the current height of the viewport
  72080. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72081. * @param view defines the view matrix to use
  72082. * @param projection defines the projection matrix to use
  72083. * @param result defines the Vector3 where to store the result
  72084. */
  72085. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  72086. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  72087. };
  72088. /**
  72089. * Unproject from screen space to object space
  72090. * @param sourceX defines the screen space x coordinate to use
  72091. * @param sourceY defines the screen space y coordinate to use
  72092. * @param sourceZ defines the screen space z coordinate to use
  72093. * @param viewportWidth defines the current width of the viewport
  72094. * @param viewportHeight defines the current height of the viewport
  72095. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72096. * @param view defines the view matrix to use
  72097. * @param projection defines the projection matrix to use
  72098. * @param result defines the Vector3 where to store the result
  72099. */
  72100. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  72101. var matrix = MathTmp.Matrix[0];
  72102. world.multiplyToRef(view, matrix);
  72103. matrix.multiplyToRef(projection, matrix);
  72104. matrix.invert();
  72105. var screenSource = MathTmp.Vector3[0];
  72106. screenSource.x = sourceX / viewportWidth * 2 - 1;
  72107. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  72108. screenSource.z = 2 * sourceZ - 1.0;
  72109. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  72110. };
  72111. /**
  72112. * Gets the minimal coordinate values between two Vector3
  72113. * @param left defines the first operand
  72114. * @param right defines the second operand
  72115. * @returns the new Vector3
  72116. */
  72117. Vector3.Minimize = function (left, right) {
  72118. var min = left.clone();
  72119. min.minimizeInPlace(right);
  72120. return min;
  72121. };
  72122. /**
  72123. * Gets the maximal coordinate values between two Vector3
  72124. * @param left defines the first operand
  72125. * @param right defines the second operand
  72126. * @returns the new Vector3
  72127. */
  72128. Vector3.Maximize = function (left, right) {
  72129. var max = left.clone();
  72130. max.maximizeInPlace(right);
  72131. return max;
  72132. };
  72133. /**
  72134. * Returns the distance between the vectors "value1" and "value2"
  72135. * @param value1 defines the first operand
  72136. * @param value2 defines the second operand
  72137. * @returns the distance
  72138. */
  72139. Vector3.Distance = function (value1, value2) {
  72140. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  72141. };
  72142. /**
  72143. * Returns the squared distance between the vectors "value1" and "value2"
  72144. * @param value1 defines the first operand
  72145. * @param value2 defines the second operand
  72146. * @returns the squared distance
  72147. */
  72148. Vector3.DistanceSquared = function (value1, value2) {
  72149. var x = value1.x - value2.x;
  72150. var y = value1.y - value2.y;
  72151. var z = value1.z - value2.z;
  72152. return (x * x) + (y * y) + (z * z);
  72153. };
  72154. /**
  72155. * Returns a new Vector3 located at the center between "value1" and "value2"
  72156. * @param value1 defines the first operand
  72157. * @param value2 defines the second operand
  72158. * @returns the new Vector3
  72159. */
  72160. Vector3.Center = function (value1, value2) {
  72161. var center = value1.add(value2);
  72162. center.scaleInPlace(0.5);
  72163. return center;
  72164. };
  72165. /**
  72166. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  72167. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  72168. * to something in order to rotate it from its local system to the given target system
  72169. * Note: axis1, axis2 and axis3 are normalized during this operation
  72170. * @param axis1 defines the first axis
  72171. * @param axis2 defines the second axis
  72172. * @param axis3 defines the third axis
  72173. * @returns a new Vector3
  72174. */
  72175. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  72176. var rotation = Vector3.Zero();
  72177. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  72178. return rotation;
  72179. };
  72180. /**
  72181. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  72182. * @param axis1 defines the first axis
  72183. * @param axis2 defines the second axis
  72184. * @param axis3 defines the third axis
  72185. * @param ref defines the Vector3 where to store the result
  72186. */
  72187. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  72188. var quat = MathTmp.Quaternion[0];
  72189. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  72190. quat.toEulerAnglesToRef(ref);
  72191. };
  72192. Vector3._UpReadOnly = Vector3.Up();
  72193. return Vector3;
  72194. }());
  72195. /**
  72196. * Vector4 class created for EulerAngle class conversion to Quaternion
  72197. */
  72198. var Vector4 = /** @class */ (function () {
  72199. /**
  72200. * Creates a Vector4 object from the given floats.
  72201. * @param x x value of the vector
  72202. * @param y y value of the vector
  72203. * @param z z value of the vector
  72204. * @param w w value of the vector
  72205. */
  72206. function Vector4(
  72207. /** x value of the vector */
  72208. x,
  72209. /** y value of the vector */
  72210. y,
  72211. /** z value of the vector */
  72212. z,
  72213. /** w value of the vector */
  72214. w) {
  72215. this.x = x;
  72216. this.y = y;
  72217. this.z = z;
  72218. this.w = w;
  72219. }
  72220. /**
  72221. * Returns the string with the Vector4 coordinates.
  72222. * @returns a string containing all the vector values
  72223. */
  72224. Vector4.prototype.toString = function () {
  72225. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  72226. };
  72227. /**
  72228. * Returns the string "Vector4".
  72229. * @returns "Vector4"
  72230. */
  72231. Vector4.prototype.getClassName = function () {
  72232. return "Vector4";
  72233. };
  72234. /**
  72235. * Returns the Vector4 hash code.
  72236. * @returns a unique hash code
  72237. */
  72238. Vector4.prototype.getHashCode = function () {
  72239. var hash = this.x || 0;
  72240. hash = (hash * 397) ^ (this.y || 0);
  72241. hash = (hash * 397) ^ (this.z || 0);
  72242. hash = (hash * 397) ^ (this.w || 0);
  72243. return hash;
  72244. };
  72245. // Operators
  72246. /**
  72247. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  72248. * @returns the resulting array
  72249. */
  72250. Vector4.prototype.asArray = function () {
  72251. var result = new Array();
  72252. this.toArray(result, 0);
  72253. return result;
  72254. };
  72255. /**
  72256. * Populates the given array from the given index with the Vector4 coordinates.
  72257. * @param array array to populate
  72258. * @param index index of the array to start at (default: 0)
  72259. * @returns the Vector4.
  72260. */
  72261. Vector4.prototype.toArray = function (array, index) {
  72262. if (index === undefined) {
  72263. index = 0;
  72264. }
  72265. array[index] = this.x;
  72266. array[index + 1] = this.y;
  72267. array[index + 2] = this.z;
  72268. array[index + 3] = this.w;
  72269. return this;
  72270. };
  72271. /**
  72272. * Adds the given vector to the current Vector4.
  72273. * @param otherVector the vector to add
  72274. * @returns the updated Vector4.
  72275. */
  72276. Vector4.prototype.addInPlace = function (otherVector) {
  72277. this.x += otherVector.x;
  72278. this.y += otherVector.y;
  72279. this.z += otherVector.z;
  72280. this.w += otherVector.w;
  72281. return this;
  72282. };
  72283. /**
  72284. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  72285. * @param otherVector the vector to add
  72286. * @returns the resulting vector
  72287. */
  72288. Vector4.prototype.add = function (otherVector) {
  72289. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  72290. };
  72291. /**
  72292. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  72293. * @param otherVector the vector to add
  72294. * @param result the vector to store the result
  72295. * @returns the current Vector4.
  72296. */
  72297. Vector4.prototype.addToRef = function (otherVector, result) {
  72298. result.x = this.x + otherVector.x;
  72299. result.y = this.y + otherVector.y;
  72300. result.z = this.z + otherVector.z;
  72301. result.w = this.w + otherVector.w;
  72302. return this;
  72303. };
  72304. /**
  72305. * Subtract in place the given vector from the current Vector4.
  72306. * @param otherVector the vector to subtract
  72307. * @returns the updated Vector4.
  72308. */
  72309. Vector4.prototype.subtractInPlace = function (otherVector) {
  72310. this.x -= otherVector.x;
  72311. this.y -= otherVector.y;
  72312. this.z -= otherVector.z;
  72313. this.w -= otherVector.w;
  72314. return this;
  72315. };
  72316. /**
  72317. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  72318. * @param otherVector the vector to add
  72319. * @returns the new vector with the result
  72320. */
  72321. Vector4.prototype.subtract = function (otherVector) {
  72322. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  72323. };
  72324. /**
  72325. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72326. * @param otherVector the vector to subtract
  72327. * @param result the vector to store the result
  72328. * @returns the current Vector4.
  72329. */
  72330. Vector4.prototype.subtractToRef = function (otherVector, result) {
  72331. result.x = this.x - otherVector.x;
  72332. result.y = this.y - otherVector.y;
  72333. result.z = this.z - otherVector.z;
  72334. result.w = this.w - otherVector.w;
  72335. return this;
  72336. };
  72337. /**
  72338. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72339. */
  72340. /**
  72341. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72342. * @param x value to subtract
  72343. * @param y value to subtract
  72344. * @param z value to subtract
  72345. * @param w value to subtract
  72346. * @returns new vector containing the result
  72347. */
  72348. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  72349. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  72350. };
  72351. /**
  72352. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72353. * @param x value to subtract
  72354. * @param y value to subtract
  72355. * @param z value to subtract
  72356. * @param w value to subtract
  72357. * @param result the vector to store the result in
  72358. * @returns the current Vector4.
  72359. */
  72360. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  72361. result.x = this.x - x;
  72362. result.y = this.y - y;
  72363. result.z = this.z - z;
  72364. result.w = this.w - w;
  72365. return this;
  72366. };
  72367. /**
  72368. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72369. * @returns a new vector with the negated values
  72370. */
  72371. Vector4.prototype.negate = function () {
  72372. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  72373. };
  72374. /**
  72375. * Multiplies the current Vector4 coordinates by scale (float).
  72376. * @param scale the number to scale with
  72377. * @returns the updated Vector4.
  72378. */
  72379. Vector4.prototype.scaleInPlace = function (scale) {
  72380. this.x *= scale;
  72381. this.y *= scale;
  72382. this.z *= scale;
  72383. this.w *= scale;
  72384. return this;
  72385. };
  72386. /**
  72387. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72388. * @param scale the number to scale with
  72389. * @returns a new vector with the result
  72390. */
  72391. Vector4.prototype.scale = function (scale) {
  72392. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  72393. };
  72394. /**
  72395. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72396. * @param scale the number to scale with
  72397. * @param result a vector to store the result in
  72398. * @returns the current Vector4.
  72399. */
  72400. Vector4.prototype.scaleToRef = function (scale, result) {
  72401. result.x = this.x * scale;
  72402. result.y = this.y * scale;
  72403. result.z = this.z * scale;
  72404. result.w = this.w * scale;
  72405. return this;
  72406. };
  72407. /**
  72408. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72409. * @param scale defines the scale factor
  72410. * @param result defines the Vector4 object where to store the result
  72411. * @returns the unmodified current Vector4
  72412. */
  72413. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  72414. result.x += this.x * scale;
  72415. result.y += this.y * scale;
  72416. result.z += this.z * scale;
  72417. result.w += this.w * scale;
  72418. return this;
  72419. };
  72420. /**
  72421. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72422. * @param otherVector the vector to compare against
  72423. * @returns true if they are equal
  72424. */
  72425. Vector4.prototype.equals = function (otherVector) {
  72426. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  72427. };
  72428. /**
  72429. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72430. * @param otherVector vector to compare against
  72431. * @param epsilon (Default: very small number)
  72432. * @returns true if they are equal
  72433. */
  72434. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  72435. if (epsilon === void 0) { epsilon = Epsilon; }
  72436. return otherVector
  72437. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  72438. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  72439. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  72440. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  72441. };
  72442. /**
  72443. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72444. * @param x x value to compare against
  72445. * @param y y value to compare against
  72446. * @param z z value to compare against
  72447. * @param w w value to compare against
  72448. * @returns true if equal
  72449. */
  72450. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  72451. return this.x === x && this.y === y && this.z === z && this.w === w;
  72452. };
  72453. /**
  72454. * Multiplies in place the current Vector4 by the given one.
  72455. * @param otherVector vector to multiple with
  72456. * @returns the updated Vector4.
  72457. */
  72458. Vector4.prototype.multiplyInPlace = function (otherVector) {
  72459. this.x *= otherVector.x;
  72460. this.y *= otherVector.y;
  72461. this.z *= otherVector.z;
  72462. this.w *= otherVector.w;
  72463. return this;
  72464. };
  72465. /**
  72466. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72467. * @param otherVector vector to multiple with
  72468. * @returns resulting new vector
  72469. */
  72470. Vector4.prototype.multiply = function (otherVector) {
  72471. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  72472. };
  72473. /**
  72474. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72475. * @param otherVector vector to multiple with
  72476. * @param result vector to store the result
  72477. * @returns the current Vector4.
  72478. */
  72479. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  72480. result.x = this.x * otherVector.x;
  72481. result.y = this.y * otherVector.y;
  72482. result.z = this.z * otherVector.z;
  72483. result.w = this.w * otherVector.w;
  72484. return this;
  72485. };
  72486. /**
  72487. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72488. * @param x x value multiply with
  72489. * @param y y value multiply with
  72490. * @param z z value multiply with
  72491. * @param w w value multiply with
  72492. * @returns resulting new vector
  72493. */
  72494. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  72495. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  72496. };
  72497. /**
  72498. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72499. * @param otherVector vector to devide with
  72500. * @returns resulting new vector
  72501. */
  72502. Vector4.prototype.divide = function (otherVector) {
  72503. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  72504. };
  72505. /**
  72506. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72507. * @param otherVector vector to devide with
  72508. * @param result vector to store the result
  72509. * @returns the current Vector4.
  72510. */
  72511. Vector4.prototype.divideToRef = function (otherVector, result) {
  72512. result.x = this.x / otherVector.x;
  72513. result.y = this.y / otherVector.y;
  72514. result.z = this.z / otherVector.z;
  72515. result.w = this.w / otherVector.w;
  72516. return this;
  72517. };
  72518. /**
  72519. * Divides the current Vector3 coordinates by the given ones.
  72520. * @param otherVector vector to devide with
  72521. * @returns the updated Vector3.
  72522. */
  72523. Vector4.prototype.divideInPlace = function (otherVector) {
  72524. return this.divideToRef(otherVector, this);
  72525. };
  72526. /**
  72527. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72528. * @param other defines the second operand
  72529. * @returns the current updated Vector4
  72530. */
  72531. Vector4.prototype.minimizeInPlace = function (other) {
  72532. if (other.x < this.x) {
  72533. this.x = other.x;
  72534. }
  72535. if (other.y < this.y) {
  72536. this.y = other.y;
  72537. }
  72538. if (other.z < this.z) {
  72539. this.z = other.z;
  72540. }
  72541. if (other.w < this.w) {
  72542. this.w = other.w;
  72543. }
  72544. return this;
  72545. };
  72546. /**
  72547. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72548. * @param other defines the second operand
  72549. * @returns the current updated Vector4
  72550. */
  72551. Vector4.prototype.maximizeInPlace = function (other) {
  72552. if (other.x > this.x) {
  72553. this.x = other.x;
  72554. }
  72555. if (other.y > this.y) {
  72556. this.y = other.y;
  72557. }
  72558. if (other.z > this.z) {
  72559. this.z = other.z;
  72560. }
  72561. if (other.w > this.w) {
  72562. this.w = other.w;
  72563. }
  72564. return this;
  72565. };
  72566. /**
  72567. * Gets a new Vector4 from current Vector4 floored values
  72568. * @returns a new Vector4
  72569. */
  72570. Vector4.prototype.floor = function () {
  72571. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  72572. };
  72573. /**
  72574. * Gets a new Vector4 from current Vector3 floored values
  72575. * @returns a new Vector4
  72576. */
  72577. Vector4.prototype.fract = function () {
  72578. 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));
  72579. };
  72580. // Properties
  72581. /**
  72582. * Returns the Vector4 length (float).
  72583. * @returns the length
  72584. */
  72585. Vector4.prototype.length = function () {
  72586. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  72587. };
  72588. /**
  72589. * Returns the Vector4 squared length (float).
  72590. * @returns the length squared
  72591. */
  72592. Vector4.prototype.lengthSquared = function () {
  72593. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  72594. };
  72595. // Methods
  72596. /**
  72597. * Normalizes in place the Vector4.
  72598. * @returns the updated Vector4.
  72599. */
  72600. Vector4.prototype.normalize = function () {
  72601. var len = this.length();
  72602. if (len === 0) {
  72603. return this;
  72604. }
  72605. return this.scaleInPlace(1.0 / len);
  72606. };
  72607. /**
  72608. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72609. * @returns this converted to a new vector3
  72610. */
  72611. Vector4.prototype.toVector3 = function () {
  72612. return new Vector3(this.x, this.y, this.z);
  72613. };
  72614. /**
  72615. * Returns a new Vector4 copied from the current one.
  72616. * @returns the new cloned vector
  72617. */
  72618. Vector4.prototype.clone = function () {
  72619. return new Vector4(this.x, this.y, this.z, this.w);
  72620. };
  72621. /**
  72622. * Updates the current Vector4 with the given one coordinates.
  72623. * @param source the source vector to copy from
  72624. * @returns the updated Vector4.
  72625. */
  72626. Vector4.prototype.copyFrom = function (source) {
  72627. this.x = source.x;
  72628. this.y = source.y;
  72629. this.z = source.z;
  72630. this.w = source.w;
  72631. return this;
  72632. };
  72633. /**
  72634. * Updates the current Vector4 coordinates with the given floats.
  72635. * @param x float to copy from
  72636. * @param y float to copy from
  72637. * @param z float to copy from
  72638. * @param w float to copy from
  72639. * @returns the updated Vector4.
  72640. */
  72641. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  72642. this.x = x;
  72643. this.y = y;
  72644. this.z = z;
  72645. this.w = w;
  72646. return this;
  72647. };
  72648. /**
  72649. * Updates the current Vector4 coordinates with the given floats.
  72650. * @param x float to set from
  72651. * @param y float to set from
  72652. * @param z float to set from
  72653. * @param w float to set from
  72654. * @returns the updated Vector4.
  72655. */
  72656. Vector4.prototype.set = function (x, y, z, w) {
  72657. return this.copyFromFloats(x, y, z, w);
  72658. };
  72659. /**
  72660. * Copies the given float to the current Vector3 coordinates
  72661. * @param v defines the x, y, z and w coordinates of the operand
  72662. * @returns the current updated Vector3
  72663. */
  72664. Vector4.prototype.setAll = function (v) {
  72665. this.x = this.y = this.z = this.w = v;
  72666. return this;
  72667. };
  72668. // Statics
  72669. /**
  72670. * Returns a new Vector4 set from the starting index of the given array.
  72671. * @param array the array to pull values from
  72672. * @param offset the offset into the array to start at
  72673. * @returns the new vector
  72674. */
  72675. Vector4.FromArray = function (array, offset) {
  72676. if (!offset) {
  72677. offset = 0;
  72678. }
  72679. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  72680. };
  72681. /**
  72682. * Updates the given vector "result" from the starting index of the given array.
  72683. * @param array the array to pull values from
  72684. * @param offset the offset into the array to start at
  72685. * @param result the vector to store the result in
  72686. */
  72687. Vector4.FromArrayToRef = function (array, offset, result) {
  72688. result.x = array[offset];
  72689. result.y = array[offset + 1];
  72690. result.z = array[offset + 2];
  72691. result.w = array[offset + 3];
  72692. };
  72693. /**
  72694. * Updates the given vector "result" from the starting index of the given Float32Array.
  72695. * @param array the array to pull values from
  72696. * @param offset the offset into the array to start at
  72697. * @param result the vector to store the result in
  72698. */
  72699. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  72700. Vector4.FromArrayToRef(array, offset, result);
  72701. };
  72702. /**
  72703. * Updates the given vector "result" coordinates from the given floats.
  72704. * @param x float to set from
  72705. * @param y float to set from
  72706. * @param z float to set from
  72707. * @param w float to set from
  72708. * @param result the vector to the floats in
  72709. */
  72710. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  72711. result.x = x;
  72712. result.y = y;
  72713. result.z = z;
  72714. result.w = w;
  72715. };
  72716. /**
  72717. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72718. * @returns the new vector
  72719. */
  72720. Vector4.Zero = function () {
  72721. return new Vector4(0.0, 0.0, 0.0, 0.0);
  72722. };
  72723. /**
  72724. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72725. * @returns the new vector
  72726. */
  72727. Vector4.One = function () {
  72728. return new Vector4(1.0, 1.0, 1.0, 1.0);
  72729. };
  72730. /**
  72731. * Returns a new normalized Vector4 from the given one.
  72732. * @param vector the vector to normalize
  72733. * @returns the vector
  72734. */
  72735. Vector4.Normalize = function (vector) {
  72736. var result = Vector4.Zero();
  72737. Vector4.NormalizeToRef(vector, result);
  72738. return result;
  72739. };
  72740. /**
  72741. * Updates the given vector "result" from the normalization of the given one.
  72742. * @param vector the vector to normalize
  72743. * @param result the vector to store the result in
  72744. */
  72745. Vector4.NormalizeToRef = function (vector, result) {
  72746. result.copyFrom(vector);
  72747. result.normalize();
  72748. };
  72749. /**
  72750. * Returns a vector with the minimum values from the left and right vectors
  72751. * @param left left vector to minimize
  72752. * @param right right vector to minimize
  72753. * @returns a new vector with the minimum of the left and right vector values
  72754. */
  72755. Vector4.Minimize = function (left, right) {
  72756. var min = left.clone();
  72757. min.minimizeInPlace(right);
  72758. return min;
  72759. };
  72760. /**
  72761. * Returns a vector with the maximum values from the left and right vectors
  72762. * @param left left vector to maximize
  72763. * @param right right vector to maximize
  72764. * @returns a new vector with the maximum of the left and right vector values
  72765. */
  72766. Vector4.Maximize = function (left, right) {
  72767. var max = left.clone();
  72768. max.maximizeInPlace(right);
  72769. return max;
  72770. };
  72771. /**
  72772. * Returns the distance (float) between the vectors "value1" and "value2".
  72773. * @param value1 value to calulate the distance between
  72774. * @param value2 value to calulate the distance between
  72775. * @return the distance between the two vectors
  72776. */
  72777. Vector4.Distance = function (value1, value2) {
  72778. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  72779. };
  72780. /**
  72781. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72782. * @param value1 value to calulate the distance between
  72783. * @param value2 value to calulate the distance between
  72784. * @return the distance between the two vectors squared
  72785. */
  72786. Vector4.DistanceSquared = function (value1, value2) {
  72787. var x = value1.x - value2.x;
  72788. var y = value1.y - value2.y;
  72789. var z = value1.z - value2.z;
  72790. var w = value1.w - value2.w;
  72791. return (x * x) + (y * y) + (z * z) + (w * w);
  72792. };
  72793. /**
  72794. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72795. * @param value1 value to calulate the center between
  72796. * @param value2 value to calulate the center between
  72797. * @return the center between the two vectors
  72798. */
  72799. Vector4.Center = function (value1, value2) {
  72800. var center = value1.add(value2);
  72801. center.scaleInPlace(0.5);
  72802. return center;
  72803. };
  72804. /**
  72805. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72806. * This methods computes transformed normalized direction vectors only.
  72807. * @param vector the vector to transform
  72808. * @param transformation the transformation matrix to apply
  72809. * @returns the new vector
  72810. */
  72811. Vector4.TransformNormal = function (vector, transformation) {
  72812. var result = Vector4.Zero();
  72813. Vector4.TransformNormalToRef(vector, transformation, result);
  72814. return result;
  72815. };
  72816. /**
  72817. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72818. * This methods computes transformed normalized direction vectors only.
  72819. * @param vector the vector to transform
  72820. * @param transformation the transformation matrix to apply
  72821. * @param result the vector to store the result in
  72822. */
  72823. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  72824. var m = transformation.m;
  72825. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  72826. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  72827. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  72828. result.x = x;
  72829. result.y = y;
  72830. result.z = z;
  72831. result.w = vector.w;
  72832. };
  72833. /**
  72834. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72835. * This methods computes transformed normalized direction vectors only.
  72836. * @param x value to transform
  72837. * @param y value to transform
  72838. * @param z value to transform
  72839. * @param w value to transform
  72840. * @param transformation the transformation matrix to apply
  72841. * @param result the vector to store the results in
  72842. */
  72843. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  72844. var m = transformation.m;
  72845. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  72846. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  72847. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  72848. result.w = w;
  72849. };
  72850. /**
  72851. * Creates a new Vector4 from a Vector3
  72852. * @param source defines the source data
  72853. * @param w defines the 4th component (default is 0)
  72854. * @returns a new Vector4
  72855. */
  72856. Vector4.FromVector3 = function (source, w) {
  72857. if (w === void 0) { w = 0; }
  72858. return new Vector4(source.x, source.y, source.z, w);
  72859. };
  72860. return Vector4;
  72861. }());
  72862. /**
  72863. * Size containing widht and height
  72864. */
  72865. var Size = /** @class */ (function () {
  72866. /**
  72867. * Creates a Size object from the given width and height (floats).
  72868. * @param width width of the new size
  72869. * @param height height of the new size
  72870. */
  72871. function Size(width, height) {
  72872. this.width = width;
  72873. this.height = height;
  72874. }
  72875. /**
  72876. * Returns a string with the Size width and height
  72877. * @returns a string with the Size width and height
  72878. */
  72879. Size.prototype.toString = function () {
  72880. return "{W: " + this.width + ", H: " + this.height + "}";
  72881. };
  72882. /**
  72883. * "Size"
  72884. * @returns the string "Size"
  72885. */
  72886. Size.prototype.getClassName = function () {
  72887. return "Size";
  72888. };
  72889. /**
  72890. * Returns the Size hash code.
  72891. * @returns a hash code for a unique width and height
  72892. */
  72893. Size.prototype.getHashCode = function () {
  72894. var hash = this.width || 0;
  72895. hash = (hash * 397) ^ (this.height || 0);
  72896. return hash;
  72897. };
  72898. /**
  72899. * Updates the current size from the given one.
  72900. * @param src the given size
  72901. */
  72902. Size.prototype.copyFrom = function (src) {
  72903. this.width = src.width;
  72904. this.height = src.height;
  72905. };
  72906. /**
  72907. * Updates in place the current Size from the given floats.
  72908. * @param width width of the new size
  72909. * @param height height of the new size
  72910. * @returns the updated Size.
  72911. */
  72912. Size.prototype.copyFromFloats = function (width, height) {
  72913. this.width = width;
  72914. this.height = height;
  72915. return this;
  72916. };
  72917. /**
  72918. * Updates in place the current Size from the given floats.
  72919. * @param width width to set
  72920. * @param height height to set
  72921. * @returns the updated Size.
  72922. */
  72923. Size.prototype.set = function (width, height) {
  72924. return this.copyFromFloats(width, height);
  72925. };
  72926. /**
  72927. * Multiplies the width and height by numbers
  72928. * @param w factor to multiple the width by
  72929. * @param h factor to multiple the height by
  72930. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  72931. */
  72932. Size.prototype.multiplyByFloats = function (w, h) {
  72933. return new Size(this.width * w, this.height * h);
  72934. };
  72935. /**
  72936. * Clones the size
  72937. * @returns a new Size copied from the given one.
  72938. */
  72939. Size.prototype.clone = function () {
  72940. return new Size(this.width, this.height);
  72941. };
  72942. /**
  72943. * True if the current Size and the given one width and height are strictly equal.
  72944. * @param other the other size to compare against
  72945. * @returns True if the current Size and the given one width and height are strictly equal.
  72946. */
  72947. Size.prototype.equals = function (other) {
  72948. if (!other) {
  72949. return false;
  72950. }
  72951. return (this.width === other.width) && (this.height === other.height);
  72952. };
  72953. Object.defineProperty(Size.prototype, "surface", {
  72954. /**
  72955. * The surface of the Size : width * height (float).
  72956. */
  72957. get: function () {
  72958. return this.width * this.height;
  72959. },
  72960. enumerable: true,
  72961. configurable: true
  72962. });
  72963. /**
  72964. * Create a new size of zero
  72965. * @returns a new Size set to (0.0, 0.0)
  72966. */
  72967. Size.Zero = function () {
  72968. return new Size(0.0, 0.0);
  72969. };
  72970. /**
  72971. * Sums the width and height of two sizes
  72972. * @param otherSize size to add to this size
  72973. * @returns a new Size set as the addition result of the current Size and the given one.
  72974. */
  72975. Size.prototype.add = function (otherSize) {
  72976. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  72977. return r;
  72978. };
  72979. /**
  72980. * Subtracts the width and height of two
  72981. * @param otherSize size to subtract to this size
  72982. * @returns a new Size set as the subtraction result of the given one from the current Size.
  72983. */
  72984. Size.prototype.subtract = function (otherSize) {
  72985. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  72986. return r;
  72987. };
  72988. /**
  72989. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  72990. * @param start starting size to lerp between
  72991. * @param end end size to lerp between
  72992. * @param amount amount to lerp between the start and end values
  72993. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  72994. */
  72995. Size.Lerp = function (start, end, amount) {
  72996. var w = start.width + ((end.width - start.width) * amount);
  72997. var h = start.height + ((end.height - start.height) * amount);
  72998. return new Size(w, h);
  72999. };
  73000. return Size;
  73001. }());
  73002. /**
  73003. * Class used to store quaternion data
  73004. * @see https://en.wikipedia.org/wiki/Quaternion
  73005. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  73006. */
  73007. var Quaternion = /** @class */ (function () {
  73008. /**
  73009. * Creates a new Quaternion from the given floats
  73010. * @param x defines the first component (0 by default)
  73011. * @param y defines the second component (0 by default)
  73012. * @param z defines the third component (0 by default)
  73013. * @param w defines the fourth component (1.0 by default)
  73014. */
  73015. function Quaternion(
  73016. /** defines the first component (0 by default) */
  73017. x,
  73018. /** defines the second component (0 by default) */
  73019. y,
  73020. /** defines the third component (0 by default) */
  73021. z,
  73022. /** defines the fourth component (1.0 by default) */
  73023. w) {
  73024. if (x === void 0) { x = 0.0; }
  73025. if (y === void 0) { y = 0.0; }
  73026. if (z === void 0) { z = 0.0; }
  73027. if (w === void 0) { w = 1.0; }
  73028. this.x = x;
  73029. this.y = y;
  73030. this.z = z;
  73031. this.w = w;
  73032. }
  73033. /**
  73034. * Gets a string representation for the current quaternion
  73035. * @returns a string with the Quaternion coordinates
  73036. */
  73037. Quaternion.prototype.toString = function () {
  73038. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  73039. };
  73040. /**
  73041. * Gets the class name of the quaternion
  73042. * @returns the string "Quaternion"
  73043. */
  73044. Quaternion.prototype.getClassName = function () {
  73045. return "Quaternion";
  73046. };
  73047. /**
  73048. * Gets a hash code for this quaternion
  73049. * @returns the quaternion hash code
  73050. */
  73051. Quaternion.prototype.getHashCode = function () {
  73052. var hash = this.x || 0;
  73053. hash = (hash * 397) ^ (this.y || 0);
  73054. hash = (hash * 397) ^ (this.z || 0);
  73055. hash = (hash * 397) ^ (this.w || 0);
  73056. return hash;
  73057. };
  73058. /**
  73059. * Copy the quaternion to an array
  73060. * @returns a new array populated with 4 elements from the quaternion coordinates
  73061. */
  73062. Quaternion.prototype.asArray = function () {
  73063. return [this.x, this.y, this.z, this.w];
  73064. };
  73065. /**
  73066. * Check if two quaternions are equals
  73067. * @param otherQuaternion defines the second operand
  73068. * @return true if the current quaternion and the given one coordinates are strictly equals
  73069. */
  73070. Quaternion.prototype.equals = function (otherQuaternion) {
  73071. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  73072. };
  73073. /**
  73074. * Clone the current quaternion
  73075. * @returns a new quaternion copied from the current one
  73076. */
  73077. Quaternion.prototype.clone = function () {
  73078. return new Quaternion(this.x, this.y, this.z, this.w);
  73079. };
  73080. /**
  73081. * Copy a quaternion to the current one
  73082. * @param other defines the other quaternion
  73083. * @returns the updated current quaternion
  73084. */
  73085. Quaternion.prototype.copyFrom = function (other) {
  73086. this.x = other.x;
  73087. this.y = other.y;
  73088. this.z = other.z;
  73089. this.w = other.w;
  73090. return this;
  73091. };
  73092. /**
  73093. * Updates the current quaternion with the given float coordinates
  73094. * @param x defines the x coordinate
  73095. * @param y defines the y coordinate
  73096. * @param z defines the z coordinate
  73097. * @param w defines the w coordinate
  73098. * @returns the updated current quaternion
  73099. */
  73100. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  73101. this.x = x;
  73102. this.y = y;
  73103. this.z = z;
  73104. this.w = w;
  73105. return this;
  73106. };
  73107. /**
  73108. * Updates the current quaternion from the given float coordinates
  73109. * @param x defines the x coordinate
  73110. * @param y defines the y coordinate
  73111. * @param z defines the z coordinate
  73112. * @param w defines the w coordinate
  73113. * @returns the updated current quaternion
  73114. */
  73115. Quaternion.prototype.set = function (x, y, z, w) {
  73116. return this.copyFromFloats(x, y, z, w);
  73117. };
  73118. /**
  73119. * Adds two quaternions
  73120. * @param other defines the second operand
  73121. * @returns a new quaternion as the addition result of the given one and the current quaternion
  73122. */
  73123. Quaternion.prototype.add = function (other) {
  73124. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  73125. };
  73126. /**
  73127. * Add a quaternion to the current one
  73128. * @param other defines the quaternion to add
  73129. * @returns the current quaternion
  73130. */
  73131. Quaternion.prototype.addInPlace = function (other) {
  73132. this.x += other.x;
  73133. this.y += other.y;
  73134. this.z += other.z;
  73135. this.w += other.w;
  73136. return this;
  73137. };
  73138. /**
  73139. * Subtract two quaternions
  73140. * @param other defines the second operand
  73141. * @returns a new quaternion as the subtraction result of the given one from the current one
  73142. */
  73143. Quaternion.prototype.subtract = function (other) {
  73144. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  73145. };
  73146. /**
  73147. * Multiplies the current quaternion by a scale factor
  73148. * @param value defines the scale factor
  73149. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  73150. */
  73151. Quaternion.prototype.scale = function (value) {
  73152. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  73153. };
  73154. /**
  73155. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  73156. * @param scale defines the scale factor
  73157. * @param result defines the Quaternion object where to store the result
  73158. * @returns the unmodified current quaternion
  73159. */
  73160. Quaternion.prototype.scaleToRef = function (scale, result) {
  73161. result.x = this.x * scale;
  73162. result.y = this.y * scale;
  73163. result.z = this.z * scale;
  73164. result.w = this.w * scale;
  73165. return this;
  73166. };
  73167. /**
  73168. * Multiplies in place the current quaternion by a scale factor
  73169. * @param value defines the scale factor
  73170. * @returns the current modified quaternion
  73171. */
  73172. Quaternion.prototype.scaleInPlace = function (value) {
  73173. this.x *= value;
  73174. this.y *= value;
  73175. this.z *= value;
  73176. this.w *= value;
  73177. return this;
  73178. };
  73179. /**
  73180. * Scale the current quaternion values by a factor and add the result to a given quaternion
  73181. * @param scale defines the scale factor
  73182. * @param result defines the Quaternion object where to store the result
  73183. * @returns the unmodified current quaternion
  73184. */
  73185. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  73186. result.x += this.x * scale;
  73187. result.y += this.y * scale;
  73188. result.z += this.z * scale;
  73189. result.w += this.w * scale;
  73190. return this;
  73191. };
  73192. /**
  73193. * Multiplies two quaternions
  73194. * @param q1 defines the second operand
  73195. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  73196. */
  73197. Quaternion.prototype.multiply = function (q1) {
  73198. var result = new Quaternion(0, 0, 0, 1.0);
  73199. this.multiplyToRef(q1, result);
  73200. return result;
  73201. };
  73202. /**
  73203. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  73204. * @param q1 defines the second operand
  73205. * @param result defines the target quaternion
  73206. * @returns the current quaternion
  73207. */
  73208. Quaternion.prototype.multiplyToRef = function (q1, result) {
  73209. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  73210. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  73211. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  73212. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  73213. result.copyFromFloats(x, y, z, w);
  73214. return this;
  73215. };
  73216. /**
  73217. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  73218. * @param q1 defines the second operand
  73219. * @returns the currentupdated quaternion
  73220. */
  73221. Quaternion.prototype.multiplyInPlace = function (q1) {
  73222. this.multiplyToRef(q1, this);
  73223. return this;
  73224. };
  73225. /**
  73226. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  73227. * @param ref defines the target quaternion
  73228. * @returns the current quaternion
  73229. */
  73230. Quaternion.prototype.conjugateToRef = function (ref) {
  73231. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  73232. return this;
  73233. };
  73234. /**
  73235. * Conjugates in place (1-q) the current quaternion
  73236. * @returns the current updated quaternion
  73237. */
  73238. Quaternion.prototype.conjugateInPlace = function () {
  73239. this.x *= -1;
  73240. this.y *= -1;
  73241. this.z *= -1;
  73242. return this;
  73243. };
  73244. /**
  73245. * Conjugates in place (1-q) the current quaternion
  73246. * @returns a new quaternion
  73247. */
  73248. Quaternion.prototype.conjugate = function () {
  73249. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  73250. return result;
  73251. };
  73252. /**
  73253. * Gets length of current quaternion
  73254. * @returns the quaternion length (float)
  73255. */
  73256. Quaternion.prototype.length = function () {
  73257. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  73258. };
  73259. /**
  73260. * Normalize in place the current quaternion
  73261. * @returns the current updated quaternion
  73262. */
  73263. Quaternion.prototype.normalize = function () {
  73264. var len = this.length();
  73265. if (len === 0) {
  73266. return this;
  73267. }
  73268. var inv = 1.0 / len;
  73269. this.x *= inv;
  73270. this.y *= inv;
  73271. this.z *= inv;
  73272. this.w *= inv;
  73273. return this;
  73274. };
  73275. /**
  73276. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  73277. * @param order is a reserved parameter and is ignore for now
  73278. * @returns a new Vector3 containing the Euler angles
  73279. */
  73280. Quaternion.prototype.toEulerAngles = function (order) {
  73281. if (order === void 0) { order = "YZX"; }
  73282. var result = Vector3.Zero();
  73283. this.toEulerAnglesToRef(result);
  73284. return result;
  73285. };
  73286. /**
  73287. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  73288. * @param result defines the vector which will be filled with the Euler angles
  73289. * @param order is a reserved parameter and is ignore for now
  73290. * @returns the current unchanged quaternion
  73291. */
  73292. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  73293. var qz = this.z;
  73294. var qx = this.x;
  73295. var qy = this.y;
  73296. var qw = this.w;
  73297. var sqw = qw * qw;
  73298. var sqz = qz * qz;
  73299. var sqx = qx * qx;
  73300. var sqy = qy * qy;
  73301. var zAxisY = qy * qz - qx * qw;
  73302. var limit = .4999999;
  73303. if (zAxisY < -limit) {
  73304. result.y = 2 * Math.atan2(qy, qw);
  73305. result.x = Math.PI / 2;
  73306. result.z = 0;
  73307. }
  73308. else if (zAxisY > limit) {
  73309. result.y = 2 * Math.atan2(qy, qw);
  73310. result.x = -Math.PI / 2;
  73311. result.z = 0;
  73312. }
  73313. else {
  73314. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  73315. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  73316. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  73317. }
  73318. return this;
  73319. };
  73320. /**
  73321. * Updates the given rotation matrix with the current quaternion values
  73322. * @param result defines the target matrix
  73323. * @returns the current unchanged quaternion
  73324. */
  73325. Quaternion.prototype.toRotationMatrix = function (result) {
  73326. Matrix.FromQuaternionToRef(this, result);
  73327. return this;
  73328. };
  73329. /**
  73330. * Updates the current quaternion from the given rotation matrix values
  73331. * @param matrix defines the source matrix
  73332. * @returns the current updated quaternion
  73333. */
  73334. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  73335. Quaternion.FromRotationMatrixToRef(matrix, this);
  73336. return this;
  73337. };
  73338. // Statics
  73339. /**
  73340. * Creates a new quaternion from a rotation matrix
  73341. * @param matrix defines the source matrix
  73342. * @returns a new quaternion created from the given rotation matrix values
  73343. */
  73344. Quaternion.FromRotationMatrix = function (matrix) {
  73345. var result = new Quaternion();
  73346. Quaternion.FromRotationMatrixToRef(matrix, result);
  73347. return result;
  73348. };
  73349. /**
  73350. * Updates the given quaternion with the given rotation matrix values
  73351. * @param matrix defines the source matrix
  73352. * @param result defines the target quaternion
  73353. */
  73354. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  73355. var data = matrix.m;
  73356. var m11 = data[0], m12 = data[4], m13 = data[8];
  73357. var m21 = data[1], m22 = data[5], m23 = data[9];
  73358. var m31 = data[2], m32 = data[6], m33 = data[10];
  73359. var trace = m11 + m22 + m33;
  73360. var s;
  73361. if (trace > 0) {
  73362. s = 0.5 / Math.sqrt(trace + 1.0);
  73363. result.w = 0.25 / s;
  73364. result.x = (m32 - m23) * s;
  73365. result.y = (m13 - m31) * s;
  73366. result.z = (m21 - m12) * s;
  73367. }
  73368. else if (m11 > m22 && m11 > m33) {
  73369. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  73370. result.w = (m32 - m23) / s;
  73371. result.x = 0.25 * s;
  73372. result.y = (m12 + m21) / s;
  73373. result.z = (m13 + m31) / s;
  73374. }
  73375. else if (m22 > m33) {
  73376. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  73377. result.w = (m13 - m31) / s;
  73378. result.x = (m12 + m21) / s;
  73379. result.y = 0.25 * s;
  73380. result.z = (m23 + m32) / s;
  73381. }
  73382. else {
  73383. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  73384. result.w = (m21 - m12) / s;
  73385. result.x = (m13 + m31) / s;
  73386. result.y = (m23 + m32) / s;
  73387. result.z = 0.25 * s;
  73388. }
  73389. };
  73390. /**
  73391. * Returns the dot product (float) between the quaternions "left" and "right"
  73392. * @param left defines the left operand
  73393. * @param right defines the right operand
  73394. * @returns the dot product
  73395. */
  73396. Quaternion.Dot = function (left, right) {
  73397. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  73398. };
  73399. /**
  73400. * Checks if the two quaternions are close to each other
  73401. * @param quat0 defines the first quaternion to check
  73402. * @param quat1 defines the second quaternion to check
  73403. * @returns true if the two quaternions are close to each other
  73404. */
  73405. Quaternion.AreClose = function (quat0, quat1) {
  73406. var dot = Quaternion.Dot(quat0, quat1);
  73407. return dot >= 0;
  73408. };
  73409. /**
  73410. * Creates an empty quaternion
  73411. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  73412. */
  73413. Quaternion.Zero = function () {
  73414. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  73415. };
  73416. /**
  73417. * Inverse a given quaternion
  73418. * @param q defines the source quaternion
  73419. * @returns a new quaternion as the inverted current quaternion
  73420. */
  73421. Quaternion.Inverse = function (q) {
  73422. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  73423. };
  73424. /**
  73425. * Inverse a given quaternion
  73426. * @param q defines the source quaternion
  73427. * @param result the quaternion the result will be stored in
  73428. * @returns the result quaternion
  73429. */
  73430. Quaternion.InverseToRef = function (q, result) {
  73431. result.set(-q.x, -q.y, -q.z, q.w);
  73432. return result;
  73433. };
  73434. /**
  73435. * Creates an identity quaternion
  73436. * @returns the identity quaternion
  73437. */
  73438. Quaternion.Identity = function () {
  73439. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  73440. };
  73441. /**
  73442. * Gets a boolean indicating if the given quaternion is identity
  73443. * @param quaternion defines the quaternion to check
  73444. * @returns true if the quaternion is identity
  73445. */
  73446. Quaternion.IsIdentity = function (quaternion) {
  73447. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  73448. };
  73449. /**
  73450. * Creates a quaternion from a rotation around an axis
  73451. * @param axis defines the axis to use
  73452. * @param angle defines the angle to use
  73453. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  73454. */
  73455. Quaternion.RotationAxis = function (axis, angle) {
  73456. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  73457. };
  73458. /**
  73459. * Creates a rotation around an axis and stores it into the given quaternion
  73460. * @param axis defines the axis to use
  73461. * @param angle defines the angle to use
  73462. * @param result defines the target quaternion
  73463. * @returns the target quaternion
  73464. */
  73465. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  73466. var sin = Math.sin(angle / 2);
  73467. axis.normalize();
  73468. result.w = Math.cos(angle / 2);
  73469. result.x = axis.x * sin;
  73470. result.y = axis.y * sin;
  73471. result.z = axis.z * sin;
  73472. return result;
  73473. };
  73474. /**
  73475. * Creates a new quaternion from data stored into an array
  73476. * @param array defines the data source
  73477. * @param offset defines the offset in the source array where the data starts
  73478. * @returns a new quaternion
  73479. */
  73480. Quaternion.FromArray = function (array, offset) {
  73481. if (!offset) {
  73482. offset = 0;
  73483. }
  73484. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  73485. };
  73486. /**
  73487. * Create a quaternion from Euler rotation angles
  73488. * @param x Pitch
  73489. * @param y Yaw
  73490. * @param z Roll
  73491. * @returns the new Quaternion
  73492. */
  73493. Quaternion.FromEulerAngles = function (x, y, z) {
  73494. var q = new Quaternion();
  73495. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  73496. return q;
  73497. };
  73498. /**
  73499. * Updates a quaternion from Euler rotation angles
  73500. * @param x Pitch
  73501. * @param y Yaw
  73502. * @param z Roll
  73503. * @param result the quaternion to store the result
  73504. * @returns the updated quaternion
  73505. */
  73506. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  73507. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  73508. return result;
  73509. };
  73510. /**
  73511. * Create a quaternion from Euler rotation vector
  73512. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73513. * @returns the new Quaternion
  73514. */
  73515. Quaternion.FromEulerVector = function (vec) {
  73516. var q = new Quaternion();
  73517. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  73518. return q;
  73519. };
  73520. /**
  73521. * Updates a quaternion from Euler rotation vector
  73522. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73523. * @param result the quaternion to store the result
  73524. * @returns the updated quaternion
  73525. */
  73526. Quaternion.FromEulerVectorToRef = function (vec, result) {
  73527. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  73528. return result;
  73529. };
  73530. /**
  73531. * Creates a new quaternion from the given Euler float angles (y, x, z)
  73532. * @param yaw defines the rotation around Y axis
  73533. * @param pitch defines the rotation around X axis
  73534. * @param roll defines the rotation around Z axis
  73535. * @returns the new quaternion
  73536. */
  73537. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  73538. var q = new Quaternion();
  73539. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  73540. return q;
  73541. };
  73542. /**
  73543. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  73544. * @param yaw defines the rotation around Y axis
  73545. * @param pitch defines the rotation around X axis
  73546. * @param roll defines the rotation around Z axis
  73547. * @param result defines the target quaternion
  73548. */
  73549. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  73550. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  73551. var halfRoll = roll * 0.5;
  73552. var halfPitch = pitch * 0.5;
  73553. var halfYaw = yaw * 0.5;
  73554. var sinRoll = Math.sin(halfRoll);
  73555. var cosRoll = Math.cos(halfRoll);
  73556. var sinPitch = Math.sin(halfPitch);
  73557. var cosPitch = Math.cos(halfPitch);
  73558. var sinYaw = Math.sin(halfYaw);
  73559. var cosYaw = Math.cos(halfYaw);
  73560. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  73561. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  73562. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  73563. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  73564. };
  73565. /**
  73566. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  73567. * @param alpha defines the rotation around first axis
  73568. * @param beta defines the rotation around second axis
  73569. * @param gamma defines the rotation around third axis
  73570. * @returns the new quaternion
  73571. */
  73572. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  73573. var result = new Quaternion();
  73574. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  73575. return result;
  73576. };
  73577. /**
  73578. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  73579. * @param alpha defines the rotation around first axis
  73580. * @param beta defines the rotation around second axis
  73581. * @param gamma defines the rotation around third axis
  73582. * @param result defines the target quaternion
  73583. */
  73584. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  73585. // Produces a quaternion from Euler angles in the z-x-z orientation
  73586. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  73587. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  73588. var halfBeta = beta * 0.5;
  73589. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  73590. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  73591. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  73592. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  73593. };
  73594. /**
  73595. * 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)
  73596. * @param axis1 defines the first axis
  73597. * @param axis2 defines the second axis
  73598. * @param axis3 defines the third axis
  73599. * @returns the new quaternion
  73600. */
  73601. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  73602. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  73603. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  73604. return quat;
  73605. };
  73606. /**
  73607. * 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
  73608. * @param axis1 defines the first axis
  73609. * @param axis2 defines the second axis
  73610. * @param axis3 defines the third axis
  73611. * @param ref defines the target quaternion
  73612. */
  73613. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  73614. var rotMat = MathTmp.Matrix[0];
  73615. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  73616. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  73617. };
  73618. /**
  73619. * Interpolates between two quaternions
  73620. * @param left defines first quaternion
  73621. * @param right defines second quaternion
  73622. * @param amount defines the gradient to use
  73623. * @returns the new interpolated quaternion
  73624. */
  73625. Quaternion.Slerp = function (left, right, amount) {
  73626. var result = Quaternion.Identity();
  73627. Quaternion.SlerpToRef(left, right, amount, result);
  73628. return result;
  73629. };
  73630. /**
  73631. * Interpolates between two quaternions and stores it into a target quaternion
  73632. * @param left defines first quaternion
  73633. * @param right defines second quaternion
  73634. * @param amount defines the gradient to use
  73635. * @param result defines the target quaternion
  73636. */
  73637. Quaternion.SlerpToRef = function (left, right, amount, result) {
  73638. var num2;
  73639. var num3;
  73640. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  73641. var flag = false;
  73642. if (num4 < 0) {
  73643. flag = true;
  73644. num4 = -num4;
  73645. }
  73646. if (num4 > 0.999999) {
  73647. num3 = 1 - amount;
  73648. num2 = flag ? -amount : amount;
  73649. }
  73650. else {
  73651. var num5 = Math.acos(num4);
  73652. var num6 = (1.0 / Math.sin(num5));
  73653. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  73654. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  73655. }
  73656. result.x = (num3 * left.x) + (num2 * right.x);
  73657. result.y = (num3 * left.y) + (num2 * right.y);
  73658. result.z = (num3 * left.z) + (num2 * right.z);
  73659. result.w = (num3 * left.w) + (num2 * right.w);
  73660. };
  73661. /**
  73662. * Interpolate between two quaternions using Hermite interpolation
  73663. * @param value1 defines first quaternion
  73664. * @param tangent1 defines the incoming tangent
  73665. * @param value2 defines second quaternion
  73666. * @param tangent2 defines the outgoing tangent
  73667. * @param amount defines the target quaternion
  73668. * @returns the new interpolated quaternion
  73669. */
  73670. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  73671. var squared = amount * amount;
  73672. var cubed = amount * squared;
  73673. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  73674. var part2 = (-2.0 * cubed) + (3.0 * squared);
  73675. var part3 = (cubed - (2.0 * squared)) + amount;
  73676. var part4 = cubed - squared;
  73677. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  73678. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  73679. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  73680. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  73681. return new Quaternion(x, y, z, w);
  73682. };
  73683. return Quaternion;
  73684. }());
  73685. /**
  73686. * Class used to store matrix data (4x4)
  73687. */
  73688. var Matrix = /** @class */ (function () {
  73689. /**
  73690. * Creates an empty matrix (filled with zeros)
  73691. */
  73692. function Matrix() {
  73693. this._isIdentity = false;
  73694. this._isIdentityDirty = true;
  73695. this._isIdentity3x2 = true;
  73696. this._isIdentity3x2Dirty = true;
  73697. this._m = new Float32Array(16);
  73698. this._updateIdentityStatus(false);
  73699. }
  73700. Object.defineProperty(Matrix.prototype, "m", {
  73701. /**
  73702. * Gets the internal data of the matrix
  73703. */
  73704. get: function () { return this._m; },
  73705. enumerable: true,
  73706. configurable: true
  73707. });
  73708. /** @hidden */
  73709. Matrix.prototype._markAsUpdated = function () {
  73710. this.updateFlag = Matrix._updateFlagSeed++;
  73711. this._isIdentity = false;
  73712. this._isIdentity3x2 = false;
  73713. this._isIdentityDirty = true;
  73714. this._isIdentity3x2Dirty = true;
  73715. };
  73716. /** @hidden */
  73717. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  73718. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  73719. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  73720. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  73721. this.updateFlag = Matrix._updateFlagSeed++;
  73722. this._isIdentity = isIdentity;
  73723. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  73724. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  73725. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  73726. };
  73727. // Properties
  73728. /**
  73729. * Check if the current matrix is identity
  73730. * @returns true is the matrix is the identity matrix
  73731. */
  73732. Matrix.prototype.isIdentity = function () {
  73733. if (this._isIdentityDirty) {
  73734. this._isIdentityDirty = false;
  73735. var m = this._m;
  73736. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  73737. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  73738. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  73739. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  73740. }
  73741. return this._isIdentity;
  73742. };
  73743. /**
  73744. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  73745. * @returns true is the matrix is the identity matrix
  73746. */
  73747. Matrix.prototype.isIdentityAs3x2 = function () {
  73748. if (this._isIdentity3x2Dirty) {
  73749. this._isIdentity3x2Dirty = false;
  73750. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  73751. this._isIdentity3x2 = false;
  73752. }
  73753. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  73754. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  73755. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  73756. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  73757. this._isIdentity3x2 = false;
  73758. }
  73759. else {
  73760. this._isIdentity3x2 = true;
  73761. }
  73762. }
  73763. return this._isIdentity3x2;
  73764. };
  73765. /**
  73766. * Gets the determinant of the matrix
  73767. * @returns the matrix determinant
  73768. */
  73769. Matrix.prototype.determinant = function () {
  73770. if (this._isIdentity === true) {
  73771. return 1;
  73772. }
  73773. var m = this._m;
  73774. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  73775. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  73776. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  73777. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  73778. // https://en.wikipedia.org/wiki/Laplace_expansion
  73779. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  73780. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  73781. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  73782. // where
  73783. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  73784. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  73785. //
  73786. // Here we do that for the 1st row.
  73787. var det_22_33 = m22 * m33 - m32 * m23;
  73788. var det_21_33 = m21 * m33 - m31 * m23;
  73789. var det_21_32 = m21 * m32 - m31 * m22;
  73790. var det_20_33 = m20 * m33 - m30 * m23;
  73791. var det_20_32 = m20 * m32 - m22 * m30;
  73792. var det_20_31 = m20 * m31 - m30 * m21;
  73793. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  73794. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  73795. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  73796. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  73797. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  73798. };
  73799. // Methods
  73800. /**
  73801. * Returns the matrix as a Float32Array
  73802. * @returns the matrix underlying array
  73803. */
  73804. Matrix.prototype.toArray = function () {
  73805. return this._m;
  73806. };
  73807. /**
  73808. * Returns the matrix as a Float32Array
  73809. * @returns the matrix underlying array.
  73810. */
  73811. Matrix.prototype.asArray = function () {
  73812. return this._m;
  73813. };
  73814. /**
  73815. * Inverts the current matrix in place
  73816. * @returns the current inverted matrix
  73817. */
  73818. Matrix.prototype.invert = function () {
  73819. this.invertToRef(this);
  73820. return this;
  73821. };
  73822. /**
  73823. * Sets all the matrix elements to zero
  73824. * @returns the current matrix
  73825. */
  73826. Matrix.prototype.reset = function () {
  73827. 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);
  73828. this._updateIdentityStatus(false);
  73829. return this;
  73830. };
  73831. /**
  73832. * Adds the current matrix with a second one
  73833. * @param other defines the matrix to add
  73834. * @returns a new matrix as the addition of the current matrix and the given one
  73835. */
  73836. Matrix.prototype.add = function (other) {
  73837. var result = new Matrix();
  73838. this.addToRef(other, result);
  73839. return result;
  73840. };
  73841. /**
  73842. * Sets the given matrix "result" to the addition of the current matrix and the given one
  73843. * @param other defines the matrix to add
  73844. * @param result defines the target matrix
  73845. * @returns the current matrix
  73846. */
  73847. Matrix.prototype.addToRef = function (other, result) {
  73848. var m = this._m;
  73849. var resultM = result._m;
  73850. var otherM = other.m;
  73851. for (var index = 0; index < 16; index++) {
  73852. resultM[index] = m[index] + otherM[index];
  73853. }
  73854. result._markAsUpdated();
  73855. return this;
  73856. };
  73857. /**
  73858. * Adds in place the given matrix to the current matrix
  73859. * @param other defines the second operand
  73860. * @returns the current updated matrix
  73861. */
  73862. Matrix.prototype.addToSelf = function (other) {
  73863. var m = this._m;
  73864. var otherM = other.m;
  73865. for (var index = 0; index < 16; index++) {
  73866. m[index] += otherM[index];
  73867. }
  73868. this._markAsUpdated();
  73869. return this;
  73870. };
  73871. /**
  73872. * Sets the given matrix to the current inverted Matrix
  73873. * @param other defines the target matrix
  73874. * @returns the unmodified current matrix
  73875. */
  73876. Matrix.prototype.invertToRef = function (other) {
  73877. if (this._isIdentity === true) {
  73878. Matrix.IdentityToRef(other);
  73879. return this;
  73880. }
  73881. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  73882. var m = this._m;
  73883. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  73884. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  73885. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  73886. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  73887. var det_22_33 = m22 * m33 - m32 * m23;
  73888. var det_21_33 = m21 * m33 - m31 * m23;
  73889. var det_21_32 = m21 * m32 - m31 * m22;
  73890. var det_20_33 = m20 * m33 - m30 * m23;
  73891. var det_20_32 = m20 * m32 - m22 * m30;
  73892. var det_20_31 = m20 * m31 - m30 * m21;
  73893. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  73894. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  73895. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  73896. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  73897. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  73898. if (det === 0) {
  73899. // not invertible
  73900. other.copyFrom(this);
  73901. return this;
  73902. }
  73903. var detInv = 1 / det;
  73904. var det_12_33 = m12 * m33 - m32 * m13;
  73905. var det_11_33 = m11 * m33 - m31 * m13;
  73906. var det_11_32 = m11 * m32 - m31 * m12;
  73907. var det_10_33 = m10 * m33 - m30 * m13;
  73908. var det_10_32 = m10 * m32 - m30 * m12;
  73909. var det_10_31 = m10 * m31 - m30 * m11;
  73910. var det_12_23 = m12 * m23 - m22 * m13;
  73911. var det_11_23 = m11 * m23 - m21 * m13;
  73912. var det_11_22 = m11 * m22 - m21 * m12;
  73913. var det_10_23 = m10 * m23 - m20 * m13;
  73914. var det_10_22 = m10 * m22 - m20 * m12;
  73915. var det_10_21 = m10 * m21 - m20 * m11;
  73916. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  73917. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  73918. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  73919. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  73920. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  73921. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  73922. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  73923. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  73924. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  73925. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  73926. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  73927. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  73928. 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);
  73929. return this;
  73930. };
  73931. /**
  73932. * add a value at the specified position in the current Matrix
  73933. * @param index the index of the value within the matrix. between 0 and 15.
  73934. * @param value the value to be added
  73935. * @returns the current updated matrix
  73936. */
  73937. Matrix.prototype.addAtIndex = function (index, value) {
  73938. this._m[index] += value;
  73939. this._markAsUpdated();
  73940. return this;
  73941. };
  73942. /**
  73943. * mutiply the specified position in the current Matrix by a value
  73944. * @param index the index of the value within the matrix. between 0 and 15.
  73945. * @param value the value to be added
  73946. * @returns the current updated matrix
  73947. */
  73948. Matrix.prototype.multiplyAtIndex = function (index, value) {
  73949. this._m[index] *= value;
  73950. this._markAsUpdated();
  73951. return this;
  73952. };
  73953. /**
  73954. * Inserts the translation vector (using 3 floats) in the current matrix
  73955. * @param x defines the 1st component of the translation
  73956. * @param y defines the 2nd component of the translation
  73957. * @param z defines the 3rd component of the translation
  73958. * @returns the current updated matrix
  73959. */
  73960. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  73961. this._m[12] = x;
  73962. this._m[13] = y;
  73963. this._m[14] = z;
  73964. this._markAsUpdated();
  73965. return this;
  73966. };
  73967. /**
  73968. * Inserts the translation vector in the current matrix
  73969. * @param vector3 defines the translation to insert
  73970. * @returns the current updated matrix
  73971. */
  73972. Matrix.prototype.setTranslation = function (vector3) {
  73973. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  73974. };
  73975. /**
  73976. * Gets the translation value of the current matrix
  73977. * @returns a new Vector3 as the extracted translation from the matrix
  73978. */
  73979. Matrix.prototype.getTranslation = function () {
  73980. return new Vector3(this._m[12], this._m[13], this._m[14]);
  73981. };
  73982. /**
  73983. * Fill a Vector3 with the extracted translation from the matrix
  73984. * @param result defines the Vector3 where to store the translation
  73985. * @returns the current matrix
  73986. */
  73987. Matrix.prototype.getTranslationToRef = function (result) {
  73988. result.x = this._m[12];
  73989. result.y = this._m[13];
  73990. result.z = this._m[14];
  73991. return this;
  73992. };
  73993. /**
  73994. * Remove rotation and scaling part from the matrix
  73995. * @returns the updated matrix
  73996. */
  73997. Matrix.prototype.removeRotationAndScaling = function () {
  73998. var m = this.m;
  73999. 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);
  74000. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  74001. return this;
  74002. };
  74003. /**
  74004. * Multiply two matrices
  74005. * @param other defines the second operand
  74006. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74007. */
  74008. Matrix.prototype.multiply = function (other) {
  74009. var result = new Matrix();
  74010. this.multiplyToRef(other, result);
  74011. return result;
  74012. };
  74013. /**
  74014. * Copy the current matrix from the given one
  74015. * @param other defines the source matrix
  74016. * @returns the current updated matrix
  74017. */
  74018. Matrix.prototype.copyFrom = function (other) {
  74019. other.copyToArray(this._m);
  74020. var o = other;
  74021. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  74022. return this;
  74023. };
  74024. /**
  74025. * Populates the given array from the starting index with the current matrix values
  74026. * @param array defines the target array
  74027. * @param offset defines the offset in the target array where to start storing values
  74028. * @returns the current matrix
  74029. */
  74030. Matrix.prototype.copyToArray = function (array, offset) {
  74031. if (offset === void 0) { offset = 0; }
  74032. for (var index = 0; index < 16; index++) {
  74033. array[offset + index] = this._m[index];
  74034. }
  74035. return this;
  74036. };
  74037. /**
  74038. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74039. * @param other defines the second operand
  74040. * @param result defines the matrix where to store the multiplication
  74041. * @returns the current matrix
  74042. */
  74043. Matrix.prototype.multiplyToRef = function (other, result) {
  74044. if (this._isIdentity) {
  74045. result.copyFrom(other);
  74046. return this;
  74047. }
  74048. if (other._isIdentity) {
  74049. result.copyFrom(this);
  74050. return this;
  74051. }
  74052. this.multiplyToArray(other, result._m, 0);
  74053. result._markAsUpdated();
  74054. return this;
  74055. };
  74056. /**
  74057. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74058. * @param other defines the second operand
  74059. * @param result defines the array where to store the multiplication
  74060. * @param offset defines the offset in the target array where to start storing values
  74061. * @returns the current matrix
  74062. */
  74063. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  74064. var m = this._m;
  74065. var otherM = other.m;
  74066. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  74067. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  74068. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  74069. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  74070. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  74071. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  74072. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  74073. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  74074. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  74075. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  74076. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  74077. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  74078. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  74079. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  74080. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  74081. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  74082. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  74083. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  74084. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  74085. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  74086. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  74087. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  74088. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  74089. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  74090. return this;
  74091. };
  74092. /**
  74093. * Check equality between this matrix and a second one
  74094. * @param value defines the second matrix to compare
  74095. * @returns true is the current matrix and the given one values are strictly equal
  74096. */
  74097. Matrix.prototype.equals = function (value) {
  74098. var other = value;
  74099. if (!other) {
  74100. return false;
  74101. }
  74102. if (this._isIdentity || other._isIdentity) {
  74103. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  74104. return this._isIdentity && other._isIdentity;
  74105. }
  74106. }
  74107. var m = this.m;
  74108. var om = other.m;
  74109. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  74110. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  74111. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  74112. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  74113. };
  74114. /**
  74115. * Clone the current matrix
  74116. * @returns a new matrix from the current matrix
  74117. */
  74118. Matrix.prototype.clone = function () {
  74119. var matrix = new Matrix();
  74120. matrix.copyFrom(this);
  74121. return matrix;
  74122. };
  74123. /**
  74124. * Returns the name of the current matrix class
  74125. * @returns the string "Matrix"
  74126. */
  74127. Matrix.prototype.getClassName = function () {
  74128. return "Matrix";
  74129. };
  74130. /**
  74131. * Gets the hash code of the current matrix
  74132. * @returns the hash code
  74133. */
  74134. Matrix.prototype.getHashCode = function () {
  74135. var hash = this._m[0] || 0;
  74136. for (var i = 1; i < 16; i++) {
  74137. hash = (hash * 397) ^ (this._m[i] || 0);
  74138. }
  74139. return hash;
  74140. };
  74141. /**
  74142. * Decomposes the current Matrix into a translation, rotation and scaling components
  74143. * @param scale defines the scale vector3 given as a reference to update
  74144. * @param rotation defines the rotation quaternion given as a reference to update
  74145. * @param translation defines the translation vector3 given as a reference to update
  74146. * @returns true if operation was successful
  74147. */
  74148. Matrix.prototype.decompose = function (scale, rotation, translation) {
  74149. if (this._isIdentity) {
  74150. if (translation) {
  74151. translation.setAll(0);
  74152. }
  74153. if (scale) {
  74154. scale.setAll(1);
  74155. }
  74156. if (rotation) {
  74157. rotation.copyFromFloats(0, 0, 0, 1);
  74158. }
  74159. return true;
  74160. }
  74161. var m = this._m;
  74162. if (translation) {
  74163. translation.copyFromFloats(m[12], m[13], m[14]);
  74164. }
  74165. scale = scale || MathTmp.Vector3[0];
  74166. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  74167. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  74168. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  74169. if (this.determinant() <= 0) {
  74170. scale.y *= -1;
  74171. }
  74172. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  74173. if (rotation) {
  74174. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  74175. }
  74176. return false;
  74177. }
  74178. if (rotation) {
  74179. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  74180. 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]);
  74181. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  74182. }
  74183. return true;
  74184. };
  74185. /**
  74186. * Gets specific row of the matrix
  74187. * @param index defines the number of the row to get
  74188. * @returns the index-th row of the current matrix as a new Vector4
  74189. */
  74190. Matrix.prototype.getRow = function (index) {
  74191. if (index < 0 || index > 3) {
  74192. return null;
  74193. }
  74194. var i = index * 4;
  74195. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  74196. };
  74197. /**
  74198. * Sets the index-th row of the current matrix to the vector4 values
  74199. * @param index defines the number of the row to set
  74200. * @param row defines the target vector4
  74201. * @returns the updated current matrix
  74202. */
  74203. Matrix.prototype.setRow = function (index, row) {
  74204. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  74205. };
  74206. /**
  74207. * Compute the transpose of the matrix
  74208. * @returns the new transposed matrix
  74209. */
  74210. Matrix.prototype.transpose = function () {
  74211. return Matrix.Transpose(this);
  74212. };
  74213. /**
  74214. * Compute the transpose of the matrix and store it in a given matrix
  74215. * @param result defines the target matrix
  74216. * @returns the current matrix
  74217. */
  74218. Matrix.prototype.transposeToRef = function (result) {
  74219. Matrix.TransposeToRef(this, result);
  74220. return this;
  74221. };
  74222. /**
  74223. * Sets the index-th row of the current matrix with the given 4 x float values
  74224. * @param index defines the row index
  74225. * @param x defines the x component to set
  74226. * @param y defines the y component to set
  74227. * @param z defines the z component to set
  74228. * @param w defines the w component to set
  74229. * @returns the updated current matrix
  74230. */
  74231. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  74232. if (index < 0 || index > 3) {
  74233. return this;
  74234. }
  74235. var i = index * 4;
  74236. this._m[i + 0] = x;
  74237. this._m[i + 1] = y;
  74238. this._m[i + 2] = z;
  74239. this._m[i + 3] = w;
  74240. this._markAsUpdated();
  74241. return this;
  74242. };
  74243. /**
  74244. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74245. * @param scale defines the scale factor
  74246. * @returns a new matrix
  74247. */
  74248. Matrix.prototype.scale = function (scale) {
  74249. var result = new Matrix();
  74250. this.scaleToRef(scale, result);
  74251. return result;
  74252. };
  74253. /**
  74254. * Scale the current matrix values by a factor to a given result matrix
  74255. * @param scale defines the scale factor
  74256. * @param result defines the matrix to store the result
  74257. * @returns the current matrix
  74258. */
  74259. Matrix.prototype.scaleToRef = function (scale, result) {
  74260. for (var index = 0; index < 16; index++) {
  74261. result._m[index] = this._m[index] * scale;
  74262. }
  74263. result._markAsUpdated();
  74264. return this;
  74265. };
  74266. /**
  74267. * Scale the current matrix values by a factor and add the result to a given matrix
  74268. * @param scale defines the scale factor
  74269. * @param result defines the Matrix to store the result
  74270. * @returns the current matrix
  74271. */
  74272. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  74273. for (var index = 0; index < 16; index++) {
  74274. result._m[index] += this._m[index] * scale;
  74275. }
  74276. result._markAsUpdated();
  74277. return this;
  74278. };
  74279. /**
  74280. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74281. * @param ref matrix to store the result
  74282. */
  74283. Matrix.prototype.toNormalMatrix = function (ref) {
  74284. var tmp = MathTmp.Matrix[0];
  74285. this.invertToRef(tmp);
  74286. tmp.transposeToRef(ref);
  74287. var m = ref._m;
  74288. 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);
  74289. };
  74290. /**
  74291. * Gets only rotation part of the current matrix
  74292. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74293. */
  74294. Matrix.prototype.getRotationMatrix = function () {
  74295. var result = new Matrix();
  74296. this.getRotationMatrixToRef(result);
  74297. return result;
  74298. };
  74299. /**
  74300. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74301. * @param result defines the target matrix to store data to
  74302. * @returns the current matrix
  74303. */
  74304. Matrix.prototype.getRotationMatrixToRef = function (result) {
  74305. var scale = MathTmp.Vector3[0];
  74306. if (!this.decompose(scale)) {
  74307. Matrix.IdentityToRef(result);
  74308. return this;
  74309. }
  74310. var m = this._m;
  74311. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  74312. 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);
  74313. return this;
  74314. };
  74315. /**
  74316. * Toggles model matrix from being right handed to left handed in place and vice versa
  74317. */
  74318. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  74319. var m = this._m;
  74320. m[2] *= -1;
  74321. m[6] *= -1;
  74322. m[8] *= -1;
  74323. m[9] *= -1;
  74324. m[14] *= -1;
  74325. this._markAsUpdated();
  74326. };
  74327. /**
  74328. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74329. */
  74330. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  74331. var m = this._m;
  74332. m[8] *= -1;
  74333. m[9] *= -1;
  74334. m[10] *= -1;
  74335. m[11] *= -1;
  74336. this._markAsUpdated();
  74337. };
  74338. // Statics
  74339. /**
  74340. * Creates a matrix from an array
  74341. * @param array defines the source array
  74342. * @param offset defines an offset in the source array
  74343. * @returns a new Matrix set from the starting index of the given array
  74344. */
  74345. Matrix.FromArray = function (array, offset) {
  74346. if (offset === void 0) { offset = 0; }
  74347. var result = new Matrix();
  74348. Matrix.FromArrayToRef(array, offset, result);
  74349. return result;
  74350. };
  74351. /**
  74352. * Copy the content of an array into a given matrix
  74353. * @param array defines the source array
  74354. * @param offset defines an offset in the source array
  74355. * @param result defines the target matrix
  74356. */
  74357. Matrix.FromArrayToRef = function (array, offset, result) {
  74358. for (var index = 0; index < 16; index++) {
  74359. result._m[index] = array[index + offset];
  74360. }
  74361. result._markAsUpdated();
  74362. };
  74363. /**
  74364. * Stores an array into a matrix after having multiplied each component by a given factor
  74365. * @param array defines the source array
  74366. * @param offset defines the offset in the source array
  74367. * @param scale defines the scaling factor
  74368. * @param result defines the target matrix
  74369. */
  74370. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  74371. for (var index = 0; index < 16; index++) {
  74372. result._m[index] = array[index + offset] * scale;
  74373. }
  74374. result._markAsUpdated();
  74375. };
  74376. Object.defineProperty(Matrix, "IdentityReadOnly", {
  74377. /**
  74378. * Gets an identity matrix that must not be updated
  74379. */
  74380. get: function () {
  74381. return Matrix._identityReadOnly;
  74382. },
  74383. enumerable: true,
  74384. configurable: true
  74385. });
  74386. /**
  74387. * Stores a list of values (16) inside a given matrix
  74388. * @param initialM11 defines 1st value of 1st row
  74389. * @param initialM12 defines 2nd value of 1st row
  74390. * @param initialM13 defines 3rd value of 1st row
  74391. * @param initialM14 defines 4th value of 1st row
  74392. * @param initialM21 defines 1st value of 2nd row
  74393. * @param initialM22 defines 2nd value of 2nd row
  74394. * @param initialM23 defines 3rd value of 2nd row
  74395. * @param initialM24 defines 4th value of 2nd row
  74396. * @param initialM31 defines 1st value of 3rd row
  74397. * @param initialM32 defines 2nd value of 3rd row
  74398. * @param initialM33 defines 3rd value of 3rd row
  74399. * @param initialM34 defines 4th value of 3rd row
  74400. * @param initialM41 defines 1st value of 4th row
  74401. * @param initialM42 defines 2nd value of 4th row
  74402. * @param initialM43 defines 3rd value of 4th row
  74403. * @param initialM44 defines 4th value of 4th row
  74404. * @param result defines the target matrix
  74405. */
  74406. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  74407. var m = result._m;
  74408. m[0] = initialM11;
  74409. m[1] = initialM12;
  74410. m[2] = initialM13;
  74411. m[3] = initialM14;
  74412. m[4] = initialM21;
  74413. m[5] = initialM22;
  74414. m[6] = initialM23;
  74415. m[7] = initialM24;
  74416. m[8] = initialM31;
  74417. m[9] = initialM32;
  74418. m[10] = initialM33;
  74419. m[11] = initialM34;
  74420. m[12] = initialM41;
  74421. m[13] = initialM42;
  74422. m[14] = initialM43;
  74423. m[15] = initialM44;
  74424. result._markAsUpdated();
  74425. };
  74426. /**
  74427. * Creates new matrix from a list of values (16)
  74428. * @param initialM11 defines 1st value of 1st row
  74429. * @param initialM12 defines 2nd value of 1st row
  74430. * @param initialM13 defines 3rd value of 1st row
  74431. * @param initialM14 defines 4th value of 1st row
  74432. * @param initialM21 defines 1st value of 2nd row
  74433. * @param initialM22 defines 2nd value of 2nd row
  74434. * @param initialM23 defines 3rd value of 2nd row
  74435. * @param initialM24 defines 4th value of 2nd row
  74436. * @param initialM31 defines 1st value of 3rd row
  74437. * @param initialM32 defines 2nd value of 3rd row
  74438. * @param initialM33 defines 3rd value of 3rd row
  74439. * @param initialM34 defines 4th value of 3rd row
  74440. * @param initialM41 defines 1st value of 4th row
  74441. * @param initialM42 defines 2nd value of 4th row
  74442. * @param initialM43 defines 3rd value of 4th row
  74443. * @param initialM44 defines 4th value of 4th row
  74444. * @returns the new matrix
  74445. */
  74446. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  74447. var result = new Matrix();
  74448. var m = result._m;
  74449. m[0] = initialM11;
  74450. m[1] = initialM12;
  74451. m[2] = initialM13;
  74452. m[3] = initialM14;
  74453. m[4] = initialM21;
  74454. m[5] = initialM22;
  74455. m[6] = initialM23;
  74456. m[7] = initialM24;
  74457. m[8] = initialM31;
  74458. m[9] = initialM32;
  74459. m[10] = initialM33;
  74460. m[11] = initialM34;
  74461. m[12] = initialM41;
  74462. m[13] = initialM42;
  74463. m[14] = initialM43;
  74464. m[15] = initialM44;
  74465. result._markAsUpdated();
  74466. return result;
  74467. };
  74468. /**
  74469. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74470. * @param scale defines the scale vector3
  74471. * @param rotation defines the rotation quaternion
  74472. * @param translation defines the translation vector3
  74473. * @returns a new matrix
  74474. */
  74475. Matrix.Compose = function (scale, rotation, translation) {
  74476. var result = new Matrix();
  74477. Matrix.ComposeToRef(scale, rotation, translation, result);
  74478. return result;
  74479. };
  74480. /**
  74481. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74482. * @param scale defines the scale vector3
  74483. * @param rotation defines the rotation quaternion
  74484. * @param translation defines the translation vector3
  74485. * @param result defines the target matrix
  74486. */
  74487. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  74488. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  74489. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  74490. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  74491. result.setTranslation(translation);
  74492. };
  74493. /**
  74494. * Creates a new identity matrix
  74495. * @returns a new identity matrix
  74496. */
  74497. Matrix.Identity = function () {
  74498. 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);
  74499. identity._updateIdentityStatus(true);
  74500. return identity;
  74501. };
  74502. /**
  74503. * Creates a new identity matrix and stores the result in a given matrix
  74504. * @param result defines the target matrix
  74505. */
  74506. Matrix.IdentityToRef = function (result) {
  74507. 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);
  74508. result._updateIdentityStatus(true);
  74509. };
  74510. /**
  74511. * Creates a new zero matrix
  74512. * @returns a new zero matrix
  74513. */
  74514. Matrix.Zero = function () {
  74515. 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);
  74516. zero._updateIdentityStatus(false);
  74517. return zero;
  74518. };
  74519. /**
  74520. * Creates a new rotation matrix for "angle" radians around the X axis
  74521. * @param angle defines the angle (in radians) to use
  74522. * @return the new matrix
  74523. */
  74524. Matrix.RotationX = function (angle) {
  74525. var result = new Matrix();
  74526. Matrix.RotationXToRef(angle, result);
  74527. return result;
  74528. };
  74529. /**
  74530. * Creates a new matrix as the invert of a given matrix
  74531. * @param source defines the source matrix
  74532. * @returns the new matrix
  74533. */
  74534. Matrix.Invert = function (source) {
  74535. var result = new Matrix();
  74536. source.invertToRef(result);
  74537. return result;
  74538. };
  74539. /**
  74540. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74541. * @param angle defines the angle (in radians) to use
  74542. * @param result defines the target matrix
  74543. */
  74544. Matrix.RotationXToRef = function (angle, result) {
  74545. var s = Math.sin(angle);
  74546. var c = Math.cos(angle);
  74547. 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);
  74548. result._updateIdentityStatus(c === 1 && s === 0);
  74549. };
  74550. /**
  74551. * Creates a new rotation matrix for "angle" radians around the Y axis
  74552. * @param angle defines the angle (in radians) to use
  74553. * @return the new matrix
  74554. */
  74555. Matrix.RotationY = function (angle) {
  74556. var result = new Matrix();
  74557. Matrix.RotationYToRef(angle, result);
  74558. return result;
  74559. };
  74560. /**
  74561. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74562. * @param angle defines the angle (in radians) to use
  74563. * @param result defines the target matrix
  74564. */
  74565. Matrix.RotationYToRef = function (angle, result) {
  74566. var s = Math.sin(angle);
  74567. var c = Math.cos(angle);
  74568. 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);
  74569. result._updateIdentityStatus(c === 1 && s === 0);
  74570. };
  74571. /**
  74572. * Creates a new rotation matrix for "angle" radians around the Z axis
  74573. * @param angle defines the angle (in radians) to use
  74574. * @return the new matrix
  74575. */
  74576. Matrix.RotationZ = function (angle) {
  74577. var result = new Matrix();
  74578. Matrix.RotationZToRef(angle, result);
  74579. return result;
  74580. };
  74581. /**
  74582. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74583. * @param angle defines the angle (in radians) to use
  74584. * @param result defines the target matrix
  74585. */
  74586. Matrix.RotationZToRef = function (angle, result) {
  74587. var s = Math.sin(angle);
  74588. var c = Math.cos(angle);
  74589. 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);
  74590. result._updateIdentityStatus(c === 1 && s === 0);
  74591. };
  74592. /**
  74593. * Creates a new rotation matrix for "angle" radians around the given axis
  74594. * @param axis defines the axis to use
  74595. * @param angle defines the angle (in radians) to use
  74596. * @return the new matrix
  74597. */
  74598. Matrix.RotationAxis = function (axis, angle) {
  74599. var result = new Matrix();
  74600. Matrix.RotationAxisToRef(axis, angle, result);
  74601. return result;
  74602. };
  74603. /**
  74604. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74605. * @param axis defines the axis to use
  74606. * @param angle defines the angle (in radians) to use
  74607. * @param result defines the target matrix
  74608. */
  74609. Matrix.RotationAxisToRef = function (axis, angle, result) {
  74610. var s = Math.sin(-angle);
  74611. var c = Math.cos(-angle);
  74612. var c1 = 1 - c;
  74613. axis.normalize();
  74614. var m = result._m;
  74615. m[0] = (axis.x * axis.x) * c1 + c;
  74616. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  74617. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  74618. m[3] = 0.0;
  74619. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  74620. m[5] = (axis.y * axis.y) * c1 + c;
  74621. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  74622. m[7] = 0.0;
  74623. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  74624. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  74625. m[10] = (axis.z * axis.z) * c1 + c;
  74626. m[11] = 0.0;
  74627. m[12] = 0.0;
  74628. m[13] = 0.0;
  74629. m[14] = 0.0;
  74630. m[15] = 1.0;
  74631. result._markAsUpdated();
  74632. };
  74633. /**
  74634. * Creates a rotation matrix
  74635. * @param yaw defines the yaw angle in radians (Y axis)
  74636. * @param pitch defines the pitch angle in radians (X axis)
  74637. * @param roll defines the roll angle in radians (X axis)
  74638. * @returns the new rotation matrix
  74639. */
  74640. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  74641. var result = new Matrix();
  74642. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  74643. return result;
  74644. };
  74645. /**
  74646. * Creates a rotation matrix and stores it in a given matrix
  74647. * @param yaw defines the yaw angle in radians (Y axis)
  74648. * @param pitch defines the pitch angle in radians (X axis)
  74649. * @param roll defines the roll angle in radians (X axis)
  74650. * @param result defines the target matrix
  74651. */
  74652. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  74653. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  74654. MathTmp.Quaternion[0].toRotationMatrix(result);
  74655. };
  74656. /**
  74657. * Creates a scaling matrix
  74658. * @param x defines the scale factor on X axis
  74659. * @param y defines the scale factor on Y axis
  74660. * @param z defines the scale factor on Z axis
  74661. * @returns the new matrix
  74662. */
  74663. Matrix.Scaling = function (x, y, z) {
  74664. var result = new Matrix();
  74665. Matrix.ScalingToRef(x, y, z, result);
  74666. return result;
  74667. };
  74668. /**
  74669. * Creates a scaling matrix and stores it in a given matrix
  74670. * @param x defines the scale factor on X axis
  74671. * @param y defines the scale factor on Y axis
  74672. * @param z defines the scale factor on Z axis
  74673. * @param result defines the target matrix
  74674. */
  74675. Matrix.ScalingToRef = function (x, y, z, result) {
  74676. 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);
  74677. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  74678. };
  74679. /**
  74680. * Creates a translation matrix
  74681. * @param x defines the translation on X axis
  74682. * @param y defines the translation on Y axis
  74683. * @param z defines the translationon Z axis
  74684. * @returns the new matrix
  74685. */
  74686. Matrix.Translation = function (x, y, z) {
  74687. var result = new Matrix();
  74688. Matrix.TranslationToRef(x, y, z, result);
  74689. return result;
  74690. };
  74691. /**
  74692. * Creates a translation matrix and stores it in a given matrix
  74693. * @param x defines the translation on X axis
  74694. * @param y defines the translation on Y axis
  74695. * @param z defines the translationon Z axis
  74696. * @param result defines the target matrix
  74697. */
  74698. Matrix.TranslationToRef = function (x, y, z, result) {
  74699. 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);
  74700. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  74701. };
  74702. /**
  74703. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74704. * @param startValue defines the start value
  74705. * @param endValue defines the end value
  74706. * @param gradient defines the gradient factor
  74707. * @returns the new matrix
  74708. */
  74709. Matrix.Lerp = function (startValue, endValue, gradient) {
  74710. var result = new Matrix();
  74711. Matrix.LerpToRef(startValue, endValue, gradient, result);
  74712. return result;
  74713. };
  74714. /**
  74715. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74716. * @param startValue defines the start value
  74717. * @param endValue defines the end value
  74718. * @param gradient defines the gradient factor
  74719. * @param result defines the Matrix object where to store data
  74720. */
  74721. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  74722. var resultM = result._m;
  74723. var startM = startValue.m;
  74724. var endM = endValue.m;
  74725. for (var index = 0; index < 16; index++) {
  74726. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  74727. }
  74728. result._markAsUpdated();
  74729. };
  74730. /**
  74731. * Builds a new matrix whose values are computed by:
  74732. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74733. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74734. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74735. * @param startValue defines the first matrix
  74736. * @param endValue defines the second matrix
  74737. * @param gradient defines the gradient between the two matrices
  74738. * @returns the new matrix
  74739. */
  74740. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  74741. var result = new Matrix();
  74742. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  74743. return result;
  74744. };
  74745. /**
  74746. * Update a matrix to values which are computed by:
  74747. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74748. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74749. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74750. * @param startValue defines the first matrix
  74751. * @param endValue defines the second matrix
  74752. * @param gradient defines the gradient between the two matrices
  74753. * @param result defines the target matrix
  74754. */
  74755. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  74756. var startScale = MathTmp.Vector3[0];
  74757. var startRotation = MathTmp.Quaternion[0];
  74758. var startTranslation = MathTmp.Vector3[1];
  74759. startValue.decompose(startScale, startRotation, startTranslation);
  74760. var endScale = MathTmp.Vector3[2];
  74761. var endRotation = MathTmp.Quaternion[1];
  74762. var endTranslation = MathTmp.Vector3[3];
  74763. endValue.decompose(endScale, endRotation, endTranslation);
  74764. var resultScale = MathTmp.Vector3[4];
  74765. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  74766. var resultRotation = MathTmp.Quaternion[2];
  74767. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  74768. var resultTranslation = MathTmp.Vector3[5];
  74769. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  74770. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  74771. };
  74772. /**
  74773. * 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"
  74774. * This function works in left handed mode
  74775. * @param eye defines the final position of the entity
  74776. * @param target defines where the entity should look at
  74777. * @param up defines the up vector for the entity
  74778. * @returns the new matrix
  74779. */
  74780. Matrix.LookAtLH = function (eye, target, up) {
  74781. var result = new Matrix();
  74782. Matrix.LookAtLHToRef(eye, target, up, result);
  74783. return result;
  74784. };
  74785. /**
  74786. * 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".
  74787. * This function works in left handed mode
  74788. * @param eye defines the final position of the entity
  74789. * @param target defines where the entity should look at
  74790. * @param up defines the up vector for the entity
  74791. * @param result defines the target matrix
  74792. */
  74793. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  74794. var xAxis = MathTmp.Vector3[0];
  74795. var yAxis = MathTmp.Vector3[1];
  74796. var zAxis = MathTmp.Vector3[2];
  74797. // Z axis
  74798. target.subtractToRef(eye, zAxis);
  74799. zAxis.normalize();
  74800. // X axis
  74801. Vector3.CrossToRef(up, zAxis, xAxis);
  74802. var xSquareLength = xAxis.lengthSquared();
  74803. if (xSquareLength === 0) {
  74804. xAxis.x = 1.0;
  74805. }
  74806. else {
  74807. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  74808. }
  74809. // Y axis
  74810. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  74811. yAxis.normalize();
  74812. // Eye angles
  74813. var ex = -Vector3.Dot(xAxis, eye);
  74814. var ey = -Vector3.Dot(yAxis, eye);
  74815. var ez = -Vector3.Dot(zAxis, eye);
  74816. 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);
  74817. };
  74818. /**
  74819. * 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"
  74820. * This function works in right handed mode
  74821. * @param eye defines the final position of the entity
  74822. * @param target defines where the entity should look at
  74823. * @param up defines the up vector for the entity
  74824. * @returns the new matrix
  74825. */
  74826. Matrix.LookAtRH = function (eye, target, up) {
  74827. var result = new Matrix();
  74828. Matrix.LookAtRHToRef(eye, target, up, result);
  74829. return result;
  74830. };
  74831. /**
  74832. * 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".
  74833. * This function works in right handed mode
  74834. * @param eye defines the final position of the entity
  74835. * @param target defines where the entity should look at
  74836. * @param up defines the up vector for the entity
  74837. * @param result defines the target matrix
  74838. */
  74839. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  74840. var xAxis = MathTmp.Vector3[0];
  74841. var yAxis = MathTmp.Vector3[1];
  74842. var zAxis = MathTmp.Vector3[2];
  74843. // Z axis
  74844. eye.subtractToRef(target, zAxis);
  74845. zAxis.normalize();
  74846. // X axis
  74847. Vector3.CrossToRef(up, zAxis, xAxis);
  74848. var xSquareLength = xAxis.lengthSquared();
  74849. if (xSquareLength === 0) {
  74850. xAxis.x = 1.0;
  74851. }
  74852. else {
  74853. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  74854. }
  74855. // Y axis
  74856. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  74857. yAxis.normalize();
  74858. // Eye angles
  74859. var ex = -Vector3.Dot(xAxis, eye);
  74860. var ey = -Vector3.Dot(yAxis, eye);
  74861. var ez = -Vector3.Dot(zAxis, eye);
  74862. 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);
  74863. };
  74864. /**
  74865. * Create a left-handed orthographic projection matrix
  74866. * @param width defines the viewport width
  74867. * @param height defines the viewport height
  74868. * @param znear defines the near clip plane
  74869. * @param zfar defines the far clip plane
  74870. * @returns a new matrix as a left-handed orthographic projection matrix
  74871. */
  74872. Matrix.OrthoLH = function (width, height, znear, zfar) {
  74873. var matrix = new Matrix();
  74874. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  74875. return matrix;
  74876. };
  74877. /**
  74878. * Store a left-handed orthographic projection to a given matrix
  74879. * @param width defines the viewport width
  74880. * @param height defines the viewport height
  74881. * @param znear defines the near clip plane
  74882. * @param zfar defines the far clip plane
  74883. * @param result defines the target matrix
  74884. */
  74885. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  74886. var n = znear;
  74887. var f = zfar;
  74888. var a = 2.0 / width;
  74889. var b = 2.0 / height;
  74890. var c = 2.0 / (f - n);
  74891. var d = -(f + n) / (f - n);
  74892. 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);
  74893. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  74894. };
  74895. /**
  74896. * Create a left-handed orthographic projection matrix
  74897. * @param left defines the viewport left coordinate
  74898. * @param right defines the viewport right coordinate
  74899. * @param bottom defines the viewport bottom coordinate
  74900. * @param top defines the viewport top coordinate
  74901. * @param znear defines the near clip plane
  74902. * @param zfar defines the far clip plane
  74903. * @returns a new matrix as a left-handed orthographic projection matrix
  74904. */
  74905. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  74906. var matrix = new Matrix();
  74907. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  74908. return matrix;
  74909. };
  74910. /**
  74911. * Stores a left-handed orthographic projection into a given matrix
  74912. * @param left defines the viewport left coordinate
  74913. * @param right defines the viewport right coordinate
  74914. * @param bottom defines the viewport bottom coordinate
  74915. * @param top defines the viewport top coordinate
  74916. * @param znear defines the near clip plane
  74917. * @param zfar defines the far clip plane
  74918. * @param result defines the target matrix
  74919. */
  74920. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  74921. var n = znear;
  74922. var f = zfar;
  74923. var a = 2.0 / (right - left);
  74924. var b = 2.0 / (top - bottom);
  74925. var c = 2.0 / (f - n);
  74926. var d = -(f + n) / (f - n);
  74927. var i0 = (left + right) / (left - right);
  74928. var i1 = (top + bottom) / (bottom - top);
  74929. 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);
  74930. result._markAsUpdated();
  74931. };
  74932. /**
  74933. * Creates a right-handed orthographic projection matrix
  74934. * @param left defines the viewport left coordinate
  74935. * @param right defines the viewport right coordinate
  74936. * @param bottom defines the viewport bottom coordinate
  74937. * @param top defines the viewport top coordinate
  74938. * @param znear defines the near clip plane
  74939. * @param zfar defines the far clip plane
  74940. * @returns a new matrix as a right-handed orthographic projection matrix
  74941. */
  74942. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  74943. var matrix = new Matrix();
  74944. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  74945. return matrix;
  74946. };
  74947. /**
  74948. * Stores a right-handed orthographic projection into a given matrix
  74949. * @param left defines the viewport left coordinate
  74950. * @param right defines the viewport right coordinate
  74951. * @param bottom defines the viewport bottom coordinate
  74952. * @param top defines the viewport top coordinate
  74953. * @param znear defines the near clip plane
  74954. * @param zfar defines the far clip plane
  74955. * @param result defines the target matrix
  74956. */
  74957. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  74958. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  74959. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  74960. };
  74961. /**
  74962. * Creates a left-handed perspective projection matrix
  74963. * @param width defines the viewport width
  74964. * @param height defines the viewport height
  74965. * @param znear defines the near clip plane
  74966. * @param zfar defines the far clip plane
  74967. * @returns a new matrix as a left-handed perspective projection matrix
  74968. */
  74969. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  74970. var matrix = new Matrix();
  74971. var n = znear;
  74972. var f = zfar;
  74973. var a = 2.0 * n / width;
  74974. var b = 2.0 * n / height;
  74975. var c = (f + n) / (f - n);
  74976. var d = -2.0 * f * n / (f - n);
  74977. 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);
  74978. matrix._updateIdentityStatus(false);
  74979. return matrix;
  74980. };
  74981. /**
  74982. * Creates a left-handed perspective projection matrix
  74983. * @param fov defines the horizontal field of view
  74984. * @param aspect defines the aspect ratio
  74985. * @param znear defines the near clip plane
  74986. * @param zfar defines the far clip plane
  74987. * @returns a new matrix as a left-handed perspective projection matrix
  74988. */
  74989. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  74990. var matrix = new Matrix();
  74991. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  74992. return matrix;
  74993. };
  74994. /**
  74995. * Stores a left-handed perspective projection into a given matrix
  74996. * @param fov defines the horizontal field of view
  74997. * @param aspect defines the aspect ratio
  74998. * @param znear defines the near clip plane
  74999. * @param zfar defines the far clip plane
  75000. * @param result defines the target matrix
  75001. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75002. */
  75003. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  75004. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  75005. var n = znear;
  75006. var f = zfar;
  75007. var t = 1.0 / (Math.tan(fov * 0.5));
  75008. var a = isVerticalFovFixed ? (t / aspect) : t;
  75009. var b = isVerticalFovFixed ? t : (t * aspect);
  75010. var c = (f + n) / (f - n);
  75011. var d = -2.0 * f * n / (f - n);
  75012. 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);
  75013. result._updateIdentityStatus(false);
  75014. };
  75015. /**
  75016. * Creates a right-handed perspective projection matrix
  75017. * @param fov defines the horizontal field of view
  75018. * @param aspect defines the aspect ratio
  75019. * @param znear defines the near clip plane
  75020. * @param zfar defines the far clip plane
  75021. * @returns a new matrix as a right-handed perspective projection matrix
  75022. */
  75023. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  75024. var matrix = new Matrix();
  75025. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  75026. return matrix;
  75027. };
  75028. /**
  75029. * Stores a right-handed perspective projection into a given matrix
  75030. * @param fov defines the horizontal field of view
  75031. * @param aspect defines the aspect ratio
  75032. * @param znear defines the near clip plane
  75033. * @param zfar defines the far clip plane
  75034. * @param result defines the target matrix
  75035. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75036. */
  75037. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  75038. //alternatively this could be expressed as:
  75039. // m = PerspectiveFovLHToRef
  75040. // m[10] *= -1.0;
  75041. // m[11] *= -1.0;
  75042. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  75043. var n = znear;
  75044. var f = zfar;
  75045. var t = 1.0 / (Math.tan(fov * 0.5));
  75046. var a = isVerticalFovFixed ? (t / aspect) : t;
  75047. var b = isVerticalFovFixed ? t : (t * aspect);
  75048. var c = -(f + n) / (f - n);
  75049. var d = -2 * f * n / (f - n);
  75050. 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);
  75051. result._updateIdentityStatus(false);
  75052. };
  75053. /**
  75054. * Stores a perspective projection for WebVR info a given matrix
  75055. * @param fov defines the field of view
  75056. * @param znear defines the near clip plane
  75057. * @param zfar defines the far clip plane
  75058. * @param result defines the target matrix
  75059. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75060. */
  75061. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  75062. if (rightHanded === void 0) { rightHanded = false; }
  75063. var rightHandedFactor = rightHanded ? -1 : 1;
  75064. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  75065. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  75066. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  75067. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  75068. var xScale = 2.0 / (leftTan + rightTan);
  75069. var yScale = 2.0 / (upTan + downTan);
  75070. var m = result._m;
  75071. m[0] = xScale;
  75072. m[1] = m[2] = m[3] = m[4] = 0.0;
  75073. m[5] = yScale;
  75074. m[6] = m[7] = 0.0;
  75075. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  75076. m[9] = -((upTan - downTan) * yScale * 0.5);
  75077. m[10] = -zfar / (znear - zfar);
  75078. m[11] = 1.0 * rightHandedFactor;
  75079. m[12] = m[13] = m[15] = 0.0;
  75080. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  75081. result._markAsUpdated();
  75082. };
  75083. /**
  75084. * Computes a complete transformation matrix
  75085. * @param viewport defines the viewport to use
  75086. * @param world defines the world matrix
  75087. * @param view defines the view matrix
  75088. * @param projection defines the projection matrix
  75089. * @param zmin defines the near clip plane
  75090. * @param zmax defines the far clip plane
  75091. * @returns the transformation matrix
  75092. */
  75093. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  75094. var cw = viewport.width;
  75095. var ch = viewport.height;
  75096. var cx = viewport.x;
  75097. var cy = viewport.y;
  75098. 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);
  75099. var matrix = MathTmp.Matrix[0];
  75100. world.multiplyToRef(view, matrix);
  75101. matrix.multiplyToRef(projection, matrix);
  75102. return matrix.multiply(viewportMatrix);
  75103. };
  75104. /**
  75105. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75106. * @param matrix defines the matrix to use
  75107. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75108. */
  75109. Matrix.GetAsMatrix2x2 = function (matrix) {
  75110. var m = matrix.m;
  75111. return new Float32Array([m[0], m[1], m[4], m[5]]);
  75112. };
  75113. /**
  75114. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75115. * @param matrix defines the matrix to use
  75116. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75117. */
  75118. Matrix.GetAsMatrix3x3 = function (matrix) {
  75119. var m = matrix.m;
  75120. return new Float32Array([
  75121. m[0], m[1], m[2],
  75122. m[4], m[5], m[6],
  75123. m[8], m[9], m[10]
  75124. ]);
  75125. };
  75126. /**
  75127. * Compute the transpose of a given matrix
  75128. * @param matrix defines the matrix to transpose
  75129. * @returns the new matrix
  75130. */
  75131. Matrix.Transpose = function (matrix) {
  75132. var result = new Matrix();
  75133. Matrix.TransposeToRef(matrix, result);
  75134. return result;
  75135. };
  75136. /**
  75137. * Compute the transpose of a matrix and store it in a target matrix
  75138. * @param matrix defines the matrix to transpose
  75139. * @param result defines the target matrix
  75140. */
  75141. Matrix.TransposeToRef = function (matrix, result) {
  75142. var rm = result._m;
  75143. var mm = matrix.m;
  75144. rm[0] = mm[0];
  75145. rm[1] = mm[4];
  75146. rm[2] = mm[8];
  75147. rm[3] = mm[12];
  75148. rm[4] = mm[1];
  75149. rm[5] = mm[5];
  75150. rm[6] = mm[9];
  75151. rm[7] = mm[13];
  75152. rm[8] = mm[2];
  75153. rm[9] = mm[6];
  75154. rm[10] = mm[10];
  75155. rm[11] = mm[14];
  75156. rm[12] = mm[3];
  75157. rm[13] = mm[7];
  75158. rm[14] = mm[11];
  75159. rm[15] = mm[15];
  75160. // identity-ness does not change when transposing
  75161. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  75162. };
  75163. /**
  75164. * Computes a reflection matrix from a plane
  75165. * @param plane defines the reflection plane
  75166. * @returns a new matrix
  75167. */
  75168. Matrix.Reflection = function (plane) {
  75169. var matrix = new Matrix();
  75170. Matrix.ReflectionToRef(plane, matrix);
  75171. return matrix;
  75172. };
  75173. /**
  75174. * Computes a reflection matrix from a plane
  75175. * @param plane defines the reflection plane
  75176. * @param result defines the target matrix
  75177. */
  75178. Matrix.ReflectionToRef = function (plane, result) {
  75179. plane.normalize();
  75180. var x = plane.normal.x;
  75181. var y = plane.normal.y;
  75182. var z = plane.normal.z;
  75183. var temp = -2 * x;
  75184. var temp2 = -2 * y;
  75185. var temp3 = -2 * z;
  75186. 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);
  75187. };
  75188. /**
  75189. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75190. * @param xaxis defines the value of the 1st axis
  75191. * @param yaxis defines the value of the 2nd axis
  75192. * @param zaxis defines the value of the 3rd axis
  75193. * @param result defines the target matrix
  75194. */
  75195. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  75196. 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);
  75197. };
  75198. /**
  75199. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75200. * @param quat defines the quaternion to use
  75201. * @param result defines the target matrix
  75202. */
  75203. Matrix.FromQuaternionToRef = function (quat, result) {
  75204. var xx = quat.x * quat.x;
  75205. var yy = quat.y * quat.y;
  75206. var zz = quat.z * quat.z;
  75207. var xy = quat.x * quat.y;
  75208. var zw = quat.z * quat.w;
  75209. var zx = quat.z * quat.x;
  75210. var yw = quat.y * quat.w;
  75211. var yz = quat.y * quat.z;
  75212. var xw = quat.x * quat.w;
  75213. result._m[0] = 1.0 - (2.0 * (yy + zz));
  75214. result._m[1] = 2.0 * (xy + zw);
  75215. result._m[2] = 2.0 * (zx - yw);
  75216. result._m[3] = 0.0;
  75217. result._m[4] = 2.0 * (xy - zw);
  75218. result._m[5] = 1.0 - (2.0 * (zz + xx));
  75219. result._m[6] = 2.0 * (yz + xw);
  75220. result._m[7] = 0.0;
  75221. result._m[8] = 2.0 * (zx + yw);
  75222. result._m[9] = 2.0 * (yz - xw);
  75223. result._m[10] = 1.0 - (2.0 * (yy + xx));
  75224. result._m[11] = 0.0;
  75225. result._m[12] = 0.0;
  75226. result._m[13] = 0.0;
  75227. result._m[14] = 0.0;
  75228. result._m[15] = 1.0;
  75229. result._markAsUpdated();
  75230. };
  75231. Matrix._updateFlagSeed = 0;
  75232. Matrix._identityReadOnly = Matrix.Identity();
  75233. return Matrix;
  75234. }());
  75235. /**
  75236. * Represens a plane by the equation ax + by + cz + d = 0
  75237. */
  75238. var Plane = /** @class */ (function () {
  75239. /**
  75240. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75241. * @param a a component of the plane
  75242. * @param b b component of the plane
  75243. * @param c c component of the plane
  75244. * @param d d component of the plane
  75245. */
  75246. function Plane(a, b, c, d) {
  75247. this.normal = new Vector3(a, b, c);
  75248. this.d = d;
  75249. }
  75250. /**
  75251. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75252. */
  75253. Plane.prototype.asArray = function () {
  75254. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  75255. };
  75256. // Methods
  75257. /**
  75258. * @returns a new plane copied from the current Plane.
  75259. */
  75260. Plane.prototype.clone = function () {
  75261. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  75262. };
  75263. /**
  75264. * @returns the string "Plane".
  75265. */
  75266. Plane.prototype.getClassName = function () {
  75267. return "Plane";
  75268. };
  75269. /**
  75270. * @returns the Plane hash code.
  75271. */
  75272. Plane.prototype.getHashCode = function () {
  75273. var hash = this.normal.getHashCode();
  75274. hash = (hash * 397) ^ (this.d || 0);
  75275. return hash;
  75276. };
  75277. /**
  75278. * Normalize the current Plane in place.
  75279. * @returns the updated Plane.
  75280. */
  75281. Plane.prototype.normalize = function () {
  75282. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  75283. var magnitude = 0.0;
  75284. if (norm !== 0) {
  75285. magnitude = 1.0 / norm;
  75286. }
  75287. this.normal.x *= magnitude;
  75288. this.normal.y *= magnitude;
  75289. this.normal.z *= magnitude;
  75290. this.d *= magnitude;
  75291. return this;
  75292. };
  75293. /**
  75294. * Applies a transformation the plane and returns the result
  75295. * @param transformation the transformation matrix to be applied to the plane
  75296. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75297. */
  75298. Plane.prototype.transform = function (transformation) {
  75299. var transposedMatrix = MathTmp.Matrix[0];
  75300. Matrix.TransposeToRef(transformation, transposedMatrix);
  75301. var m = transposedMatrix.m;
  75302. var x = this.normal.x;
  75303. var y = this.normal.y;
  75304. var z = this.normal.z;
  75305. var d = this.d;
  75306. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  75307. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  75308. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  75309. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  75310. return new Plane(normalX, normalY, normalZ, finalD);
  75311. };
  75312. /**
  75313. * Calcualtte the dot product between the point and the plane normal
  75314. * @param point point to calculate the dot product with
  75315. * @returns the dot product (float) of the point coordinates and the plane normal.
  75316. */
  75317. Plane.prototype.dotCoordinate = function (point) {
  75318. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  75319. };
  75320. /**
  75321. * Updates the current Plane from the plane defined by the three given points.
  75322. * @param point1 one of the points used to contruct the plane
  75323. * @param point2 one of the points used to contruct the plane
  75324. * @param point3 one of the points used to contruct the plane
  75325. * @returns the updated Plane.
  75326. */
  75327. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  75328. var x1 = point2.x - point1.x;
  75329. var y1 = point2.y - point1.y;
  75330. var z1 = point2.z - point1.z;
  75331. var x2 = point3.x - point1.x;
  75332. var y2 = point3.y - point1.y;
  75333. var z2 = point3.z - point1.z;
  75334. var yz = (y1 * z2) - (z1 * y2);
  75335. var xz = (z1 * x2) - (x1 * z2);
  75336. var xy = (x1 * y2) - (y1 * x2);
  75337. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  75338. var invPyth;
  75339. if (pyth !== 0) {
  75340. invPyth = 1.0 / pyth;
  75341. }
  75342. else {
  75343. invPyth = 0.0;
  75344. }
  75345. this.normal.x = yz * invPyth;
  75346. this.normal.y = xz * invPyth;
  75347. this.normal.z = xy * invPyth;
  75348. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  75349. return this;
  75350. };
  75351. /**
  75352. * Checks if the plane is facing a given direction
  75353. * @param direction the direction to check if the plane is facing
  75354. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75355. * @returns True is the vector "direction" is the same side than the plane normal.
  75356. */
  75357. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  75358. var dot = Vector3.Dot(this.normal, direction);
  75359. return (dot <= epsilon);
  75360. };
  75361. /**
  75362. * Calculates the distance to a point
  75363. * @param point point to calculate distance to
  75364. * @returns the signed distance (float) from the given point to the Plane.
  75365. */
  75366. Plane.prototype.signedDistanceTo = function (point) {
  75367. return Vector3.Dot(point, this.normal) + this.d;
  75368. };
  75369. // Statics
  75370. /**
  75371. * Creates a plane from an array
  75372. * @param array the array to create a plane from
  75373. * @returns a new Plane from the given array.
  75374. */
  75375. Plane.FromArray = function (array) {
  75376. return new Plane(array[0], array[1], array[2], array[3]);
  75377. };
  75378. /**
  75379. * Creates a plane from three points
  75380. * @param point1 point used to create the plane
  75381. * @param point2 point used to create the plane
  75382. * @param point3 point used to create the plane
  75383. * @returns a new Plane defined by the three given points.
  75384. */
  75385. Plane.FromPoints = function (point1, point2, point3) {
  75386. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  75387. result.copyFromPoints(point1, point2, point3);
  75388. return result;
  75389. };
  75390. /**
  75391. * Creates a plane from an origin point and a normal
  75392. * @param origin origin of the plane to be constructed
  75393. * @param normal normal of the plane to be constructed
  75394. * @returns a new Plane the normal vector to this plane at the given origin point.
  75395. * Note : the vector "normal" is updated because normalized.
  75396. */
  75397. Plane.FromPositionAndNormal = function (origin, normal) {
  75398. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  75399. normal.normalize();
  75400. result.normal = normal;
  75401. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  75402. return result;
  75403. };
  75404. /**
  75405. * Calculates the distance from a plane and a point
  75406. * @param origin origin of the plane to be constructed
  75407. * @param normal normal of the plane to be constructed
  75408. * @param point point to calculate distance to
  75409. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75410. */
  75411. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  75412. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  75413. return Vector3.Dot(point, normal) + d;
  75414. };
  75415. return Plane;
  75416. }());
  75417. /**
  75418. * Class used to represent a viewport on screen
  75419. */
  75420. var Viewport = /** @class */ (function () {
  75421. /**
  75422. * Creates a Viewport object located at (x, y) and sized (width, height)
  75423. * @param x defines viewport left coordinate
  75424. * @param y defines viewport top coordinate
  75425. * @param width defines the viewport width
  75426. * @param height defines the viewport height
  75427. */
  75428. function Viewport(
  75429. /** viewport left coordinate */
  75430. x,
  75431. /** viewport top coordinate */
  75432. y,
  75433. /**viewport width */
  75434. width,
  75435. /** viewport height */
  75436. height) {
  75437. this.x = x;
  75438. this.y = y;
  75439. this.width = width;
  75440. this.height = height;
  75441. }
  75442. /**
  75443. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75444. * @param renderWidth defines the rendering width
  75445. * @param renderHeight defines the rendering height
  75446. * @returns a new Viewport
  75447. */
  75448. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  75449. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  75450. };
  75451. /**
  75452. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75453. * @param renderWidth defines the rendering width
  75454. * @param renderHeight defines the rendering height
  75455. * @param ref defines the target viewport
  75456. * @returns the current viewport
  75457. */
  75458. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  75459. ref.x = this.x * renderWidth;
  75460. ref.y = this.y * renderHeight;
  75461. ref.width = this.width * renderWidth;
  75462. ref.height = this.height * renderHeight;
  75463. return this;
  75464. };
  75465. /**
  75466. * Returns a new Viewport copied from the current one
  75467. * @returns a new Viewport
  75468. */
  75469. Viewport.prototype.clone = function () {
  75470. return new Viewport(this.x, this.y, this.width, this.height);
  75471. };
  75472. return Viewport;
  75473. }());
  75474. /**
  75475. * Reprasents a camera frustum
  75476. */
  75477. var Frustum = /** @class */ (function () {
  75478. function Frustum() {
  75479. }
  75480. /**
  75481. * Gets the planes representing the frustum
  75482. * @param transform matrix to be applied to the returned planes
  75483. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  75484. */
  75485. Frustum.GetPlanes = function (transform) {
  75486. var frustumPlanes = [];
  75487. for (var index = 0; index < 6; index++) {
  75488. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  75489. }
  75490. Frustum.GetPlanesToRef(transform, frustumPlanes);
  75491. return frustumPlanes;
  75492. };
  75493. /**
  75494. * Gets the near frustum plane transformed by the transform matrix
  75495. * @param transform transformation matrix to be applied to the resulting frustum plane
  75496. * @param frustumPlane the resuling frustum plane
  75497. */
  75498. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  75499. var m = transform.m;
  75500. frustumPlane.normal.x = m[3] + m[2];
  75501. frustumPlane.normal.y = m[7] + m[6];
  75502. frustumPlane.normal.z = m[11] + m[10];
  75503. frustumPlane.d = m[15] + m[14];
  75504. frustumPlane.normalize();
  75505. };
  75506. /**
  75507. * Gets the far frustum plane transformed by the transform matrix
  75508. * @param transform transformation matrix to be applied to the resulting frustum plane
  75509. * @param frustumPlane the resuling frustum plane
  75510. */
  75511. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  75512. var m = transform.m;
  75513. frustumPlane.normal.x = m[3] - m[2];
  75514. frustumPlane.normal.y = m[7] - m[6];
  75515. frustumPlane.normal.z = m[11] - m[10];
  75516. frustumPlane.d = m[15] - m[14];
  75517. frustumPlane.normalize();
  75518. };
  75519. /**
  75520. * Gets the left frustum plane transformed by the transform matrix
  75521. * @param transform transformation matrix to be applied to the resulting frustum plane
  75522. * @param frustumPlane the resuling frustum plane
  75523. */
  75524. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  75525. var m = transform.m;
  75526. frustumPlane.normal.x = m[3] + m[0];
  75527. frustumPlane.normal.y = m[7] + m[4];
  75528. frustumPlane.normal.z = m[11] + m[8];
  75529. frustumPlane.d = m[15] + m[12];
  75530. frustumPlane.normalize();
  75531. };
  75532. /**
  75533. * Gets the right frustum plane transformed by the transform matrix
  75534. * @param transform transformation matrix to be applied to the resulting frustum plane
  75535. * @param frustumPlane the resuling frustum plane
  75536. */
  75537. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  75538. var m = transform.m;
  75539. frustumPlane.normal.x = m[3] - m[0];
  75540. frustumPlane.normal.y = m[7] - m[4];
  75541. frustumPlane.normal.z = m[11] - m[8];
  75542. frustumPlane.d = m[15] - m[12];
  75543. frustumPlane.normalize();
  75544. };
  75545. /**
  75546. * Gets the top frustum plane transformed by the transform matrix
  75547. * @param transform transformation matrix to be applied to the resulting frustum plane
  75548. * @param frustumPlane the resuling frustum plane
  75549. */
  75550. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  75551. var m = transform.m;
  75552. frustumPlane.normal.x = m[3] - m[1];
  75553. frustumPlane.normal.y = m[7] - m[5];
  75554. frustumPlane.normal.z = m[11] - m[9];
  75555. frustumPlane.d = m[15] - m[13];
  75556. frustumPlane.normalize();
  75557. };
  75558. /**
  75559. * Gets the bottom frustum plane transformed by the transform matrix
  75560. * @param transform transformation matrix to be applied to the resulting frustum plane
  75561. * @param frustumPlane the resuling frustum plane
  75562. */
  75563. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  75564. var m = transform.m;
  75565. frustumPlane.normal.x = m[3] + m[1];
  75566. frustumPlane.normal.y = m[7] + m[5];
  75567. frustumPlane.normal.z = m[11] + m[9];
  75568. frustumPlane.d = m[15] + m[13];
  75569. frustumPlane.normalize();
  75570. };
  75571. /**
  75572. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  75573. * @param transform transformation matrix to be applied to the resulting frustum planes
  75574. * @param frustumPlanes the resuling frustum planes
  75575. */
  75576. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  75577. // Near
  75578. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  75579. // Far
  75580. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  75581. // Left
  75582. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  75583. // Right
  75584. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  75585. // Top
  75586. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  75587. // Bottom
  75588. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  75589. };
  75590. return Frustum;
  75591. }());
  75592. /** Defines supported spaces */
  75593. var Space;
  75594. (function (Space) {
  75595. /** Local (object) space */
  75596. Space[Space["LOCAL"] = 0] = "LOCAL";
  75597. /** World space */
  75598. Space[Space["WORLD"] = 1] = "WORLD";
  75599. /** Bone space */
  75600. Space[Space["BONE"] = 2] = "BONE";
  75601. })(Space || (Space = {}));
  75602. /** Defines the 3 main axes */
  75603. var Axis = /** @class */ (function () {
  75604. function Axis() {
  75605. }
  75606. /** X axis */
  75607. Axis.X = new Vector3(1.0, 0.0, 0.0);
  75608. /** Y axis */
  75609. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  75610. /** Z axis */
  75611. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  75612. return Axis;
  75613. }());
  75614. /** Class used to represent a Bezier curve */
  75615. var BezierCurve = /** @class */ (function () {
  75616. function BezierCurve() {
  75617. }
  75618. /**
  75619. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75620. * @param t defines the time
  75621. * @param x1 defines the left coordinate on X axis
  75622. * @param y1 defines the left coordinate on Y axis
  75623. * @param x2 defines the right coordinate on X axis
  75624. * @param y2 defines the right coordinate on Y axis
  75625. * @returns the interpolated value
  75626. */
  75627. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  75628. // Extract X (which is equal to time here)
  75629. var f0 = 1 - 3 * x2 + 3 * x1;
  75630. var f1 = 3 * x2 - 6 * x1;
  75631. var f2 = 3 * x1;
  75632. var refinedT = t;
  75633. for (var i = 0; i < 5; i++) {
  75634. var refinedT2 = refinedT * refinedT;
  75635. var refinedT3 = refinedT2 * refinedT;
  75636. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  75637. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  75638. refinedT -= (x - t) * slope;
  75639. refinedT = Math.min(1, Math.max(0, refinedT));
  75640. }
  75641. // Resolve cubic bezier for the given x
  75642. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  75643. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  75644. Math.pow(refinedT, 3);
  75645. };
  75646. return BezierCurve;
  75647. }());
  75648. /**
  75649. * Defines potential orientation for back face culling
  75650. */
  75651. var Orientation;
  75652. (function (Orientation) {
  75653. /**
  75654. * Clockwise
  75655. */
  75656. Orientation[Orientation["CW"] = 0] = "CW";
  75657. /** Counter clockwise */
  75658. Orientation[Orientation["CCW"] = 1] = "CCW";
  75659. })(Orientation || (Orientation = {}));
  75660. /**
  75661. * Defines angle representation
  75662. */
  75663. var Angle = /** @class */ (function () {
  75664. /**
  75665. * Creates an Angle object of "radians" radians (float).
  75666. * @param radians the angle in radians
  75667. */
  75668. function Angle(radians) {
  75669. this._radians = radians;
  75670. if (this._radians < 0.0) {
  75671. this._radians += (2.0 * Math.PI);
  75672. }
  75673. }
  75674. /**
  75675. * Get value in degrees
  75676. * @returns the Angle value in degrees (float)
  75677. */
  75678. Angle.prototype.degrees = function () {
  75679. return this._radians * 180.0 / Math.PI;
  75680. };
  75681. /**
  75682. * Get value in radians
  75683. * @returns the Angle value in radians (float)
  75684. */
  75685. Angle.prototype.radians = function () {
  75686. return this._radians;
  75687. };
  75688. /**
  75689. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75690. * @param a defines first vector
  75691. * @param b defines second vector
  75692. * @returns a new Angle
  75693. */
  75694. Angle.BetweenTwoPoints = function (a, b) {
  75695. var delta = b.subtract(a);
  75696. var theta = Math.atan2(delta.y, delta.x);
  75697. return new Angle(theta);
  75698. };
  75699. /**
  75700. * Gets a new Angle object from the given float in radians
  75701. * @param radians defines the angle value in radians
  75702. * @returns a new Angle
  75703. */
  75704. Angle.FromRadians = function (radians) {
  75705. return new Angle(radians);
  75706. };
  75707. /**
  75708. * Gets a new Angle object from the given float in degrees
  75709. * @param degrees defines the angle value in degrees
  75710. * @returns a new Angle
  75711. */
  75712. Angle.FromDegrees = function (degrees) {
  75713. return new Angle(degrees * Math.PI / 180.0);
  75714. };
  75715. return Angle;
  75716. }());
  75717. /**
  75718. * This represents an arc in a 2d space.
  75719. */
  75720. var Arc2 = /** @class */ (function () {
  75721. /**
  75722. * Creates an Arc object from the three given points : start, middle and end.
  75723. * @param startPoint Defines the start point of the arc
  75724. * @param midPoint Defines the midlle point of the arc
  75725. * @param endPoint Defines the end point of the arc
  75726. */
  75727. function Arc2(
  75728. /** Defines the start point of the arc */
  75729. startPoint,
  75730. /** Defines the mid point of the arc */
  75731. midPoint,
  75732. /** Defines the end point of the arc */
  75733. endPoint) {
  75734. this.startPoint = startPoint;
  75735. this.midPoint = midPoint;
  75736. this.endPoint = endPoint;
  75737. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  75738. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  75739. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  75740. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  75741. 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);
  75742. this.radius = this.centerPoint.subtract(this.startPoint).length();
  75743. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  75744. var a1 = this.startAngle.degrees();
  75745. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  75746. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  75747. // angles correction
  75748. if (a2 - a1 > +180.0) {
  75749. a2 -= 360.0;
  75750. }
  75751. if (a2 - a1 < -180.0) {
  75752. a2 += 360.0;
  75753. }
  75754. if (a3 - a2 > +180.0) {
  75755. a3 -= 360.0;
  75756. }
  75757. if (a3 - a2 < -180.0) {
  75758. a3 += 360.0;
  75759. }
  75760. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  75761. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  75762. }
  75763. return Arc2;
  75764. }());
  75765. /**
  75766. * Represents a 2D path made up of multiple 2D points
  75767. */
  75768. var Path2 = /** @class */ (function () {
  75769. /**
  75770. * Creates a Path2 object from the starting 2D coordinates x and y.
  75771. * @param x the starting points x value
  75772. * @param y the starting points y value
  75773. */
  75774. function Path2(x, y) {
  75775. this._points = new Array();
  75776. this._length = 0.0;
  75777. /**
  75778. * If the path start and end point are the same
  75779. */
  75780. this.closed = false;
  75781. this._points.push(new Vector2(x, y));
  75782. }
  75783. /**
  75784. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75785. * @param x the added points x value
  75786. * @param y the added points y value
  75787. * @returns the updated Path2.
  75788. */
  75789. Path2.prototype.addLineTo = function (x, y) {
  75790. if (this.closed) {
  75791. return this;
  75792. }
  75793. var newPoint = new Vector2(x, y);
  75794. var previousPoint = this._points[this._points.length - 1];
  75795. this._points.push(newPoint);
  75796. this._length += newPoint.subtract(previousPoint).length();
  75797. return this;
  75798. };
  75799. /**
  75800. * 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.
  75801. * @param midX middle point x value
  75802. * @param midY middle point y value
  75803. * @param endX end point x value
  75804. * @param endY end point y value
  75805. * @param numberOfSegments (default: 36)
  75806. * @returns the updated Path2.
  75807. */
  75808. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  75809. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  75810. if (this.closed) {
  75811. return this;
  75812. }
  75813. var startPoint = this._points[this._points.length - 1];
  75814. var midPoint = new Vector2(midX, midY);
  75815. var endPoint = new Vector2(endX, endY);
  75816. var arc = new Arc2(startPoint, midPoint, endPoint);
  75817. var increment = arc.angle.radians() / numberOfSegments;
  75818. if (arc.orientation === Orientation.CW) {
  75819. increment *= -1;
  75820. }
  75821. var currentAngle = arc.startAngle.radians() + increment;
  75822. for (var i = 0; i < numberOfSegments; i++) {
  75823. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  75824. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  75825. this.addLineTo(x, y);
  75826. currentAngle += increment;
  75827. }
  75828. return this;
  75829. };
  75830. /**
  75831. * Closes the Path2.
  75832. * @returns the Path2.
  75833. */
  75834. Path2.prototype.close = function () {
  75835. this.closed = true;
  75836. return this;
  75837. };
  75838. /**
  75839. * Gets the sum of the distance between each sequential point in the path
  75840. * @returns the Path2 total length (float).
  75841. */
  75842. Path2.prototype.length = function () {
  75843. var result = this._length;
  75844. if (!this.closed) {
  75845. var lastPoint = this._points[this._points.length - 1];
  75846. var firstPoint = this._points[0];
  75847. result += (firstPoint.subtract(lastPoint).length());
  75848. }
  75849. return result;
  75850. };
  75851. /**
  75852. * Gets the points which construct the path
  75853. * @returns the Path2 internal array of points.
  75854. */
  75855. Path2.prototype.getPoints = function () {
  75856. return this._points;
  75857. };
  75858. /**
  75859. * Retreives the point at the distance aways from the starting point
  75860. * @param normalizedLengthPosition the length along the path to retreive the point from
  75861. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75862. */
  75863. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  75864. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  75865. return Vector2.Zero();
  75866. }
  75867. var lengthPosition = normalizedLengthPosition * this.length();
  75868. var previousOffset = 0;
  75869. for (var i = 0; i < this._points.length; i++) {
  75870. var j = (i + 1) % this._points.length;
  75871. var a = this._points[i];
  75872. var b = this._points[j];
  75873. var bToA = b.subtract(a);
  75874. var nextOffset = (bToA.length() + previousOffset);
  75875. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  75876. var dir = bToA.normalize();
  75877. var localOffset = lengthPosition - previousOffset;
  75878. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  75879. }
  75880. previousOffset = nextOffset;
  75881. }
  75882. return Vector2.Zero();
  75883. };
  75884. /**
  75885. * Creates a new path starting from an x and y position
  75886. * @param x starting x value
  75887. * @param y starting y value
  75888. * @returns a new Path2 starting at the coordinates (x, y).
  75889. */
  75890. Path2.StartingAt = function (x, y) {
  75891. return new Path2(x, y);
  75892. };
  75893. return Path2;
  75894. }());
  75895. /**
  75896. * Represents a 3D path made up of multiple 3D points
  75897. */
  75898. var Path3D = /** @class */ (function () {
  75899. /**
  75900. * new Path3D(path, normal, raw)
  75901. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75902. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75903. * @param path an array of Vector3, the curve axis of the Path3D
  75904. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75905. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75906. */
  75907. function Path3D(
  75908. /**
  75909. * an array of Vector3, the curve axis of the Path3D
  75910. */
  75911. path, firstNormal, raw) {
  75912. if (firstNormal === void 0) { firstNormal = null; }
  75913. this.path = path;
  75914. this._curve = new Array();
  75915. this._distances = new Array();
  75916. this._tangents = new Array();
  75917. this._normals = new Array();
  75918. this._binormals = new Array();
  75919. for (var p = 0; p < path.length; p++) {
  75920. this._curve[p] = path[p].clone(); // hard copy
  75921. }
  75922. this._raw = raw || false;
  75923. this._compute(firstNormal);
  75924. }
  75925. /**
  75926. * Returns the Path3D array of successive Vector3 designing its curve.
  75927. * @returns the Path3D array of successive Vector3 designing its curve.
  75928. */
  75929. Path3D.prototype.getCurve = function () {
  75930. return this._curve;
  75931. };
  75932. /**
  75933. * Returns an array populated with tangent vectors on each Path3D curve point.
  75934. * @returns an array populated with tangent vectors on each Path3D curve point.
  75935. */
  75936. Path3D.prototype.getTangents = function () {
  75937. return this._tangents;
  75938. };
  75939. /**
  75940. * Returns an array populated with normal vectors on each Path3D curve point.
  75941. * @returns an array populated with normal vectors on each Path3D curve point.
  75942. */
  75943. Path3D.prototype.getNormals = function () {
  75944. return this._normals;
  75945. };
  75946. /**
  75947. * Returns an array populated with binormal vectors on each Path3D curve point.
  75948. * @returns an array populated with binormal vectors on each Path3D curve point.
  75949. */
  75950. Path3D.prototype.getBinormals = function () {
  75951. return this._binormals;
  75952. };
  75953. /**
  75954. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75955. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75956. */
  75957. Path3D.prototype.getDistances = function () {
  75958. return this._distances;
  75959. };
  75960. /**
  75961. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75962. * @param path path which all values are copied into the curves points
  75963. * @param firstNormal which should be projected onto the curve
  75964. * @returns the same object updated.
  75965. */
  75966. Path3D.prototype.update = function (path, firstNormal) {
  75967. if (firstNormal === void 0) { firstNormal = null; }
  75968. for (var p = 0; p < path.length; p++) {
  75969. this._curve[p].x = path[p].x;
  75970. this._curve[p].y = path[p].y;
  75971. this._curve[p].z = path[p].z;
  75972. }
  75973. this._compute(firstNormal);
  75974. return this;
  75975. };
  75976. // private function compute() : computes tangents, normals and binormals
  75977. Path3D.prototype._compute = function (firstNormal) {
  75978. var l = this._curve.length;
  75979. // first and last tangents
  75980. this._tangents[0] = this._getFirstNonNullVector(0);
  75981. if (!this._raw) {
  75982. this._tangents[0].normalize();
  75983. }
  75984. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  75985. if (!this._raw) {
  75986. this._tangents[l - 1].normalize();
  75987. }
  75988. // normals and binormals at first point : arbitrary vector with _normalVector()
  75989. var tg0 = this._tangents[0];
  75990. var pp0 = this._normalVector(tg0, firstNormal);
  75991. this._normals[0] = pp0;
  75992. if (!this._raw) {
  75993. this._normals[0].normalize();
  75994. }
  75995. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  75996. if (!this._raw) {
  75997. this._binormals[0].normalize();
  75998. }
  75999. this._distances[0] = 0.0;
  76000. // normals and binormals : next points
  76001. var prev; // previous vector (segment)
  76002. var cur; // current vector (segment)
  76003. var curTang; // current tangent
  76004. // previous normal
  76005. var prevBinor; // previous binormal
  76006. for (var i = 1; i < l; i++) {
  76007. // tangents
  76008. prev = this._getLastNonNullVector(i);
  76009. if (i < l - 1) {
  76010. cur = this._getFirstNonNullVector(i);
  76011. this._tangents[i] = prev.add(cur);
  76012. this._tangents[i].normalize();
  76013. }
  76014. this._distances[i] = this._distances[i - 1] + prev.length();
  76015. // normals and binormals
  76016. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  76017. curTang = this._tangents[i];
  76018. prevBinor = this._binormals[i - 1];
  76019. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  76020. if (!this._raw) {
  76021. this._normals[i].normalize();
  76022. }
  76023. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  76024. if (!this._raw) {
  76025. this._binormals[i].normalize();
  76026. }
  76027. }
  76028. };
  76029. // private function getFirstNonNullVector(index)
  76030. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  76031. Path3D.prototype._getFirstNonNullVector = function (index) {
  76032. var i = 1;
  76033. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  76034. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  76035. i++;
  76036. nNVector = this._curve[index + i].subtract(this._curve[index]);
  76037. }
  76038. return nNVector;
  76039. };
  76040. // private function getLastNonNullVector(index)
  76041. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  76042. Path3D.prototype._getLastNonNullVector = function (index) {
  76043. var i = 1;
  76044. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  76045. while (nLVector.length() === 0 && index > i + 1) {
  76046. i++;
  76047. nLVector = this._curve[index].subtract(this._curve[index - i]);
  76048. }
  76049. return nLVector;
  76050. };
  76051. // private function normalVector(v0, vt, va) :
  76052. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  76053. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  76054. Path3D.prototype._normalVector = function (vt, va) {
  76055. var normal0;
  76056. var tgl = vt.length();
  76057. if (tgl === 0.0) {
  76058. tgl = 1.0;
  76059. }
  76060. if (va === undefined || va === null) {
  76061. var point;
  76062. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  76063. point = new Vector3(0.0, -1.0, 0.0);
  76064. }
  76065. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  76066. point = new Vector3(1.0, 0.0, 0.0);
  76067. }
  76068. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  76069. point = new Vector3(0.0, 0.0, 1.0);
  76070. }
  76071. else {
  76072. point = Vector3.Zero();
  76073. }
  76074. normal0 = Vector3.Cross(vt, point);
  76075. }
  76076. else {
  76077. normal0 = Vector3.Cross(vt, va);
  76078. Vector3.CrossToRef(normal0, vt, normal0);
  76079. }
  76080. normal0.normalize();
  76081. return normal0;
  76082. };
  76083. return Path3D;
  76084. }());
  76085. /**
  76086. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76087. * A Curve3 is designed from a series of successive Vector3.
  76088. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  76089. */
  76090. var Curve3 = /** @class */ (function () {
  76091. /**
  76092. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76093. * A Curve3 is designed from a series of successive Vector3.
  76094. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  76095. * @param points points which make up the curve
  76096. */
  76097. function Curve3(points) {
  76098. this._length = 0.0;
  76099. this._points = points;
  76100. this._length = this._computeLength(points);
  76101. }
  76102. /**
  76103. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  76104. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  76105. * @param v1 (Vector3) the control point
  76106. * @param v2 (Vector3) the end point of the Quadratic Bezier
  76107. * @param nbPoints (integer) the wanted number of points in the curve
  76108. * @returns the created Curve3
  76109. */
  76110. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  76111. nbPoints = nbPoints > 2 ? nbPoints : 3;
  76112. var bez = new Array();
  76113. var equation = function (t, val0, val1, val2) {
  76114. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  76115. return res;
  76116. };
  76117. for (var i = 0; i <= nbPoints; i++) {
  76118. 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)));
  76119. }
  76120. return new Curve3(bez);
  76121. };
  76122. /**
  76123. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  76124. * @param v0 (Vector3) the origin point of the Cubic Bezier
  76125. * @param v1 (Vector3) the first control point
  76126. * @param v2 (Vector3) the second control point
  76127. * @param v3 (Vector3) the end point of the Cubic Bezier
  76128. * @param nbPoints (integer) the wanted number of points in the curve
  76129. * @returns the created Curve3
  76130. */
  76131. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  76132. nbPoints = nbPoints > 3 ? nbPoints : 4;
  76133. var bez = new Array();
  76134. var equation = function (t, val0, val1, val2, val3) {
  76135. 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;
  76136. return res;
  76137. };
  76138. for (var i = 0; i <= nbPoints; i++) {
  76139. 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)));
  76140. }
  76141. return new Curve3(bez);
  76142. };
  76143. /**
  76144. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  76145. * @param p1 (Vector3) the origin point of the Hermite Spline
  76146. * @param t1 (Vector3) the tangent vector at the origin point
  76147. * @param p2 (Vector3) the end point of the Hermite Spline
  76148. * @param t2 (Vector3) the tangent vector at the end point
  76149. * @param nbPoints (integer) the wanted number of points in the curve
  76150. * @returns the created Curve3
  76151. */
  76152. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  76153. var hermite = new Array();
  76154. var step = 1.0 / nbPoints;
  76155. for (var i = 0; i <= nbPoints; i++) {
  76156. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  76157. }
  76158. return new Curve3(hermite);
  76159. };
  76160. /**
  76161. * Returns a Curve3 object along a CatmullRom Spline curve :
  76162. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  76163. * @param nbPoints (integer) the wanted number of points between each curve control points
  76164. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  76165. * @returns the created Curve3
  76166. */
  76167. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  76168. var catmullRom = new Array();
  76169. var step = 1.0 / nbPoints;
  76170. var amount = 0.0;
  76171. if (closed) {
  76172. var pointsCount = points.length;
  76173. for (var i = 0; i < pointsCount; i++) {
  76174. amount = 0;
  76175. for (var c = 0; c < nbPoints; c++) {
  76176. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  76177. amount += step;
  76178. }
  76179. }
  76180. catmullRom.push(catmullRom[0]);
  76181. }
  76182. else {
  76183. var totalPoints = new Array();
  76184. totalPoints.push(points[0].clone());
  76185. Array.prototype.push.apply(totalPoints, points);
  76186. totalPoints.push(points[points.length - 1].clone());
  76187. for (var i = 0; i < totalPoints.length - 3; i++) {
  76188. amount = 0;
  76189. for (var c = 0; c < nbPoints; c++) {
  76190. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  76191. amount += step;
  76192. }
  76193. }
  76194. i--;
  76195. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  76196. }
  76197. return new Curve3(catmullRom);
  76198. };
  76199. /**
  76200. * @returns the Curve3 stored array of successive Vector3
  76201. */
  76202. Curve3.prototype.getPoints = function () {
  76203. return this._points;
  76204. };
  76205. /**
  76206. * @returns the computed length (float) of the curve.
  76207. */
  76208. Curve3.prototype.length = function () {
  76209. return this._length;
  76210. };
  76211. /**
  76212. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  76213. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  76214. * curveA and curveB keep unchanged.
  76215. * @param curve the curve to continue from this curve
  76216. * @returns the newly constructed curve
  76217. */
  76218. Curve3.prototype.continue = function (curve) {
  76219. var lastPoint = this._points[this._points.length - 1];
  76220. var continuedPoints = this._points.slice();
  76221. var curvePoints = curve.getPoints();
  76222. for (var i = 1; i < curvePoints.length; i++) {
  76223. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  76224. }
  76225. var continuedCurve = new Curve3(continuedPoints);
  76226. return continuedCurve;
  76227. };
  76228. Curve3.prototype._computeLength = function (path) {
  76229. var l = 0;
  76230. for (var i = 1; i < path.length; i++) {
  76231. l += (path[i].subtract(path[i - 1])).length();
  76232. }
  76233. return l;
  76234. };
  76235. return Curve3;
  76236. }());
  76237. // Vertex formats
  76238. /**
  76239. * Contains position and normal vectors for a vertex
  76240. */
  76241. var PositionNormalVertex = /** @class */ (function () {
  76242. /**
  76243. * Creates a PositionNormalVertex
  76244. * @param position the position of the vertex (defaut: 0,0,0)
  76245. * @param normal the normal of the vertex (defaut: 0,1,0)
  76246. */
  76247. function PositionNormalVertex(
  76248. /** the position of the vertex (defaut: 0,0,0) */
  76249. position,
  76250. /** the normal of the vertex (defaut: 0,1,0) */
  76251. normal) {
  76252. if (position === void 0) { position = Vector3.Zero(); }
  76253. if (normal === void 0) { normal = Vector3.Up(); }
  76254. this.position = position;
  76255. this.normal = normal;
  76256. }
  76257. /**
  76258. * Clones the PositionNormalVertex
  76259. * @returns the cloned PositionNormalVertex
  76260. */
  76261. PositionNormalVertex.prototype.clone = function () {
  76262. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  76263. };
  76264. return PositionNormalVertex;
  76265. }());
  76266. /**
  76267. * Contains position, normal and uv vectors for a vertex
  76268. */
  76269. var PositionNormalTextureVertex = /** @class */ (function () {
  76270. /**
  76271. * Creates a PositionNormalTextureVertex
  76272. * @param position the position of the vertex (defaut: 0,0,0)
  76273. * @param normal the normal of the vertex (defaut: 0,1,0)
  76274. * @param uv the uv of the vertex (default: 0,0)
  76275. */
  76276. function PositionNormalTextureVertex(
  76277. /** the position of the vertex (defaut: 0,0,0) */
  76278. position,
  76279. /** the normal of the vertex (defaut: 0,1,0) */
  76280. normal,
  76281. /** the uv of the vertex (default: 0,0) */
  76282. uv) {
  76283. if (position === void 0) { position = Vector3.Zero(); }
  76284. if (normal === void 0) { normal = Vector3.Up(); }
  76285. if (uv === void 0) { uv = Vector2.Zero(); }
  76286. this.position = position;
  76287. this.normal = normal;
  76288. this.uv = uv;
  76289. }
  76290. /**
  76291. * Clones the PositionNormalTextureVertex
  76292. * @returns the cloned PositionNormalTextureVertex
  76293. */
  76294. PositionNormalTextureVertex.prototype.clone = function () {
  76295. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  76296. };
  76297. return PositionNormalTextureVertex;
  76298. }());
  76299. // Temporary pre-allocated objects for engine internal use
  76300. // usage in any internal function :
  76301. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  76302. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  76303. /**
  76304. * @hidden
  76305. */
  76306. var Tmp = /** @class */ (function () {
  76307. function Tmp() {
  76308. }
  76309. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  76310. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  76311. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  76312. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  76313. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  76314. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  76315. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  76316. return Tmp;
  76317. }());
  76318. /**
  76319. * @hidden
  76320. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  76321. */
  76322. var MathTmp = /** @class */ (function () {
  76323. function MathTmp() {
  76324. }
  76325. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  76326. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  76327. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  76328. return MathTmp;
  76329. }());
  76330. /***/ }),
  76331. /***/ "./Maths/sphericalPolynomial.ts":
  76332. /*!**************************************!*\
  76333. !*** ./Maths/sphericalPolynomial.ts ***!
  76334. \**************************************/
  76335. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  76336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76337. "use strict";
  76338. __webpack_require__.r(__webpack_exports__);
  76339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  76340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  76341. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  76342. /**
  76343. * Class representing spherical polynomial coefficients to the 3rd degree
  76344. */
  76345. var SphericalPolynomial = /** @class */ (function () {
  76346. function SphericalPolynomial() {
  76347. /**
  76348. * The x coefficients of the spherical polynomial
  76349. */
  76350. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76351. /**
  76352. * The y coefficients of the spherical polynomial
  76353. */
  76354. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76355. /**
  76356. * The z coefficients of the spherical polynomial
  76357. */
  76358. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76359. /**
  76360. * The xx coefficients of the spherical polynomial
  76361. */
  76362. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76363. /**
  76364. * The yy coefficients of the spherical polynomial
  76365. */
  76366. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76367. /**
  76368. * The zz coefficients of the spherical polynomial
  76369. */
  76370. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76371. /**
  76372. * The xy coefficients of the spherical polynomial
  76373. */
  76374. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76375. /**
  76376. * The yz coefficients of the spherical polynomial
  76377. */
  76378. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76379. /**
  76380. * The zx coefficients of the spherical polynomial
  76381. */
  76382. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76383. }
  76384. /**
  76385. * Adds an ambient color to the spherical polynomial
  76386. * @param color the color to add
  76387. */
  76388. SphericalPolynomial.prototype.addAmbient = function (color) {
  76389. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  76390. this.xx = this.xx.add(colorVector);
  76391. this.yy = this.yy.add(colorVector);
  76392. this.zz = this.zz.add(colorVector);
  76393. };
  76394. /**
  76395. * Scales the spherical polynomial by the given amount
  76396. * @param scale the amount to scale
  76397. */
  76398. SphericalPolynomial.prototype.scale = function (scale) {
  76399. this.x = this.x.scale(scale);
  76400. this.y = this.y.scale(scale);
  76401. this.z = this.z.scale(scale);
  76402. this.xx = this.xx.scale(scale);
  76403. this.yy = this.yy.scale(scale);
  76404. this.zz = this.zz.scale(scale);
  76405. this.yz = this.yz.scale(scale);
  76406. this.zx = this.zx.scale(scale);
  76407. this.xy = this.xy.scale(scale);
  76408. };
  76409. /**
  76410. * Gets the spherical polynomial from harmonics
  76411. * @param harmonics the spherical harmonics
  76412. * @returns the spherical polynomial
  76413. */
  76414. SphericalPolynomial.FromHarmonics = function (harmonics) {
  76415. var result = new SphericalPolynomial();
  76416. result.x = harmonics.l11.scale(1.02333);
  76417. result.y = harmonics.l1_1.scale(1.02333);
  76418. result.z = harmonics.l10.scale(1.02333);
  76419. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  76420. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  76421. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  76422. result.yz = harmonics.l2_1.scale(0.858086);
  76423. result.zx = harmonics.l21.scale(0.858086);
  76424. result.xy = harmonics.l2_2.scale(0.858086);
  76425. result.scale(1.0 / Math.PI);
  76426. return result;
  76427. };
  76428. /**
  76429. * Constructs a spherical polynomial from an array.
  76430. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  76431. * @returns the spherical polynomial
  76432. */
  76433. SphericalPolynomial.FromArray = function (data) {
  76434. var sp = new SphericalPolynomial();
  76435. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  76436. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  76437. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  76438. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  76439. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  76440. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  76441. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  76442. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  76443. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  76444. return sp;
  76445. };
  76446. return SphericalPolynomial;
  76447. }());
  76448. /**
  76449. * Class representing spherical harmonics coefficients to the 3rd degree
  76450. */
  76451. var SphericalHarmonics = /** @class */ (function () {
  76452. function SphericalHarmonics() {
  76453. /**
  76454. * The l0,0 coefficients of the spherical harmonics
  76455. */
  76456. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76457. /**
  76458. * The l1,-1 coefficients of the spherical harmonics
  76459. */
  76460. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76461. /**
  76462. * The l1,0 coefficients of the spherical harmonics
  76463. */
  76464. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76465. /**
  76466. * The l1,1 coefficients of the spherical harmonics
  76467. */
  76468. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76469. /**
  76470. * The l2,-2 coefficients of the spherical harmonics
  76471. */
  76472. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76473. /**
  76474. * The l2,-1 coefficients of the spherical harmonics
  76475. */
  76476. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76477. /**
  76478. * The l2,0 coefficients of the spherical harmonics
  76479. */
  76480. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76481. /**
  76482. * The l2,1 coefficients of the spherical harmonics
  76483. */
  76484. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76485. /**
  76486. * The l2,2 coefficients of the spherical harmonics
  76487. */
  76488. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76489. }
  76490. /**
  76491. * Adds a light to the spherical harmonics
  76492. * @param direction the direction of the light
  76493. * @param color the color of the light
  76494. * @param deltaSolidAngle the delta solid angle of the light
  76495. */
  76496. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  76497. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  76498. var c = colorVector.scale(deltaSolidAngle);
  76499. this.l00 = this.l00.add(c.scale(0.282095));
  76500. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  76501. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  76502. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  76503. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  76504. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  76505. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  76506. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  76507. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  76508. };
  76509. /**
  76510. * Scales the spherical harmonics by the given amount
  76511. * @param scale the amount to scale
  76512. */
  76513. SphericalHarmonics.prototype.scale = function (scale) {
  76514. this.l00 = this.l00.scale(scale);
  76515. this.l1_1 = this.l1_1.scale(scale);
  76516. this.l10 = this.l10.scale(scale);
  76517. this.l11 = this.l11.scale(scale);
  76518. this.l2_2 = this.l2_2.scale(scale);
  76519. this.l2_1 = this.l2_1.scale(scale);
  76520. this.l20 = this.l20.scale(scale);
  76521. this.l21 = this.l21.scale(scale);
  76522. this.lL22 = this.lL22.scale(scale);
  76523. };
  76524. /**
  76525. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  76526. *
  76527. * ```
  76528. * E_lm = A_l * L_lm
  76529. * ```
  76530. *
  76531. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  76532. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  76533. * the scaling factors are given in equation 9.
  76534. */
  76535. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  76536. // Constant (Band 0)
  76537. this.l00 = this.l00.scale(3.141593);
  76538. // Linear (Band 1)
  76539. this.l1_1 = this.l1_1.scale(2.094395);
  76540. this.l10 = this.l10.scale(2.094395);
  76541. this.l11 = this.l11.scale(2.094395);
  76542. // Quadratic (Band 2)
  76543. this.l2_2 = this.l2_2.scale(0.785398);
  76544. this.l2_1 = this.l2_1.scale(0.785398);
  76545. this.l20 = this.l20.scale(0.785398);
  76546. this.l21 = this.l21.scale(0.785398);
  76547. this.lL22 = this.lL22.scale(0.785398);
  76548. };
  76549. /**
  76550. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  76551. *
  76552. * ```
  76553. * L = (1/pi) * E * rho
  76554. * ```
  76555. *
  76556. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  76557. */
  76558. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  76559. this.scale(1.0 / Math.PI);
  76560. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  76561. // (The pixel shader must apply albedo after texture fetches, etc).
  76562. };
  76563. /**
  76564. * Gets the spherical harmonics from polynomial
  76565. * @param polynomial the spherical polynomial
  76566. * @returns the spherical harmonics
  76567. */
  76568. SphericalHarmonics.FromPolynomial = function (polynomial) {
  76569. var result = new SphericalHarmonics();
  76570. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  76571. result.l1_1 = polynomial.y.scale(0.977204);
  76572. result.l10 = polynomial.z.scale(0.977204);
  76573. result.l11 = polynomial.x.scale(0.977204);
  76574. result.l2_2 = polynomial.xy.scale(1.16538);
  76575. result.l2_1 = polynomial.yz.scale(1.16538);
  76576. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  76577. result.l21 = polynomial.zx.scale(1.16538);
  76578. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  76579. result.scale(Math.PI);
  76580. return result;
  76581. };
  76582. /**
  76583. * Constructs a spherical harmonics from an array.
  76584. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  76585. * @returns the spherical harmonics
  76586. */
  76587. SphericalHarmonics.FromArray = function (data) {
  76588. var sh = new SphericalHarmonics();
  76589. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  76590. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  76591. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  76592. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  76593. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  76594. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  76595. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  76596. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  76597. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  76598. return sh;
  76599. };
  76600. return SphericalHarmonics;
  76601. }());
  76602. /***/ }),
  76603. /***/ "./Meshes/Builders/boxBuilder.ts":
  76604. /*!***************************************!*\
  76605. !*** ./Meshes/Builders/boxBuilder.ts ***!
  76606. \***************************************/
  76607. /*! exports provided: BoxBuilder */
  76608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76609. "use strict";
  76610. __webpack_require__.r(__webpack_exports__);
  76611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  76612. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76613. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76614. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76615. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  76616. var normalsSource = [
  76617. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  76618. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  76619. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  76620. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  76621. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  76622. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  76623. ];
  76624. var indices = [];
  76625. var positions = [];
  76626. var normals = [];
  76627. var uvs = [];
  76628. var width = options.width || options.size || 1;
  76629. var height = options.height || options.size || 1;
  76630. var depth = options.depth || options.size || 1;
  76631. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76632. var faceUV = options.faceUV || new Array(6);
  76633. var faceColors = options.faceColors;
  76634. var colors = [];
  76635. // default face colors and UV if undefined
  76636. for (var f = 0; f < 6; f++) {
  76637. if (faceUV[f] === undefined) {
  76638. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76639. }
  76640. if (faceColors && faceColors[f] === undefined) {
  76641. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76642. }
  76643. }
  76644. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  76645. // Create each face in turn.
  76646. for (var index = 0; index < normalsSource.length; index++) {
  76647. var normal = normalsSource[index];
  76648. // Get two vectors perpendicular to the face normal and to each other.
  76649. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  76650. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  76651. // Six indices (two triangles) per face.
  76652. var verticesLength = positions.length / 3;
  76653. indices.push(verticesLength);
  76654. indices.push(verticesLength + 1);
  76655. indices.push(verticesLength + 2);
  76656. indices.push(verticesLength);
  76657. indices.push(verticesLength + 2);
  76658. indices.push(verticesLength + 3);
  76659. // Four vertices per face.
  76660. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  76661. positions.push(vertex.x, vertex.y, vertex.z);
  76662. normals.push(normal.x, normal.y, normal.z);
  76663. uvs.push(faceUV[index].z, faceUV[index].w);
  76664. if (faceColors) {
  76665. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76666. }
  76667. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  76668. positions.push(vertex.x, vertex.y, vertex.z);
  76669. normals.push(normal.x, normal.y, normal.z);
  76670. uvs.push(faceUV[index].x, faceUV[index].w);
  76671. if (faceColors) {
  76672. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76673. }
  76674. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  76675. positions.push(vertex.x, vertex.y, vertex.z);
  76676. normals.push(normal.x, normal.y, normal.z);
  76677. uvs.push(faceUV[index].x, faceUV[index].y);
  76678. if (faceColors) {
  76679. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76680. }
  76681. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  76682. positions.push(vertex.x, vertex.y, vertex.z);
  76683. normals.push(normal.x, normal.y, normal.z);
  76684. uvs.push(faceUV[index].z, faceUV[index].y);
  76685. if (faceColors) {
  76686. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76687. }
  76688. }
  76689. // sides
  76690. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76691. // Result
  76692. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76693. vertexData.indices = indices;
  76694. vertexData.positions = positions;
  76695. vertexData.normals = normals;
  76696. vertexData.uvs = uvs;
  76697. if (faceColors) {
  76698. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  76699. vertexData.colors = totalColors;
  76700. }
  76701. return vertexData;
  76702. };
  76703. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  76704. if (scene === void 0) { scene = null; }
  76705. var options = {
  76706. size: size,
  76707. sideOrientation: sideOrientation,
  76708. updatable: updatable
  76709. };
  76710. return BoxBuilder.CreateBox(name, options, scene);
  76711. };
  76712. /**
  76713. * Class containing static functions to help procedurally build meshes
  76714. */
  76715. var BoxBuilder = /** @class */ (function () {
  76716. function BoxBuilder() {
  76717. }
  76718. /**
  76719. * Creates a box mesh
  76720. * * The parameter `size` sets the size (float) of each box side (default 1)
  76721. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  76722. * * 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)
  76723. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  76724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76725. * * 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
  76726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76727. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  76728. * @param name defines the name of the mesh
  76729. * @param options defines the options used to create the mesh
  76730. * @param scene defines the hosting scene
  76731. * @returns the box mesh
  76732. */
  76733. BoxBuilder.CreateBox = function (name, options, scene) {
  76734. if (scene === void 0) { scene = null; }
  76735. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76736. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76737. box._originalBuilderSideOrientation = options.sideOrientation;
  76738. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  76739. vertexData.applyToMesh(box, options.updatable);
  76740. return box;
  76741. };
  76742. return BoxBuilder;
  76743. }());
  76744. /***/ }),
  76745. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  76746. /*!********************************************!*\
  76747. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  76748. \********************************************/
  76749. /*! exports provided: CylinderBuilder */
  76750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76751. "use strict";
  76752. __webpack_require__.r(__webpack_exports__);
  76753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  76754. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76755. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76756. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76757. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  76758. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  76759. var height = options.height || 2;
  76760. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  76761. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  76762. var tessellation = options.tessellation || 24;
  76763. var subdivisions = options.subdivisions || 1;
  76764. var hasRings = options.hasRings ? true : false;
  76765. var enclose = options.enclose ? true : false;
  76766. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  76767. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76768. var faceUV = options.faceUV || new Array(3);
  76769. var faceColors = options.faceColors;
  76770. // default face colors and UV if undefined
  76771. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  76772. var ringNb = (hasRings) ? subdivisions : 1;
  76773. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  76774. var f;
  76775. for (f = 0; f < surfaceNb; f++) {
  76776. if (faceColors && faceColors[f] === undefined) {
  76777. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76778. }
  76779. }
  76780. for (f = 0; f < surfaceNb; f++) {
  76781. if (faceUV && faceUV[f] === undefined) {
  76782. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76783. }
  76784. }
  76785. var indices = new Array();
  76786. var positions = new Array();
  76787. var normals = new Array();
  76788. var uvs = new Array();
  76789. var colors = new Array();
  76790. var angle_step = Math.PI * 2 * arc / tessellation;
  76791. var angle;
  76792. var h;
  76793. var radius;
  76794. var tan = (diameterBottom - diameterTop) / 2 / height;
  76795. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76796. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76797. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76798. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76799. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76800. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  76801. // positions, normals, uvs
  76802. var i;
  76803. var j;
  76804. var r;
  76805. var ringIdx = 1;
  76806. var s = 1; // surface index
  76807. var cs = 0;
  76808. var v = 0;
  76809. for (i = 0; i <= subdivisions; i++) {
  76810. h = i / subdivisions;
  76811. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  76812. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  76813. for (r = 0; r < ringIdx; r++) {
  76814. if (hasRings) {
  76815. s += r;
  76816. }
  76817. if (enclose) {
  76818. s += 2 * r;
  76819. }
  76820. for (j = 0; j <= tessellation; j++) {
  76821. angle = j * angle_step;
  76822. // position
  76823. ringVertex.x = Math.cos(-angle) * radius;
  76824. ringVertex.y = -height / 2 + h * height;
  76825. ringVertex.z = Math.sin(-angle) * radius;
  76826. // normal
  76827. if (diameterTop === 0 && i === subdivisions) {
  76828. // if no top cap, reuse former normals
  76829. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  76830. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  76831. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  76832. }
  76833. else {
  76834. ringNormal.x = ringVertex.x;
  76835. ringNormal.z = ringVertex.z;
  76836. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  76837. ringNormal.normalize();
  76838. }
  76839. // keep first ring vertex values for enclose
  76840. if (j === 0) {
  76841. ringFirstVertex.copyFrom(ringVertex);
  76842. ringFirstNormal.copyFrom(ringNormal);
  76843. }
  76844. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  76845. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  76846. if (hasRings) {
  76847. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  76848. }
  76849. else {
  76850. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  76851. }
  76852. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  76853. if (faceColors) {
  76854. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  76855. }
  76856. }
  76857. // if enclose, add four vertices and their dedicated normals
  76858. if (arc !== 1 && enclose) {
  76859. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  76860. positions.push(0, ringVertex.y, 0);
  76861. positions.push(0, ringVertex.y, 0);
  76862. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  76863. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  76864. quadNormal.normalize();
  76865. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  76866. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  76867. quadNormal.normalize();
  76868. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  76869. if (hasRings) {
  76870. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  76871. }
  76872. else {
  76873. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  76874. }
  76875. uvs.push(faceUV[s + 1].x, v);
  76876. uvs.push(faceUV[s + 1].z, v);
  76877. if (hasRings) {
  76878. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  76879. }
  76880. else {
  76881. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  76882. }
  76883. uvs.push(faceUV[s + 2].x, v);
  76884. uvs.push(faceUV[s + 2].z, v);
  76885. if (faceColors) {
  76886. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  76887. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  76888. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  76889. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  76890. }
  76891. }
  76892. if (cs !== s) {
  76893. cs = s;
  76894. }
  76895. }
  76896. }
  76897. // indices
  76898. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  76899. var s;
  76900. i = 0;
  76901. for (s = 0; s < subdivisions; s++) {
  76902. var i0 = 0;
  76903. var i1 = 0;
  76904. var i2 = 0;
  76905. var i3 = 0;
  76906. for (j = 0; j < tessellation; j++) {
  76907. i0 = i * (e + 1) + j;
  76908. i1 = (i + 1) * (e + 1) + j;
  76909. i2 = i * (e + 1) + (j + 1);
  76910. i3 = (i + 1) * (e + 1) + (j + 1);
  76911. indices.push(i0, i1, i2);
  76912. indices.push(i3, i2, i1);
  76913. }
  76914. if (arc !== 1 && enclose) { // if enclose, add two quads
  76915. indices.push(i0 + 2, i1 + 2, i2 + 2);
  76916. indices.push(i3 + 2, i2 + 2, i1 + 2);
  76917. indices.push(i0 + 4, i1 + 4, i2 + 4);
  76918. indices.push(i3 + 4, i2 + 4, i1 + 4);
  76919. }
  76920. i = (hasRings) ? (i + 2) : (i + 1);
  76921. }
  76922. // Caps
  76923. var createCylinderCap = function (isTop) {
  76924. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  76925. if (radius === 0) {
  76926. return;
  76927. }
  76928. // Cap positions, normals & uvs
  76929. var angle;
  76930. var circleVector;
  76931. var i;
  76932. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  76933. var c = null;
  76934. if (faceColors) {
  76935. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  76936. }
  76937. // cap center
  76938. var vbase = positions.length / 3;
  76939. var offset = isTop ? height / 2 : -height / 2;
  76940. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  76941. positions.push(center.x, center.y, center.z);
  76942. normals.push(0, isTop ? 1 : -1, 0);
  76943. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  76944. if (c) {
  76945. colors.push(c.r, c.g, c.b, c.a);
  76946. }
  76947. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  76948. for (i = 0; i <= tessellation; i++) {
  76949. angle = Math.PI * 2 * i * arc / tessellation;
  76950. var cos = Math.cos(-angle);
  76951. var sin = Math.sin(-angle);
  76952. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  76953. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  76954. positions.push(circleVector.x, circleVector.y, circleVector.z);
  76955. normals.push(0, isTop ? 1 : -1, 0);
  76956. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  76957. if (c) {
  76958. colors.push(c.r, c.g, c.b, c.a);
  76959. }
  76960. }
  76961. // Cap indices
  76962. for (i = 0; i < tessellation; i++) {
  76963. if (!isTop) {
  76964. indices.push(vbase);
  76965. indices.push(vbase + (i + 1));
  76966. indices.push(vbase + (i + 2));
  76967. }
  76968. else {
  76969. indices.push(vbase);
  76970. indices.push(vbase + (i + 2));
  76971. indices.push(vbase + (i + 1));
  76972. }
  76973. }
  76974. };
  76975. // add caps to geometry
  76976. createCylinderCap(false);
  76977. createCylinderCap(true);
  76978. // Sides
  76979. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76980. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76981. vertexData.indices = indices;
  76982. vertexData.positions = positions;
  76983. vertexData.normals = normals;
  76984. vertexData.uvs = uvs;
  76985. if (faceColors) {
  76986. vertexData.colors = colors;
  76987. }
  76988. return vertexData;
  76989. };
  76990. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  76991. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  76992. if (scene !== undefined) {
  76993. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  76994. updatable = scene;
  76995. }
  76996. scene = subdivisions;
  76997. subdivisions = 1;
  76998. }
  76999. var options = {
  77000. height: height,
  77001. diameterTop: diameterTop,
  77002. diameterBottom: diameterBottom,
  77003. tessellation: tessellation,
  77004. subdivisions: subdivisions,
  77005. sideOrientation: sideOrientation,
  77006. updatable: updatable
  77007. };
  77008. return CylinderBuilder.CreateCylinder(name, options, scene);
  77009. };
  77010. /**
  77011. * Class containing static functions to help procedurally build meshes
  77012. */
  77013. var CylinderBuilder = /** @class */ (function () {
  77014. function CylinderBuilder() {
  77015. }
  77016. /**
  77017. * Creates a cylinder or a cone mesh
  77018. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  77019. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  77020. * * 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.
  77021. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  77022. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  77023. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  77024. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  77025. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  77026. * * 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).
  77027. * * 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
  77028. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  77029. * * 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
  77030. * * 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.
  77031. * * If `enclose` is false, a ring surface is one element.
  77032. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  77033. * * 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
  77034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77035. * * 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
  77036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77037. * @param name defines the name of the mesh
  77038. * @param options defines the options used to create the mesh
  77039. * @param scene defines the hosting scene
  77040. * @returns the cylinder mesh
  77041. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  77042. */
  77043. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  77044. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77045. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77046. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  77047. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  77048. vertexData.applyToMesh(cylinder, options.updatable);
  77049. return cylinder;
  77050. };
  77051. return CylinderBuilder;
  77052. }());
  77053. /***/ }),
  77054. /***/ "./Meshes/Builders/decalBuilder.ts":
  77055. /*!*****************************************!*\
  77056. !*** ./Meshes/Builders/decalBuilder.ts ***!
  77057. \*****************************************/
  77058. /*! exports provided: DecalBuilder */
  77059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77060. "use strict";
  77061. __webpack_require__.r(__webpack_exports__);
  77062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  77063. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77064. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77065. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  77066. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77067. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  77068. var options = {
  77069. position: position,
  77070. normal: normal,
  77071. size: size,
  77072. angle: angle
  77073. };
  77074. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  77075. };
  77076. /**
  77077. * Class containing static functions to help procedurally build meshes
  77078. */
  77079. var DecalBuilder = /** @class */ (function () {
  77080. function DecalBuilder() {
  77081. }
  77082. /**
  77083. * Creates a decal mesh.
  77084. * 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
  77085. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  77086. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  77087. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  77088. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  77089. * @param name defines the name of the mesh
  77090. * @param sourceMesh defines the mesh where the decal must be applied
  77091. * @param options defines the options used to create the mesh
  77092. * @param scene defines the hosting scene
  77093. * @returns the decal mesh
  77094. * @see https://doc.babylonjs.com/how_to/decals
  77095. */
  77096. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  77097. var indices = sourceMesh.getIndices();
  77098. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  77099. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  77100. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77101. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  77102. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  77103. var angle = options.angle || 0;
  77104. // Getting correct rotation
  77105. if (!normal) {
  77106. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  77107. var camera = sourceMesh.getScene().activeCamera;
  77108. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  77109. normal = camera.globalPosition.subtract(cameraWorldTarget);
  77110. }
  77111. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  77112. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  77113. var pitch = Math.atan2(normal.y, len);
  77114. // Matrix
  77115. 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));
  77116. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  77117. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  77118. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  77119. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  77120. vertexData.indices = [];
  77121. vertexData.positions = [];
  77122. vertexData.normals = [];
  77123. vertexData.uvs = [];
  77124. var currentVertexDataIndex = 0;
  77125. var extractDecalVector3 = function (indexId) {
  77126. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  77127. if (!indices || !positions || !normals) {
  77128. return result;
  77129. }
  77130. var vertexId = indices[indexId];
  77131. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  77132. // Send vector to decal local world
  77133. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  77134. // Get normal
  77135. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  77136. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  77137. return result;
  77138. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  77139. var clip = function (vertices, axis) {
  77140. if (vertices.length === 0) {
  77141. return vertices;
  77142. }
  77143. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  77144. var clipVertices = function (v0, v1) {
  77145. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  77146. 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));
  77147. };
  77148. var result = new Array();
  77149. for (var index = 0; index < vertices.length; index += 3) {
  77150. var v1Out;
  77151. var v2Out;
  77152. var v3Out;
  77153. var total = 0;
  77154. var nV1 = null;
  77155. var nV2 = null;
  77156. var nV3 = null;
  77157. var nV4 = null;
  77158. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  77159. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  77160. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  77161. v1Out = d1 > 0;
  77162. v2Out = d2 > 0;
  77163. v3Out = d3 > 0;
  77164. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  77165. switch (total) {
  77166. case 0:
  77167. result.push(vertices[index]);
  77168. result.push(vertices[index + 1]);
  77169. result.push(vertices[index + 2]);
  77170. break;
  77171. case 1:
  77172. if (v1Out) {
  77173. nV1 = vertices[index + 1];
  77174. nV2 = vertices[index + 2];
  77175. nV3 = clipVertices(vertices[index], nV1);
  77176. nV4 = clipVertices(vertices[index], nV2);
  77177. }
  77178. if (v2Out) {
  77179. nV1 = vertices[index];
  77180. nV2 = vertices[index + 2];
  77181. nV3 = clipVertices(vertices[index + 1], nV1);
  77182. nV4 = clipVertices(vertices[index + 1], nV2);
  77183. result.push(nV3);
  77184. result.push(nV2.clone());
  77185. result.push(nV1.clone());
  77186. result.push(nV2.clone());
  77187. result.push(nV3.clone());
  77188. result.push(nV4);
  77189. break;
  77190. }
  77191. if (v3Out) {
  77192. nV1 = vertices[index];
  77193. nV2 = vertices[index + 1];
  77194. nV3 = clipVertices(vertices[index + 2], nV1);
  77195. nV4 = clipVertices(vertices[index + 2], nV2);
  77196. }
  77197. if (nV1 && nV2 && nV3 && nV4) {
  77198. result.push(nV1.clone());
  77199. result.push(nV2.clone());
  77200. result.push(nV3);
  77201. result.push(nV4);
  77202. result.push(nV3.clone());
  77203. result.push(nV2.clone());
  77204. }
  77205. break;
  77206. case 2:
  77207. if (!v1Out) {
  77208. nV1 = vertices[index].clone();
  77209. nV2 = clipVertices(nV1, vertices[index + 1]);
  77210. nV3 = clipVertices(nV1, vertices[index + 2]);
  77211. result.push(nV1);
  77212. result.push(nV2);
  77213. result.push(nV3);
  77214. }
  77215. if (!v2Out) {
  77216. nV1 = vertices[index + 1].clone();
  77217. nV2 = clipVertices(nV1, vertices[index + 2]);
  77218. nV3 = clipVertices(nV1, vertices[index]);
  77219. result.push(nV1);
  77220. result.push(nV2);
  77221. result.push(nV3);
  77222. }
  77223. if (!v3Out) {
  77224. nV1 = vertices[index + 2].clone();
  77225. nV2 = clipVertices(nV1, vertices[index]);
  77226. nV3 = clipVertices(nV1, vertices[index + 1]);
  77227. result.push(nV1);
  77228. result.push(nV2);
  77229. result.push(nV3);
  77230. }
  77231. break;
  77232. case 3:
  77233. break;
  77234. }
  77235. }
  77236. return result;
  77237. };
  77238. for (var index = 0; index < indices.length; index += 3) {
  77239. var faceVertices = new Array();
  77240. faceVertices.push(extractDecalVector3(index));
  77241. faceVertices.push(extractDecalVector3(index + 1));
  77242. faceVertices.push(extractDecalVector3(index + 2));
  77243. // Clip
  77244. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  77245. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  77246. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  77247. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  77248. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  77249. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  77250. if (faceVertices.length === 0) {
  77251. continue;
  77252. }
  77253. // Add UVs and get back to world
  77254. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  77255. var vertex = faceVertices[vIndex];
  77256. //TODO check for Int32Array | Uint32Array | Uint16Array
  77257. vertexData.indices.push(currentVertexDataIndex);
  77258. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  77259. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  77260. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  77261. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  77262. currentVertexDataIndex++;
  77263. }
  77264. }
  77265. // Return mesh
  77266. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  77267. vertexData.applyToMesh(decal);
  77268. decal.position = position.clone();
  77269. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  77270. return decal;
  77271. };
  77272. return DecalBuilder;
  77273. }());
  77274. /***/ }),
  77275. /***/ "./Meshes/Builders/discBuilder.ts":
  77276. /*!****************************************!*\
  77277. !*** ./Meshes/Builders/discBuilder.ts ***!
  77278. \****************************************/
  77279. /*! exports provided: DiscBuilder */
  77280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77281. "use strict";
  77282. __webpack_require__.r(__webpack_exports__);
  77283. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  77284. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77285. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77286. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  77287. var positions = new Array();
  77288. var indices = new Array();
  77289. var normals = new Array();
  77290. var uvs = new Array();
  77291. var radius = options.radius || 0.5;
  77292. var tessellation = options.tessellation || 64;
  77293. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77294. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  77295. // positions and uvs
  77296. positions.push(0, 0, 0); // disc center first
  77297. uvs.push(0.5, 0.5);
  77298. var theta = Math.PI * 2 * arc;
  77299. var step = theta / tessellation;
  77300. for (var a = 0; a < theta; a += step) {
  77301. var x = Math.cos(a);
  77302. var y = Math.sin(a);
  77303. var u = (x + 1) / 2;
  77304. var v = (1 - y) / 2;
  77305. positions.push(radius * x, radius * y, 0);
  77306. uvs.push(u, v);
  77307. }
  77308. if (arc === 1) {
  77309. positions.push(positions[3], positions[4], positions[5]); // close the circle
  77310. uvs.push(uvs[2], uvs[3]);
  77311. }
  77312. //indices
  77313. var vertexNb = positions.length / 3;
  77314. for (var i = 1; i < vertexNb - 1; i++) {
  77315. indices.push(i + 1, 0, i);
  77316. }
  77317. // result
  77318. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  77319. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77320. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  77321. vertexData.indices = indices;
  77322. vertexData.positions = positions;
  77323. vertexData.normals = normals;
  77324. vertexData.uvs = uvs;
  77325. return vertexData;
  77326. };
  77327. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  77328. if (scene === void 0) { scene = null; }
  77329. var options = {
  77330. radius: radius,
  77331. tessellation: tessellation,
  77332. sideOrientation: sideOrientation,
  77333. updatable: updatable
  77334. };
  77335. return DiscBuilder.CreateDisc(name, options, scene);
  77336. };
  77337. /**
  77338. * Class containing static functions to help procedurally build meshes
  77339. */
  77340. var DiscBuilder = /** @class */ (function () {
  77341. function DiscBuilder() {
  77342. }
  77343. /**
  77344. * Creates a plane polygonal mesh. By default, this is a disc
  77345. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  77346. * * 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
  77347. * * 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
  77348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77349. * * 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
  77350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77351. * @param name defines the name of the mesh
  77352. * @param options defines the options used to create the mesh
  77353. * @param scene defines the hosting scene
  77354. * @returns the plane polygonal mesh
  77355. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  77356. */
  77357. DiscBuilder.CreateDisc = function (name, options, scene) {
  77358. if (scene === void 0) { scene = null; }
  77359. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  77360. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77361. disc._originalBuilderSideOrientation = options.sideOrientation;
  77362. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  77363. vertexData.applyToMesh(disc, options.updatable);
  77364. return disc;
  77365. };
  77366. return DiscBuilder;
  77367. }());
  77368. /***/ }),
  77369. /***/ "./Meshes/Builders/groundBuilder.ts":
  77370. /*!******************************************!*\
  77371. !*** ./Meshes/Builders/groundBuilder.ts ***!
  77372. \******************************************/
  77373. /*! exports provided: GroundBuilder */
  77374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77375. "use strict";
  77376. __webpack_require__.r(__webpack_exports__);
  77377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  77378. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77379. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77380. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77381. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  77382. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  77383. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  77384. var indices = [];
  77385. var positions = [];
  77386. var normals = [];
  77387. var uvs = [];
  77388. var row, col;
  77389. var width = options.width || 1;
  77390. var height = options.height || 1;
  77391. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  77392. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  77393. for (row = 0; row <= subdivisionsY; row++) {
  77394. for (col = 0; col <= subdivisionsX; col++) {
  77395. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  77396. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  77397. positions.push(position.x, position.y, position.z);
  77398. normals.push(normal.x, normal.y, normal.z);
  77399. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  77400. }
  77401. }
  77402. for (row = 0; row < subdivisionsY; row++) {
  77403. for (col = 0; col < subdivisionsX; col++) {
  77404. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  77405. indices.push(col + 1 + row * (subdivisionsX + 1));
  77406. indices.push(col + row * (subdivisionsX + 1));
  77407. indices.push(col + (row + 1) * (subdivisionsX + 1));
  77408. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  77409. indices.push(col + row * (subdivisionsX + 1));
  77410. }
  77411. }
  77412. // Result
  77413. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77414. vertexData.indices = indices;
  77415. vertexData.positions = positions;
  77416. vertexData.normals = normals;
  77417. vertexData.uvs = uvs;
  77418. return vertexData;
  77419. };
  77420. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  77421. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  77422. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  77423. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  77424. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  77425. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  77426. var precision = options.precision || { w: 1, h: 1 };
  77427. var indices = new Array();
  77428. var positions = new Array();
  77429. var normals = new Array();
  77430. var uvs = new Array();
  77431. var row, col, tileRow, tileCol;
  77432. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  77433. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  77434. precision.w = (precision.w < 1) ? 1 : precision.w;
  77435. precision.h = (precision.h < 1) ? 1 : precision.h;
  77436. var tileSize = {
  77437. 'w': (xmax - xmin) / subdivisions.w,
  77438. 'h': (zmax - zmin) / subdivisions.h
  77439. };
  77440. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  77441. // Indices
  77442. var base = positions.length / 3;
  77443. var rowLength = precision.w + 1;
  77444. for (row = 0; row < precision.h; row++) {
  77445. for (col = 0; col < precision.w; col++) {
  77446. var square = [
  77447. base + col + row * rowLength,
  77448. base + (col + 1) + row * rowLength,
  77449. base + (col + 1) + (row + 1) * rowLength,
  77450. base + col + (row + 1) * rowLength
  77451. ];
  77452. indices.push(square[1]);
  77453. indices.push(square[2]);
  77454. indices.push(square[3]);
  77455. indices.push(square[0]);
  77456. indices.push(square[1]);
  77457. indices.push(square[3]);
  77458. }
  77459. }
  77460. // Position, normals and uvs
  77461. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77462. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  77463. for (row = 0; row <= precision.h; row++) {
  77464. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  77465. for (col = 0; col <= precision.w; col++) {
  77466. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  77467. position.y = 0;
  77468. positions.push(position.x, position.y, position.z);
  77469. normals.push(normal.x, normal.y, normal.z);
  77470. uvs.push(col / precision.w, row / precision.h);
  77471. }
  77472. }
  77473. }
  77474. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  77475. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  77476. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  77477. }
  77478. }
  77479. // Result
  77480. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77481. vertexData.indices = indices;
  77482. vertexData.positions = positions;
  77483. vertexData.normals = normals;
  77484. vertexData.uvs = uvs;
  77485. return vertexData;
  77486. };
  77487. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  77488. var indices = [];
  77489. var positions = [];
  77490. var normals = [];
  77491. var uvs = [];
  77492. var row, col;
  77493. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  77494. var alphaFilter = options.alphaFilter || 0.0;
  77495. // Vertices
  77496. for (row = 0; row <= options.subdivisions; row++) {
  77497. for (col = 0; col <= options.subdivisions; col++) {
  77498. 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));
  77499. // Compute height
  77500. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  77501. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  77502. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  77503. var r = options.buffer[pos] / 255.0;
  77504. var g = options.buffer[pos + 1] / 255.0;
  77505. var b = options.buffer[pos + 2] / 255.0;
  77506. var a = options.buffer[pos + 3] / 255.0;
  77507. var gradient = r * filter.r + g * filter.g + b * filter.b;
  77508. // If our alpha channel is not within our filter then we will assign a 'special' height
  77509. // Then when building the indices, we will ignore any vertex that is using the special height
  77510. if (a >= alphaFilter) {
  77511. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  77512. }
  77513. else {
  77514. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  77515. }
  77516. // Add vertex
  77517. positions.push(position.x, position.y, position.z);
  77518. normals.push(0, 0, 0);
  77519. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  77520. }
  77521. }
  77522. // Indices
  77523. for (row = 0; row < options.subdivisions; row++) {
  77524. for (col = 0; col < options.subdivisions; col++) {
  77525. // Calculate Indices
  77526. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  77527. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  77528. var idx3 = (col + row * (options.subdivisions + 1));
  77529. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  77530. // Check that all indices are visible (based on our special height)
  77531. // Only display the vertex if all Indices are visible
  77532. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  77533. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  77534. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  77535. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  77536. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  77537. indices.push(idx1);
  77538. indices.push(idx2);
  77539. indices.push(idx3);
  77540. }
  77541. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  77542. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  77543. indices.push(idx4);
  77544. indices.push(idx1);
  77545. indices.push(idx3);
  77546. }
  77547. }
  77548. }
  77549. // Normals
  77550. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  77551. // Result
  77552. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77553. vertexData.indices = indices;
  77554. vertexData.positions = positions;
  77555. vertexData.normals = normals;
  77556. vertexData.uvs = uvs;
  77557. return vertexData;
  77558. };
  77559. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  77560. var options = {
  77561. width: width,
  77562. height: height,
  77563. subdivisions: subdivisions,
  77564. updatable: updatable
  77565. };
  77566. return GroundBuilder.CreateGround(name, options, scene);
  77567. };
  77568. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  77569. var options = {
  77570. xmin: xmin,
  77571. zmin: zmin,
  77572. xmax: xmax,
  77573. zmax: zmax,
  77574. subdivisions: subdivisions,
  77575. precision: precision,
  77576. updatable: updatable
  77577. };
  77578. return GroundBuilder.CreateTiledGround(name, options, scene);
  77579. };
  77580. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  77581. var options = {
  77582. width: width,
  77583. height: height,
  77584. subdivisions: subdivisions,
  77585. minHeight: minHeight,
  77586. maxHeight: maxHeight,
  77587. updatable: updatable,
  77588. onReady: onReady,
  77589. alphaFilter: alphaFilter
  77590. };
  77591. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  77592. };
  77593. /**
  77594. * Class containing static functions to help procedurally build meshes
  77595. */
  77596. var GroundBuilder = /** @class */ (function () {
  77597. function GroundBuilder() {
  77598. }
  77599. /**
  77600. * Creates a ground mesh
  77601. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  77602. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  77603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77604. * @param name defines the name of the mesh
  77605. * @param options defines the options used to create the mesh
  77606. * @param scene defines the hosting scene
  77607. * @returns the ground mesh
  77608. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  77609. */
  77610. GroundBuilder.CreateGround = function (name, options, scene) {
  77611. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  77612. ground._setReady(false);
  77613. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  77614. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  77615. ground._width = options.width || 1;
  77616. ground._height = options.height || 1;
  77617. ground._maxX = ground._width / 2;
  77618. ground._maxZ = ground._height / 2;
  77619. ground._minX = -ground._maxX;
  77620. ground._minZ = -ground._maxZ;
  77621. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  77622. vertexData.applyToMesh(ground, options.updatable);
  77623. ground._setReady(true);
  77624. return ground;
  77625. };
  77626. /**
  77627. * Creates a tiled ground mesh
  77628. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  77629. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  77630. * * 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
  77631. * * 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
  77632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77633. * @param name defines the name of the mesh
  77634. * @param options defines the options used to create the mesh
  77635. * @param scene defines the hosting scene
  77636. * @returns the tiled ground mesh
  77637. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  77638. */
  77639. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  77640. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77641. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  77642. vertexData.applyToMesh(tiledGround, options.updatable);
  77643. return tiledGround;
  77644. };
  77645. /**
  77646. * Creates a ground mesh from a height map
  77647. * * The parameter `url` sets the URL of the height map image resource.
  77648. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  77649. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  77650. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  77651. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  77652. * * 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.
  77653. * * 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).
  77654. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77656. * @param name defines the name of the mesh
  77657. * @param url defines the url to the height map
  77658. * @param options defines the options used to create the mesh
  77659. * @param scene defines the hosting scene
  77660. * @returns the ground mesh
  77661. * @see https://doc.babylonjs.com/babylon101/height_map
  77662. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  77663. */
  77664. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  77665. var width = options.width || 10.0;
  77666. var height = options.height || 10.0;
  77667. var subdivisions = options.subdivisions || 1 | 0;
  77668. var minHeight = options.minHeight || 0.0;
  77669. var maxHeight = options.maxHeight || 1.0;
  77670. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  77671. var alphaFilter = options.alphaFilter || 0.0;
  77672. var updatable = options.updatable;
  77673. var onReady = options.onReady;
  77674. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  77675. ground._subdivisionsX = subdivisions;
  77676. ground._subdivisionsY = subdivisions;
  77677. ground._width = width;
  77678. ground._height = height;
  77679. ground._maxX = ground._width / 2.0;
  77680. ground._maxZ = ground._height / 2.0;
  77681. ground._minX = -ground._maxX;
  77682. ground._minZ = -ground._maxZ;
  77683. ground._setReady(false);
  77684. var onload = function (img) {
  77685. // Getting height map data
  77686. var canvas = document.createElement("canvas");
  77687. var context = canvas.getContext("2d");
  77688. if (!context) {
  77689. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  77690. }
  77691. if (scene.isDisposed) {
  77692. return;
  77693. }
  77694. var bufferWidth = img.width;
  77695. var bufferHeight = img.height;
  77696. canvas.width = bufferWidth;
  77697. canvas.height = bufferHeight;
  77698. context.drawImage(img, 0, 0);
  77699. // Create VertexData from map data
  77700. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  77701. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  77702. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  77703. width: width, height: height,
  77704. subdivisions: subdivisions,
  77705. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  77706. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  77707. alphaFilter: alphaFilter
  77708. });
  77709. vertexData.applyToMesh(ground, updatable);
  77710. //execute ready callback, if set
  77711. if (onReady) {
  77712. onReady(ground);
  77713. }
  77714. ground._setReady(true);
  77715. };
  77716. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  77717. return ground;
  77718. };
  77719. return GroundBuilder;
  77720. }());
  77721. /***/ }),
  77722. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  77723. /*!*********************************************!*\
  77724. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  77725. \*********************************************/
  77726. /*! exports provided: IcoSphereBuilder */
  77727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77728. "use strict";
  77729. __webpack_require__.r(__webpack_exports__);
  77730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  77731. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77732. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77733. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77734. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  77735. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77736. var radius = options.radius || 1;
  77737. var flat = (options.flat === undefined) ? true : options.flat;
  77738. var subdivisions = options.subdivisions || 4;
  77739. var radiusX = options.radiusX || radius;
  77740. var radiusY = options.radiusY || radius;
  77741. var radiusZ = options.radiusZ || radius;
  77742. var t = (1 + Math.sqrt(5)) / 2;
  77743. // 12 vertex x,y,z
  77744. var ico_vertices = [
  77745. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  77746. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  77747. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  77748. ];
  77749. // index of 3 vertex makes a face of icopshere
  77750. var ico_indices = [
  77751. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  77752. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  77753. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  77754. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  77755. ];
  77756. // vertex for uv have aliased position, not for UV
  77757. var vertices_unalias_id = [
  77758. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  77759. // vertex alias
  77760. 0,
  77761. 2,
  77762. 3,
  77763. 3,
  77764. 3,
  77765. 4,
  77766. 7,
  77767. 8,
  77768. 9,
  77769. 9,
  77770. 10,
  77771. 11 // 23: B + 12
  77772. ];
  77773. // uv as integer step (not pixels !)
  77774. var ico_vertexuv = [
  77775. 5, 1, 3, 1, 6, 4, 0, 0,
  77776. 5, 3, 4, 2, 2, 2, 4, 0,
  77777. 2, 0, 1, 1, 6, 0, 6, 2,
  77778. // vertex alias (for same vertex on different faces)
  77779. 0, 4,
  77780. 3, 3,
  77781. 4, 4,
  77782. 3, 1,
  77783. 4, 2,
  77784. 4, 4,
  77785. 0, 2,
  77786. 1, 1,
  77787. 2, 2,
  77788. 3, 3,
  77789. 1, 3,
  77790. 2, 4 // 23: B + 12
  77791. ];
  77792. // Vertices[0, 1, ...9, A, B] : position on UV plane
  77793. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  77794. // First island of uv mapping
  77795. // v = 4h 3+ 2
  77796. // v = 3h 9+ 4
  77797. // v = 2h 9+ 5 B
  77798. // v = 1h 9 1 0
  77799. // v = 0h 3 8 7 A
  77800. // u = 0 1 2 3 4 5 6 *a
  77801. // Second island of uv mapping
  77802. // v = 4h 0+ B+ 4+
  77803. // v = 3h A+ 2+
  77804. // v = 2h 7+ 6 3+
  77805. // v = 1h 8+ 3+
  77806. // v = 0h
  77807. // u = 0 1 2 3 4 5 6 *a
  77808. // Face layout on texture UV mapping
  77809. // ============
  77810. // \ 4 /\ 16 / ======
  77811. // \ / \ / /\ 11 /
  77812. // \/ 7 \/ / \ /
  77813. // ======= / 10 \/
  77814. // /\ 17 /\ =======
  77815. // / \ / \ \ 15 /\
  77816. // / 8 \/ 12 \ \ / \
  77817. // ============ \/ 6 \
  77818. // \ 18 /\ ============
  77819. // \ / \ \ 5 /\ 0 /
  77820. // \/ 13 \ \ / \ /
  77821. // ======= \/ 1 \/
  77822. // =============
  77823. // /\ 19 /\ 2 /\
  77824. // / \ / \ / \
  77825. // / 14 \/ 9 \/ 3 \
  77826. // ===================
  77827. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  77828. var ustep = 138 / 1024;
  77829. var vstep = 239 / 1024;
  77830. var uoffset = 60 / 1024;
  77831. var voffset = 26 / 1024;
  77832. // Second island should have margin, not to touch the first island
  77833. // avoid any borderline artefact in pixel rounding
  77834. var island_u_offset = -40 / 1024;
  77835. var island_v_offset = +20 / 1024;
  77836. // face is either island 0 or 1 :
  77837. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  77838. var island = [
  77839. 0, 0, 0, 0, 1,
  77840. 0, 0, 1, 1, 0,
  77841. 0, 0, 1, 1, 0,
  77842. 0, 1, 1, 1, 0 // 15 - 19
  77843. ];
  77844. var indices = new Array();
  77845. var positions = new Array();
  77846. var normals = new Array();
  77847. var uvs = new Array();
  77848. var current_indice = 0;
  77849. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  77850. var face_vertex_pos = new Array(3);
  77851. var face_vertex_uv = new Array(3);
  77852. var v012;
  77853. for (v012 = 0; v012 < 3; v012++) {
  77854. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77855. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  77856. }
  77857. // create all with normals
  77858. for (var face = 0; face < 20; face++) {
  77859. // 3 vertex per face
  77860. for (v012 = 0; v012 < 3; v012++) {
  77861. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  77862. var v_id = ico_indices[3 * face + v012];
  77863. // vertex have 3D position (x,y,z)
  77864. 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]);
  77865. // Normalize to get normal, then scale to radius
  77866. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  77867. // uv Coordinates from vertex ID
  77868. 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);
  77869. }
  77870. // Subdivide the face (interpolate pos, norm, uv)
  77871. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  77872. // - norm is linear interpolation of vertex corner normal
  77873. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  77874. // - uv is linear interpolation
  77875. //
  77876. // Topology is as below for sub-divide by 2
  77877. // vertex shown as v0,v1,v2
  77878. // interp index is i1 to progress in range [v0,v1[
  77879. // interp index is i2 to progress in range [v0,v2[
  77880. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  77881. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  77882. //
  77883. //
  77884. // i2 v2
  77885. // ^ ^
  77886. // / / \
  77887. // / / \
  77888. // / / \
  77889. // / / (0,1) \
  77890. // / #---------\
  77891. // / / \ (0,0)'/ \
  77892. // / / \ / \
  77893. // / / \ / \
  77894. // / / (0,0) \ / (1,0) \
  77895. // / #---------#---------\
  77896. // v0 v1
  77897. //
  77898. // --------------------> i1
  77899. //
  77900. // interp of (i1,i2):
  77901. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  77902. // along i1 : lerp(x0,x1, i1/(S-i2))
  77903. //
  77904. // centroid of triangle is needed to get help normal computation
  77905. // (c1,c2) are used for centroid location
  77906. var interp_vertex = function (i1, i2, c1, c2) {
  77907. // vertex is interpolated from
  77908. // - face_vertex_pos[0..2]
  77909. // - face_vertex_uv[0..2]
  77910. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  77911. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  77912. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  77913. pos_interp.normalize();
  77914. var vertex_normal;
  77915. if (flat) {
  77916. // in flat mode, recalculate normal as face centroid normal
  77917. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  77918. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  77919. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  77920. }
  77921. else {
  77922. // in smooth mode, recalculate normal from each single vertex position
  77923. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  77924. }
  77925. // Vertex normal need correction due to X,Y,Z radius scaling
  77926. vertex_normal.x /= radiusX;
  77927. vertex_normal.y /= radiusY;
  77928. vertex_normal.z /= radiusZ;
  77929. vertex_normal.normalize();
  77930. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  77931. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  77932. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  77933. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  77934. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  77935. uvs.push(uv_interp.x, uv_interp.y);
  77936. // push each vertex has member of a face
  77937. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  77938. indices.push(current_indice);
  77939. current_indice++;
  77940. };
  77941. for (var i2 = 0; i2 < subdivisions; i2++) {
  77942. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  77943. // face : (i1,i2) for /\ :
  77944. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  77945. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  77946. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  77947. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  77948. if (i1 + i2 + 1 < subdivisions) {
  77949. // face : (i1,i2)' for \/ :
  77950. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  77951. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  77952. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  77953. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  77954. }
  77955. }
  77956. }
  77957. }
  77958. // Sides
  77959. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77960. // Result
  77961. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77962. vertexData.indices = indices;
  77963. vertexData.positions = positions;
  77964. vertexData.normals = normals;
  77965. vertexData.uvs = uvs;
  77966. return vertexData;
  77967. };
  77968. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  77969. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  77970. };
  77971. /**
  77972. * Class containing static functions to help procedurally build meshes
  77973. */
  77974. var IcoSphereBuilder = /** @class */ (function () {
  77975. function IcoSphereBuilder() {
  77976. }
  77977. /**
  77978. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77979. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77980. * * 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`)
  77981. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77982. * * 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
  77983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77984. * * 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
  77985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77986. * @param name defines the name of the mesh
  77987. * @param options defines the options used to create the mesh
  77988. * @param scene defines the hosting scene
  77989. * @returns the icosahedron mesh
  77990. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77991. */
  77992. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  77993. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77994. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77995. sphere._originalBuilderSideOrientation = options.sideOrientation;
  77996. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  77997. vertexData.applyToMesh(sphere, options.updatable);
  77998. return sphere;
  77999. };
  78000. return IcoSphereBuilder;
  78001. }());
  78002. /***/ }),
  78003. /***/ "./Meshes/Builders/index.ts":
  78004. /*!**********************************!*\
  78005. !*** ./Meshes/Builders/index.ts ***!
  78006. \**********************************/
  78007. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  78008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78009. "use strict";
  78010. __webpack_require__.r(__webpack_exports__);
  78011. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  78012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  78013. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  78014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  78015. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  78016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  78017. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  78018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  78019. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  78020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  78021. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  78022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  78023. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  78024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  78025. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  78026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  78027. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  78028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  78029. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  78030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  78031. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  78032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  78033. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  78034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  78035. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  78036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  78037. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  78038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  78039. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  78040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  78041. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  78042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  78043. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  78044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  78045. /***/ }),
  78046. /***/ "./Meshes/Builders/latheBuilder.ts":
  78047. /*!*****************************************!*\
  78048. !*** ./Meshes/Builders/latheBuilder.ts ***!
  78049. \*****************************************/
  78050. /*! exports provided: LatheBuilder */
  78051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78052. "use strict";
  78053. __webpack_require__.r(__webpack_exports__);
  78054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  78055. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78056. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78057. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  78058. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  78059. var options = {
  78060. shape: shape,
  78061. radius: radius,
  78062. tessellation: tessellation,
  78063. sideOrientation: sideOrientation,
  78064. updatable: updatable
  78065. };
  78066. return LatheBuilder.CreateLathe(name, options, scene);
  78067. };
  78068. /**
  78069. * Class containing static functions to help procedurally build meshes
  78070. */
  78071. var LatheBuilder = /** @class */ (function () {
  78072. function LatheBuilder() {
  78073. }
  78074. /**
  78075. * Creates lathe mesh.
  78076. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  78077. * * 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
  78078. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  78079. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  78080. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  78081. * * 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
  78082. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  78083. * * 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
  78084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78085. * * 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
  78086. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  78087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78088. * @param name defines the name of the mesh
  78089. * @param options defines the options used to create the mesh
  78090. * @param scene defines the hosting scene
  78091. * @returns the lathe mesh
  78092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  78093. */
  78094. LatheBuilder.CreateLathe = function (name, options, scene) {
  78095. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  78096. var closed = (options.closed === undefined) ? true : options.closed;
  78097. var shape = options.shape;
  78098. var radius = options.radius || 1;
  78099. var tessellation = options.tessellation || 64;
  78100. var clip = options.clip || 0;
  78101. var updatable = options.updatable;
  78102. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78103. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  78104. var pi2 = Math.PI * 2;
  78105. var paths = new Array();
  78106. var invertUV = options.invertUV || false;
  78107. var i = 0;
  78108. var p = 0;
  78109. var step = pi2 / tessellation * arc;
  78110. var rotated;
  78111. var path = new Array();
  78112. for (i = 0; i <= tessellation - clip; i++) {
  78113. var path = [];
  78114. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  78115. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  78116. 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));
  78117. }
  78118. for (p = 0; p < shape.length; p++) {
  78119. 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);
  78120. path.push(rotated);
  78121. }
  78122. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  78123. 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));
  78124. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  78125. }
  78126. paths.push(path);
  78127. }
  78128. // lathe ribbon
  78129. 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);
  78130. return lathe;
  78131. };
  78132. return LatheBuilder;
  78133. }());
  78134. /***/ }),
  78135. /***/ "./Meshes/Builders/linesBuilder.ts":
  78136. /*!*****************************************!*\
  78137. !*** ./Meshes/Builders/linesBuilder.ts ***!
  78138. \*****************************************/
  78139. /*! exports provided: LinesBuilder */
  78140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78141. "use strict";
  78142. __webpack_require__.r(__webpack_exports__);
  78143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  78144. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78145. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78146. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78147. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  78148. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  78149. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  78150. var indices = [];
  78151. var positions = [];
  78152. var lines = options.lines;
  78153. var colors = options.colors;
  78154. var vertexColors = [];
  78155. var idx = 0;
  78156. for (var l = 0; l < lines.length; l++) {
  78157. var points = lines[l];
  78158. for (var index = 0; index < points.length; index++) {
  78159. positions.push(points[index].x, points[index].y, points[index].z);
  78160. if (colors) {
  78161. var color = colors[l];
  78162. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  78163. }
  78164. if (index > 0) {
  78165. indices.push(idx - 1);
  78166. indices.push(idx);
  78167. }
  78168. idx++;
  78169. }
  78170. }
  78171. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78172. vertexData.indices = indices;
  78173. vertexData.positions = positions;
  78174. if (colors) {
  78175. vertexData.colors = vertexColors;
  78176. }
  78177. return vertexData;
  78178. };
  78179. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  78180. var dashSize = options.dashSize || 3;
  78181. var gapSize = options.gapSize || 1;
  78182. var dashNb = options.dashNb || 200;
  78183. var points = options.points;
  78184. var positions = new Array();
  78185. var indices = new Array();
  78186. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78187. var lg = 0;
  78188. var nb = 0;
  78189. var shft = 0;
  78190. var dashshft = 0;
  78191. var curshft = 0;
  78192. var idx = 0;
  78193. var i = 0;
  78194. for (i = 0; i < points.length - 1; i++) {
  78195. points[i + 1].subtractToRef(points[i], curvect);
  78196. lg += curvect.length();
  78197. }
  78198. shft = lg / dashNb;
  78199. dashshft = dashSize * shft / (dashSize + gapSize);
  78200. for (i = 0; i < points.length - 1; i++) {
  78201. points[i + 1].subtractToRef(points[i], curvect);
  78202. nb = Math.floor(curvect.length() / shft);
  78203. curvect.normalize();
  78204. for (var j = 0; j < nb; j++) {
  78205. curshft = shft * j;
  78206. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  78207. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  78208. indices.push(idx, idx + 1);
  78209. idx += 2;
  78210. }
  78211. }
  78212. // Result
  78213. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78214. vertexData.positions = positions;
  78215. vertexData.indices = indices;
  78216. return vertexData;
  78217. };
  78218. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  78219. if (scene === void 0) { scene = null; }
  78220. if (updatable === void 0) { updatable = false; }
  78221. if (instance === void 0) { instance = null; }
  78222. var options = {
  78223. points: points,
  78224. updatable: updatable,
  78225. instance: instance
  78226. };
  78227. return LinesBuilder.CreateLines(name, options, scene);
  78228. };
  78229. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  78230. if (scene === void 0) { scene = null; }
  78231. var options = {
  78232. points: points,
  78233. dashSize: dashSize,
  78234. gapSize: gapSize,
  78235. dashNb: dashNb,
  78236. updatable: updatable,
  78237. instance: instance
  78238. };
  78239. return LinesBuilder.CreateDashedLines(name, options, scene);
  78240. };
  78241. /**
  78242. * Class containing static functions to help procedurally build meshes
  78243. */
  78244. var LinesBuilder = /** @class */ (function () {
  78245. function LinesBuilder() {
  78246. }
  78247. /**
  78248. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  78249. * * 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
  78250. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  78251. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  78252. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  78253. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  78254. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  78255. * * 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
  78256. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  78257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  78259. * @param name defines the name of the new line system
  78260. * @param options defines the options used to create the line system
  78261. * @param scene defines the hosting scene
  78262. * @returns a new line system mesh
  78263. */
  78264. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  78265. var instance = options.instance;
  78266. var lines = options.lines;
  78267. var colors = options.colors;
  78268. if (instance) { // lines update
  78269. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  78270. var vertexColor;
  78271. var lineColors;
  78272. if (colors) {
  78273. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  78274. }
  78275. var i = 0;
  78276. var c = 0;
  78277. for (var l = 0; l < lines.length; l++) {
  78278. var points = lines[l];
  78279. for (var p = 0; p < points.length; p++) {
  78280. positions[i] = points[p].x;
  78281. positions[i + 1] = points[p].y;
  78282. positions[i + 2] = points[p].z;
  78283. if (colors && vertexColor) {
  78284. lineColors = colors[l];
  78285. vertexColor[c] = lineColors[p].r;
  78286. vertexColor[c + 1] = lineColors[p].g;
  78287. vertexColor[c + 2] = lineColors[p].b;
  78288. vertexColor[c + 3] = lineColors[p].a;
  78289. c += 4;
  78290. }
  78291. i += 3;
  78292. }
  78293. }
  78294. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  78295. if (colors && vertexColor) {
  78296. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  78297. }
  78298. return instance;
  78299. }
  78300. // line system creation
  78301. var useVertexColor = (colors) ? true : false;
  78302. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  78303. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  78304. vertexData.applyToMesh(lineSystem, options.updatable);
  78305. return lineSystem;
  78306. };
  78307. /**
  78308. * Creates a line mesh
  78309. * 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
  78310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  78311. * * The parameter `points` is an array successive Vector3
  78312. * * 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
  78313. * * The optional parameter `colors` is an array of successive Color4, one per line point
  78314. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  78315. * * When updating an instance, remember that only point positions can change, not the number of points
  78316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  78318. * @param name defines the name of the new line system
  78319. * @param options defines the options used to create the line system
  78320. * @param scene defines the hosting scene
  78321. * @returns a new line mesh
  78322. */
  78323. LinesBuilder.CreateLines = function (name, options, scene) {
  78324. if (scene === void 0) { scene = null; }
  78325. var colors = (options.colors) ? [options.colors] : null;
  78326. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  78327. return lines;
  78328. };
  78329. /**
  78330. * Creates a dashed line mesh
  78331. * * 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
  78332. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  78333. * * The parameter `points` is an array successive Vector3
  78334. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  78335. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  78336. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78337. * * 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
  78338. * * When updating an instance, remember that only point positions can change, not the number of points
  78339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78340. * @param name defines the name of the mesh
  78341. * @param options defines the options used to create the mesh
  78342. * @param scene defines the hosting scene
  78343. * @returns the dashed line mesh
  78344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  78345. */
  78346. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  78347. if (scene === void 0) { scene = null; }
  78348. var points = options.points;
  78349. var instance = options.instance;
  78350. var gapSize = options.gapSize || 1;
  78351. var dashSize = options.dashSize || 3;
  78352. if (instance) { // dashed lines update
  78353. var positionFunction = function (positions) {
  78354. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78355. var nbSeg = positions.length / 6;
  78356. var lg = 0;
  78357. var nb = 0;
  78358. var shft = 0;
  78359. var dashshft = 0;
  78360. var curshft = 0;
  78361. var p = 0;
  78362. var i = 0;
  78363. var j = 0;
  78364. for (i = 0; i < points.length - 1; i++) {
  78365. points[i + 1].subtractToRef(points[i], curvect);
  78366. lg += curvect.length();
  78367. }
  78368. shft = lg / nbSeg;
  78369. var dashSize = instance._creationDataStorage.dashSize;
  78370. var gapSize = instance._creationDataStorage.gapSize;
  78371. dashshft = dashSize * shft / (dashSize + gapSize);
  78372. for (i = 0; i < points.length - 1; i++) {
  78373. points[i + 1].subtractToRef(points[i], curvect);
  78374. nb = Math.floor(curvect.length() / shft);
  78375. curvect.normalize();
  78376. j = 0;
  78377. while (j < nb && p < positions.length) {
  78378. curshft = shft * j;
  78379. positions[p] = points[i].x + curshft * curvect.x;
  78380. positions[p + 1] = points[i].y + curshft * curvect.y;
  78381. positions[p + 2] = points[i].z + curshft * curvect.z;
  78382. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  78383. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  78384. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  78385. p += 6;
  78386. j++;
  78387. }
  78388. }
  78389. while (p < positions.length) {
  78390. positions[p] = points[i].x;
  78391. positions[p + 1] = points[i].y;
  78392. positions[p + 2] = points[i].z;
  78393. p += 3;
  78394. }
  78395. };
  78396. instance.updateMeshPositions(positionFunction, false);
  78397. return instance;
  78398. }
  78399. // dashed lines creation
  78400. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  78401. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  78402. vertexData.applyToMesh(dashedLines, options.updatable);
  78403. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  78404. dashedLines._creationDataStorage.dashSize = dashSize;
  78405. dashedLines._creationDataStorage.gapSize = gapSize;
  78406. return dashedLines;
  78407. };
  78408. return LinesBuilder;
  78409. }());
  78410. /***/ }),
  78411. /***/ "./Meshes/Builders/planeBuilder.ts":
  78412. /*!*****************************************!*\
  78413. !*** ./Meshes/Builders/planeBuilder.ts ***!
  78414. \*****************************************/
  78415. /*! exports provided: PlaneBuilder */
  78416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78417. "use strict";
  78418. __webpack_require__.r(__webpack_exports__);
  78419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  78420. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78421. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78422. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  78423. var indices = [];
  78424. var positions = [];
  78425. var normals = [];
  78426. var uvs = [];
  78427. var width = options.width || options.size || 1;
  78428. var height = options.height || options.size || 1;
  78429. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  78430. // Vertices
  78431. var halfWidth = width / 2.0;
  78432. var halfHeight = height / 2.0;
  78433. positions.push(-halfWidth, -halfHeight, 0);
  78434. normals.push(0, 0, -1.0);
  78435. uvs.push(0.0, 0.0);
  78436. positions.push(halfWidth, -halfHeight, 0);
  78437. normals.push(0, 0, -1.0);
  78438. uvs.push(1.0, 0.0);
  78439. positions.push(halfWidth, halfHeight, 0);
  78440. normals.push(0, 0, -1.0);
  78441. uvs.push(1.0, 1.0);
  78442. positions.push(-halfWidth, halfHeight, 0);
  78443. normals.push(0, 0, -1.0);
  78444. uvs.push(0.0, 1.0);
  78445. // Indices
  78446. indices.push(0);
  78447. indices.push(1);
  78448. indices.push(2);
  78449. indices.push(0);
  78450. indices.push(2);
  78451. indices.push(3);
  78452. // Sides
  78453. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78454. // Result
  78455. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78456. vertexData.indices = indices;
  78457. vertexData.positions = positions;
  78458. vertexData.normals = normals;
  78459. vertexData.uvs = uvs;
  78460. return vertexData;
  78461. };
  78462. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  78463. var options = {
  78464. size: size,
  78465. width: size,
  78466. height: size,
  78467. sideOrientation: sideOrientation,
  78468. updatable: updatable
  78469. };
  78470. return PlaneBuilder.CreatePlane(name, options, scene);
  78471. };
  78472. /**
  78473. * Class containing static functions to help procedurally build meshes
  78474. */
  78475. var PlaneBuilder = /** @class */ (function () {
  78476. function PlaneBuilder() {
  78477. }
  78478. /**
  78479. * Creates a plane mesh
  78480. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  78481. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  78482. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  78483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78484. * * 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
  78485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78486. * @param name defines the name of the mesh
  78487. * @param options defines the options used to create the mesh
  78488. * @param scene defines the hosting scene
  78489. * @returns the plane mesh
  78490. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  78491. */
  78492. PlaneBuilder.CreatePlane = function (name, options, scene) {
  78493. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  78494. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78495. plane._originalBuilderSideOrientation = options.sideOrientation;
  78496. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  78497. vertexData.applyToMesh(plane, options.updatable);
  78498. if (options.sourcePlane) {
  78499. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  78500. plane.setDirection(options.sourcePlane.normal.scale(-1));
  78501. }
  78502. return plane;
  78503. };
  78504. return PlaneBuilder;
  78505. }());
  78506. /***/ }),
  78507. /***/ "./Meshes/Builders/polygonBuilder.ts":
  78508. /*!*******************************************!*\
  78509. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  78510. \*******************************************/
  78511. /*! exports provided: PolygonBuilder */
  78512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78513. "use strict";
  78514. __webpack_require__.r(__webpack_exports__);
  78515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  78516. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78517. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78518. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78519. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  78520. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  78521. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  78522. var faceUV = fUV || new Array(3);
  78523. var faceColors = fColors;
  78524. var colors = [];
  78525. // default face colors and UV if undefined
  78526. for (var f = 0; f < 3; f++) {
  78527. if (faceUV[f] === undefined) {
  78528. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78529. }
  78530. if (faceColors && faceColors[f] === undefined) {
  78531. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78532. }
  78533. }
  78534. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  78535. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  78536. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  78537. var indices = polygon.getIndices();
  78538. // set face colours and textures
  78539. var idx = 0;
  78540. var face = 0;
  78541. for (var index = 0; index < normals.length; index += 3) {
  78542. //Edge Face no. 1
  78543. if (Math.abs(normals[index + 1]) < 0.001) {
  78544. face = 1;
  78545. }
  78546. //Top Face no. 0
  78547. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  78548. face = 0;
  78549. }
  78550. //Bottom Face no. 2
  78551. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  78552. face = 2;
  78553. }
  78554. idx = index / 3;
  78555. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  78556. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  78557. if (faceColors) {
  78558. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  78559. }
  78560. }
  78561. // sides
  78562. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  78563. // Result
  78564. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78565. vertexData.indices = indices;
  78566. vertexData.positions = positions;
  78567. vertexData.normals = normals;
  78568. vertexData.uvs = uvs;
  78569. if (faceColors) {
  78570. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  78571. vertexData.colors = totalColors;
  78572. }
  78573. return vertexData;
  78574. };
  78575. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  78576. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78577. var options = {
  78578. shape: shape,
  78579. holes: holes,
  78580. updatable: updatable,
  78581. sideOrientation: sideOrientation
  78582. };
  78583. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  78584. };
  78585. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  78586. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78587. var options = {
  78588. shape: shape,
  78589. holes: holes,
  78590. depth: depth,
  78591. updatable: updatable,
  78592. sideOrientation: sideOrientation
  78593. };
  78594. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  78595. };
  78596. /**
  78597. * Class containing static functions to help procedurally build meshes
  78598. */
  78599. var PolygonBuilder = /** @class */ (function () {
  78600. function PolygonBuilder() {
  78601. }
  78602. /**
  78603. * Creates a polygon mesh
  78604. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  78605. * * 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
  78606. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78608. * * 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)
  78609. * * Remember you can only change the shape positions, not their number when updating a polygon
  78610. * @param name defines the name of the mesh
  78611. * @param options defines the options used to create the mesh
  78612. * @param scene defines the hosting scene
  78613. * @param earcutInjection can be used to inject your own earcut reference
  78614. * @returns the polygon mesh
  78615. */
  78616. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  78617. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78618. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78619. var shape = options.shape;
  78620. var holes = options.holes || [];
  78621. var depth = options.depth || 0;
  78622. var contours = [];
  78623. var hole = [];
  78624. for (var i = 0; i < shape.length; i++) {
  78625. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  78626. }
  78627. var epsilon = 0.00000001;
  78628. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  78629. contours.pop();
  78630. }
  78631. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  78632. for (var hNb = 0; hNb < holes.length; hNb++) {
  78633. hole = [];
  78634. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  78635. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  78636. }
  78637. polygonTriangulation.addHole(hole);
  78638. }
  78639. var polygon = polygonTriangulation.build(options.updatable, depth);
  78640. polygon._originalBuilderSideOrientation = options.sideOrientation;
  78641. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  78642. vertexData.applyToMesh(polygon, options.updatable);
  78643. return polygon;
  78644. };
  78645. /**
  78646. * Creates an extruded polygon mesh, with depth in the Y direction.
  78647. * * 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)
  78648. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  78649. * @param name defines the name of the mesh
  78650. * @param options defines the options used to create the mesh
  78651. * @param scene defines the hosting scene
  78652. * @param earcutInjection can be used to inject your own earcut reference
  78653. * @returns the polygon mesh
  78654. */
  78655. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  78656. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78657. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  78658. };
  78659. return PolygonBuilder;
  78660. }());
  78661. /***/ }),
  78662. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  78663. /*!**********************************************!*\
  78664. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  78665. \**********************************************/
  78666. /*! exports provided: PolyhedronBuilder */
  78667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78668. "use strict";
  78669. __webpack_require__.r(__webpack_exports__);
  78670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  78671. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78672. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78673. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78674. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  78675. // provided polyhedron types :
  78676. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78677. // 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)
  78678. var polyhedra = [];
  78679. 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]] };
  78680. 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]] };
  78681. polyhedra[2] = {
  78682. 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]],
  78683. 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]]
  78684. };
  78685. polyhedra[3] = {
  78686. 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]],
  78687. 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]]
  78688. };
  78689. polyhedra[4] = {
  78690. 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]],
  78691. 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]]
  78692. };
  78693. 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]] };
  78694. 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]] };
  78695. 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]] };
  78696. 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]] };
  78697. 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]] };
  78698. 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]] };
  78699. 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]] };
  78700. 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]] };
  78701. 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]] };
  78702. polyhedra[14] = {
  78703. 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]],
  78704. 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]]
  78705. };
  78706. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  78707. var size = options.size;
  78708. var sizeX = options.sizeX || size || 1;
  78709. var sizeY = options.sizeY || size || 1;
  78710. var sizeZ = options.sizeZ || size || 1;
  78711. var data = options.custom || polyhedra[type];
  78712. var nbfaces = data.face.length;
  78713. var faceUV = options.faceUV || new Array(nbfaces);
  78714. var faceColors = options.faceColors;
  78715. var flat = (options.flat === undefined) ? true : options.flat;
  78716. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78717. var positions = new Array();
  78718. var indices = new Array();
  78719. var normals = new Array();
  78720. var uvs = new Array();
  78721. var colors = new Array();
  78722. var index = 0;
  78723. var faceIdx = 0; // face cursor in the array "indexes"
  78724. var indexes = new Array();
  78725. var i = 0;
  78726. var f = 0;
  78727. var u, v, ang, x, y, tmp;
  78728. // default face colors and UV if undefined
  78729. if (flat) {
  78730. for (f = 0; f < nbfaces; f++) {
  78731. if (faceColors && faceColors[f] === undefined) {
  78732. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78733. }
  78734. if (faceUV && faceUV[f] === undefined) {
  78735. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78736. }
  78737. }
  78738. }
  78739. if (!flat) {
  78740. for (i = 0; i < data.vertex.length; i++) {
  78741. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  78742. uvs.push(0, 0);
  78743. }
  78744. for (f = 0; f < nbfaces; f++) {
  78745. for (i = 0; i < data.face[f].length - 2; i++) {
  78746. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  78747. }
  78748. }
  78749. }
  78750. else {
  78751. for (f = 0; f < nbfaces; f++) {
  78752. var fl = data.face[f].length; // number of vertices of the current face
  78753. ang = 2 * Math.PI / fl;
  78754. x = 0.5 * Math.tan(ang / 2);
  78755. y = 0.5;
  78756. // positions, uvs, colors
  78757. for (i = 0; i < fl; i++) {
  78758. // positions
  78759. 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);
  78760. indexes.push(index);
  78761. index++;
  78762. // uvs
  78763. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  78764. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  78765. uvs.push(u, v);
  78766. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  78767. y = x * Math.sin(ang) + y * Math.cos(ang);
  78768. x = tmp;
  78769. // colors
  78770. if (faceColors) {
  78771. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  78772. }
  78773. }
  78774. // indices from indexes
  78775. for (i = 0; i < fl - 2; i++) {
  78776. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  78777. }
  78778. faceIdx += fl;
  78779. }
  78780. }
  78781. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  78782. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78783. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78784. vertexData.positions = positions;
  78785. vertexData.indices = indices;
  78786. vertexData.normals = normals;
  78787. vertexData.uvs = uvs;
  78788. if (faceColors && flat) {
  78789. vertexData.colors = colors;
  78790. }
  78791. return vertexData;
  78792. };
  78793. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  78794. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  78795. };
  78796. /**
  78797. * Class containing static functions to help procedurally build meshes
  78798. */
  78799. var PolyhedronBuilder = /** @class */ (function () {
  78800. function PolyhedronBuilder() {
  78801. }
  78802. /**
  78803. * Creates a polyhedron mesh
  78804. * * 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
  78805. * * The parameter `size` (positive float, default 1) sets the polygon size
  78806. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78807. * * 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`
  78808. * * 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
  78809. * * 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)`)
  78810. * * 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
  78811. * * 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
  78812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78813. * * 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
  78814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78815. * @param name defines the name of the mesh
  78816. * @param options defines the options used to create the mesh
  78817. * @param scene defines the hosting scene
  78818. * @returns the polyhedron mesh
  78819. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  78820. */
  78821. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  78822. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78823. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78824. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  78825. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  78826. vertexData.applyToMesh(polyhedron, options.updatable);
  78827. return polyhedron;
  78828. };
  78829. return PolyhedronBuilder;
  78830. }());
  78831. /***/ }),
  78832. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  78833. /*!******************************************!*\
  78834. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  78835. \******************************************/
  78836. /*! exports provided: RibbonBuilder */
  78837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78838. "use strict";
  78839. __webpack_require__.r(__webpack_exports__);
  78840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  78841. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78842. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78843. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  78844. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78845. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  78846. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  78847. var pathArray = options.pathArray;
  78848. var closeArray = options.closeArray || false;
  78849. var closePath = options.closePath || false;
  78850. var invertUV = options.invertUV || false;
  78851. var defaultOffset = Math.floor(pathArray[0].length / 2);
  78852. var offset = options.offset || defaultOffset;
  78853. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  78854. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  78855. var customUV = options.uvs;
  78856. var customColors = options.colors;
  78857. var positions = [];
  78858. var indices = [];
  78859. var normals = [];
  78860. var uvs = [];
  78861. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  78862. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  78863. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  78864. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  78865. var minlg; // minimal length among all paths from pathArray
  78866. var lg = []; // array of path lengths : nb of vertex per path
  78867. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  78868. var p; // path iterator
  78869. var i; // point iterator
  78870. var j; // point iterator
  78871. // if single path in pathArray
  78872. if (pathArray.length < 2) {
  78873. var ar1 = [];
  78874. var ar2 = [];
  78875. for (i = 0; i < pathArray[0].length - offset; i++) {
  78876. ar1.push(pathArray[0][i]);
  78877. ar2.push(pathArray[0][i + offset]);
  78878. }
  78879. pathArray = [ar1, ar2];
  78880. }
  78881. // positions and horizontal distances (u)
  78882. var idc = 0;
  78883. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  78884. var path;
  78885. var l;
  78886. minlg = pathArray[0].length;
  78887. var vectlg;
  78888. var dist;
  78889. for (p = 0; p < pathArray.length; p++) {
  78890. uTotalDistance[p] = 0;
  78891. us[p] = [0];
  78892. path = pathArray[p];
  78893. l = path.length;
  78894. minlg = (minlg < l) ? minlg : l;
  78895. j = 0;
  78896. while (j < l) {
  78897. positions.push(path[j].x, path[j].y, path[j].z);
  78898. if (j > 0) {
  78899. vectlg = path[j].subtract(path[j - 1]).length();
  78900. dist = vectlg + uTotalDistance[p];
  78901. us[p].push(dist);
  78902. uTotalDistance[p] = dist;
  78903. }
  78904. j++;
  78905. }
  78906. if (closePath) { // an extra hidden vertex is added in the "positions" array
  78907. j--;
  78908. positions.push(path[0].x, path[0].y, path[0].z);
  78909. vectlg = path[j].subtract(path[0]).length();
  78910. dist = vectlg + uTotalDistance[p];
  78911. us[p].push(dist);
  78912. uTotalDistance[p] = dist;
  78913. }
  78914. lg[p] = l + closePathCorr;
  78915. idx[p] = idc;
  78916. idc += (l + closePathCorr);
  78917. }
  78918. // vertical distances (v)
  78919. var path1;
  78920. var path2;
  78921. var vertex1 = null;
  78922. var vertex2 = null;
  78923. for (i = 0; i < minlg + closePathCorr; i++) {
  78924. vTotalDistance[i] = 0;
  78925. vs[i] = [0];
  78926. for (p = 0; p < pathArray.length - 1; p++) {
  78927. path1 = pathArray[p];
  78928. path2 = pathArray[p + 1];
  78929. if (i === minlg) { // closePath
  78930. vertex1 = path1[0];
  78931. vertex2 = path2[0];
  78932. }
  78933. else {
  78934. vertex1 = path1[i];
  78935. vertex2 = path2[i];
  78936. }
  78937. vectlg = vertex2.subtract(vertex1).length();
  78938. dist = vectlg + vTotalDistance[i];
  78939. vs[i].push(dist);
  78940. vTotalDistance[i] = dist;
  78941. }
  78942. if (closeArray && vertex2 && vertex1) {
  78943. path1 = pathArray[p];
  78944. path2 = pathArray[0];
  78945. if (i === minlg) { // closePath
  78946. vertex2 = path2[0];
  78947. }
  78948. vectlg = vertex2.subtract(vertex1).length();
  78949. dist = vectlg + vTotalDistance[i];
  78950. vTotalDistance[i] = dist;
  78951. }
  78952. }
  78953. // uvs
  78954. var u;
  78955. var v;
  78956. if (customUV) {
  78957. for (p = 0; p < customUV.length; p++) {
  78958. uvs.push(customUV[p].x, customUV[p].y);
  78959. }
  78960. }
  78961. else {
  78962. for (p = 0; p < pathArray.length; p++) {
  78963. for (i = 0; i < minlg + closePathCorr; i++) {
  78964. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  78965. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  78966. if (invertUV) {
  78967. uvs.push(v, u);
  78968. }
  78969. else {
  78970. uvs.push(u, v);
  78971. }
  78972. }
  78973. }
  78974. }
  78975. // indices
  78976. p = 0; // path index
  78977. var pi = 0; // positions array index
  78978. var l1 = lg[p] - 1; // path1 length
  78979. var l2 = lg[p + 1] - 1; // path2 length
  78980. var min = (l1 < l2) ? l1 : l2; // current path stop index
  78981. var shft = idx[1] - idx[0]; // shift
  78982. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  78983. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  78984. // 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
  78985. indices.push(pi, pi + shft, pi + 1);
  78986. indices.push(pi + shft + 1, pi + 1, pi + shft);
  78987. pi += 1;
  78988. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  78989. p++;
  78990. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  78991. shft = idx[0] - idx[p];
  78992. l1 = lg[p] - 1;
  78993. l2 = lg[0] - 1;
  78994. }
  78995. else {
  78996. shft = idx[p + 1] - idx[p];
  78997. l1 = lg[p] - 1;
  78998. l2 = lg[p + 1] - 1;
  78999. }
  79000. pi = idx[p];
  79001. min = (l1 < l2) ? l1 + pi : l2 + pi;
  79002. }
  79003. }
  79004. // normals
  79005. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  79006. if (closePath) { // update both the first and last vertex normals to their average value
  79007. var indexFirst = 0;
  79008. var indexLast = 0;
  79009. for (p = 0; p < pathArray.length; p++) {
  79010. indexFirst = idx[p] * 3;
  79011. if (p + 1 < pathArray.length) {
  79012. indexLast = (idx[p + 1] - 1) * 3;
  79013. }
  79014. else {
  79015. indexLast = normals.length - 3;
  79016. }
  79017. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  79018. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  79019. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  79020. normals[indexLast] = normals[indexFirst];
  79021. normals[indexLast + 1] = normals[indexFirst + 1];
  79022. normals[indexLast + 2] = normals[indexFirst + 2];
  79023. }
  79024. }
  79025. // sides
  79026. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79027. // Colors
  79028. var colors = null;
  79029. if (customColors) {
  79030. colors = new Float32Array(customColors.length * 4);
  79031. for (var c = 0; c < customColors.length; c++) {
  79032. colors[c * 4] = customColors[c].r;
  79033. colors[c * 4 + 1] = customColors[c].g;
  79034. colors[c * 4 + 2] = customColors[c].b;
  79035. colors[c * 4 + 3] = customColors[c].a;
  79036. }
  79037. }
  79038. // Result
  79039. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  79040. var positions32 = new Float32Array(positions);
  79041. var normals32 = new Float32Array(normals);
  79042. var uvs32 = new Float32Array(uvs);
  79043. vertexData.indices = indices;
  79044. vertexData.positions = positions32;
  79045. vertexData.normals = normals32;
  79046. vertexData.uvs = uvs32;
  79047. if (colors) {
  79048. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  79049. }
  79050. if (closePath) {
  79051. vertexData._idx = idx;
  79052. }
  79053. return vertexData;
  79054. };
  79055. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  79056. if (closeArray === void 0) { closeArray = false; }
  79057. if (updatable === void 0) { updatable = false; }
  79058. return RibbonBuilder.CreateRibbon(name, {
  79059. pathArray: pathArray,
  79060. closeArray: closeArray,
  79061. closePath: closePath,
  79062. offset: offset,
  79063. updatable: updatable,
  79064. sideOrientation: sideOrientation,
  79065. instance: instance
  79066. }, scene);
  79067. };
  79068. /**
  79069. * Class containing static functions to help procedurally build meshes
  79070. */
  79071. var RibbonBuilder = /** @class */ (function () {
  79072. function RibbonBuilder() {
  79073. }
  79074. /**
  79075. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  79076. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  79077. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  79078. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  79079. * * 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
  79080. * * 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
  79081. * * 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
  79082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79083. * * 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
  79084. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79085. * * 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
  79086. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  79087. * * 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
  79088. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  79089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79090. * @param name defines the name of the mesh
  79091. * @param options defines the options used to create the mesh
  79092. * @param scene defines the hosting scene
  79093. * @returns the ribbon mesh
  79094. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  79095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79096. */
  79097. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  79098. if (scene === void 0) { scene = null; }
  79099. var pathArray = options.pathArray;
  79100. var closeArray = options.closeArray;
  79101. var closePath = options.closePath;
  79102. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79103. var instance = options.instance;
  79104. var updatable = options.updatable;
  79105. if (instance) { // existing ribbon instance update
  79106. // positionFunction : ribbon case
  79107. // only pathArray and sideOrientation parameters are taken into account for positions update
  79108. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  79109. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  79110. var positionFunction = function (positions) {
  79111. var minlg = pathArray[0].length;
  79112. var mesh = instance;
  79113. var i = 0;
  79114. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  79115. for (var si = 1; si <= ns; ++si) {
  79116. for (var p = 0; p < pathArray.length; ++p) {
  79117. var path = pathArray[p];
  79118. var l = path.length;
  79119. minlg = (minlg < l) ? minlg : l;
  79120. for (var j = 0; j < minlg; ++j) {
  79121. var pathPoint = path[j];
  79122. positions[i] = pathPoint.x;
  79123. positions[i + 1] = pathPoint.y;
  79124. positions[i + 2] = pathPoint.z;
  79125. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  79126. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  79127. i += 3;
  79128. }
  79129. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  79130. var pathPoint = path[0];
  79131. positions[i] = pathPoint.x;
  79132. positions[i + 1] = pathPoint.y;
  79133. positions[i + 2] = pathPoint.z;
  79134. i += 3;
  79135. }
  79136. }
  79137. }
  79138. };
  79139. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  79140. positionFunction(positions);
  79141. if (instance._boundingInfo) {
  79142. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  79143. }
  79144. else {
  79145. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  79146. }
  79147. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  79148. if (options.colors) {
  79149. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  79150. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  79151. var color = options.colors[c];
  79152. colors[colorIndex] = color.r;
  79153. colors[colorIndex + 1] = color.g;
  79154. colors[colorIndex + 2] = color.b;
  79155. colors[colorIndex + 3] = color.a;
  79156. }
  79157. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  79158. }
  79159. if (options.uvs) {
  79160. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  79161. for (var i = 0; i < options.uvs.length; i++) {
  79162. uvs[i * 2] = options.uvs[i].x;
  79163. uvs[i * 2 + 1] = options.uvs[i].y;
  79164. }
  79165. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  79166. }
  79167. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  79168. var indices = instance.getIndices();
  79169. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  79170. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  79171. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  79172. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  79173. var indexFirst = 0;
  79174. var indexLast = 0;
  79175. for (var p = 0; p < pathArray.length; p++) {
  79176. indexFirst = instance._creationDataStorage.idx[p] * 3;
  79177. if (p + 1 < pathArray.length) {
  79178. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  79179. }
  79180. else {
  79181. indexLast = normals.length - 3;
  79182. }
  79183. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  79184. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  79185. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  79186. normals[indexLast] = normals[indexFirst];
  79187. normals[indexLast + 1] = normals[indexFirst + 1];
  79188. normals[indexLast + 2] = normals[indexFirst + 2];
  79189. }
  79190. }
  79191. if (!(instance.areNormalsFrozen)) {
  79192. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  79193. }
  79194. }
  79195. return instance;
  79196. }
  79197. else { // new ribbon creation
  79198. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79199. ribbon._originalBuilderSideOrientation = sideOrientation;
  79200. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  79201. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  79202. if (closePath) {
  79203. ribbon._creationDataStorage.idx = vertexData._idx;
  79204. }
  79205. ribbon._creationDataStorage.closePath = closePath;
  79206. ribbon._creationDataStorage.closeArray = closeArray;
  79207. vertexData.applyToMesh(ribbon, updatable);
  79208. return ribbon;
  79209. }
  79210. };
  79211. return RibbonBuilder;
  79212. }());
  79213. /***/ }),
  79214. /***/ "./Meshes/Builders/shapeBuilder.ts":
  79215. /*!*****************************************!*\
  79216. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  79217. \*****************************************/
  79218. /*! exports provided: ShapeBuilder */
  79219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79220. "use strict";
  79221. __webpack_require__.r(__webpack_exports__);
  79222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  79223. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79224. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79225. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79226. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  79227. if (scene === void 0) { scene = null; }
  79228. var options = {
  79229. shape: shape,
  79230. path: path,
  79231. scale: scale,
  79232. rotation: rotation,
  79233. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  79234. sideOrientation: sideOrientation,
  79235. instance: instance,
  79236. updatable: updatable
  79237. };
  79238. return ShapeBuilder.ExtrudeShape(name, options, scene);
  79239. };
  79240. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  79241. var options = {
  79242. shape: shape,
  79243. path: path,
  79244. scaleFunction: scaleFunction,
  79245. rotationFunction: rotationFunction,
  79246. ribbonCloseArray: ribbonCloseArray,
  79247. ribbonClosePath: ribbonClosePath,
  79248. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  79249. sideOrientation: sideOrientation,
  79250. instance: instance,
  79251. updatable: updatable
  79252. };
  79253. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  79254. };
  79255. /**
  79256. * Class containing static functions to help procedurally build meshes
  79257. */
  79258. var ShapeBuilder = /** @class */ (function () {
  79259. function ShapeBuilder() {
  79260. }
  79261. /**
  79262. * 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.
  79263. * * 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.
  79264. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  79265. * * 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.
  79266. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  79267. * * 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
  79268. * * 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
  79269. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  79270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79271. * * 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
  79272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  79273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79274. * @param name defines the name of the mesh
  79275. * @param options defines the options used to create the mesh
  79276. * @param scene defines the hosting scene
  79277. * @returns the extruded shape mesh
  79278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79280. */
  79281. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  79282. if (scene === void 0) { scene = null; }
  79283. var path = options.path;
  79284. var shape = options.shape;
  79285. var scale = options.scale || 1;
  79286. var rotation = options.rotation || 0;
  79287. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79288. var updatable = options.updatable;
  79289. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79290. var instance = options.instance || null;
  79291. var invertUV = options.invertUV || false;
  79292. 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);
  79293. };
  79294. /**
  79295. * Creates an custom extruded shape mesh.
  79296. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  79297. * * 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.
  79298. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  79299. * * 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
  79300. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  79301. * * 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
  79302. * * It must returns a float value that will be the scale value applied to the shape on each path point
  79303. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79304. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  79305. * * 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
  79306. * * 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
  79307. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  79308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79309. * * 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
  79310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79312. * @param name defines the name of the mesh
  79313. * @param options defines the options used to create the mesh
  79314. * @param scene defines the hosting scene
  79315. * @returns the custom extruded shape mesh
  79316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  79317. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79319. */
  79320. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  79321. var path = options.path;
  79322. var shape = options.shape;
  79323. var scaleFunction = options.scaleFunction || (function () { return 1; });
  79324. var rotationFunction = options.rotationFunction || (function () { return 0; });
  79325. var ribbonCloseArray = options.ribbonCloseArray || false;
  79326. var ribbonClosePath = options.ribbonClosePath || false;
  79327. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79328. var updatable = options.updatable;
  79329. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79330. var instance = options.instance;
  79331. var invertUV = options.invertUV || false;
  79332. 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);
  79333. };
  79334. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  79335. // extrusion geometry
  79336. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  79337. var tangents = path3D.getTangents();
  79338. var normals = path3D.getNormals();
  79339. var binormals = path3D.getBinormals();
  79340. var distances = path3D.getDistances();
  79341. var angle = 0;
  79342. var returnScale = function () { return scale !== null ? scale : 1; };
  79343. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  79344. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  79345. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  79346. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  79347. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  79348. for (var i = 0; i < curve.length; i++) {
  79349. var shapePath = new Array();
  79350. var angleStep = rotate(i, distances[i]);
  79351. var scaleRatio = scl(i, distances[i]);
  79352. for (var p = 0; p < shape.length; p++) {
  79353. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  79354. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  79355. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79356. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  79357. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  79358. shapePath[p] = rotated;
  79359. }
  79360. shapePaths[index] = shapePath;
  79361. angle += angleStep;
  79362. index++;
  79363. }
  79364. // cap
  79365. var capPath = function (shapePath) {
  79366. var pointCap = Array();
  79367. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79368. var i;
  79369. for (i = 0; i < shapePath.length; i++) {
  79370. barycenter.addInPlace(shapePath[i]);
  79371. }
  79372. barycenter.scaleInPlace(1.0 / shapePath.length);
  79373. for (i = 0; i < shapePath.length; i++) {
  79374. pointCap.push(barycenter);
  79375. }
  79376. return pointCap;
  79377. };
  79378. switch (cap) {
  79379. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  79380. break;
  79381. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  79382. shapePaths[0] = capPath(shapePaths[2]);
  79383. shapePaths[1] = shapePaths[2];
  79384. break;
  79385. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  79386. shapePaths[index] = shapePaths[index - 1];
  79387. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  79388. break;
  79389. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  79390. shapePaths[0] = capPath(shapePaths[2]);
  79391. shapePaths[1] = shapePaths[2];
  79392. shapePaths[index] = shapePaths[index - 1];
  79393. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  79394. break;
  79395. default:
  79396. break;
  79397. }
  79398. return shapePaths;
  79399. };
  79400. var path3D;
  79401. var pathArray;
  79402. if (instance) { // instance update
  79403. var storage = instance._creationDataStorage;
  79404. path3D = storage.path3D.update(curve);
  79405. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  79406. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  79407. return instance;
  79408. }
  79409. // extruded shape creation
  79410. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  79411. var newShapePaths = new Array();
  79412. cap = (cap < 0 || cap > 3) ? 0 : cap;
  79413. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  79414. 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);
  79415. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  79416. extrudedGeneric._creationDataStorage.path3D = path3D;
  79417. extrudedGeneric._creationDataStorage.cap = cap;
  79418. return extrudedGeneric;
  79419. };
  79420. return ShapeBuilder;
  79421. }());
  79422. /***/ }),
  79423. /***/ "./Meshes/Builders/sphereBuilder.ts":
  79424. /*!******************************************!*\
  79425. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  79426. \******************************************/
  79427. /*! exports provided: SphereBuilder */
  79428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79429. "use strict";
  79430. __webpack_require__.r(__webpack_exports__);
  79431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  79432. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79433. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79434. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79435. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  79436. var segments = options.segments || 32;
  79437. var diameterX = options.diameterX || options.diameter || 1;
  79438. var diameterY = options.diameterY || options.diameter || 1;
  79439. var diameterZ = options.diameterZ || options.diameter || 1;
  79440. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  79441. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  79442. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79443. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  79444. var totalZRotationSteps = 2 + segments;
  79445. var totalYRotationSteps = 2 * totalZRotationSteps;
  79446. var indices = [];
  79447. var positions = [];
  79448. var normals = [];
  79449. var uvs = [];
  79450. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  79451. var normalizedZ = zRotationStep / totalZRotationSteps;
  79452. var angleZ = normalizedZ * Math.PI * slice;
  79453. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  79454. var normalizedY = yRotationStep / totalYRotationSteps;
  79455. var angleY = normalizedY * Math.PI * 2 * arc;
  79456. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  79457. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  79458. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  79459. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  79460. var vertex = complete.multiply(radius);
  79461. var normal = complete.divide(radius).normalize();
  79462. positions.push(vertex.x, vertex.y, vertex.z);
  79463. normals.push(normal.x, normal.y, normal.z);
  79464. uvs.push(normalizedY, normalizedZ);
  79465. }
  79466. if (zRotationStep > 0) {
  79467. var verticesCount = positions.length / 3;
  79468. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  79469. indices.push((firstIndex));
  79470. indices.push((firstIndex + 1));
  79471. indices.push(firstIndex + totalYRotationSteps + 1);
  79472. indices.push((firstIndex + totalYRotationSteps + 1));
  79473. indices.push((firstIndex + 1));
  79474. indices.push((firstIndex + totalYRotationSteps + 2));
  79475. }
  79476. }
  79477. }
  79478. // Sides
  79479. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79480. // Result
  79481. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79482. vertexData.indices = indices;
  79483. vertexData.positions = positions;
  79484. vertexData.normals = normals;
  79485. vertexData.uvs = uvs;
  79486. return vertexData;
  79487. };
  79488. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  79489. var options = {
  79490. segments: segments,
  79491. diameterX: diameter,
  79492. diameterY: diameter,
  79493. diameterZ: diameter,
  79494. sideOrientation: sideOrientation,
  79495. updatable: updatable
  79496. };
  79497. return SphereBuilder.CreateSphere(name, options, scene);
  79498. };
  79499. /**
  79500. * Class containing static functions to help procedurally build meshes
  79501. */
  79502. var SphereBuilder = /** @class */ (function () {
  79503. function SphereBuilder() {
  79504. }
  79505. /**
  79506. * Creates a sphere mesh
  79507. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  79508. * * 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`)
  79509. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  79510. * * 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
  79511. * * 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)
  79512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79513. * * 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
  79514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79515. * @param name defines the name of the mesh
  79516. * @param options defines the options used to create the mesh
  79517. * @param scene defines the hosting scene
  79518. * @returns the sphere mesh
  79519. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  79520. */
  79521. SphereBuilder.CreateSphere = function (name, options, scene) {
  79522. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79523. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79524. sphere._originalBuilderSideOrientation = options.sideOrientation;
  79525. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  79526. vertexData.applyToMesh(sphere, options.updatable);
  79527. return sphere;
  79528. };
  79529. return SphereBuilder;
  79530. }());
  79531. /***/ }),
  79532. /***/ "./Meshes/Builders/torusBuilder.ts":
  79533. /*!*****************************************!*\
  79534. !*** ./Meshes/Builders/torusBuilder.ts ***!
  79535. \*****************************************/
  79536. /*! exports provided: TorusBuilder */
  79537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79538. "use strict";
  79539. __webpack_require__.r(__webpack_exports__);
  79540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  79541. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79542. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79543. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79544. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  79545. var indices = [];
  79546. var positions = [];
  79547. var normals = [];
  79548. var uvs = [];
  79549. var diameter = options.diameter || 1;
  79550. var thickness = options.thickness || 0.5;
  79551. var tessellation = options.tessellation || 16;
  79552. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79553. var stride = tessellation + 1;
  79554. for (var i = 0; i <= tessellation; i++) {
  79555. var u = i / tessellation;
  79556. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  79557. 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));
  79558. for (var j = 0; j <= tessellation; j++) {
  79559. var v = 1 - j / tessellation;
  79560. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  79561. var dx = Math.cos(innerAngle);
  79562. var dy = Math.sin(innerAngle);
  79563. // Create a vertex.
  79564. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  79565. var position = normal.scale(thickness / 2);
  79566. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  79567. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  79568. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  79569. positions.push(position.x, position.y, position.z);
  79570. normals.push(normal.x, normal.y, normal.z);
  79571. uvs.push(textureCoordinate.x, textureCoordinate.y);
  79572. // And create indices for two triangles.
  79573. var nextI = (i + 1) % stride;
  79574. var nextJ = (j + 1) % stride;
  79575. indices.push(i * stride + j);
  79576. indices.push(i * stride + nextJ);
  79577. indices.push(nextI * stride + j);
  79578. indices.push(i * stride + nextJ);
  79579. indices.push(nextI * stride + nextJ);
  79580. indices.push(nextI * stride + j);
  79581. }
  79582. }
  79583. // Sides
  79584. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79585. // Result
  79586. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79587. vertexData.indices = indices;
  79588. vertexData.positions = positions;
  79589. vertexData.normals = normals;
  79590. vertexData.uvs = uvs;
  79591. return vertexData;
  79592. };
  79593. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  79594. var options = {
  79595. diameter: diameter,
  79596. thickness: thickness,
  79597. tessellation: tessellation,
  79598. sideOrientation: sideOrientation,
  79599. updatable: updatable
  79600. };
  79601. return TorusBuilder.CreateTorus(name, options, scene);
  79602. };
  79603. /**
  79604. * Class containing static functions to help procedurally build meshes
  79605. */
  79606. var TorusBuilder = /** @class */ (function () {
  79607. function TorusBuilder() {
  79608. }
  79609. /**
  79610. * Creates a torus mesh
  79611. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  79612. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  79613. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  79614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79615. * * 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
  79616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79617. * @param name defines the name of the mesh
  79618. * @param options defines the options used to create the mesh
  79619. * @param scene defines the hosting scene
  79620. * @returns the torus mesh
  79621. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  79622. */
  79623. TorusBuilder.CreateTorus = function (name, options, scene) {
  79624. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79625. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79626. torus._originalBuilderSideOrientation = options.sideOrientation;
  79627. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  79628. vertexData.applyToMesh(torus, options.updatable);
  79629. return torus;
  79630. };
  79631. return TorusBuilder;
  79632. }());
  79633. /***/ }),
  79634. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  79635. /*!*********************************************!*\
  79636. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  79637. \*********************************************/
  79638. /*! exports provided: TorusKnotBuilder */
  79639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79640. "use strict";
  79641. __webpack_require__.r(__webpack_exports__);
  79642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  79643. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79644. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79645. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79646. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  79647. var indices = new Array();
  79648. var positions = new Array();
  79649. var normals = new Array();
  79650. var uvs = new Array();
  79651. var radius = options.radius || 2;
  79652. var tube = options.tube || 0.5;
  79653. var radialSegments = options.radialSegments || 32;
  79654. var tubularSegments = options.tubularSegments || 32;
  79655. var p = options.p || 2;
  79656. var q = options.q || 3;
  79657. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79658. // Helper
  79659. var getPos = function (angle) {
  79660. var cu = Math.cos(angle);
  79661. var su = Math.sin(angle);
  79662. var quOverP = q / p * angle;
  79663. var cs = Math.cos(quOverP);
  79664. var tx = radius * (2 + cs) * 0.5 * cu;
  79665. var ty = radius * (2 + cs) * su * 0.5;
  79666. var tz = radius * Math.sin(quOverP) * 0.5;
  79667. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  79668. };
  79669. // Vertices
  79670. var i;
  79671. var j;
  79672. for (i = 0; i <= radialSegments; i++) {
  79673. var modI = i % radialSegments;
  79674. var u = modI / radialSegments * 2 * p * Math.PI;
  79675. var p1 = getPos(u);
  79676. var p2 = getPos(u + 0.01);
  79677. var tang = p2.subtract(p1);
  79678. var n = p2.add(p1);
  79679. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  79680. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  79681. bitan.normalize();
  79682. n.normalize();
  79683. for (j = 0; j < tubularSegments; j++) {
  79684. var modJ = j % tubularSegments;
  79685. var v = modJ / tubularSegments * 2 * Math.PI;
  79686. var cx = -tube * Math.cos(v);
  79687. var cy = tube * Math.sin(v);
  79688. positions.push(p1.x + cx * n.x + cy * bitan.x);
  79689. positions.push(p1.y + cx * n.y + cy * bitan.y);
  79690. positions.push(p1.z + cx * n.z + cy * bitan.z);
  79691. uvs.push(i / radialSegments);
  79692. uvs.push(j / tubularSegments);
  79693. }
  79694. }
  79695. for (i = 0; i < radialSegments; i++) {
  79696. for (j = 0; j < tubularSegments; j++) {
  79697. var jNext = (j + 1) % tubularSegments;
  79698. var a = i * tubularSegments + j;
  79699. var b = (i + 1) * tubularSegments + j;
  79700. var c = (i + 1) * tubularSegments + jNext;
  79701. var d = i * tubularSegments + jNext;
  79702. indices.push(d);
  79703. indices.push(b);
  79704. indices.push(a);
  79705. indices.push(d);
  79706. indices.push(c);
  79707. indices.push(b);
  79708. }
  79709. }
  79710. // Normals
  79711. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  79712. // Sides
  79713. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79714. // Result
  79715. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79716. vertexData.indices = indices;
  79717. vertexData.positions = positions;
  79718. vertexData.normals = normals;
  79719. vertexData.uvs = uvs;
  79720. return vertexData;
  79721. };
  79722. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  79723. var options = {
  79724. radius: radius,
  79725. tube: tube,
  79726. radialSegments: radialSegments,
  79727. tubularSegments: tubularSegments,
  79728. p: p,
  79729. q: q,
  79730. sideOrientation: sideOrientation,
  79731. updatable: updatable
  79732. };
  79733. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  79734. };
  79735. /**
  79736. * Class containing static functions to help procedurally build meshes
  79737. */
  79738. var TorusKnotBuilder = /** @class */ (function () {
  79739. function TorusKnotBuilder() {
  79740. }
  79741. /**
  79742. * Creates a torus knot mesh
  79743. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  79744. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  79745. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  79746. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  79747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79748. * * 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
  79749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79750. * @param name defines the name of the mesh
  79751. * @param options defines the options used to create the mesh
  79752. * @param scene defines the hosting scene
  79753. * @returns the torus knot mesh
  79754. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  79755. */
  79756. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  79757. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79758. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79759. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  79760. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  79761. vertexData.applyToMesh(torusKnot, options.updatable);
  79762. return torusKnot;
  79763. };
  79764. return TorusKnotBuilder;
  79765. }());
  79766. /***/ }),
  79767. /***/ "./Meshes/Builders/tubeBuilder.ts":
  79768. /*!****************************************!*\
  79769. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  79770. \****************************************/
  79771. /*! exports provided: TubeBuilder */
  79772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79773. "use strict";
  79774. __webpack_require__.r(__webpack_exports__);
  79775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  79776. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79777. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79778. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79779. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  79780. var options = {
  79781. path: path,
  79782. radius: radius,
  79783. tessellation: tessellation,
  79784. radiusFunction: radiusFunction,
  79785. arc: 1,
  79786. cap: cap,
  79787. updatable: updatable,
  79788. sideOrientation: sideOrientation,
  79789. instance: instance
  79790. };
  79791. return TubeBuilder.CreateTube(name, options, scene);
  79792. };
  79793. /**
  79794. * Class containing static functions to help procedurally build meshes
  79795. */
  79796. var TubeBuilder = /** @class */ (function () {
  79797. function TubeBuilder() {
  79798. }
  79799. /**
  79800. * Creates a tube mesh.
  79801. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  79802. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  79803. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  79804. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  79805. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  79806. * * 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)
  79807. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  79808. * * 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
  79809. * * 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
  79810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79811. * * 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
  79812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79814. * @param name defines the name of the mesh
  79815. * @param options defines the options used to create the mesh
  79816. * @param scene defines the hosting scene
  79817. * @returns the tube mesh
  79818. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79819. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  79820. */
  79821. TubeBuilder.CreateTube = function (name, options, scene) {
  79822. var path = options.path;
  79823. var instance = options.instance;
  79824. var radius = 1.0;
  79825. if (options.radius !== undefined) {
  79826. radius = options.radius;
  79827. }
  79828. else if (instance) {
  79829. radius = instance._creationDataStorage.radius;
  79830. }
  79831. var tessellation = options.tessellation || 64 | 0;
  79832. var radiusFunction = options.radiusFunction || null;
  79833. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79834. var invertUV = options.invertUV || false;
  79835. var updatable = options.updatable;
  79836. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79837. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  79838. // tube geometry
  79839. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  79840. var tangents = path3D.getTangents();
  79841. var normals = path3D.getNormals();
  79842. var distances = path3D.getDistances();
  79843. var pi2 = Math.PI * 2;
  79844. var step = pi2 / tessellation * arc;
  79845. var returnRadius = function () { return radius; };
  79846. var radiusFunctionFinal = radiusFunction || returnRadius;
  79847. var circlePath;
  79848. var rad;
  79849. var normal;
  79850. var rotated;
  79851. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  79852. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  79853. for (var i = 0; i < path.length; i++) {
  79854. rad = radiusFunctionFinal(i, distances[i]); // current radius
  79855. circlePath = Array(); // current circle array
  79856. normal = normals[i]; // current normal
  79857. for (var t = 0; t < tessellation; t++) {
  79858. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  79859. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79860. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  79861. rotated.scaleInPlace(rad).addInPlace(path[i]);
  79862. circlePath[t] = rotated;
  79863. }
  79864. circlePaths[index] = circlePath;
  79865. index++;
  79866. }
  79867. // cap
  79868. var capPath = function (nbPoints, pathIndex) {
  79869. var pointCap = Array();
  79870. for (var i = 0; i < nbPoints; i++) {
  79871. pointCap.push(path[pathIndex]);
  79872. }
  79873. return pointCap;
  79874. };
  79875. switch (cap) {
  79876. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  79877. break;
  79878. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  79879. circlePaths[0] = capPath(tessellation, 0);
  79880. circlePaths[1] = circlePaths[2].slice(0);
  79881. break;
  79882. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  79883. circlePaths[index] = circlePaths[index - 1].slice(0);
  79884. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  79885. break;
  79886. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  79887. circlePaths[0] = capPath(tessellation, 0);
  79888. circlePaths[1] = circlePaths[2].slice(0);
  79889. circlePaths[index] = circlePaths[index - 1].slice(0);
  79890. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  79891. break;
  79892. default:
  79893. break;
  79894. }
  79895. return circlePaths;
  79896. };
  79897. var path3D;
  79898. var pathArray;
  79899. if (instance) { // tube update
  79900. var storage = instance._creationDataStorage;
  79901. var arc = options.arc || storage.arc;
  79902. path3D = storage.path3D.update(path);
  79903. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  79904. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  79905. // Update mode, no need to recreate the storage.
  79906. storage.path3D = path3D;
  79907. storage.pathArray = pathArray;
  79908. storage.arc = arc;
  79909. storage.radius = radius;
  79910. return instance;
  79911. }
  79912. // tube creation
  79913. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  79914. var newPathArray = new Array();
  79915. cap = (cap < 0 || cap > 3) ? 0 : cap;
  79916. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  79917. 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);
  79918. tube._creationDataStorage.pathArray = pathArray;
  79919. tube._creationDataStorage.path3D = path3D;
  79920. tube._creationDataStorage.tessellation = tessellation;
  79921. tube._creationDataStorage.cap = cap;
  79922. tube._creationDataStorage.arc = options.arc;
  79923. tube._creationDataStorage.radius = radius;
  79924. return tube;
  79925. };
  79926. return TubeBuilder;
  79927. }());
  79928. /***/ }),
  79929. /***/ "./Meshes/Compression/dracoCompression.ts":
  79930. /*!************************************************!*\
  79931. !*** ./Meshes/Compression/dracoCompression.ts ***!
  79932. \************************************************/
  79933. /*! exports provided: DracoCompression */
  79934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79935. "use strict";
  79936. __webpack_require__.r(__webpack_exports__);
  79937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  79938. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  79939. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79940. /**
  79941. * Draco compression (https://google.github.io/draco/)
  79942. *
  79943. * This class wraps the Draco module.
  79944. *
  79945. * **Encoder**
  79946. *
  79947. * The encoder is not currently implemented.
  79948. *
  79949. * **Decoder**
  79950. *
  79951. * 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.
  79952. *
  79953. * To update the configuration, use the following code:
  79954. * ```javascript
  79955. * DracoCompression.Configuration = {
  79956. * decoder: {
  79957. * wasmUrl: "<url to the WebAssembly library>",
  79958. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  79959. * fallbackUrl: "<url to the fallback JavaScript library>",
  79960. * }
  79961. * };
  79962. * ```
  79963. *
  79964. * 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.
  79965. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  79966. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  79967. *
  79968. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  79969. * ```javascript
  79970. * var dracoCompression = new DracoCompression();
  79971. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  79972. * [VertexBuffer.PositionKind]: 0
  79973. * });
  79974. * ```
  79975. *
  79976. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  79977. */
  79978. var DracoCompression = /** @class */ (function () {
  79979. /**
  79980. * Constructor
  79981. */
  79982. function DracoCompression() {
  79983. }
  79984. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  79985. /**
  79986. * Returns true if the decoder is available.
  79987. */
  79988. get: function () {
  79989. if (typeof DracoDecoderModule !== "undefined") {
  79990. return true;
  79991. }
  79992. var decoder = DracoCompression.Configuration.decoder;
  79993. if (decoder) {
  79994. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  79995. return true;
  79996. }
  79997. if (decoder.fallbackUrl) {
  79998. return true;
  79999. }
  80000. }
  80001. return false;
  80002. },
  80003. enumerable: true,
  80004. configurable: true
  80005. });
  80006. /**
  80007. * Stop all async operations and release resources.
  80008. */
  80009. DracoCompression.prototype.dispose = function () {
  80010. };
  80011. /**
  80012. * Decode Draco compressed mesh data to vertex data.
  80013. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  80014. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  80015. * @returns A promise that resolves with the decoded vertex data
  80016. */
  80017. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  80018. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  80019. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  80020. var module = wrappedModule.module;
  80021. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  80022. var buffer = new module.DecoderBuffer();
  80023. buffer.Init(dataView, dataView.byteLength);
  80024. var decoder = new module.Decoder();
  80025. var geometry;
  80026. var status;
  80027. try {
  80028. var type = decoder.GetEncodedGeometryType(buffer);
  80029. switch (type) {
  80030. case module.TRIANGULAR_MESH:
  80031. geometry = new module.Mesh();
  80032. status = decoder.DecodeBufferToMesh(buffer, geometry);
  80033. break;
  80034. case module.POINT_CLOUD:
  80035. geometry = new module.PointCloud();
  80036. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  80037. break;
  80038. default:
  80039. throw new Error("Invalid geometry type " + type);
  80040. }
  80041. if (!status.ok() || !geometry.ptr) {
  80042. throw new Error(status.error_msg());
  80043. }
  80044. var numPoints = geometry.num_points();
  80045. if (type === module.TRIANGULAR_MESH) {
  80046. var numFaces = geometry.num_faces();
  80047. var faceIndices = new module.DracoInt32Array();
  80048. try {
  80049. var indices = new Uint32Array(numFaces * 3);
  80050. for (var i = 0; i < numFaces; i++) {
  80051. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  80052. var offset = i * 3;
  80053. indices[offset + 0] = faceIndices.GetValue(0);
  80054. indices[offset + 1] = faceIndices.GetValue(1);
  80055. indices[offset + 2] = faceIndices.GetValue(2);
  80056. }
  80057. vertexData.indices = indices;
  80058. }
  80059. finally {
  80060. module.destroy(faceIndices);
  80061. }
  80062. }
  80063. for (var kind in attributes) {
  80064. var uniqueId = attributes[kind];
  80065. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  80066. var dracoData = new module.DracoFloat32Array();
  80067. try {
  80068. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  80069. var babylonData = new Float32Array(numPoints * attribute.num_components());
  80070. for (var i = 0; i < babylonData.length; i++) {
  80071. babylonData[i] = dracoData.GetValue(i);
  80072. }
  80073. vertexData.set(babylonData, kind);
  80074. }
  80075. finally {
  80076. module.destroy(dracoData);
  80077. }
  80078. }
  80079. }
  80080. finally {
  80081. if (geometry) {
  80082. module.destroy(geometry);
  80083. }
  80084. module.destroy(decoder);
  80085. module.destroy(buffer);
  80086. }
  80087. return vertexData;
  80088. });
  80089. };
  80090. DracoCompression._GetDecoderModule = function () {
  80091. if (!DracoCompression._DecoderModulePromise) {
  80092. var promise = null;
  80093. var config_1 = {};
  80094. if (typeof DracoDecoderModule !== "undefined") {
  80095. promise = Promise.resolve();
  80096. }
  80097. else {
  80098. var decoder = DracoCompression.Configuration.decoder;
  80099. if (decoder) {
  80100. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  80101. promise = Promise.all([
  80102. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  80103. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  80104. config_1.wasmBinary = data;
  80105. })
  80106. ]);
  80107. }
  80108. else if (decoder.fallbackUrl) {
  80109. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  80110. }
  80111. }
  80112. }
  80113. if (!promise) {
  80114. throw new Error("Draco decoder module is not available");
  80115. }
  80116. DracoCompression._DecoderModulePromise = promise.then(function () {
  80117. return new Promise(function (resolve) {
  80118. config_1.onModuleLoaded = function (decoderModule) {
  80119. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  80120. resolve({ module: decoderModule });
  80121. };
  80122. DracoDecoderModule(config_1);
  80123. });
  80124. });
  80125. }
  80126. return DracoCompression._DecoderModulePromise;
  80127. };
  80128. DracoCompression._LoadScriptAsync = function (url) {
  80129. return new Promise(function (resolve, reject) {
  80130. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  80131. resolve();
  80132. }, function (message) {
  80133. reject(new Error(message));
  80134. });
  80135. });
  80136. };
  80137. DracoCompression._LoadFileAsync = function (url) {
  80138. return new Promise(function (resolve, reject) {
  80139. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  80140. resolve(data);
  80141. }, undefined, undefined, true, function (request, exception) {
  80142. reject(exception);
  80143. });
  80144. });
  80145. };
  80146. /**
  80147. * The configuration. Defaults to the following urls:
  80148. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  80149. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  80150. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  80151. */
  80152. DracoCompression.Configuration = {
  80153. decoder: {
  80154. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  80155. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  80156. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  80157. }
  80158. };
  80159. return DracoCompression;
  80160. }());
  80161. /***/ }),
  80162. /***/ "./Meshes/Compression/index.ts":
  80163. /*!*************************************!*\
  80164. !*** ./Meshes/Compression/index.ts ***!
  80165. \*************************************/
  80166. /*! exports provided: DracoCompression */
  80167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80168. "use strict";
  80169. __webpack_require__.r(__webpack_exports__);
  80170. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  80171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  80172. /***/ }),
  80173. /***/ "./Meshes/abstractMesh.ts":
  80174. /*!********************************!*\
  80175. !*** ./Meshes/abstractMesh.ts ***!
  80176. \********************************/
  80177. /*! exports provided: AbstractMesh */
  80178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80179. "use strict";
  80180. __webpack_require__.r(__webpack_exports__);
  80181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  80182. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  80183. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  80184. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  80185. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80186. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  80187. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80188. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80189. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  80190. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  80191. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  80192. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  80193. /** @hidden */
  80194. var _FacetDataStorage = /** @class */ (function () {
  80195. function _FacetDataStorage() {
  80196. this.facetNb = 0; // facet number
  80197. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  80198. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  80199. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  80200. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  80201. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  80202. this.subDiv = {
  80203. max: 1,
  80204. X: 1,
  80205. Y: 1,
  80206. Z: 1
  80207. };
  80208. this.facetDepthSort = false; // is the facet depth sort to be computed
  80209. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  80210. }
  80211. return _FacetDataStorage;
  80212. }());
  80213. /**
  80214. * Class used to store all common mesh properties
  80215. */
  80216. var AbstractMesh = /** @class */ (function (_super) {
  80217. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  80218. // Constructor
  80219. /**
  80220. * Creates a new AbstractMesh
  80221. * @param name defines the name of the mesh
  80222. * @param scene defines the hosting scene
  80223. */
  80224. function AbstractMesh(name, scene) {
  80225. if (scene === void 0) { scene = null; }
  80226. var _this = _super.call(this, name, scene, false) || this;
  80227. _this._facetData = new _FacetDataStorage();
  80228. /**
  80229. * The culling strategy to use to check whether the mesh must be rendered or not.
  80230. * This value can be changed at any time and will be used on the next render mesh selection.
  80231. * The possible values are :
  80232. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80233. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80234. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80235. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80236. * Please read each static variable documentation to get details about the culling process.
  80237. * */
  80238. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  80239. // Events
  80240. /**
  80241. * An event triggered when this mesh collides with another one
  80242. */
  80243. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80244. /**
  80245. * An event triggered when the collision's position changes
  80246. */
  80247. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80248. /**
  80249. * An event triggered when material is changed
  80250. */
  80251. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80252. // Properties
  80253. /**
  80254. * Gets or sets the orientation for POV movement & rotation
  80255. */
  80256. _this.definedFacingForward = true;
  80257. _this._visibility = 1.0;
  80258. /** Gets or sets the alpha index used to sort transparent meshes
  80259. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80260. */
  80261. _this.alphaIndex = Number.MAX_VALUE;
  80262. /**
  80263. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80264. */
  80265. _this.isVisible = true;
  80266. /**
  80267. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80268. */
  80269. _this.isPickable = true;
  80270. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80271. _this.showSubMeshesBoundingBox = false;
  80272. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80273. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80274. */
  80275. _this.isBlocker = false;
  80276. /**
  80277. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80278. */
  80279. _this.enablePointerMoveEvents = false;
  80280. /**
  80281. * Specifies the rendering group id for this mesh (0 by default)
  80282. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80283. */
  80284. _this.renderingGroupId = 0;
  80285. _this._receiveShadows = false;
  80286. /** Defines color to use when rendering outline */
  80287. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  80288. /** Define width to use when rendering outline */
  80289. _this.outlineWidth = 0.02;
  80290. /** Defines color to use when rendering overlay */
  80291. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  80292. /** Defines alpha to use when rendering overlay */
  80293. _this.overlayAlpha = 0.5;
  80294. _this._hasVertexAlpha = false;
  80295. _this._useVertexColors = true;
  80296. _this._computeBonesUsingShaders = true;
  80297. _this._numBoneInfluencers = 4;
  80298. _this._applyFog = true;
  80299. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80300. _this.useOctreeForRenderingSelection = true;
  80301. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80302. _this.useOctreeForPicking = true;
  80303. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80304. _this.useOctreeForCollisions = true;
  80305. _this._layerMask = 0x0FFFFFFF;
  80306. /**
  80307. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80308. */
  80309. _this.alwaysSelectAsActiveMesh = false;
  80310. /**
  80311. * Gets or sets the current action manager
  80312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80313. */
  80314. _this.actionManager = null;
  80315. // Collisions
  80316. _this._checkCollisions = false;
  80317. _this._collisionMask = -1;
  80318. _this._collisionGroup = -1;
  80319. /**
  80320. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80322. */
  80323. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  80324. /**
  80325. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80327. */
  80328. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  80329. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  80330. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  80331. // Edges
  80332. /**
  80333. * Defines edge width used when edgesRenderer is enabled
  80334. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80335. */
  80336. _this.edgesWidth = 1;
  80337. /**
  80338. * Defines edge color used when edgesRenderer is enabled
  80339. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80340. */
  80341. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  80342. /** @hidden */
  80343. _this._renderId = 0;
  80344. /** @hidden */
  80345. _this._intersectionsInProgress = new Array();
  80346. /** @hidden */
  80347. _this._unIndexed = false;
  80348. /** @hidden */
  80349. _this._lightSources = new Array();
  80350. /**
  80351. * An event triggered when the mesh is rebuilt.
  80352. */
  80353. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  80354. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  80355. if (collidedMesh === void 0) { collidedMesh = null; }
  80356. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  80357. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  80358. _this.position.addInPlace(_this._diffPositionForCollisions);
  80359. }
  80360. if (collidedMesh) {
  80361. _this.onCollideObservable.notifyObservers(collidedMesh);
  80362. }
  80363. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  80364. };
  80365. _this.getScene().addMesh(_this);
  80366. _this._resyncLightSources();
  80367. return _this;
  80368. }
  80369. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  80370. /**
  80371. * No billboard
  80372. */
  80373. get: function () {
  80374. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  80375. },
  80376. enumerable: true,
  80377. configurable: true
  80378. });
  80379. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  80380. /** Billboard on X axis */
  80381. get: function () {
  80382. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  80383. },
  80384. enumerable: true,
  80385. configurable: true
  80386. });
  80387. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  80388. /** Billboard on Y axis */
  80389. get: function () {
  80390. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  80391. },
  80392. enumerable: true,
  80393. configurable: true
  80394. });
  80395. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  80396. /** Billboard on Z axis */
  80397. get: function () {
  80398. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  80399. },
  80400. enumerable: true,
  80401. configurable: true
  80402. });
  80403. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  80404. /** Billboard on all axes */
  80405. get: function () {
  80406. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  80407. },
  80408. enumerable: true,
  80409. configurable: true
  80410. });
  80411. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  80412. /**
  80413. * Gets the number of facets in the mesh
  80414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80415. */
  80416. get: function () {
  80417. return this._facetData.facetNb;
  80418. },
  80419. enumerable: true,
  80420. configurable: true
  80421. });
  80422. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  80423. /**
  80424. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80425. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80426. */
  80427. get: function () {
  80428. return this._facetData.partitioningSubdivisions;
  80429. },
  80430. set: function (nb) {
  80431. this._facetData.partitioningSubdivisions = nb;
  80432. },
  80433. enumerable: true,
  80434. configurable: true
  80435. });
  80436. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  80437. /**
  80438. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80439. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80441. */
  80442. get: function () {
  80443. return this._facetData.partitioningBBoxRatio;
  80444. },
  80445. set: function (ratio) {
  80446. this._facetData.partitioningBBoxRatio = ratio;
  80447. },
  80448. enumerable: true,
  80449. configurable: true
  80450. });
  80451. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  80452. /**
  80453. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80454. * Works only for updatable meshes.
  80455. * Doesn't work with multi-materials
  80456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80457. */
  80458. get: function () {
  80459. return this._facetData.facetDepthSort;
  80460. },
  80461. set: function (sort) {
  80462. this._facetData.facetDepthSort = sort;
  80463. },
  80464. enumerable: true,
  80465. configurable: true
  80466. });
  80467. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  80468. /**
  80469. * The location (Vector3) where the facet depth sort must be computed from.
  80470. * By default, the active camera position.
  80471. * Used only when facet depth sort is enabled
  80472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80473. */
  80474. get: function () {
  80475. return this._facetData.facetDepthSortFrom;
  80476. },
  80477. set: function (location) {
  80478. this._facetData.facetDepthSortFrom = location;
  80479. },
  80480. enumerable: true,
  80481. configurable: true
  80482. });
  80483. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  80484. /**
  80485. * gets a boolean indicating if facetData is enabled
  80486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80487. */
  80488. get: function () {
  80489. return this._facetData.facetDataEnabled;
  80490. },
  80491. enumerable: true,
  80492. configurable: true
  80493. });
  80494. /** @hidden */
  80495. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  80496. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  80497. return false;
  80498. }
  80499. this._markSubMeshesAsMiscDirty();
  80500. return true;
  80501. };
  80502. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  80503. /** Set a function to call when this mesh collides with another one */
  80504. set: function (callback) {
  80505. if (this._onCollideObserver) {
  80506. this.onCollideObservable.remove(this._onCollideObserver);
  80507. }
  80508. this._onCollideObserver = this.onCollideObservable.add(callback);
  80509. },
  80510. enumerable: true,
  80511. configurable: true
  80512. });
  80513. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  80514. /** Set a function to call when the collision's position changes */
  80515. set: function (callback) {
  80516. if (this._onCollisionPositionChangeObserver) {
  80517. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  80518. }
  80519. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  80520. },
  80521. enumerable: true,
  80522. configurable: true
  80523. });
  80524. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  80525. /**
  80526. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80527. */
  80528. get: function () {
  80529. return this._visibility;
  80530. },
  80531. /**
  80532. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80533. */
  80534. set: function (value) {
  80535. if (this._visibility === value) {
  80536. return;
  80537. }
  80538. this._visibility = value;
  80539. this._markSubMeshesAsMiscDirty();
  80540. },
  80541. enumerable: true,
  80542. configurable: true
  80543. });
  80544. Object.defineProperty(AbstractMesh.prototype, "material", {
  80545. /** Gets or sets current material */
  80546. get: function () {
  80547. return this._material;
  80548. },
  80549. set: function (value) {
  80550. if (this._material === value) {
  80551. return;
  80552. }
  80553. // remove from material mesh map id needed
  80554. if (this._material && this._material.meshMap) {
  80555. this._material.meshMap[this.uniqueId] = undefined;
  80556. }
  80557. this._material = value;
  80558. if (value && value.meshMap) {
  80559. value.meshMap[this.uniqueId] = this;
  80560. }
  80561. if (this.onMaterialChangedObservable.hasObservers) {
  80562. this.onMaterialChangedObservable.notifyObservers(this);
  80563. }
  80564. if (!this.subMeshes) {
  80565. return;
  80566. }
  80567. this._unBindEffect();
  80568. },
  80569. enumerable: true,
  80570. configurable: true
  80571. });
  80572. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  80573. /**
  80574. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80575. * @see http://doc.babylonjs.com/babylon101/shadows
  80576. */
  80577. get: function () {
  80578. return this._receiveShadows;
  80579. },
  80580. set: function (value) {
  80581. if (this._receiveShadows === value) {
  80582. return;
  80583. }
  80584. this._receiveShadows = value;
  80585. this._markSubMeshesAsLightDirty();
  80586. },
  80587. enumerable: true,
  80588. configurable: true
  80589. });
  80590. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  80591. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80592. get: function () {
  80593. return this._hasVertexAlpha;
  80594. },
  80595. set: function (value) {
  80596. if (this._hasVertexAlpha === value) {
  80597. return;
  80598. }
  80599. this._hasVertexAlpha = value;
  80600. this._markSubMeshesAsAttributesDirty();
  80601. this._markSubMeshesAsMiscDirty();
  80602. },
  80603. enumerable: true,
  80604. configurable: true
  80605. });
  80606. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  80607. /** 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) */
  80608. get: function () {
  80609. return this._useVertexColors;
  80610. },
  80611. set: function (value) {
  80612. if (this._useVertexColors === value) {
  80613. return;
  80614. }
  80615. this._useVertexColors = value;
  80616. this._markSubMeshesAsAttributesDirty();
  80617. },
  80618. enumerable: true,
  80619. configurable: true
  80620. });
  80621. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  80622. /**
  80623. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80624. */
  80625. get: function () {
  80626. return this._computeBonesUsingShaders;
  80627. },
  80628. set: function (value) {
  80629. if (this._computeBonesUsingShaders === value) {
  80630. return;
  80631. }
  80632. this._computeBonesUsingShaders = value;
  80633. this._markSubMeshesAsAttributesDirty();
  80634. },
  80635. enumerable: true,
  80636. configurable: true
  80637. });
  80638. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  80639. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80640. get: function () {
  80641. return this._numBoneInfluencers;
  80642. },
  80643. set: function (value) {
  80644. if (this._numBoneInfluencers === value) {
  80645. return;
  80646. }
  80647. this._numBoneInfluencers = value;
  80648. this._markSubMeshesAsAttributesDirty();
  80649. },
  80650. enumerable: true,
  80651. configurable: true
  80652. });
  80653. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  80654. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80655. get: function () {
  80656. return this._applyFog;
  80657. },
  80658. set: function (value) {
  80659. if (this._applyFog === value) {
  80660. return;
  80661. }
  80662. this._applyFog = value;
  80663. this._markSubMeshesAsMiscDirty();
  80664. },
  80665. enumerable: true,
  80666. configurable: true
  80667. });
  80668. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  80669. /**
  80670. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80671. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80672. */
  80673. get: function () {
  80674. return this._layerMask;
  80675. },
  80676. set: function (value) {
  80677. if (value === this._layerMask) {
  80678. return;
  80679. }
  80680. this._layerMask = value;
  80681. this._resyncLightSources();
  80682. },
  80683. enumerable: true,
  80684. configurable: true
  80685. });
  80686. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  80687. /**
  80688. * Gets or sets a collision mask used to mask collisions (default is -1).
  80689. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80690. */
  80691. get: function () {
  80692. return this._collisionMask;
  80693. },
  80694. set: function (mask) {
  80695. this._collisionMask = !isNaN(mask) ? mask : -1;
  80696. },
  80697. enumerable: true,
  80698. configurable: true
  80699. });
  80700. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  80701. /**
  80702. * Gets or sets the current collision group mask (-1 by default).
  80703. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80704. */
  80705. get: function () {
  80706. return this._collisionGroup;
  80707. },
  80708. set: function (mask) {
  80709. this._collisionGroup = !isNaN(mask) ? mask : -1;
  80710. },
  80711. enumerable: true,
  80712. configurable: true
  80713. });
  80714. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  80715. /** @hidden */
  80716. get: function () {
  80717. return null;
  80718. },
  80719. enumerable: true,
  80720. configurable: true
  80721. });
  80722. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  80723. get: function () {
  80724. return this._skeleton;
  80725. },
  80726. /**
  80727. * Gets or sets a skeleton to apply skining transformations
  80728. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80729. */
  80730. set: function (value) {
  80731. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  80732. this._skeleton._unregisterMeshWithPoseMatrix(this);
  80733. }
  80734. if (value && value.needInitialSkinMatrix) {
  80735. value._registerMeshWithPoseMatrix(this);
  80736. }
  80737. this._skeleton = value;
  80738. if (!this._skeleton) {
  80739. this._bonesTransformMatrices = null;
  80740. }
  80741. this._markSubMeshesAsAttributesDirty();
  80742. },
  80743. enumerable: true,
  80744. configurable: true
  80745. });
  80746. /**
  80747. * Returns the string "AbstractMesh"
  80748. * @returns "AbstractMesh"
  80749. */
  80750. AbstractMesh.prototype.getClassName = function () {
  80751. return "AbstractMesh";
  80752. };
  80753. /**
  80754. * Gets a string representation of the current mesh
  80755. * @param fullDetails defines a boolean indicating if full details must be included
  80756. * @returns a string representation of the current mesh
  80757. */
  80758. AbstractMesh.prototype.toString = function (fullDetails) {
  80759. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  80760. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  80761. if (this._skeleton) {
  80762. ret += ", skeleton: " + this._skeleton.name;
  80763. }
  80764. if (fullDetails) {
  80765. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  80766. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  80767. }
  80768. return ret;
  80769. };
  80770. /** @hidden */
  80771. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  80772. if (initialCall === void 0) { initialCall = true; }
  80773. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  80774. if (trigger) {
  80775. if (this.actionManager.hasSpecificTrigger(trigger)) {
  80776. return this.actionManager;
  80777. }
  80778. }
  80779. else {
  80780. return this.actionManager;
  80781. }
  80782. }
  80783. if (!this.parent) {
  80784. return null;
  80785. }
  80786. return this.parent._getActionManagerForTrigger(trigger, false);
  80787. };
  80788. /** @hidden */
  80789. AbstractMesh.prototype._rebuild = function () {
  80790. this.onRebuildObservable.notifyObservers(this);
  80791. if (this._occlusionQuery) {
  80792. this._occlusionQuery = null;
  80793. }
  80794. if (!this.subMeshes) {
  80795. return;
  80796. }
  80797. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80798. var subMesh = _a[_i];
  80799. subMesh._rebuild();
  80800. }
  80801. };
  80802. /** @hidden */
  80803. AbstractMesh.prototype._resyncLightSources = function () {
  80804. this._lightSources.length = 0;
  80805. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  80806. var light = _a[_i];
  80807. if (!light.isEnabled()) {
  80808. continue;
  80809. }
  80810. if (light.canAffectMesh(this)) {
  80811. this._lightSources.push(light);
  80812. }
  80813. }
  80814. this._markSubMeshesAsLightDirty();
  80815. };
  80816. /** @hidden */
  80817. AbstractMesh.prototype._resyncLighSource = function (light) {
  80818. var isIn = light.isEnabled() && light.canAffectMesh(this);
  80819. var index = this._lightSources.indexOf(light);
  80820. if (index === -1) {
  80821. if (!isIn) {
  80822. return;
  80823. }
  80824. this._lightSources.push(light);
  80825. }
  80826. else {
  80827. if (isIn) {
  80828. return;
  80829. }
  80830. this._lightSources.splice(index, 1);
  80831. }
  80832. this._markSubMeshesAsLightDirty();
  80833. };
  80834. /** @hidden */
  80835. AbstractMesh.prototype._unBindEffect = function () {
  80836. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80837. var subMesh = _a[_i];
  80838. subMesh.setEffect(null);
  80839. }
  80840. };
  80841. /** @hidden */
  80842. AbstractMesh.prototype._removeLightSource = function (light) {
  80843. var index = this._lightSources.indexOf(light);
  80844. if (index === -1) {
  80845. return;
  80846. }
  80847. this._lightSources.splice(index, 1);
  80848. this._markSubMeshesAsLightDirty();
  80849. };
  80850. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  80851. if (!this.subMeshes) {
  80852. return;
  80853. }
  80854. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80855. var subMesh = _a[_i];
  80856. if (subMesh._materialDefines) {
  80857. func(subMesh._materialDefines);
  80858. }
  80859. }
  80860. };
  80861. /** @hidden */
  80862. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  80863. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  80864. };
  80865. /** @hidden */
  80866. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  80867. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  80868. };
  80869. /** @hidden */
  80870. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  80871. if (!this.subMeshes) {
  80872. return;
  80873. }
  80874. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80875. var subMesh = _a[_i];
  80876. var material = subMesh.getMaterial();
  80877. if (material) {
  80878. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  80879. }
  80880. }
  80881. };
  80882. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  80883. /**
  80884. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80885. */
  80886. get: function () {
  80887. return this._scaling;
  80888. },
  80889. set: function (newScaling) {
  80890. this._scaling = newScaling;
  80891. if (this.physicsImpostor) {
  80892. this.physicsImpostor.forceUpdate();
  80893. }
  80894. },
  80895. enumerable: true,
  80896. configurable: true
  80897. });
  80898. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  80899. // Methods
  80900. /**
  80901. * Returns true if the mesh is blocked. Implemented by child classes
  80902. */
  80903. get: function () {
  80904. return false;
  80905. },
  80906. enumerable: true,
  80907. configurable: true
  80908. });
  80909. /**
  80910. * Returns the mesh itself by default. Implemented by child classes
  80911. * @param camera defines the camera to use to pick the right LOD level
  80912. * @returns the currentAbstractMesh
  80913. */
  80914. AbstractMesh.prototype.getLOD = function (camera) {
  80915. return this;
  80916. };
  80917. /**
  80918. * Returns 0 by default. Implemented by child classes
  80919. * @returns an integer
  80920. */
  80921. AbstractMesh.prototype.getTotalVertices = function () {
  80922. return 0;
  80923. };
  80924. /**
  80925. * Returns a positive integer : the total number of indices in this mesh geometry.
  80926. * @returns the numner of indices or zero if the mesh has no geometry.
  80927. */
  80928. AbstractMesh.prototype.getTotalIndices = function () {
  80929. return 0;
  80930. };
  80931. /**
  80932. * Returns null by default. Implemented by child classes
  80933. * @returns null
  80934. */
  80935. AbstractMesh.prototype.getIndices = function () {
  80936. return null;
  80937. };
  80938. /**
  80939. * Returns the array of the requested vertex data kind. Implemented by child classes
  80940. * @param kind defines the vertex data kind to use
  80941. * @returns null
  80942. */
  80943. AbstractMesh.prototype.getVerticesData = function (kind) {
  80944. return null;
  80945. };
  80946. /**
  80947. * Sets the vertex data of the mesh geometry for the requested `kind`.
  80948. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  80949. * Note that a new underlying VertexBuffer object is created each call.
  80950. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  80951. * @param kind defines vertex data kind:
  80952. * * VertexBuffer.PositionKind
  80953. * * VertexBuffer.UVKind
  80954. * * VertexBuffer.UV2Kind
  80955. * * VertexBuffer.UV3Kind
  80956. * * VertexBuffer.UV4Kind
  80957. * * VertexBuffer.UV5Kind
  80958. * * VertexBuffer.UV6Kind
  80959. * * VertexBuffer.ColorKind
  80960. * * VertexBuffer.MatricesIndicesKind
  80961. * * VertexBuffer.MatricesIndicesExtraKind
  80962. * * VertexBuffer.MatricesWeightsKind
  80963. * * VertexBuffer.MatricesWeightsExtraKind
  80964. * @param data defines the data source
  80965. * @param updatable defines if the data must be flagged as updatable (or static)
  80966. * @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
  80967. * @returns the current mesh
  80968. */
  80969. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  80970. return this;
  80971. };
  80972. /**
  80973. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80974. * If the mesh has no geometry, it is simply returned as it is.
  80975. * @param kind defines vertex data kind:
  80976. * * VertexBuffer.PositionKind
  80977. * * VertexBuffer.UVKind
  80978. * * VertexBuffer.UV2Kind
  80979. * * VertexBuffer.UV3Kind
  80980. * * VertexBuffer.UV4Kind
  80981. * * VertexBuffer.UV5Kind
  80982. * * VertexBuffer.UV6Kind
  80983. * * VertexBuffer.ColorKind
  80984. * * VertexBuffer.MatricesIndicesKind
  80985. * * VertexBuffer.MatricesIndicesExtraKind
  80986. * * VertexBuffer.MatricesWeightsKind
  80987. * * VertexBuffer.MatricesWeightsExtraKind
  80988. * @param data defines the data source
  80989. * @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
  80990. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  80991. * @returns the current mesh
  80992. */
  80993. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  80994. return this;
  80995. };
  80996. /**
  80997. * Sets the mesh indices,
  80998. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  80999. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81000. * @param totalVertices Defines the total number of vertices
  81001. * @returns the current mesh
  81002. */
  81003. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  81004. return this;
  81005. };
  81006. /**
  81007. * Gets a boolean indicating if specific vertex data is present
  81008. * @param kind defines the vertex data kind to use
  81009. * @returns true is data kind is present
  81010. */
  81011. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  81012. return false;
  81013. };
  81014. /**
  81015. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81016. * @returns a BoundingInfo
  81017. */
  81018. AbstractMesh.prototype.getBoundingInfo = function () {
  81019. if (this._masterMesh) {
  81020. return this._masterMesh.getBoundingInfo();
  81021. }
  81022. if (!this._boundingInfo) {
  81023. // this._boundingInfo is being created here
  81024. this._updateBoundingInfo();
  81025. }
  81026. // cannot be null.
  81027. return this._boundingInfo;
  81028. };
  81029. /**
  81030. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81031. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81032. * @returns the current mesh
  81033. */
  81034. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  81035. if (includeDescendants === void 0) { includeDescendants = true; }
  81036. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  81037. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  81038. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  81039. if (maxDimension === 0) {
  81040. return this;
  81041. }
  81042. var scale = 1 / maxDimension;
  81043. this.scaling.scaleInPlace(scale);
  81044. return this;
  81045. };
  81046. /**
  81047. * Overwrite the current bounding info
  81048. * @param boundingInfo defines the new bounding info
  81049. * @returns the current mesh
  81050. */
  81051. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  81052. this._boundingInfo = boundingInfo;
  81053. return this;
  81054. };
  81055. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  81056. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81057. get: function () {
  81058. 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));
  81059. },
  81060. enumerable: true,
  81061. configurable: true
  81062. });
  81063. /** @hidden */
  81064. AbstractMesh.prototype._preActivate = function () {
  81065. };
  81066. /** @hidden */
  81067. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  81068. };
  81069. /** @hidden */
  81070. AbstractMesh.prototype._activate = function (renderId) {
  81071. this._renderId = renderId;
  81072. };
  81073. /**
  81074. * Gets the current world matrix
  81075. * @returns a Matrix
  81076. */
  81077. AbstractMesh.prototype.getWorldMatrix = function () {
  81078. if (this._masterMesh) {
  81079. return this._masterMesh.getWorldMatrix();
  81080. }
  81081. return _super.prototype.getWorldMatrix.call(this);
  81082. };
  81083. /** @hidden */
  81084. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  81085. if (this._masterMesh) {
  81086. return this._masterMesh._getWorldMatrixDeterminant();
  81087. }
  81088. return _super.prototype._getWorldMatrixDeterminant.call(this);
  81089. };
  81090. // ================================== Point of View Movement =================================
  81091. /**
  81092. * Perform relative position change from the point of view of behind the front of the mesh.
  81093. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81094. * Supports definition of mesh facing forward or backward
  81095. * @param amountRight defines the distance on the right axis
  81096. * @param amountUp defines the distance on the up axis
  81097. * @param amountForward defines the distance on the forward axis
  81098. * @returns the current mesh
  81099. */
  81100. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  81101. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  81102. return this;
  81103. };
  81104. /**
  81105. * Calculate relative position change from the point of view of behind the front of the mesh.
  81106. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81107. * Supports definition of mesh facing forward or backward
  81108. * @param amountRight defines the distance on the right axis
  81109. * @param amountUp defines the distance on the up axis
  81110. * @param amountForward defines the distance on the forward axis
  81111. * @returns the new displacement vector
  81112. */
  81113. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  81114. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  81115. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  81116. rotQuaternion.toRotationMatrix(rotMatrix);
  81117. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81118. var defForwardMult = this.definedFacingForward ? -1 : 1;
  81119. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  81120. return translationDelta;
  81121. };
  81122. // ================================== Point of View Rotation =================================
  81123. /**
  81124. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81125. * Supports definition of mesh facing forward or backward
  81126. * @param flipBack defines the flip
  81127. * @param twirlClockwise defines the twirl
  81128. * @param tiltRight defines the tilt
  81129. * @returns the current mesh
  81130. */
  81131. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  81132. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  81133. return this;
  81134. };
  81135. /**
  81136. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81137. * Supports definition of mesh facing forward or backward.
  81138. * @param flipBack defines the flip
  81139. * @param twirlClockwise defines the twirl
  81140. * @param tiltRight defines the tilt
  81141. * @returns the new rotation vector
  81142. */
  81143. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  81144. var defForwardMult = this.definedFacingForward ? 1 : -1;
  81145. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  81146. };
  81147. /**
  81148. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81149. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81150. * @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
  81151. * @returns the new bounding vectors
  81152. */
  81153. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  81154. if (includeDescendants === void 0) { includeDescendants = true; }
  81155. if (predicate === void 0) { predicate = null; }
  81156. // Ensures that all world matrix will be recomputed.
  81157. this.getScene().incrementRenderId();
  81158. this.computeWorldMatrix(true);
  81159. var min;
  81160. var max;
  81161. var boundingInfo = this.getBoundingInfo();
  81162. if (!this.subMeshes) {
  81163. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  81164. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  81165. }
  81166. else {
  81167. min = boundingInfo.boundingBox.minimumWorld;
  81168. max = boundingInfo.boundingBox.maximumWorld;
  81169. }
  81170. if (includeDescendants) {
  81171. var descendants = this.getDescendants(false);
  81172. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  81173. var descendant = descendants_1[_i];
  81174. var childMesh = descendant;
  81175. childMesh.computeWorldMatrix(true);
  81176. // Filters meshes based on custom predicate function.
  81177. if (predicate && !predicate(childMesh)) {
  81178. continue;
  81179. }
  81180. //make sure we have the needed params to get mix and max
  81181. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  81182. continue;
  81183. }
  81184. var childBoundingInfo = childMesh.getBoundingInfo();
  81185. var boundingBox = childBoundingInfo.boundingBox;
  81186. var minBox = boundingBox.minimumWorld;
  81187. var maxBox = boundingBox.maximumWorld;
  81188. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  81189. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  81190. }
  81191. }
  81192. return {
  81193. min: min,
  81194. max: max
  81195. };
  81196. };
  81197. /**
  81198. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81199. * This means the mesh underlying bounding box and sphere are recomputed.
  81200. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81201. * @returns the current mesh
  81202. */
  81203. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  81204. if (applySkeleton === void 0) { applySkeleton = false; }
  81205. if (this._boundingInfo && this._boundingInfo.isLocked) {
  81206. return this;
  81207. }
  81208. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  81209. return this;
  81210. };
  81211. /** @hidden */
  81212. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  81213. if (data) {
  81214. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  81215. if (this._boundingInfo) {
  81216. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  81217. }
  81218. else {
  81219. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  81220. }
  81221. }
  81222. if (this.subMeshes) {
  81223. for (var index = 0; index < this.subMeshes.length; index++) {
  81224. this.subMeshes[index].refreshBoundingInfo();
  81225. }
  81226. }
  81227. this._updateBoundingInfo();
  81228. };
  81229. /** @hidden */
  81230. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  81231. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  81232. if (data && applySkeleton && this.skeleton) {
  81233. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  81234. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  81235. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  81236. if (matricesWeightsData && matricesIndicesData) {
  81237. var needExtras = this.numBoneInfluencers > 4;
  81238. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  81239. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  81240. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  81241. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  81242. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  81243. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  81244. var matWeightIdx = 0;
  81245. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  81246. finalMatrix.reset();
  81247. var inf;
  81248. var weight;
  81249. for (inf = 0; inf < 4; inf++) {
  81250. weight = matricesWeightsData[matWeightIdx + inf];
  81251. if (weight > 0) {
  81252. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  81253. finalMatrix.addToSelf(tempMatrix);
  81254. }
  81255. }
  81256. if (needExtras) {
  81257. for (inf = 0; inf < 4; inf++) {
  81258. weight = matricesWeightsExtraData[matWeightIdx + inf];
  81259. if (weight > 0) {
  81260. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  81261. finalMatrix.addToSelf(tempMatrix);
  81262. }
  81263. }
  81264. }
  81265. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  81266. tempVector.toArray(data, index);
  81267. }
  81268. }
  81269. }
  81270. return data;
  81271. };
  81272. /** @hidden */
  81273. AbstractMesh.prototype._updateBoundingInfo = function () {
  81274. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  81275. if (this._boundingInfo) {
  81276. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  81277. }
  81278. else {
  81279. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  81280. }
  81281. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  81282. return this;
  81283. };
  81284. /** @hidden */
  81285. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  81286. if (!this.subMeshes) {
  81287. return this;
  81288. }
  81289. var count = this.subMeshes.length;
  81290. for (var subIndex = 0; subIndex < count; subIndex++) {
  81291. var subMesh = this.subMeshes[subIndex];
  81292. if (count > 1 || !subMesh.IsGlobal) {
  81293. subMesh.updateBoundingInfo(matrix);
  81294. }
  81295. }
  81296. return this;
  81297. };
  81298. /** @hidden */
  81299. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  81300. // Bounding info
  81301. this._updateBoundingInfo();
  81302. };
  81303. /**
  81304. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81305. * A mesh is in the frustum if its bounding box intersects the frustum
  81306. * @param frustumPlanes defines the frustum to test
  81307. * @returns true if the mesh is in the frustum planes
  81308. */
  81309. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  81310. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  81311. };
  81312. /**
  81313. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81314. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81315. * @param frustumPlanes defines the frustum to test
  81316. * @returns true if the mesh is completely in the frustum planes
  81317. */
  81318. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  81319. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  81320. };
  81321. /**
  81322. * True if the mesh intersects another mesh or a SolidParticle object
  81323. * @param mesh defines a target mesh or SolidParticle to test
  81324. * @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)
  81325. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81326. * @returns true if there is an intersection
  81327. */
  81328. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  81329. if (precise === void 0) { precise = false; }
  81330. if (!this._boundingInfo || !mesh._boundingInfo) {
  81331. return false;
  81332. }
  81333. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  81334. return true;
  81335. }
  81336. if (includeDescendants) {
  81337. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  81338. var child = _a[_i];
  81339. if (child.intersectsMesh(mesh, precise, true)) {
  81340. return true;
  81341. }
  81342. }
  81343. }
  81344. return false;
  81345. };
  81346. /**
  81347. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81348. * @param point defines the point to test
  81349. * @returns true if there is an intersection
  81350. */
  81351. AbstractMesh.prototype.intersectsPoint = function (point) {
  81352. if (!this._boundingInfo) {
  81353. return false;
  81354. }
  81355. return this._boundingInfo.intersectsPoint(point);
  81356. };
  81357. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  81358. // Collisions
  81359. /**
  81360. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81361. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81362. */
  81363. get: function () {
  81364. return this._checkCollisions;
  81365. },
  81366. set: function (collisionEnabled) {
  81367. this._checkCollisions = collisionEnabled;
  81368. },
  81369. enumerable: true,
  81370. configurable: true
  81371. });
  81372. Object.defineProperty(AbstractMesh.prototype, "collider", {
  81373. /**
  81374. * Gets Collider object used to compute collisions (not physics)
  81375. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81376. */
  81377. get: function () {
  81378. return this._collider;
  81379. },
  81380. enumerable: true,
  81381. configurable: true
  81382. });
  81383. /**
  81384. * Move the mesh using collision engine
  81385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81386. * @param displacement defines the requested displacement vector
  81387. * @returns the current mesh
  81388. */
  81389. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  81390. var globalPosition = this.getAbsolutePosition();
  81391. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  81392. var coordinator = this.getScene().collisionCoordinator;
  81393. if (!this._collider) {
  81394. this._collider = coordinator.createCollider();
  81395. }
  81396. this._collider._radius = this.ellipsoid;
  81397. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  81398. return this;
  81399. };
  81400. // Collisions
  81401. /** @hidden */
  81402. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  81403. this._generatePointsArray();
  81404. if (!this._positions) {
  81405. return this;
  81406. }
  81407. // Transformation
  81408. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  81409. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  81410. subMesh._lastColliderWorldVertices = [];
  81411. subMesh._trianglePlanes = [];
  81412. var start = subMesh.verticesStart;
  81413. var end = (subMesh.verticesStart + subMesh.verticesCount);
  81414. for (var i = start; i < end; i++) {
  81415. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  81416. }
  81417. }
  81418. // Collide
  81419. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  81420. if (collider.collisionFound) {
  81421. collider.collidedMesh = this;
  81422. }
  81423. return this;
  81424. };
  81425. /** @hidden */
  81426. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  81427. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  81428. var len = subMeshes.length;
  81429. for (var index = 0; index < len; index++) {
  81430. var subMesh = subMeshes.data[index];
  81431. // Bounding test
  81432. if (len > 1 && !subMesh._checkCollision(collider)) {
  81433. continue;
  81434. }
  81435. this._collideForSubMesh(subMesh, transformMatrix, collider);
  81436. }
  81437. return this;
  81438. };
  81439. /** @hidden */
  81440. AbstractMesh.prototype._checkCollision = function (collider) {
  81441. // Bounding box test
  81442. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  81443. return this;
  81444. }
  81445. // Transformation matrix
  81446. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  81447. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  81448. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  81449. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  81450. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  81451. return this;
  81452. };
  81453. // Picking
  81454. /** @hidden */
  81455. AbstractMesh.prototype._generatePointsArray = function () {
  81456. return false;
  81457. };
  81458. /**
  81459. * Checks if the passed Ray intersects with the mesh
  81460. * @param ray defines the ray to use
  81461. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81462. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81463. * @returns the picking info
  81464. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81465. */
  81466. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  81467. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  81468. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  81469. var boundingInfo = this._boundingInfo;
  81470. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  81471. return pickingInfo;
  81472. }
  81473. if (!this._generatePointsArray()) {
  81474. return pickingInfo;
  81475. }
  81476. var intersectInfo = null;
  81477. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  81478. var len = subMeshes.length;
  81479. for (var index = 0; index < len; index++) {
  81480. var subMesh = subMeshes.data[index];
  81481. // Bounding test
  81482. if (len > 1 && !subMesh.canIntersects(ray)) {
  81483. continue;
  81484. }
  81485. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  81486. if (currentIntersectInfo) {
  81487. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  81488. intersectInfo = currentIntersectInfo;
  81489. intersectInfo.subMeshId = index;
  81490. if (fastCheck) {
  81491. break;
  81492. }
  81493. }
  81494. }
  81495. }
  81496. if (intersectInfo) {
  81497. // Get picked point
  81498. var world = this.getWorldMatrix();
  81499. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  81500. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  81501. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  81502. ray.direction.scaleToRef(intersectInfo.distance, direction);
  81503. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  81504. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  81505. // Return result
  81506. pickingInfo.hit = true;
  81507. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  81508. pickingInfo.pickedPoint = pickedPoint;
  81509. pickingInfo.pickedMesh = this;
  81510. pickingInfo.bu = intersectInfo.bu || 0;
  81511. pickingInfo.bv = intersectInfo.bv || 0;
  81512. pickingInfo.faceId = intersectInfo.faceId;
  81513. pickingInfo.subMeshId = intersectInfo.subMeshId;
  81514. return pickingInfo;
  81515. }
  81516. return pickingInfo;
  81517. };
  81518. /**
  81519. * Clones the current mesh
  81520. * @param name defines the mesh name
  81521. * @param newParent defines the new mesh parent
  81522. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81523. * @returns the new mesh
  81524. */
  81525. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  81526. return null;
  81527. };
  81528. /**
  81529. * Disposes all the submeshes of the current meshnp
  81530. * @returns the current mesh
  81531. */
  81532. AbstractMesh.prototype.releaseSubMeshes = function () {
  81533. if (this.subMeshes) {
  81534. while (this.subMeshes.length) {
  81535. this.subMeshes[0].dispose();
  81536. }
  81537. }
  81538. else {
  81539. this.subMeshes = new Array();
  81540. }
  81541. return this;
  81542. };
  81543. /**
  81544. * Releases resources associated with this abstract mesh.
  81545. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81546. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81547. */
  81548. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  81549. var _this = this;
  81550. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  81551. var index;
  81552. // Smart Array Retainers.
  81553. this.getScene().freeActiveMeshes();
  81554. this.getScene().freeRenderingGroups();
  81555. // Action manager
  81556. if (this.actionManager !== undefined && this.actionManager !== null) {
  81557. this.actionManager.dispose();
  81558. this.actionManager = null;
  81559. }
  81560. // Skeleton
  81561. this._skeleton = null;
  81562. // Intersections in progress
  81563. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  81564. var other = this._intersectionsInProgress[index];
  81565. var pos = other._intersectionsInProgress.indexOf(this);
  81566. other._intersectionsInProgress.splice(pos, 1);
  81567. }
  81568. this._intersectionsInProgress = [];
  81569. // Lights
  81570. var lights = this.getScene().lights;
  81571. lights.forEach(function (light) {
  81572. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  81573. if (meshIndex !== -1) {
  81574. light.includedOnlyMeshes.splice(meshIndex, 1);
  81575. }
  81576. meshIndex = light.excludedMeshes.indexOf(_this);
  81577. if (meshIndex !== -1) {
  81578. light.excludedMeshes.splice(meshIndex, 1);
  81579. }
  81580. // Shadow generators
  81581. var generator = light.getShadowGenerator();
  81582. if (generator) {
  81583. var shadowMap = generator.getShadowMap();
  81584. if (shadowMap && shadowMap.renderList) {
  81585. meshIndex = shadowMap.renderList.indexOf(_this);
  81586. if (meshIndex !== -1) {
  81587. shadowMap.renderList.splice(meshIndex, 1);
  81588. }
  81589. }
  81590. }
  81591. });
  81592. // SubMeshes
  81593. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  81594. this.releaseSubMeshes();
  81595. }
  81596. // Query
  81597. var engine = this.getScene().getEngine();
  81598. if (this._occlusionQuery) {
  81599. this.isOcclusionQueryInProgress = false;
  81600. engine.deleteQuery(this._occlusionQuery);
  81601. this._occlusionQuery = null;
  81602. }
  81603. // Engine
  81604. engine.wipeCaches();
  81605. // Remove from scene
  81606. this.getScene().removeMesh(this);
  81607. if (disposeMaterialAndTextures) {
  81608. if (this.material) {
  81609. if (this.material.getClassName() === "MultiMaterial") {
  81610. this.material.dispose(false, true, true);
  81611. }
  81612. else {
  81613. this.material.dispose(false, true);
  81614. }
  81615. }
  81616. }
  81617. if (!doNotRecurse) {
  81618. // Particles
  81619. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  81620. if (this.getScene().particleSystems[index].emitter === this) {
  81621. this.getScene().particleSystems[index].dispose();
  81622. index--;
  81623. }
  81624. }
  81625. }
  81626. // facet data
  81627. if (this._facetData.facetDataEnabled) {
  81628. this.disableFacetData();
  81629. }
  81630. this.onAfterWorldMatrixUpdateObservable.clear();
  81631. this.onCollideObservable.clear();
  81632. this.onCollisionPositionChangeObservable.clear();
  81633. this.onRebuildObservable.clear();
  81634. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  81635. };
  81636. /**
  81637. * Adds the passed mesh as a child to the current mesh
  81638. * @param mesh defines the child mesh
  81639. * @returns the current mesh
  81640. */
  81641. AbstractMesh.prototype.addChild = function (mesh) {
  81642. mesh.setParent(this);
  81643. return this;
  81644. };
  81645. /**
  81646. * Removes the passed mesh from the current mesh children list
  81647. * @param mesh defines the child mesh
  81648. * @returns the current mesh
  81649. */
  81650. AbstractMesh.prototype.removeChild = function (mesh) {
  81651. mesh.setParent(null);
  81652. return this;
  81653. };
  81654. // Facet data
  81655. /** @hidden */
  81656. AbstractMesh.prototype._initFacetData = function () {
  81657. var data = this._facetData;
  81658. if (!data.facetNormals) {
  81659. data.facetNormals = new Array();
  81660. }
  81661. if (!data.facetPositions) {
  81662. data.facetPositions = new Array();
  81663. }
  81664. if (!data.facetPartitioning) {
  81665. data.facetPartitioning = new Array();
  81666. }
  81667. data.facetNb = (this.getIndices().length / 3) | 0;
  81668. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  81669. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  81670. for (var f = 0; f < data.facetNb; f++) {
  81671. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81672. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81673. }
  81674. data.facetDataEnabled = true;
  81675. return this;
  81676. };
  81677. /**
  81678. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81679. * This method can be called within the render loop.
  81680. * 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
  81681. * @returns the current mesh
  81682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81683. */
  81684. AbstractMesh.prototype.updateFacetData = function () {
  81685. var data = this._facetData;
  81686. if (!data.facetDataEnabled) {
  81687. this._initFacetData();
  81688. }
  81689. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  81690. var indices = this.getIndices();
  81691. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  81692. var bInfo = this.getBoundingInfo();
  81693. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  81694. // init arrays, matrix and sort function on first call
  81695. data.facetDepthSortEnabled = true;
  81696. if (indices instanceof Uint16Array) {
  81697. data.depthSortedIndices = new Uint16Array(indices);
  81698. }
  81699. else if (indices instanceof Uint32Array) {
  81700. data.depthSortedIndices = new Uint32Array(indices);
  81701. }
  81702. else {
  81703. var needs32bits = false;
  81704. for (var i = 0; i < indices.length; i++) {
  81705. if (indices[i] > 65535) {
  81706. needs32bits = true;
  81707. break;
  81708. }
  81709. }
  81710. if (needs32bits) {
  81711. data.depthSortedIndices = new Uint32Array(indices);
  81712. }
  81713. else {
  81714. data.depthSortedIndices = new Uint16Array(indices);
  81715. }
  81716. }
  81717. data.facetDepthSortFunction = function (f1, f2) {
  81718. return (f2.sqDistance - f1.sqDistance);
  81719. };
  81720. if (!data.facetDepthSortFrom) {
  81721. var camera = this.getScene().activeCamera;
  81722. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81723. }
  81724. data.depthSortedFacets = [];
  81725. for (var f = 0; f < data.facetNb; f++) {
  81726. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  81727. data.depthSortedFacets.push(depthSortedFacet);
  81728. }
  81729. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  81730. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81731. }
  81732. 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"];
  81733. 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"];
  81734. 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"];
  81735. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  81736. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  81737. data.subDiv.max = data.partitioningSubdivisions;
  81738. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  81739. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  81740. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  81741. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  81742. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  81743. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  81744. // set the parameters for ComputeNormals()
  81745. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  81746. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  81747. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  81748. data.facetParameters.bInfo = bInfo;
  81749. data.facetParameters.bbSize = data.bbSize;
  81750. data.facetParameters.subDiv = data.subDiv;
  81751. data.facetParameters.ratio = this.partitioningBBoxRatio;
  81752. data.facetParameters.depthSort = data.facetDepthSort;
  81753. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  81754. this.computeWorldMatrix(true);
  81755. this._worldMatrix.invertToRef(data.invertedMatrix);
  81756. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  81757. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  81758. }
  81759. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  81760. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  81761. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  81762. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  81763. var l = (data.depthSortedIndices.length / 3) | 0;
  81764. for (var f = 0; f < l; f++) {
  81765. var sind = data.depthSortedFacets[f].ind;
  81766. data.depthSortedIndices[f * 3] = indices[sind];
  81767. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  81768. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  81769. }
  81770. this.updateIndices(data.depthSortedIndices);
  81771. }
  81772. return this;
  81773. };
  81774. /**
  81775. * Returns the facetLocalNormals array.
  81776. * The normals are expressed in the mesh local spac
  81777. * @returns an array of Vector3
  81778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81779. */
  81780. AbstractMesh.prototype.getFacetLocalNormals = function () {
  81781. if (!this._facetData.facetNormals) {
  81782. this.updateFacetData();
  81783. }
  81784. return this._facetData.facetNormals;
  81785. };
  81786. /**
  81787. * Returns the facetLocalPositions array.
  81788. * The facet positions are expressed in the mesh local space
  81789. * @returns an array of Vector3
  81790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81791. */
  81792. AbstractMesh.prototype.getFacetLocalPositions = function () {
  81793. if (!this._facetData.facetPositions) {
  81794. this.updateFacetData();
  81795. }
  81796. return this._facetData.facetPositions;
  81797. };
  81798. /**
  81799. * Returns the facetLocalPartioning array
  81800. * @returns an array of array of numbers
  81801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81802. */
  81803. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  81804. if (!this._facetData.facetPartitioning) {
  81805. this.updateFacetData();
  81806. }
  81807. return this._facetData.facetPartitioning;
  81808. };
  81809. /**
  81810. * Returns the i-th facet position in the world system.
  81811. * This method allocates a new Vector3 per call
  81812. * @param i defines the facet index
  81813. * @returns a new Vector3
  81814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81815. */
  81816. AbstractMesh.prototype.getFacetPosition = function (i) {
  81817. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81818. this.getFacetPositionToRef(i, pos);
  81819. return pos;
  81820. };
  81821. /**
  81822. * Sets the reference Vector3 with the i-th facet position in the world system
  81823. * @param i defines the facet index
  81824. * @param ref defines the target vector
  81825. * @returns the current mesh
  81826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81827. */
  81828. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  81829. var localPos = (this.getFacetLocalPositions())[i];
  81830. var world = this.getWorldMatrix();
  81831. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  81832. return this;
  81833. };
  81834. /**
  81835. * Returns the i-th facet normal in the world system.
  81836. * This method allocates a new Vector3 per call
  81837. * @param i defines the facet index
  81838. * @returns a new Vector3
  81839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81840. */
  81841. AbstractMesh.prototype.getFacetNormal = function (i) {
  81842. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81843. this.getFacetNormalToRef(i, norm);
  81844. return norm;
  81845. };
  81846. /**
  81847. * Sets the reference Vector3 with the i-th facet normal in the world system
  81848. * @param i defines the facet index
  81849. * @param ref defines the target vector
  81850. * @returns the current mesh
  81851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81852. */
  81853. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  81854. var localNorm = (this.getFacetLocalNormals())[i];
  81855. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  81856. return this;
  81857. };
  81858. /**
  81859. * 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)
  81860. * @param x defines x coordinate
  81861. * @param y defines y coordinate
  81862. * @param z defines z coordinate
  81863. * @returns the array of facet indexes
  81864. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81865. */
  81866. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  81867. var bInfo = this.getBoundingInfo();
  81868. var data = this._facetData;
  81869. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  81870. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  81871. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  81872. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  81873. return null;
  81874. }
  81875. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  81876. };
  81877. /**
  81878. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81879. * @param projected sets as the (x,y,z) world projection on the facet
  81880. * @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
  81881. * @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
  81882. * @param x defines x coordinate
  81883. * @param y defines y coordinate
  81884. * @param z defines z coordinate
  81885. * @returns the face index if found (or null instead)
  81886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81887. */
  81888. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  81889. if (checkFace === void 0) { checkFace = false; }
  81890. if (facing === void 0) { facing = true; }
  81891. var world = this.getWorldMatrix();
  81892. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  81893. world.invertToRef(invMat);
  81894. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  81895. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  81896. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  81897. if (projected) {
  81898. // tranform the local computed projected vector to world coordinates
  81899. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  81900. }
  81901. return closest;
  81902. };
  81903. /**
  81904. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81905. * @param projected sets as the (x,y,z) local projection on the facet
  81906. * @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
  81907. * @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
  81908. * @param x defines x coordinate
  81909. * @param y defines y coordinate
  81910. * @param z defines z coordinate
  81911. * @returns the face index if found (or null instead)
  81912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81913. */
  81914. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  81915. if (checkFace === void 0) { checkFace = false; }
  81916. if (facing === void 0) { facing = true; }
  81917. var closest = null;
  81918. var tmpx = 0.0;
  81919. var tmpy = 0.0;
  81920. var tmpz = 0.0;
  81921. var d = 0.0; // tmp dot facet normal * facet position
  81922. var t0 = 0.0;
  81923. var projx = 0.0;
  81924. var projy = 0.0;
  81925. var projz = 0.0;
  81926. // Get all the facets in the same partitioning block than (x, y, z)
  81927. var facetPositions = this.getFacetLocalPositions();
  81928. var facetNormals = this.getFacetLocalNormals();
  81929. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  81930. if (!facetsInBlock) {
  81931. return null;
  81932. }
  81933. // Get the closest facet to (x, y, z)
  81934. var shortest = Number.MAX_VALUE; // init distance vars
  81935. var tmpDistance = shortest;
  81936. var fib; // current facet in the block
  81937. var norm; // current facet normal
  81938. var p0; // current facet barycenter position
  81939. // loop on all the facets in the current partitioning block
  81940. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  81941. fib = facetsInBlock[idx];
  81942. norm = facetNormals[fib];
  81943. p0 = facetPositions[fib];
  81944. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  81945. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  81946. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  81947. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  81948. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  81949. projx = x + norm.x * t0;
  81950. projy = y + norm.y * t0;
  81951. projz = z + norm.z * t0;
  81952. tmpx = projx - x;
  81953. tmpy = projy - y;
  81954. tmpz = projz - z;
  81955. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  81956. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  81957. shortest = tmpDistance;
  81958. closest = fib;
  81959. if (projected) {
  81960. projected.x = projx;
  81961. projected.y = projy;
  81962. projected.z = projz;
  81963. }
  81964. }
  81965. }
  81966. }
  81967. return closest;
  81968. };
  81969. /**
  81970. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81971. * @returns the parameters
  81972. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81973. */
  81974. AbstractMesh.prototype.getFacetDataParameters = function () {
  81975. return this._facetData.facetParameters;
  81976. };
  81977. /**
  81978. * Disables the feature FacetData and frees the related memory
  81979. * @returns the current mesh
  81980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81981. */
  81982. AbstractMesh.prototype.disableFacetData = function () {
  81983. if (this._facetData.facetDataEnabled) {
  81984. this._facetData.facetDataEnabled = false;
  81985. this._facetData.facetPositions = new Array();
  81986. this._facetData.facetNormals = new Array();
  81987. this._facetData.facetPartitioning = new Array();
  81988. this._facetData.facetParameters = null;
  81989. this._facetData.depthSortedIndices = new Uint32Array(0);
  81990. }
  81991. return this;
  81992. };
  81993. /**
  81994. * Updates the AbstractMesh indices array
  81995. * @param indices defines the data source
  81996. * @returns the current mesh
  81997. */
  81998. AbstractMesh.prototype.updateIndices = function (indices) {
  81999. return this;
  82000. };
  82001. /**
  82002. * Creates new normals data for the mesh
  82003. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  82004. * @returns the current mesh
  82005. */
  82006. AbstractMesh.prototype.createNormals = function (updatable) {
  82007. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  82008. var indices = this.getIndices();
  82009. var normals;
  82010. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  82011. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  82012. }
  82013. else {
  82014. normals = [];
  82015. }
  82016. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  82017. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  82018. return this;
  82019. };
  82020. /**
  82021. * Align the mesh with a normal
  82022. * @param normal defines the normal to use
  82023. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  82024. * @returns the current mesh
  82025. */
  82026. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  82027. if (!upDirection) {
  82028. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  82029. }
  82030. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  82031. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  82032. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  82033. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  82034. if (this.rotationQuaternion) {
  82035. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  82036. }
  82037. else {
  82038. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  82039. }
  82040. return this;
  82041. };
  82042. /** @hidden */
  82043. AbstractMesh.prototype._checkOcclusionQuery = function () {
  82044. return false;
  82045. };
  82046. /** No occlusion */
  82047. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  82048. /** Occlusion set to optimisitic */
  82049. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  82050. /** Occlusion set to strict */
  82051. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  82052. /** Use an accurante occlusion algorithm */
  82053. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  82054. /** Use a conservative occlusion algorithm */
  82055. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  82056. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82057. * Test order :
  82058. * Is the bounding sphere outside the frustum ?
  82059. * If not, are the bounding box vertices outside the frustum ?
  82060. * It not, then the cullable object is in the frustum.
  82061. */
  82062. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  82063. /** Culling strategy : Bounding Sphere Only.
  82064. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82065. * It's also less accurate than the standard because some not visible objects can still be selected.
  82066. * Test : is the bounding sphere outside the frustum ?
  82067. * If not, then the cullable object is in the frustum.
  82068. */
  82069. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  82070. /** Culling strategy : Optimistic Inclusion.
  82071. * This in an inclusion test first, then the standard exclusion test.
  82072. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82073. * 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.
  82074. * Anyway, it's as accurate as the standard strategy.
  82075. * Test :
  82076. * Is the cullable object bounding sphere center in the frustum ?
  82077. * If not, apply the default culling strategy.
  82078. */
  82079. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  82080. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82081. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82082. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82083. * 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.
  82084. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82085. * Test :
  82086. * Is the cullable object bounding sphere center in the frustum ?
  82087. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82088. */
  82089. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  82090. return AbstractMesh;
  82091. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  82092. /***/ }),
  82093. /***/ "./Meshes/buffer.ts":
  82094. /*!**************************!*\
  82095. !*** ./Meshes/buffer.ts ***!
  82096. \**************************/
  82097. /*! exports provided: Buffer, VertexBuffer */
  82098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82099. "use strict";
  82100. __webpack_require__.r(__webpack_exports__);
  82101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  82102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  82103. /**
  82104. * Class used to store data that will be store in GPU memory
  82105. */
  82106. var Buffer = /** @class */ (function () {
  82107. /**
  82108. * Constructor
  82109. * @param engine the engine
  82110. * @param data the data to use for this buffer
  82111. * @param updatable whether the data is updatable
  82112. * @param stride the stride (optional)
  82113. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82114. * @param instanced whether the buffer is instanced (optional)
  82115. * @param useBytes set to true if the stride in in bytes (optional)
  82116. */
  82117. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  82118. if (stride === void 0) { stride = 0; }
  82119. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  82120. if (instanced === void 0) { instanced = false; }
  82121. if (useBytes === void 0) { useBytes = false; }
  82122. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  82123. this._engine = engine.getScene().getEngine();
  82124. }
  82125. else {
  82126. this._engine = engine;
  82127. }
  82128. this._updatable = updatable;
  82129. this._instanced = instanced;
  82130. this._data = data;
  82131. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  82132. if (!postponeInternalCreation) { // by default
  82133. this.create();
  82134. }
  82135. }
  82136. /**
  82137. * Create a new VertexBuffer based on the current buffer
  82138. * @param kind defines the vertex buffer kind (position, normal, etc.)
  82139. * @param offset defines offset in the buffer (0 by default)
  82140. * @param size defines the size in floats of attributes (position is 3 for instance)
  82141. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  82142. * @param instanced defines if the vertex buffer contains indexed data
  82143. * @param useBytes defines if the offset and stride are in bytes
  82144. * @returns the new vertex buffer
  82145. */
  82146. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  82147. if (useBytes === void 0) { useBytes = false; }
  82148. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  82149. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  82150. // a lot of these parameters are ignored as they are overriden by the buffer
  82151. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  82152. };
  82153. // Properties
  82154. /**
  82155. * Gets a boolean indicating if the Buffer is updatable?
  82156. * @returns true if the buffer is updatable
  82157. */
  82158. Buffer.prototype.isUpdatable = function () {
  82159. return this._updatable;
  82160. };
  82161. /**
  82162. * Gets current buffer's data
  82163. * @returns a DataArray or null
  82164. */
  82165. Buffer.prototype.getData = function () {
  82166. return this._data;
  82167. };
  82168. /**
  82169. * Gets underlying native buffer
  82170. * @returns underlying native buffer
  82171. */
  82172. Buffer.prototype.getBuffer = function () {
  82173. return this._buffer;
  82174. };
  82175. /**
  82176. * Gets the stride in float32 units (i.e. byte stride / 4).
  82177. * May not be an integer if the byte stride is not divisible by 4.
  82178. * DEPRECATED. Use byteStride instead.
  82179. * @returns the stride in float32 units
  82180. */
  82181. Buffer.prototype.getStrideSize = function () {
  82182. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  82183. };
  82184. // Methods
  82185. /**
  82186. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82187. * @param data defines the data to store
  82188. */
  82189. Buffer.prototype.create = function (data) {
  82190. if (data === void 0) { data = null; }
  82191. if (!data && this._buffer) {
  82192. return; // nothing to do
  82193. }
  82194. data = data || this._data;
  82195. if (!data) {
  82196. return;
  82197. }
  82198. if (!this._buffer) { // create buffer
  82199. if (this._updatable) {
  82200. this._buffer = this._engine.createDynamicVertexBuffer(data);
  82201. this._data = data;
  82202. }
  82203. else {
  82204. this._buffer = this._engine.createVertexBuffer(data);
  82205. }
  82206. }
  82207. else if (this._updatable) { // update buffer
  82208. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  82209. this._data = data;
  82210. }
  82211. };
  82212. /** @hidden */
  82213. Buffer.prototype._rebuild = function () {
  82214. this._buffer = null;
  82215. this.create(this._data);
  82216. };
  82217. /**
  82218. * Update current buffer data
  82219. * @param data defines the data to store
  82220. */
  82221. Buffer.prototype.update = function (data) {
  82222. this.create(data);
  82223. };
  82224. /**
  82225. * Updates the data directly.
  82226. * @param data the new data
  82227. * @param offset the new offset
  82228. * @param vertexCount the vertex count (optional)
  82229. * @param useBytes set to true if the offset is in bytes
  82230. */
  82231. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  82232. if (useBytes === void 0) { useBytes = false; }
  82233. if (!this._buffer) {
  82234. return;
  82235. }
  82236. if (this._updatable) { // update buffer
  82237. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  82238. this._data = null;
  82239. }
  82240. };
  82241. /**
  82242. * Release all resources
  82243. */
  82244. Buffer.prototype.dispose = function () {
  82245. if (!this._buffer) {
  82246. return;
  82247. }
  82248. if (this._engine._releaseBuffer(this._buffer)) {
  82249. this._buffer = null;
  82250. }
  82251. };
  82252. return Buffer;
  82253. }());
  82254. /**
  82255. * Specialized buffer used to store vertex data
  82256. */
  82257. var VertexBuffer = /** @class */ (function () {
  82258. /**
  82259. * Constructor
  82260. * @param engine the engine
  82261. * @param data the data to use for this vertex buffer
  82262. * @param kind the vertex buffer kind
  82263. * @param updatable whether the data is updatable
  82264. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82265. * @param stride the stride (optional)
  82266. * @param instanced whether the buffer is instanced (optional)
  82267. * @param offset the offset of the data (optional)
  82268. * @param size the number of components (optional)
  82269. * @param type the type of the component (optional)
  82270. * @param normalized whether the data contains normalized data (optional)
  82271. * @param useBytes set to true if stride and offset are in bytes (optional)
  82272. */
  82273. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  82274. if (normalized === void 0) { normalized = false; }
  82275. if (useBytes === void 0) { useBytes = false; }
  82276. if (data instanceof Buffer) {
  82277. this._buffer = data;
  82278. this._ownsBuffer = false;
  82279. }
  82280. else {
  82281. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  82282. this._ownsBuffer = true;
  82283. }
  82284. this._kind = kind;
  82285. if (type == undefined) {
  82286. var data_1 = this.getData();
  82287. this.type = VertexBuffer.FLOAT;
  82288. if (data_1 instanceof Int8Array) {
  82289. this.type = VertexBuffer.BYTE;
  82290. }
  82291. else if (data_1 instanceof Uint8Array) {
  82292. this.type = VertexBuffer.UNSIGNED_BYTE;
  82293. }
  82294. else if (data_1 instanceof Int16Array) {
  82295. this.type = VertexBuffer.SHORT;
  82296. }
  82297. else if (data_1 instanceof Uint16Array) {
  82298. this.type = VertexBuffer.UNSIGNED_SHORT;
  82299. }
  82300. else if (data_1 instanceof Int32Array) {
  82301. this.type = VertexBuffer.INT;
  82302. }
  82303. else if (data_1 instanceof Uint32Array) {
  82304. this.type = VertexBuffer.UNSIGNED_INT;
  82305. }
  82306. }
  82307. else {
  82308. this.type = type;
  82309. }
  82310. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  82311. if (useBytes) {
  82312. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  82313. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  82314. this.byteOffset = offset || 0;
  82315. }
  82316. else {
  82317. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  82318. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  82319. this.byteOffset = (offset || 0) * typeByteLength;
  82320. }
  82321. this.normalized = normalized;
  82322. this._instanced = instanced !== undefined ? instanced : false;
  82323. this._instanceDivisor = instanced ? 1 : 0;
  82324. }
  82325. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  82326. /**
  82327. * Gets or sets the instance divisor when in instanced mode
  82328. */
  82329. get: function () {
  82330. return this._instanceDivisor;
  82331. },
  82332. set: function (value) {
  82333. this._instanceDivisor = value;
  82334. if (value == 0) {
  82335. this._instanced = false;
  82336. }
  82337. else {
  82338. this._instanced = true;
  82339. }
  82340. },
  82341. enumerable: true,
  82342. configurable: true
  82343. });
  82344. /** @hidden */
  82345. VertexBuffer.prototype._rebuild = function () {
  82346. if (!this._buffer) {
  82347. return;
  82348. }
  82349. this._buffer._rebuild();
  82350. };
  82351. /**
  82352. * Returns the kind of the VertexBuffer (string)
  82353. * @returns a string
  82354. */
  82355. VertexBuffer.prototype.getKind = function () {
  82356. return this._kind;
  82357. };
  82358. // Properties
  82359. /**
  82360. * Gets a boolean indicating if the VertexBuffer is updatable?
  82361. * @returns true if the buffer is updatable
  82362. */
  82363. VertexBuffer.prototype.isUpdatable = function () {
  82364. return this._buffer.isUpdatable();
  82365. };
  82366. /**
  82367. * Gets current buffer's data
  82368. * @returns a DataArray or null
  82369. */
  82370. VertexBuffer.prototype.getData = function () {
  82371. return this._buffer.getData();
  82372. };
  82373. /**
  82374. * Gets underlying native buffer
  82375. * @returns underlying native buffer
  82376. */
  82377. VertexBuffer.prototype.getBuffer = function () {
  82378. return this._buffer.getBuffer();
  82379. };
  82380. /**
  82381. * Gets the stride in float32 units (i.e. byte stride / 4).
  82382. * May not be an integer if the byte stride is not divisible by 4.
  82383. * DEPRECATED. Use byteStride instead.
  82384. * @returns the stride in float32 units
  82385. */
  82386. VertexBuffer.prototype.getStrideSize = function () {
  82387. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  82388. };
  82389. /**
  82390. * Returns the offset as a multiple of the type byte length.
  82391. * DEPRECATED. Use byteOffset instead.
  82392. * @returns the offset in bytes
  82393. */
  82394. VertexBuffer.prototype.getOffset = function () {
  82395. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  82396. };
  82397. /**
  82398. * Returns the number of components per vertex attribute (integer)
  82399. * @returns the size in float
  82400. */
  82401. VertexBuffer.prototype.getSize = function () {
  82402. return this._size;
  82403. };
  82404. /**
  82405. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  82406. * @returns true if this buffer is instanced
  82407. */
  82408. VertexBuffer.prototype.getIsInstanced = function () {
  82409. return this._instanced;
  82410. };
  82411. /**
  82412. * Returns the instancing divisor, zero for non-instanced (integer).
  82413. * @returns a number
  82414. */
  82415. VertexBuffer.prototype.getInstanceDivisor = function () {
  82416. return this._instanceDivisor;
  82417. };
  82418. // Methods
  82419. /**
  82420. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82421. * @param data defines the data to store
  82422. */
  82423. VertexBuffer.prototype.create = function (data) {
  82424. this._buffer.create(data);
  82425. };
  82426. /**
  82427. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  82428. * This function will create a new buffer if the current one is not updatable
  82429. * @param data defines the data to store
  82430. */
  82431. VertexBuffer.prototype.update = function (data) {
  82432. this._buffer.update(data);
  82433. };
  82434. /**
  82435. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  82436. * Returns the directly updated WebGLBuffer.
  82437. * @param data the new data
  82438. * @param offset the new offset
  82439. * @param useBytes set to true if the offset is in bytes
  82440. */
  82441. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  82442. if (useBytes === void 0) { useBytes = false; }
  82443. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  82444. };
  82445. /**
  82446. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  82447. */
  82448. VertexBuffer.prototype.dispose = function () {
  82449. if (this._ownsBuffer) {
  82450. this._buffer.dispose();
  82451. }
  82452. };
  82453. /**
  82454. * Enumerates each value of this vertex buffer as numbers.
  82455. * @param count the number of values to enumerate
  82456. * @param callback the callback function called for each value
  82457. */
  82458. VertexBuffer.prototype.forEach = function (count, callback) {
  82459. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  82460. };
  82461. /**
  82462. * Deduces the stride given a kind.
  82463. * @param kind The kind string to deduce
  82464. * @returns The deduced stride
  82465. */
  82466. VertexBuffer.DeduceStride = function (kind) {
  82467. switch (kind) {
  82468. case VertexBuffer.UVKind:
  82469. case VertexBuffer.UV2Kind:
  82470. case VertexBuffer.UV3Kind:
  82471. case VertexBuffer.UV4Kind:
  82472. case VertexBuffer.UV5Kind:
  82473. case VertexBuffer.UV6Kind:
  82474. return 2;
  82475. case VertexBuffer.NormalKind:
  82476. case VertexBuffer.PositionKind:
  82477. return 3;
  82478. case VertexBuffer.ColorKind:
  82479. case VertexBuffer.MatricesIndicesKind:
  82480. case VertexBuffer.MatricesIndicesExtraKind:
  82481. case VertexBuffer.MatricesWeightsKind:
  82482. case VertexBuffer.MatricesWeightsExtraKind:
  82483. case VertexBuffer.TangentKind:
  82484. return 4;
  82485. default:
  82486. throw new Error("Invalid kind '" + kind + "'");
  82487. }
  82488. };
  82489. /**
  82490. * Gets the byte length of the given type.
  82491. * @param type the type
  82492. * @returns the number of bytes
  82493. */
  82494. VertexBuffer.GetTypeByteLength = function (type) {
  82495. switch (type) {
  82496. case VertexBuffer.BYTE:
  82497. case VertexBuffer.UNSIGNED_BYTE:
  82498. return 1;
  82499. case VertexBuffer.SHORT:
  82500. case VertexBuffer.UNSIGNED_SHORT:
  82501. return 2;
  82502. case VertexBuffer.INT:
  82503. case VertexBuffer.FLOAT:
  82504. return 4;
  82505. default:
  82506. throw new Error("Invalid type '" + type + "'");
  82507. }
  82508. };
  82509. /**
  82510. * Enumerates each value of the given parameters as numbers.
  82511. * @param data the data to enumerate
  82512. * @param byteOffset the byte offset of the data
  82513. * @param byteStride the byte stride of the data
  82514. * @param componentCount the number of components per element
  82515. * @param componentType the type of the component
  82516. * @param count the total number of components
  82517. * @param normalized whether the data is normalized
  82518. * @param callback the callback function called for each value
  82519. */
  82520. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  82521. if (data instanceof Array) {
  82522. var offset = byteOffset / 4;
  82523. var stride = byteStride / 4;
  82524. for (var index = 0; index < count; index += componentCount) {
  82525. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  82526. callback(data[offset + componentIndex], index + componentIndex);
  82527. }
  82528. offset += stride;
  82529. }
  82530. }
  82531. else {
  82532. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  82533. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  82534. for (var index = 0; index < count; index += componentCount) {
  82535. var componentByteOffset = byteOffset;
  82536. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  82537. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  82538. callback(value, index + componentIndex);
  82539. componentByteOffset += componentByteLength;
  82540. }
  82541. byteOffset += byteStride;
  82542. }
  82543. }
  82544. };
  82545. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  82546. switch (type) {
  82547. case VertexBuffer.BYTE: {
  82548. var value = dataView.getInt8(byteOffset);
  82549. if (normalized) {
  82550. value = Math.max(value / 127, -1);
  82551. }
  82552. return value;
  82553. }
  82554. case VertexBuffer.UNSIGNED_BYTE: {
  82555. var value = dataView.getUint8(byteOffset);
  82556. if (normalized) {
  82557. value = value / 255;
  82558. }
  82559. return value;
  82560. }
  82561. case VertexBuffer.SHORT: {
  82562. var value = dataView.getInt16(byteOffset, true);
  82563. if (normalized) {
  82564. value = Math.max(value / 16383, -1);
  82565. }
  82566. return value;
  82567. }
  82568. case VertexBuffer.UNSIGNED_SHORT: {
  82569. var value = dataView.getUint16(byteOffset, true);
  82570. if (normalized) {
  82571. value = value / 65535;
  82572. }
  82573. return value;
  82574. }
  82575. case VertexBuffer.FLOAT: {
  82576. return dataView.getFloat32(byteOffset, true);
  82577. }
  82578. default: {
  82579. throw new Error("Invalid component type " + type);
  82580. }
  82581. }
  82582. };
  82583. /**
  82584. * The byte type.
  82585. */
  82586. VertexBuffer.BYTE = 5120;
  82587. /**
  82588. * The unsigned byte type.
  82589. */
  82590. VertexBuffer.UNSIGNED_BYTE = 5121;
  82591. /**
  82592. * The short type.
  82593. */
  82594. VertexBuffer.SHORT = 5122;
  82595. /**
  82596. * The unsigned short type.
  82597. */
  82598. VertexBuffer.UNSIGNED_SHORT = 5123;
  82599. /**
  82600. * The integer type.
  82601. */
  82602. VertexBuffer.INT = 5124;
  82603. /**
  82604. * The unsigned integer type.
  82605. */
  82606. VertexBuffer.UNSIGNED_INT = 5125;
  82607. /**
  82608. * The float type.
  82609. */
  82610. VertexBuffer.FLOAT = 5126;
  82611. // Enums
  82612. /**
  82613. * Positions
  82614. */
  82615. VertexBuffer.PositionKind = "position";
  82616. /**
  82617. * Normals
  82618. */
  82619. VertexBuffer.NormalKind = "normal";
  82620. /**
  82621. * Tangents
  82622. */
  82623. VertexBuffer.TangentKind = "tangent";
  82624. /**
  82625. * Texture coordinates
  82626. */
  82627. VertexBuffer.UVKind = "uv";
  82628. /**
  82629. * Texture coordinates 2
  82630. */
  82631. VertexBuffer.UV2Kind = "uv2";
  82632. /**
  82633. * Texture coordinates 3
  82634. */
  82635. VertexBuffer.UV3Kind = "uv3";
  82636. /**
  82637. * Texture coordinates 4
  82638. */
  82639. VertexBuffer.UV4Kind = "uv4";
  82640. /**
  82641. * Texture coordinates 5
  82642. */
  82643. VertexBuffer.UV5Kind = "uv5";
  82644. /**
  82645. * Texture coordinates 6
  82646. */
  82647. VertexBuffer.UV6Kind = "uv6";
  82648. /**
  82649. * Colors
  82650. */
  82651. VertexBuffer.ColorKind = "color";
  82652. /**
  82653. * Matrix indices (for bones)
  82654. */
  82655. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  82656. /**
  82657. * Matrix weights (for bones)
  82658. */
  82659. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  82660. /**
  82661. * Additional matrix indices (for bones)
  82662. */
  82663. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  82664. /**
  82665. * Additional matrix weights (for bones)
  82666. */
  82667. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  82668. return VertexBuffer;
  82669. }());
  82670. /***/ }),
  82671. /***/ "./Meshes/csg.ts":
  82672. /*!***********************!*\
  82673. !*** ./Meshes/csg.ts ***!
  82674. \***********************/
  82675. /*! exports provided: CSG */
  82676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82677. "use strict";
  82678. __webpack_require__.r(__webpack_exports__);
  82679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  82680. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82681. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82682. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  82683. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  82684. /**
  82685. * Unique ID when we import meshes from Babylon to CSG
  82686. */
  82687. var currentCSGMeshId = 0;
  82688. /**
  82689. * Represents a vertex of a polygon. Use your own vertex class instead of this
  82690. * one to provide additional features like texture coordinates and vertex
  82691. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  82692. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  82693. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  82694. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  82695. * is not used anywhere else.
  82696. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  82697. */
  82698. var Vertex = /** @class */ (function () {
  82699. /**
  82700. * Initializes the vertex
  82701. * @param pos The position of the vertex
  82702. * @param normal The normal of the vertex
  82703. * @param uv The texture coordinate of the vertex
  82704. */
  82705. function Vertex(
  82706. /**
  82707. * The position of the vertex
  82708. */
  82709. pos,
  82710. /**
  82711. * The normal of the vertex
  82712. */
  82713. normal,
  82714. /**
  82715. * The texture coordinate of the vertex
  82716. */
  82717. uv) {
  82718. this.pos = pos;
  82719. this.normal = normal;
  82720. this.uv = uv;
  82721. }
  82722. /**
  82723. * Make a clone, or deep copy, of the vertex
  82724. * @returns A new Vertex
  82725. */
  82726. Vertex.prototype.clone = function () {
  82727. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  82728. };
  82729. /**
  82730. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  82731. * orientation of a polygon is flipped.
  82732. */
  82733. Vertex.prototype.flip = function () {
  82734. this.normal = this.normal.scale(-1);
  82735. };
  82736. /**
  82737. * Create a new vertex between this vertex and `other` by linearly
  82738. * interpolating all properties using a parameter of `t`. Subclasses should
  82739. * override this to interpolate additional properties.
  82740. * @param other the vertex to interpolate against
  82741. * @param t The factor used to linearly interpolate between the vertices
  82742. */
  82743. Vertex.prototype.interpolate = function (other, t) {
  82744. 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));
  82745. };
  82746. return Vertex;
  82747. }());
  82748. /**
  82749. * Represents a plane in 3D space.
  82750. */
  82751. var Plane = /** @class */ (function () {
  82752. /**
  82753. * Initializes the plane
  82754. * @param normal The normal for the plane
  82755. * @param w
  82756. */
  82757. function Plane(normal, w) {
  82758. this.normal = normal;
  82759. this.w = w;
  82760. }
  82761. /**
  82762. * Construct a plane from three points
  82763. * @param a Point a
  82764. * @param b Point b
  82765. * @param c Point c
  82766. */
  82767. Plane.FromPoints = function (a, b, c) {
  82768. var v0 = c.subtract(a);
  82769. var v1 = b.subtract(a);
  82770. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  82771. return null;
  82772. }
  82773. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  82774. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  82775. };
  82776. /**
  82777. * Clone, or make a deep copy of the plane
  82778. * @returns a new Plane
  82779. */
  82780. Plane.prototype.clone = function () {
  82781. return new Plane(this.normal.clone(), this.w);
  82782. };
  82783. /**
  82784. * Flip the face of the plane
  82785. */
  82786. Plane.prototype.flip = function () {
  82787. this.normal.scaleInPlace(-1);
  82788. this.w = -this.w;
  82789. };
  82790. /**
  82791. * Split `polygon` by this plane if needed, then put the polygon or polygon
  82792. * fragments in the appropriate lists. Coplanar polygons go into either
  82793. `* coplanarFront` or `coplanarBack` depending on their orientation with
  82794. * respect to this plane. Polygons in front or in back of this plane go into
  82795. * either `front` or `back`
  82796. * @param polygon The polygon to be split
  82797. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  82798. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  82799. * @param front Will contain the polygons in front of the plane
  82800. * @param back Will contain the polygons begind the plane
  82801. */
  82802. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  82803. var COPLANAR = 0;
  82804. var FRONT = 1;
  82805. var BACK = 2;
  82806. var SPANNING = 3;
  82807. // Classify each point as well as the entire polygon into one of the above
  82808. // four classes.
  82809. var polygonType = 0;
  82810. var types = [];
  82811. var i;
  82812. var t;
  82813. for (i = 0; i < polygon.vertices.length; i++) {
  82814. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  82815. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  82816. polygonType |= type;
  82817. types.push(type);
  82818. }
  82819. // Put the polygon in the correct list, splitting it when necessary
  82820. switch (polygonType) {
  82821. case COPLANAR:
  82822. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  82823. break;
  82824. case FRONT:
  82825. front.push(polygon);
  82826. break;
  82827. case BACK:
  82828. back.push(polygon);
  82829. break;
  82830. case SPANNING:
  82831. var f = [], b = [];
  82832. for (i = 0; i < polygon.vertices.length; i++) {
  82833. var j = (i + 1) % polygon.vertices.length;
  82834. var ti = types[i], tj = types[j];
  82835. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  82836. if (ti !== BACK) {
  82837. f.push(vi);
  82838. }
  82839. if (ti !== FRONT) {
  82840. b.push(ti !== BACK ? vi.clone() : vi);
  82841. }
  82842. if ((ti | tj) === SPANNING) {
  82843. 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));
  82844. var v = vi.interpolate(vj, t);
  82845. f.push(v);
  82846. b.push(v.clone());
  82847. }
  82848. }
  82849. var poly;
  82850. if (f.length >= 3) {
  82851. poly = new Polygon(f, polygon.shared);
  82852. if (poly.plane) {
  82853. front.push(poly);
  82854. }
  82855. }
  82856. if (b.length >= 3) {
  82857. poly = new Polygon(b, polygon.shared);
  82858. if (poly.plane) {
  82859. back.push(poly);
  82860. }
  82861. }
  82862. break;
  82863. }
  82864. };
  82865. /**
  82866. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  82867. * point is on the plane
  82868. */
  82869. Plane.EPSILON = 1e-5;
  82870. return Plane;
  82871. }());
  82872. /**
  82873. * Represents a convex polygon. The vertices used to initialize a polygon must
  82874. * be coplanar and form a convex loop.
  82875. *
  82876. * Each convex polygon has a `shared` property, which is shared between all
  82877. * polygons that are clones of each other or were split from the same polygon.
  82878. * This can be used to define per-polygon properties (such as surface color)
  82879. */
  82880. var Polygon = /** @class */ (function () {
  82881. /**
  82882. * Initializes the polygon
  82883. * @param vertices The vertices of the polygon
  82884. * @param shared The properties shared across all polygons
  82885. */
  82886. function Polygon(vertices, shared) {
  82887. this.vertices = vertices;
  82888. this.shared = shared;
  82889. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  82890. }
  82891. /**
  82892. * Clones, or makes a deep copy, or the polygon
  82893. */
  82894. Polygon.prototype.clone = function () {
  82895. var vertices = this.vertices.map(function (v) { return v.clone(); });
  82896. return new Polygon(vertices, this.shared);
  82897. };
  82898. /**
  82899. * Flips the faces of the polygon
  82900. */
  82901. Polygon.prototype.flip = function () {
  82902. this.vertices.reverse().map(function (v) { v.flip(); });
  82903. this.plane.flip();
  82904. };
  82905. return Polygon;
  82906. }());
  82907. /**
  82908. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  82909. * by picking a polygon to split along. That polygon (and all other coplanar
  82910. * polygons) are added directly to that node and the other polygons are added to
  82911. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  82912. * no distinction between internal and leaf nodes
  82913. */
  82914. var Node = /** @class */ (function () {
  82915. /**
  82916. * Initializes the node
  82917. * @param polygons A collection of polygons held in the node
  82918. */
  82919. function Node(polygons) {
  82920. this.plane = null;
  82921. this.front = null;
  82922. this.back = null;
  82923. this.polygons = new Array();
  82924. if (polygons) {
  82925. this.build(polygons);
  82926. }
  82927. }
  82928. /**
  82929. * Clones, or makes a deep copy, of the node
  82930. * @returns The cloned node
  82931. */
  82932. Node.prototype.clone = function () {
  82933. var node = new Node();
  82934. node.plane = this.plane && this.plane.clone();
  82935. node.front = this.front && this.front.clone();
  82936. node.back = this.back && this.back.clone();
  82937. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  82938. return node;
  82939. };
  82940. /**
  82941. * Convert solid space to empty space and empty space to solid space
  82942. */
  82943. Node.prototype.invert = function () {
  82944. for (var i = 0; i < this.polygons.length; i++) {
  82945. this.polygons[i].flip();
  82946. }
  82947. if (this.plane) {
  82948. this.plane.flip();
  82949. }
  82950. if (this.front) {
  82951. this.front.invert();
  82952. }
  82953. if (this.back) {
  82954. this.back.invert();
  82955. }
  82956. var temp = this.front;
  82957. this.front = this.back;
  82958. this.back = temp;
  82959. };
  82960. /**
  82961. * Recursively remove all polygons in `polygons` that are inside this BSP
  82962. * tree.
  82963. * @param polygons Polygons to remove from the BSP
  82964. * @returns Polygons clipped from the BSP
  82965. */
  82966. Node.prototype.clipPolygons = function (polygons) {
  82967. if (!this.plane) {
  82968. return polygons.slice();
  82969. }
  82970. var front = new Array(), back = new Array();
  82971. for (var i = 0; i < polygons.length; i++) {
  82972. this.plane.splitPolygon(polygons[i], front, back, front, back);
  82973. }
  82974. if (this.front) {
  82975. front = this.front.clipPolygons(front);
  82976. }
  82977. if (this.back) {
  82978. back = this.back.clipPolygons(back);
  82979. }
  82980. else {
  82981. back = [];
  82982. }
  82983. return front.concat(back);
  82984. };
  82985. /**
  82986. * Remove all polygons in this BSP tree that are inside the other BSP tree
  82987. * `bsp`.
  82988. * @param bsp BSP containing polygons to remove from this BSP
  82989. */
  82990. Node.prototype.clipTo = function (bsp) {
  82991. this.polygons = bsp.clipPolygons(this.polygons);
  82992. if (this.front) {
  82993. this.front.clipTo(bsp);
  82994. }
  82995. if (this.back) {
  82996. this.back.clipTo(bsp);
  82997. }
  82998. };
  82999. /**
  83000. * Return a list of all polygons in this BSP tree
  83001. * @returns List of all polygons in this BSP tree
  83002. */
  83003. Node.prototype.allPolygons = function () {
  83004. var polygons = this.polygons.slice();
  83005. if (this.front) {
  83006. polygons = polygons.concat(this.front.allPolygons());
  83007. }
  83008. if (this.back) {
  83009. polygons = polygons.concat(this.back.allPolygons());
  83010. }
  83011. return polygons;
  83012. };
  83013. /**
  83014. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  83015. * new polygons are filtered down to the bottom of the tree and become new
  83016. * nodes there. Each set of polygons is partitioned using the first polygon
  83017. * (no heuristic is used to pick a good split)
  83018. * @param polygons Polygons used to construct the BSP tree
  83019. */
  83020. Node.prototype.build = function (polygons) {
  83021. if (!polygons.length) {
  83022. return;
  83023. }
  83024. if (!this.plane) {
  83025. this.plane = polygons[0].plane.clone();
  83026. }
  83027. var front = new Array(), back = new Array();
  83028. for (var i = 0; i < polygons.length; i++) {
  83029. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  83030. }
  83031. if (front.length) {
  83032. if (!this.front) {
  83033. this.front = new Node();
  83034. }
  83035. this.front.build(front);
  83036. }
  83037. if (back.length) {
  83038. if (!this.back) {
  83039. this.back = new Node();
  83040. }
  83041. this.back.build(back);
  83042. }
  83043. };
  83044. return Node;
  83045. }());
  83046. /**
  83047. * Class for building Constructive Solid Geometry
  83048. */
  83049. var CSG = /** @class */ (function () {
  83050. function CSG() {
  83051. this.polygons = new Array();
  83052. }
  83053. /**
  83054. * Convert the Mesh to CSG
  83055. * @param mesh The Mesh to convert to CSG
  83056. * @returns A new CSG from the Mesh
  83057. */
  83058. CSG.FromMesh = function (mesh) {
  83059. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  83060. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  83061. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  83062. mesh.computeWorldMatrix(true);
  83063. matrix = mesh.getWorldMatrix();
  83064. meshPosition = mesh.position.clone();
  83065. meshRotation = mesh.rotation.clone();
  83066. if (mesh.rotationQuaternion) {
  83067. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  83068. }
  83069. meshScaling = mesh.scaling.clone();
  83070. }
  83071. else {
  83072. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  83073. }
  83074. 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);
  83075. var subMeshes = mesh.subMeshes;
  83076. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  83077. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  83078. vertices = [];
  83079. for (var j = 0; j < 3; j++) {
  83080. 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]);
  83081. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  83082. 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]);
  83083. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  83084. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  83085. vertex = new Vertex(position, normal, uv);
  83086. vertices.push(vertex);
  83087. }
  83088. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  83089. // To handle the case of degenerated triangle
  83090. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  83091. if (polygon.plane) {
  83092. polygons.push(polygon);
  83093. }
  83094. }
  83095. }
  83096. var csg = CSG.FromPolygons(polygons);
  83097. csg.matrix = matrix;
  83098. csg.position = meshPosition;
  83099. csg.rotation = meshRotation;
  83100. csg.scaling = meshScaling;
  83101. csg.rotationQuaternion = meshRotationQuaternion;
  83102. currentCSGMeshId++;
  83103. return csg;
  83104. };
  83105. /**
  83106. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  83107. * @param polygons Polygons used to construct a CSG solid
  83108. */
  83109. CSG.FromPolygons = function (polygons) {
  83110. var csg = new CSG();
  83111. csg.polygons = polygons;
  83112. return csg;
  83113. };
  83114. /**
  83115. * Clones, or makes a deep copy, of the CSG
  83116. * @returns A new CSG
  83117. */
  83118. CSG.prototype.clone = function () {
  83119. var csg = new CSG();
  83120. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  83121. csg.copyTransformAttributes(this);
  83122. return csg;
  83123. };
  83124. /**
  83125. * Unions this CSG with another CSG
  83126. * @param csg The CSG to union against this CSG
  83127. * @returns The unioned CSG
  83128. */
  83129. CSG.prototype.union = function (csg) {
  83130. var a = new Node(this.clone().polygons);
  83131. var b = new Node(csg.clone().polygons);
  83132. a.clipTo(b);
  83133. b.clipTo(a);
  83134. b.invert();
  83135. b.clipTo(a);
  83136. b.invert();
  83137. a.build(b.allPolygons());
  83138. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  83139. };
  83140. /**
  83141. * Unions this CSG with another CSG in place
  83142. * @param csg The CSG to union against this CSG
  83143. */
  83144. CSG.prototype.unionInPlace = function (csg) {
  83145. var a = new Node(this.polygons);
  83146. var b = new Node(csg.polygons);
  83147. a.clipTo(b);
  83148. b.clipTo(a);
  83149. b.invert();
  83150. b.clipTo(a);
  83151. b.invert();
  83152. a.build(b.allPolygons());
  83153. this.polygons = a.allPolygons();
  83154. };
  83155. /**
  83156. * Subtracts this CSG with another CSG
  83157. * @param csg The CSG to subtract against this CSG
  83158. * @returns A new CSG
  83159. */
  83160. CSG.prototype.subtract = function (csg) {
  83161. var a = new Node(this.clone().polygons);
  83162. var b = new Node(csg.clone().polygons);
  83163. a.invert();
  83164. a.clipTo(b);
  83165. b.clipTo(a);
  83166. b.invert();
  83167. b.clipTo(a);
  83168. b.invert();
  83169. a.build(b.allPolygons());
  83170. a.invert();
  83171. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  83172. };
  83173. /**
  83174. * Subtracts this CSG with another CSG in place
  83175. * @param csg The CSG to subtact against this CSG
  83176. */
  83177. CSG.prototype.subtractInPlace = function (csg) {
  83178. var a = new Node(this.polygons);
  83179. var b = new Node(csg.polygons);
  83180. a.invert();
  83181. a.clipTo(b);
  83182. b.clipTo(a);
  83183. b.invert();
  83184. b.clipTo(a);
  83185. b.invert();
  83186. a.build(b.allPolygons());
  83187. a.invert();
  83188. this.polygons = a.allPolygons();
  83189. };
  83190. /**
  83191. * Intersect this CSG with another CSG
  83192. * @param csg The CSG to intersect against this CSG
  83193. * @returns A new CSG
  83194. */
  83195. CSG.prototype.intersect = function (csg) {
  83196. var a = new Node(this.clone().polygons);
  83197. var b = new Node(csg.clone().polygons);
  83198. a.invert();
  83199. b.clipTo(a);
  83200. b.invert();
  83201. a.clipTo(b);
  83202. b.clipTo(a);
  83203. a.build(b.allPolygons());
  83204. a.invert();
  83205. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  83206. };
  83207. /**
  83208. * Intersects this CSG with another CSG in place
  83209. * @param csg The CSG to intersect against this CSG
  83210. */
  83211. CSG.prototype.intersectInPlace = function (csg) {
  83212. var a = new Node(this.polygons);
  83213. var b = new Node(csg.polygons);
  83214. a.invert();
  83215. b.clipTo(a);
  83216. b.invert();
  83217. a.clipTo(b);
  83218. b.clipTo(a);
  83219. a.build(b.allPolygons());
  83220. a.invert();
  83221. this.polygons = a.allPolygons();
  83222. };
  83223. /**
  83224. * Return a new CSG solid with solid and empty space switched. This solid is
  83225. * not modified.
  83226. * @returns A new CSG solid with solid and empty space switched
  83227. */
  83228. CSG.prototype.inverse = function () {
  83229. var csg = this.clone();
  83230. csg.inverseInPlace();
  83231. return csg;
  83232. };
  83233. /**
  83234. * Inverses the CSG in place
  83235. */
  83236. CSG.prototype.inverseInPlace = function () {
  83237. this.polygons.map(function (p) { p.flip(); });
  83238. };
  83239. /**
  83240. * This is used to keep meshes transformations so they can be restored
  83241. * when we build back a Babylon Mesh
  83242. * NB : All CSG operations are performed in world coordinates
  83243. * @param csg The CSG to copy the transform attributes from
  83244. * @returns This CSG
  83245. */
  83246. CSG.prototype.copyTransformAttributes = function (csg) {
  83247. this.matrix = csg.matrix;
  83248. this.position = csg.position;
  83249. this.rotation = csg.rotation;
  83250. this.scaling = csg.scaling;
  83251. this.rotationQuaternion = csg.rotationQuaternion;
  83252. return this;
  83253. };
  83254. /**
  83255. * Build Raw mesh from CSG
  83256. * Coordinates here are in world space
  83257. * @param name The name of the mesh geometry
  83258. * @param scene The Scene
  83259. * @param keepSubMeshes Specifies if the submeshes should be kept
  83260. * @returns A new Mesh
  83261. */
  83262. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  83263. var matrix = this.matrix.clone();
  83264. matrix.invert();
  83265. 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;
  83266. if (keepSubMeshes) {
  83267. // Sort Polygons, since subMeshes are indices range
  83268. polygons.sort(function (a, b) {
  83269. if (a.shared.meshId === b.shared.meshId) {
  83270. return a.shared.subMeshId - b.shared.subMeshId;
  83271. }
  83272. else {
  83273. return a.shared.meshId - b.shared.meshId;
  83274. }
  83275. });
  83276. }
  83277. for (var i = 0, il = polygons.length; i < il; i++) {
  83278. polygon = polygons[i];
  83279. // Building SubMeshes
  83280. if (!subMesh_dict[polygon.shared.meshId]) {
  83281. subMesh_dict[polygon.shared.meshId] = {};
  83282. }
  83283. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  83284. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  83285. indexStart: +Infinity,
  83286. indexEnd: -Infinity,
  83287. materialIndex: polygon.shared.materialIndex
  83288. };
  83289. }
  83290. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  83291. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  83292. polygonIndices[0] = 0;
  83293. polygonIndices[1] = j - 1;
  83294. polygonIndices[2] = j;
  83295. for (var k = 0; k < 3; k++) {
  83296. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  83297. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  83298. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  83299. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  83300. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  83301. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  83302. // Check if 2 points can be merged
  83303. if (!(typeof vertex_idx !== 'undefined' &&
  83304. normals[vertex_idx * 3] === localNormal.x &&
  83305. normals[vertex_idx * 3 + 1] === localNormal.y &&
  83306. normals[vertex_idx * 3 + 2] === localNormal.z &&
  83307. uvs[vertex_idx * 2] === uv.x &&
  83308. uvs[vertex_idx * 2 + 1] === uv.y)) {
  83309. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  83310. uvs.push(uv.x, uv.y);
  83311. normals.push(normal.x, normal.y, normal.z);
  83312. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  83313. }
  83314. indices.push(vertex_idx);
  83315. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  83316. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  83317. currentIndex++;
  83318. }
  83319. }
  83320. }
  83321. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  83322. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  83323. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  83324. mesh.setIndices(indices, null);
  83325. if (keepSubMeshes) {
  83326. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  83327. var materialIndexOffset = 0, materialMaxIndex;
  83328. mesh.subMeshes = new Array();
  83329. for (var m in subMesh_dict) {
  83330. materialMaxIndex = -1;
  83331. for (var sm in subMesh_dict[m]) {
  83332. subMesh_obj = subMesh_dict[m][sm];
  83333. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  83334. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  83335. }
  83336. materialIndexOffset += ++materialMaxIndex;
  83337. }
  83338. }
  83339. return mesh;
  83340. };
  83341. /**
  83342. * Build Mesh from CSG taking material and transforms into account
  83343. * @param name The name of the Mesh
  83344. * @param material The material of the Mesh
  83345. * @param scene The Scene
  83346. * @param keepSubMeshes Specifies if submeshes should be kept
  83347. * @returns The new Mesh
  83348. */
  83349. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  83350. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  83351. mesh.material = material;
  83352. mesh.position.copyFrom(this.position);
  83353. mesh.rotation.copyFrom(this.rotation);
  83354. if (this.rotationQuaternion) {
  83355. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  83356. }
  83357. mesh.scaling.copyFrom(this.scaling);
  83358. mesh.computeWorldMatrix(true);
  83359. return mesh;
  83360. };
  83361. return CSG;
  83362. }());
  83363. /***/ }),
  83364. /***/ "./Meshes/geometry.ts":
  83365. /*!****************************!*\
  83366. !*** ./Meshes/geometry.ts ***!
  83367. \****************************/
  83368. /*! exports provided: Geometry */
  83369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83370. "use strict";
  83371. __webpack_require__.r(__webpack_exports__);
  83372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  83373. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83374. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83375. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83376. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  83377. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  83378. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  83379. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  83380. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  83381. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  83382. /**
  83383. * Class used to store geometry data (vertex buffers + index buffer)
  83384. */
  83385. var Geometry = /** @class */ (function () {
  83386. /**
  83387. * Creates a new geometry
  83388. * @param id defines the unique ID
  83389. * @param scene defines the hosting scene
  83390. * @param vertexData defines the VertexData used to get geometry data
  83391. * @param updatable defines if geometry must be updatable (false by default)
  83392. * @param mesh defines the mesh that will be associated with the geometry
  83393. */
  83394. function Geometry(id, scene, vertexData, updatable, mesh) {
  83395. if (updatable === void 0) { updatable = false; }
  83396. if (mesh === void 0) { mesh = null; }
  83397. /**
  83398. * Gets the delay loading state of the geometry (none by default which means not delayed)
  83399. */
  83400. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  83401. this._totalVertices = 0;
  83402. this._isDisposed = false;
  83403. this._indexBufferIsUpdatable = false;
  83404. this.id = id;
  83405. this.uniqueId = scene.getUniqueId();
  83406. this._engine = scene.getEngine();
  83407. this._meshes = [];
  83408. this._scene = scene;
  83409. //Init vertex buffer cache
  83410. this._vertexBuffers = {};
  83411. this._indices = [];
  83412. this._updatable = updatable;
  83413. // vertexData
  83414. if (vertexData) {
  83415. this.setAllVerticesData(vertexData, updatable);
  83416. }
  83417. else {
  83418. this._totalVertices = 0;
  83419. this._indices = [];
  83420. }
  83421. if (this._engine.getCaps().vertexArrayObject) {
  83422. this._vertexArrayObjects = {};
  83423. }
  83424. // applyToMesh
  83425. if (mesh) {
  83426. this.applyToMesh(mesh);
  83427. mesh.computeWorldMatrix(true);
  83428. }
  83429. }
  83430. Object.defineProperty(Geometry.prototype, "boundingBias", {
  83431. /**
  83432. * 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
  83433. */
  83434. get: function () {
  83435. return this._boundingBias;
  83436. },
  83437. /**
  83438. * 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
  83439. */
  83440. set: function (value) {
  83441. if (this._boundingBias) {
  83442. this._boundingBias.copyFrom(value);
  83443. }
  83444. else {
  83445. this._boundingBias = value.clone();
  83446. }
  83447. this._updateBoundingInfo(true, null);
  83448. },
  83449. enumerable: true,
  83450. configurable: true
  83451. });
  83452. /**
  83453. * Static function used to attach a new empty geometry to a mesh
  83454. * @param mesh defines the mesh to attach the geometry to
  83455. * @returns the new Geometry
  83456. */
  83457. Geometry.CreateGeometryForMesh = function (mesh) {
  83458. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  83459. geometry.applyToMesh(mesh);
  83460. return geometry;
  83461. };
  83462. Object.defineProperty(Geometry.prototype, "extend", {
  83463. /**
  83464. * Gets the current extend of the geometry
  83465. */
  83466. get: function () {
  83467. return this._extend;
  83468. },
  83469. enumerable: true,
  83470. configurable: true
  83471. });
  83472. /**
  83473. * Gets the hosting scene
  83474. * @returns the hosting Scene
  83475. */
  83476. Geometry.prototype.getScene = function () {
  83477. return this._scene;
  83478. };
  83479. /**
  83480. * Gets the hosting engine
  83481. * @returns the hosting Engine
  83482. */
  83483. Geometry.prototype.getEngine = function () {
  83484. return this._engine;
  83485. };
  83486. /**
  83487. * Defines if the geometry is ready to use
  83488. * @returns true if the geometry is ready to be used
  83489. */
  83490. Geometry.prototype.isReady = function () {
  83491. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  83492. };
  83493. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  83494. /**
  83495. * Gets a value indicating that the geometry should not be serialized
  83496. */
  83497. get: function () {
  83498. for (var index = 0; index < this._meshes.length; index++) {
  83499. if (!this._meshes[index].doNotSerialize) {
  83500. return false;
  83501. }
  83502. }
  83503. return true;
  83504. },
  83505. enumerable: true,
  83506. configurable: true
  83507. });
  83508. /** @hidden */
  83509. Geometry.prototype._rebuild = function () {
  83510. if (this._vertexArrayObjects) {
  83511. this._vertexArrayObjects = {};
  83512. }
  83513. // Index buffer
  83514. if (this._meshes.length !== 0 && this._indices) {
  83515. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  83516. }
  83517. // Vertex buffers
  83518. for (var key in this._vertexBuffers) {
  83519. var vertexBuffer = this._vertexBuffers[key];
  83520. vertexBuffer._rebuild();
  83521. }
  83522. };
  83523. /**
  83524. * Affects all geometry data in one call
  83525. * @param vertexData defines the geometry data
  83526. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  83527. */
  83528. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  83529. vertexData.applyToGeometry(this, updatable);
  83530. this.notifyUpdate();
  83531. };
  83532. /**
  83533. * Set specific vertex data
  83534. * @param kind defines the data kind (Position, normal, etc...)
  83535. * @param data defines the vertex data to use
  83536. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  83537. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  83538. */
  83539. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  83540. if (updatable === void 0) { updatable = false; }
  83541. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  83542. this.setVerticesBuffer(buffer);
  83543. };
  83544. /**
  83545. * Removes a specific vertex data
  83546. * @param kind defines the data kind (Position, normal, etc...)
  83547. */
  83548. Geometry.prototype.removeVerticesData = function (kind) {
  83549. if (this._vertexBuffers[kind]) {
  83550. this._vertexBuffers[kind].dispose();
  83551. delete this._vertexBuffers[kind];
  83552. }
  83553. };
  83554. /**
  83555. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  83556. * @param buffer defines the vertex buffer to use
  83557. * @param totalVertices defines the total number of vertices for position kind (could be null)
  83558. */
  83559. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  83560. if (totalVertices === void 0) { totalVertices = null; }
  83561. var kind = buffer.getKind();
  83562. if (this._vertexBuffers[kind]) {
  83563. this._vertexBuffers[kind].dispose();
  83564. }
  83565. this._vertexBuffers[kind] = buffer;
  83566. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  83567. var data = buffer.getData();
  83568. if (totalVertices != null) {
  83569. this._totalVertices = totalVertices;
  83570. }
  83571. else {
  83572. if (data != null) {
  83573. this._totalVertices = data.length / (buffer.byteStride / 4);
  83574. }
  83575. }
  83576. this._updateExtend(data);
  83577. this._resetPointsArrayCache();
  83578. var meshes = this._meshes;
  83579. var numOfMeshes = meshes.length;
  83580. for (var index = 0; index < numOfMeshes; index++) {
  83581. var mesh = meshes[index];
  83582. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  83583. mesh._createGlobalSubMesh(false);
  83584. mesh.computeWorldMatrix(true);
  83585. }
  83586. }
  83587. this.notifyUpdate(kind);
  83588. if (this._vertexArrayObjects) {
  83589. this._disposeVertexArrayObjects();
  83590. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  83591. }
  83592. };
  83593. /**
  83594. * Update a specific vertex buffer
  83595. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  83596. * It will do nothing if the buffer is not updatable
  83597. * @param kind defines the data kind (Position, normal, etc...)
  83598. * @param data defines the data to use
  83599. * @param offset defines the offset in the target buffer where to store the data
  83600. * @param useBytes set to true if the offset is in bytes
  83601. */
  83602. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  83603. if (useBytes === void 0) { useBytes = false; }
  83604. var vertexBuffer = this.getVertexBuffer(kind);
  83605. if (!vertexBuffer) {
  83606. return;
  83607. }
  83608. vertexBuffer.updateDirectly(data, offset, useBytes);
  83609. this.notifyUpdate(kind);
  83610. };
  83611. /**
  83612. * Update a specific vertex buffer
  83613. * This function will create a new buffer if the current one is not updatable
  83614. * @param kind defines the data kind (Position, normal, etc...)
  83615. * @param data defines the data to use
  83616. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  83617. */
  83618. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  83619. if (updateExtends === void 0) { updateExtends = false; }
  83620. var vertexBuffer = this.getVertexBuffer(kind);
  83621. if (!vertexBuffer) {
  83622. return;
  83623. }
  83624. vertexBuffer.update(data);
  83625. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  83626. this._updateBoundingInfo(updateExtends, data);
  83627. }
  83628. this.notifyUpdate(kind);
  83629. };
  83630. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  83631. if (updateExtends) {
  83632. this._updateExtend(data);
  83633. }
  83634. this._resetPointsArrayCache();
  83635. if (updateExtends) {
  83636. var meshes = this._meshes;
  83637. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  83638. var mesh = meshes_1[_i];
  83639. if (mesh._boundingInfo) {
  83640. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  83641. }
  83642. else {
  83643. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  83644. }
  83645. var subMeshes = mesh.subMeshes;
  83646. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  83647. var subMesh = subMeshes_1[_a];
  83648. subMesh.refreshBoundingInfo();
  83649. }
  83650. }
  83651. }
  83652. };
  83653. /** @hidden */
  83654. Geometry.prototype._bind = function (effect, indexToBind) {
  83655. if (!effect) {
  83656. return;
  83657. }
  83658. if (indexToBind === undefined) {
  83659. indexToBind = this._indexBuffer;
  83660. }
  83661. var vbs = this.getVertexBuffers();
  83662. if (!vbs) {
  83663. return;
  83664. }
  83665. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  83666. this._engine.bindBuffers(vbs, indexToBind, effect);
  83667. return;
  83668. }
  83669. // Using VAO
  83670. if (!this._vertexArrayObjects[effect.key]) {
  83671. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  83672. }
  83673. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  83674. };
  83675. /**
  83676. * Gets total number of vertices
  83677. * @returns the total number of vertices
  83678. */
  83679. Geometry.prototype.getTotalVertices = function () {
  83680. if (!this.isReady()) {
  83681. return 0;
  83682. }
  83683. return this._totalVertices;
  83684. };
  83685. /**
  83686. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  83687. * @param kind defines the data kind (Position, normal, etc...)
  83688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  83689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83690. * @returns a float array containing vertex data
  83691. */
  83692. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  83693. var vertexBuffer = this.getVertexBuffer(kind);
  83694. if (!vertexBuffer) {
  83695. return null;
  83696. }
  83697. var data = vertexBuffer.getData();
  83698. if (!data) {
  83699. return null;
  83700. }
  83701. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  83702. var count = this._totalVertices * vertexBuffer.getSize();
  83703. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  83704. var copy_1 = [];
  83705. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  83706. return copy_1;
  83707. }
  83708. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  83709. if (data instanceof Array) {
  83710. var offset = vertexBuffer.byteOffset / 4;
  83711. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  83712. }
  83713. else if (data instanceof ArrayBuffer) {
  83714. return new Float32Array(data, vertexBuffer.byteOffset, count);
  83715. }
  83716. else {
  83717. var offset = data.byteOffset + vertexBuffer.byteOffset;
  83718. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  83719. var result = new Float32Array(count);
  83720. var source = new Float32Array(data.buffer, offset, count);
  83721. result.set(source);
  83722. return result;
  83723. }
  83724. return new Float32Array(data.buffer, offset, count);
  83725. }
  83726. }
  83727. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  83728. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  83729. }
  83730. return data;
  83731. };
  83732. /**
  83733. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  83734. * @param kind defines the data kind (Position, normal, etc...)
  83735. * @returns true if the vertex buffer with the specified kind is updatable
  83736. */
  83737. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  83738. var vb = this._vertexBuffers[kind];
  83739. if (!vb) {
  83740. return false;
  83741. }
  83742. return vb.isUpdatable();
  83743. };
  83744. /**
  83745. * Gets a specific vertex buffer
  83746. * @param kind defines the data kind (Position, normal, etc...)
  83747. * @returns a VertexBuffer
  83748. */
  83749. Geometry.prototype.getVertexBuffer = function (kind) {
  83750. if (!this.isReady()) {
  83751. return null;
  83752. }
  83753. return this._vertexBuffers[kind];
  83754. };
  83755. /**
  83756. * Returns all vertex buffers
  83757. * @return an object holding all vertex buffers indexed by kind
  83758. */
  83759. Geometry.prototype.getVertexBuffers = function () {
  83760. if (!this.isReady()) {
  83761. return null;
  83762. }
  83763. return this._vertexBuffers;
  83764. };
  83765. /**
  83766. * Gets a boolean indicating if specific vertex buffer is present
  83767. * @param kind defines the data kind (Position, normal, etc...)
  83768. * @returns true if data is present
  83769. */
  83770. Geometry.prototype.isVerticesDataPresent = function (kind) {
  83771. if (!this._vertexBuffers) {
  83772. if (this._delayInfo) {
  83773. return this._delayInfo.indexOf(kind) !== -1;
  83774. }
  83775. return false;
  83776. }
  83777. return this._vertexBuffers[kind] !== undefined;
  83778. };
  83779. /**
  83780. * Gets a list of all attached data kinds (Position, normal, etc...)
  83781. * @returns a list of string containing all kinds
  83782. */
  83783. Geometry.prototype.getVerticesDataKinds = function () {
  83784. var result = [];
  83785. var kind;
  83786. if (!this._vertexBuffers && this._delayInfo) {
  83787. for (kind in this._delayInfo) {
  83788. result.push(kind);
  83789. }
  83790. }
  83791. else {
  83792. for (kind in this._vertexBuffers) {
  83793. result.push(kind);
  83794. }
  83795. }
  83796. return result;
  83797. };
  83798. /**
  83799. * Update index buffer
  83800. * @param indices defines the indices to store in the index buffer
  83801. * @param offset defines the offset in the target buffer where to store the data
  83802. */
  83803. Geometry.prototype.updateIndices = function (indices, offset) {
  83804. if (!this._indexBuffer) {
  83805. return;
  83806. }
  83807. if (!this._indexBufferIsUpdatable) {
  83808. this.setIndices(indices, null, true);
  83809. }
  83810. else {
  83811. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  83812. this._indices = indices;
  83813. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  83814. if (needToUpdateSubMeshes) {
  83815. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  83816. var mesh = _a[_i];
  83817. mesh._createGlobalSubMesh(true);
  83818. }
  83819. }
  83820. }
  83821. };
  83822. /**
  83823. * Creates a new index buffer
  83824. * @param indices defines the indices to store in the index buffer
  83825. * @param totalVertices defines the total number of vertices (could be null)
  83826. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83827. */
  83828. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  83829. if (totalVertices === void 0) { totalVertices = null; }
  83830. if (updatable === void 0) { updatable = false; }
  83831. if (this._indexBuffer) {
  83832. this._engine._releaseBuffer(this._indexBuffer);
  83833. }
  83834. this._disposeVertexArrayObjects();
  83835. this._indices = indices;
  83836. this._indexBufferIsUpdatable = updatable;
  83837. if (this._meshes.length !== 0 && this._indices) {
  83838. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  83839. }
  83840. if (totalVertices != undefined) { // including null and undefined
  83841. this._totalVertices = totalVertices;
  83842. }
  83843. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  83844. var mesh = _a[_i];
  83845. mesh._createGlobalSubMesh(true);
  83846. }
  83847. this.notifyUpdate();
  83848. };
  83849. /**
  83850. * Return the total number of indices
  83851. * @returns the total number of indices
  83852. */
  83853. Geometry.prototype.getTotalIndices = function () {
  83854. if (!this.isReady()) {
  83855. return 0;
  83856. }
  83857. return this._indices.length;
  83858. };
  83859. /**
  83860. * Gets the index buffer array
  83861. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  83862. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83863. * @returns the index buffer array
  83864. */
  83865. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  83866. if (!this.isReady()) {
  83867. return null;
  83868. }
  83869. var orig = this._indices;
  83870. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  83871. return orig;
  83872. }
  83873. else {
  83874. var len = orig.length;
  83875. var copy = [];
  83876. for (var i = 0; i < len; i++) {
  83877. copy.push(orig[i]);
  83878. }
  83879. return copy;
  83880. }
  83881. };
  83882. /**
  83883. * Gets the index buffer
  83884. * @return the index buffer
  83885. */
  83886. Geometry.prototype.getIndexBuffer = function () {
  83887. if (!this.isReady()) {
  83888. return null;
  83889. }
  83890. return this._indexBuffer;
  83891. };
  83892. /** @hidden */
  83893. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  83894. if (effect === void 0) { effect = null; }
  83895. if (!effect || !this._vertexArrayObjects) {
  83896. return;
  83897. }
  83898. if (this._vertexArrayObjects[effect.key]) {
  83899. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  83900. delete this._vertexArrayObjects[effect.key];
  83901. }
  83902. };
  83903. /**
  83904. * Release the associated resources for a specific mesh
  83905. * @param mesh defines the source mesh
  83906. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  83907. */
  83908. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  83909. var meshes = this._meshes;
  83910. var index = meshes.indexOf(mesh);
  83911. if (index === -1) {
  83912. return;
  83913. }
  83914. meshes.splice(index, 1);
  83915. mesh._geometry = null;
  83916. if (meshes.length === 0 && shouldDispose) {
  83917. this.dispose();
  83918. }
  83919. };
  83920. /**
  83921. * Apply current geometry to a given mesh
  83922. * @param mesh defines the mesh to apply geometry to
  83923. */
  83924. Geometry.prototype.applyToMesh = function (mesh) {
  83925. if (mesh._geometry === this) {
  83926. return;
  83927. }
  83928. var previousGeometry = mesh._geometry;
  83929. if (previousGeometry) {
  83930. previousGeometry.releaseForMesh(mesh);
  83931. }
  83932. var meshes = this._meshes;
  83933. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  83934. mesh._geometry = this;
  83935. this._scene.pushGeometry(this);
  83936. meshes.push(mesh);
  83937. if (this.isReady()) {
  83938. this._applyToMesh(mesh);
  83939. }
  83940. else {
  83941. mesh._boundingInfo = this._boundingInfo;
  83942. }
  83943. };
  83944. Geometry.prototype._updateExtend = function (data) {
  83945. if (data === void 0) { data = null; }
  83946. if (!data) {
  83947. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  83948. }
  83949. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  83950. };
  83951. Geometry.prototype._applyToMesh = function (mesh) {
  83952. var numOfMeshes = this._meshes.length;
  83953. // vertexBuffers
  83954. for (var kind in this._vertexBuffers) {
  83955. if (numOfMeshes === 1) {
  83956. this._vertexBuffers[kind].create();
  83957. }
  83958. var buffer = this._vertexBuffers[kind].getBuffer();
  83959. if (buffer) {
  83960. buffer.references = numOfMeshes;
  83961. }
  83962. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  83963. if (!this._extend) {
  83964. this._updateExtend();
  83965. }
  83966. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  83967. mesh._createGlobalSubMesh(false);
  83968. //bounding info was just created again, world matrix should be applied again.
  83969. mesh._updateBoundingInfo();
  83970. }
  83971. }
  83972. // indexBuffer
  83973. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  83974. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  83975. }
  83976. if (this._indexBuffer) {
  83977. this._indexBuffer.references = numOfMeshes;
  83978. }
  83979. // morphTargets
  83980. mesh._syncGeometryWithMorphTargetManager();
  83981. // instances
  83982. mesh.synchronizeInstances();
  83983. };
  83984. Geometry.prototype.notifyUpdate = function (kind) {
  83985. if (this.onGeometryUpdated) {
  83986. this.onGeometryUpdated(this, kind);
  83987. }
  83988. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  83989. var mesh = _a[_i];
  83990. mesh._markSubMeshesAsAttributesDirty();
  83991. }
  83992. };
  83993. /**
  83994. * Load the geometry if it was flagged as delay loaded
  83995. * @param scene defines the hosting scene
  83996. * @param onLoaded defines a callback called when the geometry is loaded
  83997. */
  83998. Geometry.prototype.load = function (scene, onLoaded) {
  83999. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  84000. return;
  84001. }
  84002. if (this.isReady()) {
  84003. if (onLoaded) {
  84004. onLoaded();
  84005. }
  84006. return;
  84007. }
  84008. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  84009. this._queueLoad(scene, onLoaded);
  84010. };
  84011. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  84012. var _this = this;
  84013. if (!this.delayLoadingFile) {
  84014. return;
  84015. }
  84016. scene._addPendingData(this);
  84017. scene._loadFile(this.delayLoadingFile, function (data) {
  84018. if (!_this._delayLoadingFunction) {
  84019. return;
  84020. }
  84021. _this._delayLoadingFunction(JSON.parse(data), _this);
  84022. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  84023. _this._delayInfo = [];
  84024. scene._removePendingData(_this);
  84025. var meshes = _this._meshes;
  84026. var numOfMeshes = meshes.length;
  84027. for (var index = 0; index < numOfMeshes; index++) {
  84028. _this._applyToMesh(meshes[index]);
  84029. }
  84030. if (onLoaded) {
  84031. onLoaded();
  84032. }
  84033. }, undefined, true);
  84034. };
  84035. /**
  84036. * Invert the geometry to move from a right handed system to a left handed one.
  84037. */
  84038. Geometry.prototype.toLeftHanded = function () {
  84039. // Flip faces
  84040. var tIndices = this.getIndices(false);
  84041. if (tIndices != null && tIndices.length > 0) {
  84042. for (var i = 0; i < tIndices.length; i += 3) {
  84043. var tTemp = tIndices[i + 0];
  84044. tIndices[i + 0] = tIndices[i + 2];
  84045. tIndices[i + 2] = tTemp;
  84046. }
  84047. this.setIndices(tIndices);
  84048. }
  84049. // Negate position.z
  84050. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  84051. if (tPositions != null && tPositions.length > 0) {
  84052. for (var i = 0; i < tPositions.length; i += 3) {
  84053. tPositions[i + 2] = -tPositions[i + 2];
  84054. }
  84055. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  84056. }
  84057. // Negate normal.z
  84058. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  84059. if (tNormals != null && tNormals.length > 0) {
  84060. for (var i = 0; i < tNormals.length; i += 3) {
  84061. tNormals[i + 2] = -tNormals[i + 2];
  84062. }
  84063. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  84064. }
  84065. };
  84066. // Cache
  84067. /** @hidden */
  84068. Geometry.prototype._resetPointsArrayCache = function () {
  84069. this._positions = null;
  84070. };
  84071. /** @hidden */
  84072. Geometry.prototype._generatePointsArray = function () {
  84073. if (this._positions) {
  84074. return true;
  84075. }
  84076. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  84077. if (!data || data.length === 0) {
  84078. return false;
  84079. }
  84080. this._positions = [];
  84081. for (var index = 0; index < data.length; index += 3) {
  84082. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  84083. }
  84084. return true;
  84085. };
  84086. /**
  84087. * Gets a value indicating if the geometry is disposed
  84088. * @returns true if the geometry was disposed
  84089. */
  84090. Geometry.prototype.isDisposed = function () {
  84091. return this._isDisposed;
  84092. };
  84093. Geometry.prototype._disposeVertexArrayObjects = function () {
  84094. if (this._vertexArrayObjects) {
  84095. for (var kind in this._vertexArrayObjects) {
  84096. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  84097. }
  84098. this._vertexArrayObjects = {};
  84099. }
  84100. };
  84101. /**
  84102. * Free all associated resources
  84103. */
  84104. Geometry.prototype.dispose = function () {
  84105. var meshes = this._meshes;
  84106. var numOfMeshes = meshes.length;
  84107. var index;
  84108. for (index = 0; index < numOfMeshes; index++) {
  84109. this.releaseForMesh(meshes[index]);
  84110. }
  84111. this._meshes = [];
  84112. this._disposeVertexArrayObjects();
  84113. for (var kind in this._vertexBuffers) {
  84114. this._vertexBuffers[kind].dispose();
  84115. }
  84116. this._vertexBuffers = {};
  84117. this._totalVertices = 0;
  84118. if (this._indexBuffer) {
  84119. this._engine._releaseBuffer(this._indexBuffer);
  84120. }
  84121. this._indexBuffer = null;
  84122. this._indices = [];
  84123. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  84124. this.delayLoadingFile = null;
  84125. this._delayLoadingFunction = null;
  84126. this._delayInfo = [];
  84127. this._boundingInfo = null;
  84128. this._scene.removeGeometry(this);
  84129. this._isDisposed = true;
  84130. };
  84131. /**
  84132. * Clone the current geometry into a new geometry
  84133. * @param id defines the unique ID of the new geometry
  84134. * @returns a new geometry object
  84135. */
  84136. Geometry.prototype.copy = function (id) {
  84137. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  84138. vertexData.indices = [];
  84139. var indices = this.getIndices();
  84140. if (indices) {
  84141. for (var index = 0; index < indices.length; index++) {
  84142. vertexData.indices.push(indices[index]);
  84143. }
  84144. }
  84145. var updatable = false;
  84146. var stopChecking = false;
  84147. var kind;
  84148. for (kind in this._vertexBuffers) {
  84149. // using slice() to make a copy of the array and not just reference it
  84150. var data = this.getVerticesData(kind);
  84151. if (data) {
  84152. if (data instanceof Float32Array) {
  84153. vertexData.set(new Float32Array(data), kind);
  84154. }
  84155. else {
  84156. vertexData.set(data.slice(0), kind);
  84157. }
  84158. if (!stopChecking) {
  84159. var vb = this.getVertexBuffer(kind);
  84160. if (vb) {
  84161. updatable = vb.isUpdatable();
  84162. stopChecking = !updatable;
  84163. }
  84164. }
  84165. }
  84166. }
  84167. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  84168. geometry.delayLoadState = this.delayLoadState;
  84169. geometry.delayLoadingFile = this.delayLoadingFile;
  84170. geometry._delayLoadingFunction = this._delayLoadingFunction;
  84171. for (kind in this._delayInfo) {
  84172. geometry._delayInfo = geometry._delayInfo || [];
  84173. geometry._delayInfo.push(kind);
  84174. }
  84175. // Bounding info
  84176. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84177. return geometry;
  84178. };
  84179. /**
  84180. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84181. * @return a JSON representation of the current geometry data (without the vertices data)
  84182. */
  84183. Geometry.prototype.serialize = function () {
  84184. var serializationObject = {};
  84185. serializationObject.id = this.id;
  84186. serializationObject.updatable = this._updatable;
  84187. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  84188. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  84189. }
  84190. return serializationObject;
  84191. };
  84192. Geometry.prototype.toNumberArray = function (origin) {
  84193. if (Array.isArray(origin)) {
  84194. return origin;
  84195. }
  84196. else {
  84197. return Array.prototype.slice.call(origin);
  84198. }
  84199. };
  84200. /**
  84201. * Serialize all vertices data into a JSON oject
  84202. * @returns a JSON representation of the current geometry data
  84203. */
  84204. Geometry.prototype.serializeVerticeData = function () {
  84205. var serializationObject = this.serialize();
  84206. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  84207. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  84208. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  84209. serializationObject.positions._updatable = true;
  84210. }
  84211. }
  84212. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  84213. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  84214. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  84215. serializationObject.normals._updatable = true;
  84216. }
  84217. }
  84218. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  84219. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  84220. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  84221. serializationObject.tangets._updatable = true;
  84222. }
  84223. }
  84224. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  84225. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  84226. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  84227. serializationObject.uvs._updatable = true;
  84228. }
  84229. }
  84230. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  84231. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  84232. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  84233. serializationObject.uv2s._updatable = true;
  84234. }
  84235. }
  84236. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  84237. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  84238. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  84239. serializationObject.uv3s._updatable = true;
  84240. }
  84241. }
  84242. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  84243. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  84244. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  84245. serializationObject.uv4s._updatable = true;
  84246. }
  84247. }
  84248. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  84249. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  84250. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  84251. serializationObject.uv5s._updatable = true;
  84252. }
  84253. }
  84254. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  84255. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  84256. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  84257. serializationObject.uv6s._updatable = true;
  84258. }
  84259. }
  84260. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  84261. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  84262. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  84263. serializationObject.colors._updatable = true;
  84264. }
  84265. }
  84266. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  84267. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  84268. serializationObject.matricesIndices._isExpanded = true;
  84269. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  84270. serializationObject.matricesIndices._updatable = true;
  84271. }
  84272. }
  84273. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  84274. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  84275. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  84276. serializationObject.matricesWeights._updatable = true;
  84277. }
  84278. }
  84279. serializationObject.indices = this.toNumberArray(this.getIndices());
  84280. return serializationObject;
  84281. };
  84282. // Statics
  84283. /**
  84284. * Extracts a clone of a mesh geometry
  84285. * @param mesh defines the source mesh
  84286. * @param id defines the unique ID of the new geometry object
  84287. * @returns the new geometry object
  84288. */
  84289. Geometry.ExtractFromMesh = function (mesh, id) {
  84290. var geometry = mesh._geometry;
  84291. if (!geometry) {
  84292. return null;
  84293. }
  84294. return geometry.copy(id);
  84295. };
  84296. /**
  84297. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84298. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84299. * Be aware Math.random() could cause collisions, but:
  84300. * "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"
  84301. * @returns a string containing a new GUID
  84302. */
  84303. Geometry.RandomId = function () {
  84304. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  84305. };
  84306. /** @hidden */
  84307. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  84308. var scene = mesh.getScene();
  84309. // Geometry
  84310. var geometryId = parsedGeometry.geometryId;
  84311. if (geometryId) {
  84312. var geometry = scene.getGeometryByID(geometryId);
  84313. if (geometry) {
  84314. geometry.applyToMesh(mesh);
  84315. }
  84316. }
  84317. else if (parsedGeometry instanceof ArrayBuffer) {
  84318. var binaryInfo = mesh._binaryInfo;
  84319. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  84320. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  84321. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  84322. }
  84323. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  84324. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  84325. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  84326. }
  84327. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  84328. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  84329. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  84330. }
  84331. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  84332. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  84333. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  84334. }
  84335. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  84336. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  84337. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  84338. }
  84339. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  84340. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  84341. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  84342. }
  84343. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  84344. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  84345. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  84346. }
  84347. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  84348. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  84349. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  84350. }
  84351. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  84352. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  84353. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  84354. }
  84355. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  84356. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  84357. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  84358. }
  84359. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  84360. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  84361. var floatIndices = [];
  84362. for (var i = 0; i < matricesIndicesData.length; i++) {
  84363. var index = matricesIndicesData[i];
  84364. floatIndices.push(index & 0x000000FF);
  84365. floatIndices.push((index & 0x0000FF00) >> 8);
  84366. floatIndices.push((index & 0x00FF0000) >> 16);
  84367. floatIndices.push(index >> 24);
  84368. }
  84369. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  84370. }
  84371. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  84372. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  84373. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  84374. }
  84375. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  84376. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  84377. mesh.setIndices(indicesData, null);
  84378. }
  84379. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  84380. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  84381. mesh.subMeshes = [];
  84382. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  84383. var materialIndex = subMeshesData[(i * 5) + 0];
  84384. var verticesStart = subMeshesData[(i * 5) + 1];
  84385. var verticesCount = subMeshesData[(i * 5) + 2];
  84386. var indexStart = subMeshesData[(i * 5) + 3];
  84387. var indexCount = subMeshesData[(i * 5) + 4];
  84388. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  84389. }
  84390. }
  84391. }
  84392. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  84393. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  84394. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  84395. if (parsedGeometry.tangents) {
  84396. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  84397. }
  84398. if (parsedGeometry.uvs) {
  84399. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  84400. }
  84401. if (parsedGeometry.uvs2) {
  84402. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  84403. }
  84404. if (parsedGeometry.uvs3) {
  84405. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  84406. }
  84407. if (parsedGeometry.uvs4) {
  84408. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  84409. }
  84410. if (parsedGeometry.uvs5) {
  84411. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  84412. }
  84413. if (parsedGeometry.uvs6) {
  84414. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  84415. }
  84416. if (parsedGeometry.colors) {
  84417. 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);
  84418. }
  84419. if (parsedGeometry.matricesIndices) {
  84420. if (!parsedGeometry.matricesIndices._isExpanded) {
  84421. var floatIndices = [];
  84422. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  84423. var matricesIndex = parsedGeometry.matricesIndices[i];
  84424. floatIndices.push(matricesIndex & 0x000000FF);
  84425. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  84426. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  84427. floatIndices.push(matricesIndex >> 24);
  84428. }
  84429. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  84430. }
  84431. else {
  84432. delete parsedGeometry.matricesIndices._isExpanded;
  84433. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  84434. }
  84435. }
  84436. if (parsedGeometry.matricesIndicesExtra) {
  84437. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  84438. var floatIndices = [];
  84439. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  84440. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  84441. floatIndices.push(matricesIndex & 0x000000FF);
  84442. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  84443. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  84444. floatIndices.push(matricesIndex >> 24);
  84445. }
  84446. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  84447. }
  84448. else {
  84449. delete parsedGeometry.matricesIndices._isExpanded;
  84450. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  84451. }
  84452. }
  84453. if (parsedGeometry.matricesWeights) {
  84454. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  84455. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  84456. }
  84457. if (parsedGeometry.matricesWeightsExtra) {
  84458. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  84459. }
  84460. mesh.setIndices(parsedGeometry.indices, null);
  84461. }
  84462. // SubMeshes
  84463. if (parsedGeometry.subMeshes) {
  84464. mesh.subMeshes = [];
  84465. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  84466. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  84467. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  84468. }
  84469. }
  84470. // Flat shading
  84471. if (mesh._shouldGenerateFlatShading) {
  84472. mesh.convertToFlatShadedMesh();
  84473. delete mesh._shouldGenerateFlatShading;
  84474. }
  84475. // Update
  84476. mesh.computeWorldMatrix(true);
  84477. scene.onMeshImportedObservable.notifyObservers(mesh);
  84478. };
  84479. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  84480. var epsilon = 1e-3;
  84481. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  84482. return;
  84483. }
  84484. var noInfluenceBoneIndex = 0.0;
  84485. if (parsedGeometry.skeletonId > -1) {
  84486. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  84487. if (!skeleton) {
  84488. return;
  84489. }
  84490. noInfluenceBoneIndex = skeleton.bones.length;
  84491. }
  84492. else {
  84493. return;
  84494. }
  84495. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  84496. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  84497. var matricesWeights = parsedGeometry.matricesWeights;
  84498. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  84499. var influencers = parsedGeometry.numBoneInfluencer;
  84500. var size = matricesWeights.length;
  84501. for (var i = 0; i < size; i += 4) {
  84502. var weight = 0.0;
  84503. var firstZeroWeight = -1;
  84504. for (var j = 0; j < 4; j++) {
  84505. var w = matricesWeights[i + j];
  84506. weight += w;
  84507. if (w < epsilon && firstZeroWeight < 0) {
  84508. firstZeroWeight = j;
  84509. }
  84510. }
  84511. if (matricesWeightsExtra) {
  84512. for (var j = 0; j < 4; j++) {
  84513. var w = matricesWeightsExtra[i + j];
  84514. weight += w;
  84515. if (w < epsilon && firstZeroWeight < 0) {
  84516. firstZeroWeight = j + 4;
  84517. }
  84518. }
  84519. }
  84520. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  84521. firstZeroWeight = influencers - 1;
  84522. }
  84523. if (weight > epsilon) {
  84524. var mweight = 1.0 / weight;
  84525. for (var j = 0; j < 4; j++) {
  84526. matricesWeights[i + j] *= mweight;
  84527. }
  84528. if (matricesWeightsExtra) {
  84529. for (var j = 0; j < 4; j++) {
  84530. matricesWeightsExtra[i + j] *= mweight;
  84531. }
  84532. }
  84533. }
  84534. else {
  84535. if (firstZeroWeight >= 4) {
  84536. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  84537. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  84538. }
  84539. else {
  84540. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  84541. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  84542. }
  84543. }
  84544. }
  84545. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  84546. if (parsedGeometry.matricesWeightsExtra) {
  84547. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  84548. }
  84549. };
  84550. /**
  84551. * Create a new geometry from persisted data (Using .babylon file format)
  84552. * @param parsedVertexData defines the persisted data
  84553. * @param scene defines the hosting scene
  84554. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84555. * @returns the new geometry object
  84556. */
  84557. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  84558. if (scene.getGeometryByID(parsedVertexData.id)) {
  84559. return null; // null since geometry could be something else than a box...
  84560. }
  84561. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  84562. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  84563. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  84564. }
  84565. if (parsedVertexData.delayLoadingFile) {
  84566. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  84567. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  84568. 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));
  84569. geometry._delayInfo = [];
  84570. if (parsedVertexData.hasUVs) {
  84571. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  84572. }
  84573. if (parsedVertexData.hasUVs2) {
  84574. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  84575. }
  84576. if (parsedVertexData.hasUVs3) {
  84577. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  84578. }
  84579. if (parsedVertexData.hasUVs4) {
  84580. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  84581. }
  84582. if (parsedVertexData.hasUVs5) {
  84583. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  84584. }
  84585. if (parsedVertexData.hasUVs6) {
  84586. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  84587. }
  84588. if (parsedVertexData.hasColors) {
  84589. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  84590. }
  84591. if (parsedVertexData.hasMatricesIndices) {
  84592. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  84593. }
  84594. if (parsedVertexData.hasMatricesWeights) {
  84595. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  84596. }
  84597. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  84598. }
  84599. else {
  84600. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  84601. }
  84602. scene.pushGeometry(geometry, true);
  84603. return geometry;
  84604. };
  84605. return Geometry;
  84606. }());
  84607. /***/ }),
  84608. /***/ "./Meshes/groundMesh.ts":
  84609. /*!******************************!*\
  84610. !*** ./Meshes/groundMesh.ts ***!
  84611. \******************************/
  84612. /*! exports provided: GroundMesh */
  84613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84614. "use strict";
  84615. __webpack_require__.r(__webpack_exports__);
  84616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  84617. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  84618. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  84619. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  84620. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  84621. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  84622. return GroundMesh.Parse(parsedMesh, scene);
  84623. };
  84624. /**
  84625. * Mesh representing the gorund
  84626. */
  84627. var GroundMesh = /** @class */ (function (_super) {
  84628. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  84629. function GroundMesh(name, scene) {
  84630. var _this = _super.call(this, name, scene) || this;
  84631. /** If octree should be generated */
  84632. _this.generateOctree = false;
  84633. return _this;
  84634. }
  84635. /**
  84636. * "GroundMesh"
  84637. * @returns "GroundMesh"
  84638. */
  84639. GroundMesh.prototype.getClassName = function () {
  84640. return "GroundMesh";
  84641. };
  84642. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  84643. /**
  84644. * The minimum of x and y subdivisions
  84645. */
  84646. get: function () {
  84647. return Math.min(this._subdivisionsX, this._subdivisionsY);
  84648. },
  84649. enumerable: true,
  84650. configurable: true
  84651. });
  84652. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  84653. /**
  84654. * X subdivisions
  84655. */
  84656. get: function () {
  84657. return this._subdivisionsX;
  84658. },
  84659. enumerable: true,
  84660. configurable: true
  84661. });
  84662. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  84663. /**
  84664. * Y subdivisions
  84665. */
  84666. get: function () {
  84667. return this._subdivisionsY;
  84668. },
  84669. enumerable: true,
  84670. configurable: true
  84671. });
  84672. /**
  84673. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  84674. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  84675. * @param chunksCount the number of subdivisions for x and y
  84676. * @param octreeBlocksSize (Default: 32)
  84677. */
  84678. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  84679. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  84680. this._subdivisionsX = chunksCount;
  84681. this._subdivisionsY = chunksCount;
  84682. this.subdivide(chunksCount);
  84683. // Call the octree system optimization if it is defined.
  84684. var thisAsAny = this;
  84685. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  84686. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  84687. }
  84688. };
  84689. /**
  84690. * Returns a height (y) value in the Worl system :
  84691. * the ground altitude at the coordinates (x, z) expressed in the World system.
  84692. * @param x x coordinate
  84693. * @param z z coordinate
  84694. * @returns the ground y position if (x, z) are outside the ground surface.
  84695. */
  84696. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  84697. var world = this.getWorldMatrix();
  84698. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  84699. world.invertToRef(invMat);
  84700. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  84701. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  84702. x = tmpVect.x;
  84703. z = tmpVect.z;
  84704. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  84705. return this.position.y;
  84706. }
  84707. if (!this._heightQuads || this._heightQuads.length == 0) {
  84708. this._initHeightQuads();
  84709. this._computeHeightQuads();
  84710. }
  84711. var facet = this._getFacetAt(x, z);
  84712. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  84713. // return y in the World system
  84714. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  84715. return tmpVect.y;
  84716. };
  84717. /**
  84718. * Returns a normalized vector (Vector3) orthogonal to the ground
  84719. * at the ground coordinates (x, z) expressed in the World system.
  84720. * @param x x coordinate
  84721. * @param z z coordinate
  84722. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  84723. */
  84724. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  84725. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  84726. this.getNormalAtCoordinatesToRef(x, z, normal);
  84727. return normal;
  84728. };
  84729. /**
  84730. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  84731. * at the ground coordinates (x, z) expressed in the World system.
  84732. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  84733. * @param x x coordinate
  84734. * @param z z coordinate
  84735. * @param ref vector to store the result
  84736. * @returns the GroundMesh.
  84737. */
  84738. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  84739. var world = this.getWorldMatrix();
  84740. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  84741. world.invertToRef(tmpMat);
  84742. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  84743. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  84744. x = tmpVect.x;
  84745. z = tmpVect.z;
  84746. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  84747. return this;
  84748. }
  84749. if (!this._heightQuads || this._heightQuads.length == 0) {
  84750. this._initHeightQuads();
  84751. this._computeHeightQuads();
  84752. }
  84753. var facet = this._getFacetAt(x, z);
  84754. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  84755. return this;
  84756. };
  84757. /**
  84758. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  84759. * if the ground has been updated.
  84760. * This can be used in the render loop.
  84761. * @returns the GroundMesh.
  84762. */
  84763. GroundMesh.prototype.updateCoordinateHeights = function () {
  84764. if (!this._heightQuads || this._heightQuads.length == 0) {
  84765. this._initHeightQuads();
  84766. }
  84767. this._computeHeightQuads();
  84768. return this;
  84769. };
  84770. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  84771. GroundMesh.prototype._getFacetAt = function (x, z) {
  84772. // retrieve col and row from x, z coordinates in the ground local system
  84773. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  84774. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  84775. var quad = this._heightQuads[row * this._subdivisionsX + col];
  84776. var facet;
  84777. if (z < quad.slope.x * x + quad.slope.y) {
  84778. facet = quad.facet1;
  84779. }
  84780. else {
  84781. facet = quad.facet2;
  84782. }
  84783. return facet;
  84784. };
  84785. // Creates and populates the heightMap array with "facet" elements :
  84786. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  84787. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  84788. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  84789. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  84790. // Returns the GroundMesh.
  84791. GroundMesh.prototype._initHeightQuads = function () {
  84792. var subdivisionsX = this._subdivisionsX;
  84793. var subdivisionsY = this._subdivisionsY;
  84794. this._heightQuads = new Array();
  84795. for (var row = 0; row < subdivisionsY; row++) {
  84796. for (var col = 0; col < subdivisionsX; col++) {
  84797. 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) };
  84798. this._heightQuads[row * subdivisionsX + col] = quad;
  84799. }
  84800. }
  84801. return this;
  84802. };
  84803. // Compute each quad element values and update the the heightMap array :
  84804. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  84805. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  84806. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  84807. // Returns the GroundMesh.
  84808. GroundMesh.prototype._computeHeightQuads = function () {
  84809. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  84810. if (!positions) {
  84811. return this;
  84812. }
  84813. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  84814. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  84815. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  84816. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  84817. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  84818. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  84819. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  84820. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  84821. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  84822. var i = 0;
  84823. var j = 0;
  84824. var k = 0;
  84825. var cd = 0; // 2D slope coefficient : z = cd * x + h
  84826. var h = 0;
  84827. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  84828. var d2 = 0;
  84829. var subdivisionsX = this._subdivisionsX;
  84830. var subdivisionsY = this._subdivisionsY;
  84831. for (var row = 0; row < subdivisionsY; row++) {
  84832. for (var col = 0; col < subdivisionsX; col++) {
  84833. i = col * 3;
  84834. j = row * (subdivisionsX + 1) * 3;
  84835. k = (row + 1) * (subdivisionsX + 1) * 3;
  84836. v1.x = positions[j + i];
  84837. v1.y = positions[j + i + 1];
  84838. v1.z = positions[j + i + 2];
  84839. v2.x = positions[j + i + 3];
  84840. v2.y = positions[j + i + 4];
  84841. v2.z = positions[j + i + 5];
  84842. v3.x = positions[k + i];
  84843. v3.y = positions[k + i + 1];
  84844. v3.z = positions[k + i + 2];
  84845. v4.x = positions[k + i + 3];
  84846. v4.y = positions[k + i + 4];
  84847. v4.z = positions[k + i + 5];
  84848. // 2D slope V1V4
  84849. cd = (v4.z - v1.z) / (v4.x - v1.x);
  84850. h = v1.z - cd * v1.x; // v1 belongs to the slope
  84851. // facet equations :
  84852. // we compute each facet normal vector
  84853. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  84854. // we compute the value d by applying the equation to v1 which belongs to the plane
  84855. // then we store the facet equation in a Vector4
  84856. v2.subtractToRef(v1, v1v2);
  84857. v3.subtractToRef(v1, v1v3);
  84858. v4.subtractToRef(v1, v1v4);
  84859. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  84860. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  84861. norm1.normalize();
  84862. norm2.normalize();
  84863. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  84864. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  84865. var quad = this._heightQuads[row * subdivisionsX + col];
  84866. quad.slope.copyFromFloats(cd, h);
  84867. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  84868. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  84869. }
  84870. }
  84871. return this;
  84872. };
  84873. /**
  84874. * Serializes this ground mesh
  84875. * @param serializationObject object to write serialization to
  84876. */
  84877. GroundMesh.prototype.serialize = function (serializationObject) {
  84878. _super.prototype.serialize.call(this, serializationObject);
  84879. serializationObject.subdivisionsX = this._subdivisionsX;
  84880. serializationObject.subdivisionsY = this._subdivisionsY;
  84881. serializationObject.minX = this._minX;
  84882. serializationObject.maxX = this._maxX;
  84883. serializationObject.minZ = this._minZ;
  84884. serializationObject.maxZ = this._maxZ;
  84885. serializationObject.width = this._width;
  84886. serializationObject.height = this._height;
  84887. };
  84888. /**
  84889. * Parses a serialized ground mesh
  84890. * @param parsedMesh the serialized mesh
  84891. * @param scene the scene to create the ground mesh in
  84892. * @returns the created ground mesh
  84893. */
  84894. GroundMesh.Parse = function (parsedMesh, scene) {
  84895. var result = new GroundMesh(parsedMesh.name, scene);
  84896. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  84897. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  84898. result._minX = parsedMesh.minX;
  84899. result._maxX = parsedMesh.maxX;
  84900. result._minZ = parsedMesh.minZ;
  84901. result._maxZ = parsedMesh.maxZ;
  84902. result._width = parsedMesh.width;
  84903. result._height = parsedMesh.height;
  84904. return result;
  84905. };
  84906. return GroundMesh;
  84907. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  84908. /***/ }),
  84909. /***/ "./Meshes/index.ts":
  84910. /*!*************************!*\
  84911. !*** ./Meshes/index.ts ***!
  84912. \*************************/
  84913. /*! 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 */
  84914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84915. "use strict";
  84916. __webpack_require__.r(__webpack_exports__);
  84917. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  84918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  84919. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  84920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  84921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  84922. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  84923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  84924. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  84925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  84926. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  84927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  84928. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  84929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  84930. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  84931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  84932. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  84933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  84934. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  84935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  84936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  84937. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  84938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["MeshLODLevel"]; });
  84939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  84940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  84941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  84942. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  84943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  84944. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  84945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  84946. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  84947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  84948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  84949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  84950. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  84951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  84952. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  84953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  84954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  84955. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  84956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  84957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  84958. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  84959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_16__["TransformNode"]; });
  84960. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  84961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["BoxBuilder"]; });
  84962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["SphereBuilder"]; });
  84963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["CylinderBuilder"]; });
  84964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LinesBuilder"]; });
  84965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PlaneBuilder"]; });
  84966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DiscBuilder"]; });
  84967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["RibbonBuilder"]; });
  84968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusBuilder"]; });
  84969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusKnotBuilder"]; });
  84970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolygonBuilder"]; });
  84971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["ShapeBuilder"]; });
  84972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LatheBuilder"]; });
  84973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["GroundBuilder"]; });
  84974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TubeBuilder"]; });
  84975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  84976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"]; });
  84977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  84978. /***/ }),
  84979. /***/ "./Meshes/instancedMesh.ts":
  84980. /*!*********************************!*\
  84981. !*** ./Meshes/instancedMesh.ts ***!
  84982. \*********************************/
  84983. /*! exports provided: InstancedMesh */
  84984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84985. "use strict";
  84986. __webpack_require__.r(__webpack_exports__);
  84987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  84988. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  84989. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  84990. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  84991. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  84992. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  84993. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  84994. return new InstancedMesh(name, mesh);
  84995. };
  84996. /**
  84997. * Creates an instance based on a source mesh.
  84998. */
  84999. var InstancedMesh = /** @class */ (function (_super) {
  85000. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  85001. function InstancedMesh(name, source) {
  85002. var _this = _super.call(this, name, source.getScene()) || this;
  85003. /** @hidden */
  85004. _this._indexInSourceMeshInstanceArray = -1;
  85005. source.addInstance(_this);
  85006. _this._sourceMesh = source;
  85007. _this.position.copyFrom(source.position);
  85008. _this.rotation.copyFrom(source.rotation);
  85009. _this.scaling.copyFrom(source.scaling);
  85010. if (source.rotationQuaternion) {
  85011. _this.rotationQuaternion = source.rotationQuaternion.clone();
  85012. }
  85013. _this.infiniteDistance = source.infiniteDistance;
  85014. _this.setPivotMatrix(source.getPivotMatrix());
  85015. _this.refreshBoundingInfo();
  85016. _this._syncSubMeshes();
  85017. return _this;
  85018. }
  85019. /**
  85020. * Returns the string "InstancedMesh".
  85021. */
  85022. InstancedMesh.prototype.getClassName = function () {
  85023. return "InstancedMesh";
  85024. };
  85025. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  85026. // Methods
  85027. /**
  85028. * If the source mesh receives shadows
  85029. */
  85030. get: function () {
  85031. return this._sourceMesh.receiveShadows;
  85032. },
  85033. enumerable: true,
  85034. configurable: true
  85035. });
  85036. Object.defineProperty(InstancedMesh.prototype, "material", {
  85037. /**
  85038. * The material of the source mesh
  85039. */
  85040. get: function () {
  85041. return this._sourceMesh.material;
  85042. },
  85043. enumerable: true,
  85044. configurable: true
  85045. });
  85046. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  85047. /**
  85048. * Visibility of the source mesh
  85049. */
  85050. get: function () {
  85051. return this._sourceMesh.visibility;
  85052. },
  85053. enumerable: true,
  85054. configurable: true
  85055. });
  85056. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  85057. /**
  85058. * Skeleton of the source mesh
  85059. */
  85060. get: function () {
  85061. return this._sourceMesh.skeleton;
  85062. },
  85063. enumerable: true,
  85064. configurable: true
  85065. });
  85066. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  85067. /**
  85068. * Rendering ground id of the source mesh
  85069. */
  85070. get: function () {
  85071. return this._sourceMesh.renderingGroupId;
  85072. },
  85073. set: function (value) {
  85074. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  85075. return;
  85076. }
  85077. //no-op with warning
  85078. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  85079. },
  85080. enumerable: true,
  85081. configurable: true
  85082. });
  85083. /**
  85084. * Returns the total number of vertices (integer).
  85085. */
  85086. InstancedMesh.prototype.getTotalVertices = function () {
  85087. return this._sourceMesh.getTotalVertices();
  85088. };
  85089. /**
  85090. * Returns a positive integer : the total number of indices in this mesh geometry.
  85091. * @returns the numner of indices or zero if the mesh has no geometry.
  85092. */
  85093. InstancedMesh.prototype.getTotalIndices = function () {
  85094. return this._sourceMesh.getTotalIndices();
  85095. };
  85096. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  85097. /**
  85098. * The source mesh of the instance
  85099. */
  85100. get: function () {
  85101. return this._sourceMesh;
  85102. },
  85103. enumerable: true,
  85104. configurable: true
  85105. });
  85106. /**
  85107. * Is this node ready to be used/rendered
  85108. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85109. * @return {boolean} is it ready
  85110. */
  85111. InstancedMesh.prototype.isReady = function (completeCheck) {
  85112. if (completeCheck === void 0) { completeCheck = false; }
  85113. return this._sourceMesh.isReady(completeCheck, true);
  85114. };
  85115. /**
  85116. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85117. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85118. * @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.
  85119. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85120. */
  85121. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  85122. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  85123. };
  85124. /**
  85125. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85126. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85127. * The `data` are either a numeric array either a Float32Array.
  85128. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85129. * 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).
  85130. * Note that a new underlying VertexBuffer object is created each call.
  85131. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85132. *
  85133. * Possible `kind` values :
  85134. * - VertexBuffer.PositionKind
  85135. * - VertexBuffer.UVKind
  85136. * - VertexBuffer.UV2Kind
  85137. * - VertexBuffer.UV3Kind
  85138. * - VertexBuffer.UV4Kind
  85139. * - VertexBuffer.UV5Kind
  85140. * - VertexBuffer.UV6Kind
  85141. * - VertexBuffer.ColorKind
  85142. * - VertexBuffer.MatricesIndicesKind
  85143. * - VertexBuffer.MatricesIndicesExtraKind
  85144. * - VertexBuffer.MatricesWeightsKind
  85145. * - VertexBuffer.MatricesWeightsExtraKind
  85146. *
  85147. * Returns the Mesh.
  85148. */
  85149. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  85150. if (this.sourceMesh) {
  85151. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  85152. }
  85153. return this.sourceMesh;
  85154. };
  85155. /**
  85156. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85157. * If the mesh has no geometry, it is simply returned as it is.
  85158. * The `data` are either a numeric array either a Float32Array.
  85159. * No new underlying VertexBuffer object is created.
  85160. * 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.
  85161. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85162. *
  85163. * Possible `kind` values :
  85164. * - VertexBuffer.PositionKind
  85165. * - VertexBuffer.UVKind
  85166. * - VertexBuffer.UV2Kind
  85167. * - VertexBuffer.UV3Kind
  85168. * - VertexBuffer.UV4Kind
  85169. * - VertexBuffer.UV5Kind
  85170. * - VertexBuffer.UV6Kind
  85171. * - VertexBuffer.ColorKind
  85172. * - VertexBuffer.MatricesIndicesKind
  85173. * - VertexBuffer.MatricesIndicesExtraKind
  85174. * - VertexBuffer.MatricesWeightsKind
  85175. * - VertexBuffer.MatricesWeightsExtraKind
  85176. *
  85177. * Returns the Mesh.
  85178. */
  85179. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  85180. if (this.sourceMesh) {
  85181. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  85182. }
  85183. return this.sourceMesh;
  85184. };
  85185. /**
  85186. * Sets the mesh indices.
  85187. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85188. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85189. * This method creates a new index buffer each call.
  85190. * Returns the Mesh.
  85191. */
  85192. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  85193. if (totalVertices === void 0) { totalVertices = null; }
  85194. if (this.sourceMesh) {
  85195. this.sourceMesh.setIndices(indices, totalVertices);
  85196. }
  85197. return this.sourceMesh;
  85198. };
  85199. /**
  85200. * Boolean : True if the mesh owns the requested kind of data.
  85201. */
  85202. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  85203. return this._sourceMesh.isVerticesDataPresent(kind);
  85204. };
  85205. /**
  85206. * Returns an array of indices (IndicesArray).
  85207. */
  85208. InstancedMesh.prototype.getIndices = function () {
  85209. return this._sourceMesh.getIndices();
  85210. };
  85211. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  85212. get: function () {
  85213. return this._sourceMesh._positions;
  85214. },
  85215. enumerable: true,
  85216. configurable: true
  85217. });
  85218. /**
  85219. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85220. * This means the mesh underlying bounding box and sphere are recomputed.
  85221. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85222. * @returns the current mesh
  85223. */
  85224. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  85225. if (applySkeleton === void 0) { applySkeleton = false; }
  85226. if (this._boundingInfo && this._boundingInfo.isLocked) {
  85227. return this;
  85228. }
  85229. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  85230. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  85231. return this;
  85232. };
  85233. /** @hidden */
  85234. InstancedMesh.prototype._preActivate = function () {
  85235. if (this._currentLOD) {
  85236. this._currentLOD._preActivate();
  85237. }
  85238. return this;
  85239. };
  85240. /** @hidden */
  85241. InstancedMesh.prototype._activate = function (renderId) {
  85242. if (this._currentLOD) {
  85243. this._currentLOD._registerInstanceForRenderId(this, renderId);
  85244. }
  85245. return this;
  85246. };
  85247. /**
  85248. * Returns the current associated LOD AbstractMesh.
  85249. */
  85250. InstancedMesh.prototype.getLOD = function (camera) {
  85251. if (!camera) {
  85252. return this;
  85253. }
  85254. var boundingInfo = this.getBoundingInfo();
  85255. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  85256. if (this._currentLOD === this.sourceMesh) {
  85257. return this;
  85258. }
  85259. return this._currentLOD;
  85260. };
  85261. /** @hidden */
  85262. InstancedMesh.prototype._syncSubMeshes = function () {
  85263. this.releaseSubMeshes();
  85264. if (this._sourceMesh.subMeshes) {
  85265. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  85266. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  85267. }
  85268. }
  85269. return this;
  85270. };
  85271. /** @hidden */
  85272. InstancedMesh.prototype._generatePointsArray = function () {
  85273. return this._sourceMesh._generatePointsArray();
  85274. };
  85275. /**
  85276. * Creates a new InstancedMesh from the current mesh.
  85277. * - name (string) : the cloned mesh name
  85278. * - newParent (optional Node) : the optional Node to parent the clone to.
  85279. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85280. *
  85281. * Returns the clone.
  85282. */
  85283. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  85284. var result = this._sourceMesh.createInstance(name);
  85285. // Deep copy
  85286. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  85287. // Bounding info
  85288. this.refreshBoundingInfo();
  85289. // Parent
  85290. if (newParent) {
  85291. result.parent = newParent;
  85292. }
  85293. if (!doNotCloneChildren) {
  85294. // Children
  85295. for (var index = 0; index < this.getScene().meshes.length; index++) {
  85296. var mesh = this.getScene().meshes[index];
  85297. if (mesh.parent === this) {
  85298. mesh.clone(mesh.name, result);
  85299. }
  85300. }
  85301. }
  85302. result.computeWorldMatrix(true);
  85303. return result;
  85304. };
  85305. /**
  85306. * Disposes the InstancedMesh.
  85307. * Returns nothing.
  85308. */
  85309. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85310. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85311. // Remove from mesh
  85312. this._sourceMesh.removeInstance(this);
  85313. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85314. };
  85315. return InstancedMesh;
  85316. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  85317. /***/ }),
  85318. /***/ "./Meshes/linesMesh.ts":
  85319. /*!*****************************!*\
  85320. !*** ./Meshes/linesMesh.ts ***!
  85321. \*****************************/
  85322. /*! exports provided: LinesMesh, InstancedLinesMesh */
  85323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85324. "use strict";
  85325. __webpack_require__.r(__webpack_exports__);
  85326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  85327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  85328. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85329. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85330. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  85331. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  85332. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  85333. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  85334. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  85335. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  85336. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  85337. /**
  85338. * Line mesh
  85339. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85340. */
  85341. var LinesMesh = /** @class */ (function (_super) {
  85342. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  85343. /**
  85344. * Creates a new LinesMesh
  85345. * @param name defines the name
  85346. * @param scene defines the hosting scene
  85347. * @param parent defines the parent mesh if any
  85348. * @param source defines the optional source LinesMesh used to clone data from
  85349. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85350. * When false, achieved by calling a clone(), also passing False.
  85351. * This will make creation of children, recursive.
  85352. * @param useVertexColor defines if this LinesMesh supports vertex color
  85353. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85354. */
  85355. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  85356. /**
  85357. * If vertex color should be applied to the mesh
  85358. */
  85359. useVertexColor,
  85360. /**
  85361. * If vertex alpha should be applied to the mesh
  85362. */
  85363. useVertexAlpha) {
  85364. if (scene === void 0) { scene = null; }
  85365. if (parent === void 0) { parent = null; }
  85366. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  85367. _this.useVertexColor = useVertexColor;
  85368. _this.useVertexAlpha = useVertexAlpha;
  85369. /**
  85370. * Color of the line (Default: White)
  85371. */
  85372. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  85373. /**
  85374. * Alpha of the line (Default: 1)
  85375. */
  85376. _this.alpha = 1;
  85377. if (source) {
  85378. _this.color = source.color.clone();
  85379. _this.alpha = source.alpha;
  85380. _this.useVertexColor = source.useVertexColor;
  85381. _this.useVertexAlpha = source.useVertexAlpha;
  85382. }
  85383. _this.intersectionThreshold = 0.1;
  85384. var defines = [];
  85385. var options = {
  85386. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  85387. uniforms: ["world", "viewProjection"],
  85388. needAlphaBlending: true,
  85389. defines: defines
  85390. };
  85391. if (useVertexAlpha === false) {
  85392. options.needAlphaBlending = false;
  85393. }
  85394. if (!useVertexColor) {
  85395. options.uniforms.push("color");
  85396. }
  85397. else {
  85398. options.defines.push("#define VERTEXCOLOR");
  85399. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  85400. }
  85401. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  85402. return _this;
  85403. }
  85404. /**
  85405. * Returns the string "LineMesh"
  85406. */
  85407. LinesMesh.prototype.getClassName = function () {
  85408. return "LinesMesh";
  85409. };
  85410. Object.defineProperty(LinesMesh.prototype, "material", {
  85411. /**
  85412. * @hidden
  85413. */
  85414. get: function () {
  85415. return this._colorShader;
  85416. },
  85417. /**
  85418. * @hidden
  85419. */
  85420. set: function (value) {
  85421. // Do nothing
  85422. },
  85423. enumerable: true,
  85424. configurable: true
  85425. });
  85426. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  85427. /**
  85428. * @hidden
  85429. */
  85430. get: function () {
  85431. return false;
  85432. },
  85433. enumerable: true,
  85434. configurable: true
  85435. });
  85436. /** @hidden */
  85437. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  85438. if (!this._geometry) {
  85439. return this;
  85440. }
  85441. // VBOs
  85442. this._geometry._bind(this._colorShader.getEffect());
  85443. // Color
  85444. if (!this.useVertexColor) {
  85445. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  85446. }
  85447. return this;
  85448. };
  85449. /** @hidden */
  85450. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  85451. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  85452. return this;
  85453. }
  85454. var engine = this.getScene().getEngine();
  85455. // Draw order
  85456. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  85457. return this;
  85458. };
  85459. /**
  85460. * Disposes of the line mesh
  85461. * @param doNotRecurse If children should be disposed
  85462. */
  85463. LinesMesh.prototype.dispose = function (doNotRecurse) {
  85464. this._colorShader.dispose(false, false, true);
  85465. _super.prototype.dispose.call(this, doNotRecurse);
  85466. };
  85467. /**
  85468. * Returns a new LineMesh object cloned from the current one.
  85469. */
  85470. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  85471. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  85472. };
  85473. /**
  85474. * Creates a new InstancedLinesMesh object from the mesh model.
  85475. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85476. * @param name defines the name of the new instance
  85477. * @returns a new InstancedLinesMesh
  85478. */
  85479. LinesMesh.prototype.createInstance = function (name) {
  85480. return new InstancedLinesMesh(name, this);
  85481. };
  85482. return LinesMesh;
  85483. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  85484. /**
  85485. * Creates an instance based on a source LinesMesh
  85486. */
  85487. var InstancedLinesMesh = /** @class */ (function (_super) {
  85488. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  85489. function InstancedLinesMesh(name, source) {
  85490. var _this = _super.call(this, name, source) || this;
  85491. _this.intersectionThreshold = source.intersectionThreshold;
  85492. return _this;
  85493. }
  85494. /**
  85495. * Returns the string "InstancedLinesMesh".
  85496. */
  85497. InstancedLinesMesh.prototype.getClassName = function () {
  85498. return "InstancedLinesMesh";
  85499. };
  85500. return InstancedLinesMesh;
  85501. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  85502. /***/ }),
  85503. /***/ "./Meshes/mesh.ts":
  85504. /*!************************!*\
  85505. !*** ./Meshes/mesh.ts ***!
  85506. \************************/
  85507. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  85508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85509. "use strict";
  85510. __webpack_require__.r(__webpack_exports__);
  85511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  85512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  85513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  85514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  85515. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85516. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  85517. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  85518. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  85519. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  85520. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85521. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  85522. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  85523. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85524. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  85525. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  85526. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  85527. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  85528. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  85529. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  85530. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  85531. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  85532. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  85533. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  85534. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  85535. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  85536. /**
  85537. * Class used to represent a specific level of detail of a mesh
  85538. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85539. */
  85540. var MeshLODLevel = /** @class */ (function () {
  85541. /**
  85542. * Creates a new LOD level
  85543. * @param distance defines the distance where this level should star being displayed
  85544. * @param mesh defines the mesh to use to render this level
  85545. */
  85546. function MeshLODLevel(
  85547. /** Defines the distance where this level should star being displayed */
  85548. distance,
  85549. /** Defines the mesh to use to render this level */
  85550. mesh) {
  85551. this.distance = distance;
  85552. this.mesh = mesh;
  85553. }
  85554. return MeshLODLevel;
  85555. }());
  85556. /**
  85557. * @hidden
  85558. **/
  85559. var _CreationDataStorage = /** @class */ (function () {
  85560. function _CreationDataStorage() {
  85561. }
  85562. return _CreationDataStorage;
  85563. }());
  85564. /**
  85565. * @hidden
  85566. **/
  85567. var _InstanceDataStorage = /** @class */ (function () {
  85568. function _InstanceDataStorage() {
  85569. this.visibleInstances = {};
  85570. this.renderIdForInstances = new Array();
  85571. this.batchCache = new _InstancesBatch();
  85572. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  85573. }
  85574. return _InstanceDataStorage;
  85575. }());
  85576. /**
  85577. * @hidden
  85578. **/
  85579. var _InstancesBatch = /** @class */ (function () {
  85580. function _InstancesBatch() {
  85581. this.mustReturn = false;
  85582. this.visibleInstances = new Array();
  85583. this.renderSelf = new Array();
  85584. }
  85585. return _InstancesBatch;
  85586. }());
  85587. /**
  85588. * Class used to represent renderable models
  85589. */
  85590. var Mesh = /** @class */ (function (_super) {
  85591. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  85592. /**
  85593. * @constructor
  85594. * @param name The value used by scene.getMeshByName() to do a lookup.
  85595. * @param scene The scene to add this mesh to.
  85596. * @param parent The parent of this mesh, if it has one
  85597. * @param source An optional Mesh from which geometry is shared, cloned.
  85598. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85599. * When false, achieved by calling a clone(), also passing False.
  85600. * This will make creation of children, recursive.
  85601. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  85602. */
  85603. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  85604. if (scene === void 0) { scene = null; }
  85605. if (parent === void 0) { parent = null; }
  85606. if (source === void 0) { source = null; }
  85607. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  85608. var _this = _super.call(this, name, scene) || this;
  85609. // Members
  85610. /**
  85611. * Gets the delay loading state of the mesh (when delay loading is turned on)
  85612. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  85613. */
  85614. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  85615. /**
  85616. * Gets the list of instances created from this mesh
  85617. * it is not supposed to be modified manually.
  85618. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  85619. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85620. */
  85621. _this.instances = new Array();
  85622. _this._LODLevels = new Array();
  85623. /** @hidden */
  85624. _this._instanceDataStorage = new _InstanceDataStorage();
  85625. // Use by builder only to know what orientation were the mesh build in.
  85626. /** @hidden */
  85627. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  85628. /**
  85629. * Use this property to change the original side orientation defined at construction time
  85630. */
  85631. _this.overrideMaterialSideOrientation = null;
  85632. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  85633. // Will be used to save a source mesh reference, If any
  85634. _this._source = null;
  85635. /** @hidden */
  85636. _this._isMesh = true;
  85637. scene = _this.getScene();
  85638. if (source) {
  85639. // Geometry
  85640. if (source._geometry) {
  85641. source._geometry.applyToMesh(_this);
  85642. }
  85643. // Deep copy
  85644. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  85645. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  85646. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  85647. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  85648. "onDisposeObservable"
  85649. ], ["_poseMatrix"]);
  85650. // Source mesh
  85651. _this._source = source;
  85652. if (scene.useClonedMeshhMap) {
  85653. if (!source.meshMap) {
  85654. source.meshMap = {};
  85655. }
  85656. source.meshMap[_this.uniqueId] = _this;
  85657. }
  85658. // Construction Params
  85659. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  85660. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  85661. _this._creationDataStorage = source._creationDataStorage;
  85662. // Animation ranges
  85663. if (_this._source._ranges) {
  85664. var ranges = _this._source._ranges;
  85665. for (var name in ranges) {
  85666. if (!ranges.hasOwnProperty(name)) {
  85667. continue;
  85668. }
  85669. if (!ranges[name]) {
  85670. continue;
  85671. }
  85672. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  85673. }
  85674. }
  85675. // Metadata
  85676. if (source.metadata && source.metadata.clone) {
  85677. _this.metadata = source.metadata.clone();
  85678. }
  85679. else {
  85680. _this.metadata = source.metadata;
  85681. }
  85682. // Tags
  85683. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  85684. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  85685. }
  85686. // Parent
  85687. _this.parent = source.parent;
  85688. // Pivot
  85689. _this.setPivotMatrix(source.getPivotMatrix());
  85690. _this.id = name + "." + source.id;
  85691. // Material
  85692. _this.material = source.material;
  85693. var index;
  85694. if (!doNotCloneChildren) {
  85695. // Children
  85696. var directDescendants = source.getDescendants(true);
  85697. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  85698. var child = directDescendants[index_1];
  85699. if (child.clone) {
  85700. child.clone(name + "." + child.name, _this);
  85701. }
  85702. }
  85703. }
  85704. // Physics clone
  85705. var physicsEngine = _this.getScene().getPhysicsEngine();
  85706. if (clonePhysicsImpostor && physicsEngine) {
  85707. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  85708. if (impostor) {
  85709. _this.physicsImpostor = impostor.clone(_this);
  85710. }
  85711. }
  85712. // Particles
  85713. for (index = 0; index < scene.particleSystems.length; index++) {
  85714. var system = scene.particleSystems[index];
  85715. if (system.emitter === source) {
  85716. system.clone(system.name, _this);
  85717. }
  85718. }
  85719. _this.refreshBoundingInfo();
  85720. _this.computeWorldMatrix(true);
  85721. }
  85722. // Parent
  85723. if (parent !== null) {
  85724. _this.parent = parent;
  85725. }
  85726. return _this;
  85727. }
  85728. /**
  85729. * Gets the default side orientation.
  85730. * @param orientation the orientation to value to attempt to get
  85731. * @returns the default orientation
  85732. * @hidden
  85733. */
  85734. Mesh._GetDefaultSideOrientation = function (orientation) {
  85735. return orientation || Mesh.FRONTSIDE; // works as Mesh.FRONTSIDE is 0
  85736. };
  85737. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  85738. /**
  85739. * An event triggered before rendering the mesh
  85740. */
  85741. get: function () {
  85742. if (!this._onBeforeRenderObservable) {
  85743. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  85744. }
  85745. return this._onBeforeRenderObservable;
  85746. },
  85747. enumerable: true,
  85748. configurable: true
  85749. });
  85750. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  85751. /**
  85752. * An event triggered before binding the mesh
  85753. */
  85754. get: function () {
  85755. if (!this._onBeforeBindObservable) {
  85756. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  85757. }
  85758. return this._onBeforeBindObservable;
  85759. },
  85760. enumerable: true,
  85761. configurable: true
  85762. });
  85763. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  85764. /**
  85765. * An event triggered after rendering the mesh
  85766. */
  85767. get: function () {
  85768. if (!this._onAfterRenderObservable) {
  85769. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  85770. }
  85771. return this._onAfterRenderObservable;
  85772. },
  85773. enumerable: true,
  85774. configurable: true
  85775. });
  85776. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  85777. /**
  85778. * An event triggered before drawing the mesh
  85779. */
  85780. get: function () {
  85781. if (!this._onBeforeDrawObservable) {
  85782. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  85783. }
  85784. return this._onBeforeDrawObservable;
  85785. },
  85786. enumerable: true,
  85787. configurable: true
  85788. });
  85789. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  85790. /**
  85791. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  85792. */
  85793. set: function (callback) {
  85794. if (this._onBeforeDrawObserver) {
  85795. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  85796. }
  85797. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  85798. },
  85799. enumerable: true,
  85800. configurable: true
  85801. });
  85802. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  85803. /**
  85804. * Gets or sets the morph target manager
  85805. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85806. */
  85807. get: function () {
  85808. return this._morphTargetManager;
  85809. },
  85810. set: function (value) {
  85811. if (this._morphTargetManager === value) {
  85812. return;
  85813. }
  85814. this._morphTargetManager = value;
  85815. this._syncGeometryWithMorphTargetManager();
  85816. },
  85817. enumerable: true,
  85818. configurable: true
  85819. });
  85820. Object.defineProperty(Mesh.prototype, "source", {
  85821. /**
  85822. * Gets the source mesh (the one used to clone this one from)
  85823. */
  85824. get: function () {
  85825. return this._source;
  85826. },
  85827. enumerable: true,
  85828. configurable: true
  85829. });
  85830. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  85831. /**
  85832. * Gets or sets a boolean indicating that this mesh does not use index buffer
  85833. */
  85834. get: function () {
  85835. return this._unIndexed;
  85836. },
  85837. set: function (value) {
  85838. if (this._unIndexed !== value) {
  85839. this._unIndexed = value;
  85840. this._markSubMeshesAsAttributesDirty();
  85841. }
  85842. },
  85843. enumerable: true,
  85844. configurable: true
  85845. });
  85846. // Methods
  85847. /**
  85848. * Gets the class name
  85849. * @returns the string "Mesh".
  85850. */
  85851. Mesh.prototype.getClassName = function () {
  85852. return "Mesh";
  85853. };
  85854. /**
  85855. * Returns a description of this mesh
  85856. * @param fullDetails define if full details about this mesh must be used
  85857. * @returns a descriptive string representing this mesh
  85858. */
  85859. Mesh.prototype.toString = function (fullDetails) {
  85860. var ret = _super.prototype.toString.call(this, fullDetails);
  85861. ret += ", n vertices: " + this.getTotalVertices();
  85862. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  85863. if (this.animations) {
  85864. for (var i = 0; i < this.animations.length; i++) {
  85865. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  85866. }
  85867. }
  85868. if (fullDetails) {
  85869. if (this._geometry) {
  85870. var ib = this.getIndices();
  85871. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85872. if (vb && ib) {
  85873. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  85874. }
  85875. }
  85876. else {
  85877. ret += ", flat shading: UNKNOWN";
  85878. }
  85879. }
  85880. return ret;
  85881. };
  85882. /** @hidden */
  85883. Mesh.prototype._unBindEffect = function () {
  85884. _super.prototype._unBindEffect.call(this);
  85885. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  85886. var instance = _a[_i];
  85887. instance._unBindEffect();
  85888. }
  85889. };
  85890. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  85891. /**
  85892. * Gets a boolean indicating if this mesh has LOD
  85893. */
  85894. get: function () {
  85895. return this._LODLevels.length > 0;
  85896. },
  85897. enumerable: true,
  85898. configurable: true
  85899. });
  85900. /**
  85901. * Gets the list of MeshLODLevel associated with the current mesh
  85902. * @returns an array of MeshLODLevel
  85903. */
  85904. Mesh.prototype.getLODLevels = function () {
  85905. return this._LODLevels;
  85906. };
  85907. Mesh.prototype._sortLODLevels = function () {
  85908. this._LODLevels.sort(function (a, b) {
  85909. if (a.distance < b.distance) {
  85910. return 1;
  85911. }
  85912. if (a.distance > b.distance) {
  85913. return -1;
  85914. }
  85915. return 0;
  85916. });
  85917. };
  85918. /**
  85919. * Add a mesh as LOD level triggered at the given distance.
  85920. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  85921. * @param distance The distance from the center of the object to show this level
  85922. * @param mesh The mesh to be added as LOD level (can be null)
  85923. * @return This mesh (for chaining)
  85924. */
  85925. Mesh.prototype.addLODLevel = function (distance, mesh) {
  85926. if (mesh && mesh._masterMesh) {
  85927. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  85928. return this;
  85929. }
  85930. var level = new MeshLODLevel(distance, mesh);
  85931. this._LODLevels.push(level);
  85932. if (mesh) {
  85933. mesh._masterMesh = this;
  85934. }
  85935. this._sortLODLevels();
  85936. return this;
  85937. };
  85938. /**
  85939. * Returns the LOD level mesh at the passed distance or null if not found.
  85940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  85941. * @param distance The distance from the center of the object to show this level
  85942. * @returns a Mesh or `null`
  85943. */
  85944. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  85945. for (var index = 0; index < this._LODLevels.length; index++) {
  85946. var level = this._LODLevels[index];
  85947. if (level.distance === distance) {
  85948. return level.mesh;
  85949. }
  85950. }
  85951. return null;
  85952. };
  85953. /**
  85954. * Remove a mesh from the LOD array
  85955. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  85956. * @param mesh defines the mesh to be removed
  85957. * @return This mesh (for chaining)
  85958. */
  85959. Mesh.prototype.removeLODLevel = function (mesh) {
  85960. for (var index = 0; index < this._LODLevels.length; index++) {
  85961. if (this._LODLevels[index].mesh === mesh) {
  85962. this._LODLevels.splice(index, 1);
  85963. if (mesh) {
  85964. mesh._masterMesh = null;
  85965. }
  85966. }
  85967. }
  85968. this._sortLODLevels();
  85969. return this;
  85970. };
  85971. /**
  85972. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  85973. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  85974. * @param camera defines the camera to use to compute distance
  85975. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  85976. * @return This mesh (for chaining)
  85977. */
  85978. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  85979. if (!this._LODLevels || this._LODLevels.length === 0) {
  85980. return this;
  85981. }
  85982. var bSphere;
  85983. if (boundingSphere) {
  85984. bSphere = boundingSphere;
  85985. }
  85986. else {
  85987. var boundingInfo = this.getBoundingInfo();
  85988. bSphere = boundingInfo.boundingSphere;
  85989. }
  85990. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  85991. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  85992. if (this.onLODLevelSelection) {
  85993. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  85994. }
  85995. return this;
  85996. }
  85997. for (var index = 0; index < this._LODLevels.length; index++) {
  85998. var level = this._LODLevels[index];
  85999. if (level.distance < distanceToCamera) {
  86000. if (level.mesh) {
  86001. level.mesh._preActivate();
  86002. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  86003. }
  86004. if (this.onLODLevelSelection) {
  86005. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  86006. }
  86007. return level.mesh;
  86008. }
  86009. }
  86010. if (this.onLODLevelSelection) {
  86011. this.onLODLevelSelection(distanceToCamera, this, this);
  86012. }
  86013. return this;
  86014. };
  86015. Object.defineProperty(Mesh.prototype, "geometry", {
  86016. /**
  86017. * Gets the mesh internal Geometry object
  86018. */
  86019. get: function () {
  86020. return this._geometry;
  86021. },
  86022. enumerable: true,
  86023. configurable: true
  86024. });
  86025. /**
  86026. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  86027. * @returns the total number of vertices
  86028. */
  86029. Mesh.prototype.getTotalVertices = function () {
  86030. if (this._geometry === null || this._geometry === undefined) {
  86031. return 0;
  86032. }
  86033. return this._geometry.getTotalVertices();
  86034. };
  86035. /**
  86036. * Returns the content of an associated vertex buffer
  86037. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86038. * - VertexBuffer.PositionKind
  86039. * - VertexBuffer.UVKind
  86040. * - VertexBuffer.UV2Kind
  86041. * - VertexBuffer.UV3Kind
  86042. * - VertexBuffer.UV4Kind
  86043. * - VertexBuffer.UV5Kind
  86044. * - VertexBuffer.UV6Kind
  86045. * - VertexBuffer.ColorKind
  86046. * - VertexBuffer.MatricesIndicesKind
  86047. * - VertexBuffer.MatricesIndicesExtraKind
  86048. * - VertexBuffer.MatricesWeightsKind
  86049. * - VertexBuffer.MatricesWeightsExtraKind
  86050. * @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
  86051. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  86052. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  86053. */
  86054. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  86055. if (!this._geometry) {
  86056. return null;
  86057. }
  86058. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  86059. };
  86060. /**
  86061. * Returns the mesh VertexBuffer object from the requested `kind`
  86062. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86063. * - VertexBuffer.PositionKind
  86064. * - VertexBuffer.UVKind
  86065. * - VertexBuffer.UV2Kind
  86066. * - VertexBuffer.UV3Kind
  86067. * - VertexBuffer.UV4Kind
  86068. * - VertexBuffer.UV5Kind
  86069. * - VertexBuffer.UV6Kind
  86070. * - VertexBuffer.ColorKind
  86071. * - VertexBuffer.MatricesIndicesKind
  86072. * - VertexBuffer.MatricesIndicesExtraKind
  86073. * - VertexBuffer.MatricesWeightsKind
  86074. * - VertexBuffer.MatricesWeightsExtraKind
  86075. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  86076. */
  86077. Mesh.prototype.getVertexBuffer = function (kind) {
  86078. if (!this._geometry) {
  86079. return null;
  86080. }
  86081. return this._geometry.getVertexBuffer(kind);
  86082. };
  86083. /**
  86084. * Tests if a specific vertex buffer is associated with this mesh
  86085. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  86086. * - VertexBuffer.PositionKind
  86087. * - VertexBuffer.UVKind
  86088. * - VertexBuffer.UV2Kind
  86089. * - VertexBuffer.UV3Kind
  86090. * - VertexBuffer.UV4Kind
  86091. * - VertexBuffer.UV5Kind
  86092. * - VertexBuffer.UV6Kind
  86093. * - VertexBuffer.ColorKind
  86094. * - VertexBuffer.MatricesIndicesKind
  86095. * - VertexBuffer.MatricesIndicesExtraKind
  86096. * - VertexBuffer.MatricesWeightsKind
  86097. * - VertexBuffer.MatricesWeightsExtraKind
  86098. * @returns a boolean
  86099. */
  86100. Mesh.prototype.isVerticesDataPresent = function (kind) {
  86101. if (!this._geometry) {
  86102. if (this._delayInfo) {
  86103. return this._delayInfo.indexOf(kind) !== -1;
  86104. }
  86105. return false;
  86106. }
  86107. return this._geometry.isVerticesDataPresent(kind);
  86108. };
  86109. /**
  86110. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  86111. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  86112. * - VertexBuffer.PositionKind
  86113. * - VertexBuffer.UVKind
  86114. * - VertexBuffer.UV2Kind
  86115. * - VertexBuffer.UV3Kind
  86116. * - VertexBuffer.UV4Kind
  86117. * - VertexBuffer.UV5Kind
  86118. * - VertexBuffer.UV6Kind
  86119. * - VertexBuffer.ColorKind
  86120. * - VertexBuffer.MatricesIndicesKind
  86121. * - VertexBuffer.MatricesIndicesExtraKind
  86122. * - VertexBuffer.MatricesWeightsKind
  86123. * - VertexBuffer.MatricesWeightsExtraKind
  86124. * @returns a boolean
  86125. */
  86126. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  86127. if (!this._geometry) {
  86128. if (this._delayInfo) {
  86129. return this._delayInfo.indexOf(kind) !== -1;
  86130. }
  86131. return false;
  86132. }
  86133. return this._geometry.isVertexBufferUpdatable(kind);
  86134. };
  86135. /**
  86136. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  86137. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86138. * - VertexBuffer.PositionKind
  86139. * - VertexBuffer.UVKind
  86140. * - VertexBuffer.UV2Kind
  86141. * - VertexBuffer.UV3Kind
  86142. * - VertexBuffer.UV4Kind
  86143. * - VertexBuffer.UV5Kind
  86144. * - VertexBuffer.UV6Kind
  86145. * - VertexBuffer.ColorKind
  86146. * - VertexBuffer.MatricesIndicesKind
  86147. * - VertexBuffer.MatricesIndicesExtraKind
  86148. * - VertexBuffer.MatricesWeightsKind
  86149. * - VertexBuffer.MatricesWeightsExtraKind
  86150. * @returns an array of strings
  86151. */
  86152. Mesh.prototype.getVerticesDataKinds = function () {
  86153. if (!this._geometry) {
  86154. var result = new Array();
  86155. if (this._delayInfo) {
  86156. this._delayInfo.forEach(function (kind) {
  86157. result.push(kind);
  86158. });
  86159. }
  86160. return result;
  86161. }
  86162. return this._geometry.getVerticesDataKinds();
  86163. };
  86164. /**
  86165. * Returns a positive integer : the total number of indices in this mesh geometry.
  86166. * @returns the numner of indices or zero if the mesh has no geometry.
  86167. */
  86168. Mesh.prototype.getTotalIndices = function () {
  86169. if (!this._geometry) {
  86170. return 0;
  86171. }
  86172. return this._geometry.getTotalIndices();
  86173. };
  86174. /**
  86175. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86176. * @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.
  86177. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86178. * @returns the indices array or an empty array if the mesh has no geometry
  86179. */
  86180. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  86181. if (!this._geometry) {
  86182. return [];
  86183. }
  86184. return this._geometry.getIndices(copyWhenShared, forceCopy);
  86185. };
  86186. Object.defineProperty(Mesh.prototype, "isBlocked", {
  86187. get: function () {
  86188. return this._masterMesh !== null && this._masterMesh !== undefined;
  86189. },
  86190. enumerable: true,
  86191. configurable: true
  86192. });
  86193. /**
  86194. * Determine if the current mesh is ready to be rendered
  86195. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86196. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  86197. * @returns true if all associated assets are ready (material, textures, shaders)
  86198. */
  86199. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  86200. if (completeCheck === void 0) { completeCheck = false; }
  86201. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  86202. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  86203. return false;
  86204. }
  86205. if (!_super.prototype.isReady.call(this, completeCheck)) {
  86206. return false;
  86207. }
  86208. if (!this.subMeshes || this.subMeshes.length === 0) {
  86209. return true;
  86210. }
  86211. if (!completeCheck) {
  86212. return true;
  86213. }
  86214. var engine = this.getEngine();
  86215. var scene = this.getScene();
  86216. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  86217. this.computeWorldMatrix();
  86218. var mat = this.material || scene.defaultMaterial;
  86219. if (mat) {
  86220. if (mat._storeEffectOnSubMeshes) {
  86221. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  86222. var subMesh = _a[_i];
  86223. var effectiveMaterial = subMesh.getMaterial();
  86224. if (effectiveMaterial) {
  86225. if (effectiveMaterial._storeEffectOnSubMeshes) {
  86226. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  86227. return false;
  86228. }
  86229. }
  86230. else {
  86231. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  86232. return false;
  86233. }
  86234. }
  86235. }
  86236. }
  86237. }
  86238. else {
  86239. if (!mat.isReady(this, hardwareInstancedRendering)) {
  86240. return false;
  86241. }
  86242. }
  86243. }
  86244. // Shadows
  86245. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  86246. var light = _c[_b];
  86247. var generator = light.getShadowGenerator();
  86248. if (generator) {
  86249. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  86250. var subMesh = _e[_d];
  86251. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  86252. return false;
  86253. }
  86254. }
  86255. }
  86256. }
  86257. // LOD
  86258. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  86259. var lod = _g[_f];
  86260. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  86261. return false;
  86262. }
  86263. }
  86264. return true;
  86265. };
  86266. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  86267. /**
  86268. * 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.
  86269. */
  86270. get: function () {
  86271. return this._areNormalsFrozen;
  86272. },
  86273. enumerable: true,
  86274. configurable: true
  86275. });
  86276. /**
  86277. * 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.
  86278. * @returns the current mesh
  86279. */
  86280. Mesh.prototype.freezeNormals = function () {
  86281. this._areNormalsFrozen = true;
  86282. return this;
  86283. };
  86284. /**
  86285. * 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
  86286. * @returns the current mesh
  86287. */
  86288. Mesh.prototype.unfreezeNormals = function () {
  86289. this._areNormalsFrozen = false;
  86290. return this;
  86291. };
  86292. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  86293. /**
  86294. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  86295. */
  86296. set: function (count) {
  86297. this._instanceDataStorage.overridenInstanceCount = count;
  86298. },
  86299. enumerable: true,
  86300. configurable: true
  86301. });
  86302. // Methods
  86303. /** @hidden */
  86304. Mesh.prototype._preActivate = function () {
  86305. var sceneRenderId = this.getScene().getRenderId();
  86306. if (this._preActivateId === sceneRenderId) {
  86307. return this;
  86308. }
  86309. this._preActivateId = sceneRenderId;
  86310. this._instanceDataStorage.visibleInstances = null;
  86311. return this;
  86312. };
  86313. /** @hidden */
  86314. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  86315. if (this._instanceDataStorage.visibleInstances) {
  86316. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  86317. }
  86318. return this;
  86319. };
  86320. /** @hidden */
  86321. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  86322. if (!this._instanceDataStorage.visibleInstances) {
  86323. this._instanceDataStorage.visibleInstances = {
  86324. defaultRenderId: renderId,
  86325. selfDefaultRenderId: this._renderId
  86326. };
  86327. }
  86328. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  86329. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  86330. }
  86331. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  86332. return this;
  86333. };
  86334. /**
  86335. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86336. * This means the mesh underlying bounding box and sphere are recomputed.
  86337. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86338. * @returns the current mesh
  86339. */
  86340. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  86341. if (applySkeleton === void 0) { applySkeleton = false; }
  86342. if (this._boundingInfo && this._boundingInfo.isLocked) {
  86343. return this;
  86344. }
  86345. var bias = this.geometry ? this.geometry.boundingBias : null;
  86346. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  86347. return this;
  86348. };
  86349. /** @hidden */
  86350. Mesh.prototype._createGlobalSubMesh = function (force) {
  86351. var totalVertices = this.getTotalVertices();
  86352. if (!totalVertices || !this.getIndices()) {
  86353. return null;
  86354. }
  86355. // Check if we need to recreate the submeshes
  86356. if (this.subMeshes && this.subMeshes.length > 0) {
  86357. var ib = this.getIndices();
  86358. if (!ib) {
  86359. return null;
  86360. }
  86361. var totalIndices = ib.length;
  86362. var needToRecreate = false;
  86363. if (force) {
  86364. needToRecreate = true;
  86365. }
  86366. else {
  86367. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  86368. var submesh = _a[_i];
  86369. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  86370. needToRecreate = true;
  86371. break;
  86372. }
  86373. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  86374. needToRecreate = true;
  86375. break;
  86376. }
  86377. }
  86378. }
  86379. if (!needToRecreate) {
  86380. return this.subMeshes[0];
  86381. }
  86382. }
  86383. this.releaseSubMeshes();
  86384. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  86385. };
  86386. /**
  86387. * This function will subdivide the mesh into multiple submeshes
  86388. * @param count defines the expected number of submeshes
  86389. */
  86390. Mesh.prototype.subdivide = function (count) {
  86391. if (count < 1) {
  86392. return;
  86393. }
  86394. var totalIndices = this.getTotalIndices();
  86395. var subdivisionSize = (totalIndices / count) | 0;
  86396. var offset = 0;
  86397. // Ensure that subdivisionSize is a multiple of 3
  86398. while (subdivisionSize % 3 !== 0) {
  86399. subdivisionSize++;
  86400. }
  86401. this.releaseSubMeshes();
  86402. for (var index = 0; index < count; index++) {
  86403. if (offset >= totalIndices) {
  86404. break;
  86405. }
  86406. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  86407. offset += subdivisionSize;
  86408. }
  86409. this.synchronizeInstances();
  86410. };
  86411. /**
  86412. * Copy a FloatArray into a specific associated vertex buffer
  86413. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86414. * - VertexBuffer.PositionKind
  86415. * - VertexBuffer.UVKind
  86416. * - VertexBuffer.UV2Kind
  86417. * - VertexBuffer.UV3Kind
  86418. * - VertexBuffer.UV4Kind
  86419. * - VertexBuffer.UV5Kind
  86420. * - VertexBuffer.UV6Kind
  86421. * - VertexBuffer.ColorKind
  86422. * - VertexBuffer.MatricesIndicesKind
  86423. * - VertexBuffer.MatricesIndicesExtraKind
  86424. * - VertexBuffer.MatricesWeightsKind
  86425. * - VertexBuffer.MatricesWeightsExtraKind
  86426. * @param data defines the data source
  86427. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  86428. * @param stride defines the data stride size (can be null)
  86429. * @returns the current mesh
  86430. */
  86431. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  86432. if (updatable === void 0) { updatable = false; }
  86433. if (!this._geometry) {
  86434. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  86435. vertexData.set(data, kind);
  86436. var scene = this.getScene();
  86437. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  86438. }
  86439. else {
  86440. this._geometry.setVerticesData(kind, data, updatable, stride);
  86441. }
  86442. return this;
  86443. };
  86444. /**
  86445. * Flags an associated vertex buffer as updatable
  86446. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  86447. * - VertexBuffer.PositionKind
  86448. * - VertexBuffer.UVKind
  86449. * - VertexBuffer.UV2Kind
  86450. * - VertexBuffer.UV3Kind
  86451. * - VertexBuffer.UV4Kind
  86452. * - VertexBuffer.UV5Kind
  86453. * - VertexBuffer.UV6Kind
  86454. * - VertexBuffer.ColorKind
  86455. * - VertexBuffer.MatricesIndicesKind
  86456. * - VertexBuffer.MatricesIndicesExtraKind
  86457. * - VertexBuffer.MatricesWeightsKind
  86458. * - VertexBuffer.MatricesWeightsExtraKind
  86459. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  86460. */
  86461. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  86462. if (updatable === void 0) { updatable = true; }
  86463. var vb = this.getVertexBuffer(kind);
  86464. if (!vb || vb.isUpdatable() === updatable) {
  86465. return;
  86466. }
  86467. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  86468. };
  86469. /**
  86470. * Sets the mesh global Vertex Buffer
  86471. * @param buffer defines the buffer to use
  86472. * @returns the current mesh
  86473. */
  86474. Mesh.prototype.setVerticesBuffer = function (buffer) {
  86475. if (!this._geometry) {
  86476. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  86477. }
  86478. this._geometry.setVerticesBuffer(buffer);
  86479. return this;
  86480. };
  86481. /**
  86482. * Update a specific associated vertex buffer
  86483. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86484. * - VertexBuffer.PositionKind
  86485. * - VertexBuffer.UVKind
  86486. * - VertexBuffer.UV2Kind
  86487. * - VertexBuffer.UV3Kind
  86488. * - VertexBuffer.UV4Kind
  86489. * - VertexBuffer.UV5Kind
  86490. * - VertexBuffer.UV6Kind
  86491. * - VertexBuffer.ColorKind
  86492. * - VertexBuffer.MatricesIndicesKind
  86493. * - VertexBuffer.MatricesIndicesExtraKind
  86494. * - VertexBuffer.MatricesWeightsKind
  86495. * - VertexBuffer.MatricesWeightsExtraKind
  86496. * @param data defines the data source
  86497. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86498. * @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)
  86499. * @returns the current mesh
  86500. */
  86501. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  86502. if (!this._geometry) {
  86503. return this;
  86504. }
  86505. if (!makeItUnique) {
  86506. this._geometry.updateVerticesData(kind, data, updateExtends);
  86507. }
  86508. else {
  86509. this.makeGeometryUnique();
  86510. this.updateVerticesData(kind, data, updateExtends, false);
  86511. }
  86512. return this;
  86513. };
  86514. /**
  86515. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  86516. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  86517. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  86518. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  86519. * @returns the current mesh
  86520. */
  86521. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  86522. if (computeNormals === void 0) { computeNormals = true; }
  86523. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86524. if (!positions) {
  86525. return this;
  86526. }
  86527. positionFunction(positions);
  86528. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  86529. if (computeNormals) {
  86530. var indices = this.getIndices();
  86531. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86532. if (!normals) {
  86533. return this;
  86534. }
  86535. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  86536. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  86537. }
  86538. return this;
  86539. };
  86540. /**
  86541. * Creates a un-shared specific occurence of the geometry for the mesh.
  86542. * @returns the current mesh
  86543. */
  86544. Mesh.prototype.makeGeometryUnique = function () {
  86545. if (!this._geometry) {
  86546. return this;
  86547. }
  86548. var oldGeometry = this._geometry;
  86549. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  86550. oldGeometry.releaseForMesh(this, true);
  86551. geometry.applyToMesh(this);
  86552. return this;
  86553. };
  86554. /**
  86555. * Set the index buffer of this mesh
  86556. * @param indices defines the source data
  86557. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  86558. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  86559. * @returns the current mesh
  86560. */
  86561. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  86562. if (totalVertices === void 0) { totalVertices = null; }
  86563. if (updatable === void 0) { updatable = false; }
  86564. if (!this._geometry) {
  86565. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  86566. vertexData.indices = indices;
  86567. var scene = this.getScene();
  86568. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  86569. }
  86570. else {
  86571. this._geometry.setIndices(indices, totalVertices, updatable);
  86572. }
  86573. return this;
  86574. };
  86575. /**
  86576. * Update the current index buffer
  86577. * @param indices defines the source data
  86578. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  86579. * @returns the current mesh
  86580. */
  86581. Mesh.prototype.updateIndices = function (indices, offset) {
  86582. if (!this._geometry) {
  86583. return this;
  86584. }
  86585. this._geometry.updateIndices(indices, offset);
  86586. return this;
  86587. };
  86588. /**
  86589. * Invert the geometry to move from a right handed system to a left handed one.
  86590. * @returns the current mesh
  86591. */
  86592. Mesh.prototype.toLeftHanded = function () {
  86593. if (!this._geometry) {
  86594. return this;
  86595. }
  86596. this._geometry.toLeftHanded();
  86597. return this;
  86598. };
  86599. /** @hidden */
  86600. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  86601. if (!this._geometry) {
  86602. return this;
  86603. }
  86604. var engine = this.getScene().getEngine();
  86605. // Wireframe
  86606. var indexToBind;
  86607. if (this._unIndexed) {
  86608. indexToBind = null;
  86609. }
  86610. else {
  86611. switch (fillMode) {
  86612. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  86613. indexToBind = null;
  86614. break;
  86615. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  86616. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  86617. break;
  86618. default:
  86619. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  86620. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  86621. break;
  86622. }
  86623. }
  86624. // VBOs
  86625. this._geometry._bind(effect, indexToBind);
  86626. return this;
  86627. };
  86628. /** @hidden */
  86629. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  86630. if (alternate === void 0) { alternate = false; }
  86631. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  86632. return this;
  86633. }
  86634. if (this._onBeforeDrawObservable) {
  86635. this._onBeforeDrawObservable.notifyObservers(this);
  86636. }
  86637. var scene = this.getScene();
  86638. var engine = scene.getEngine();
  86639. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  86640. // or triangles as points
  86641. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  86642. }
  86643. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  86644. // Triangles as wireframe
  86645. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  86646. }
  86647. else {
  86648. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  86649. }
  86650. if (scene._isAlternateRenderingEnabled && !alternate) {
  86651. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  86652. if (!effect || !scene.activeCamera) {
  86653. return this;
  86654. }
  86655. scene._switchToAlternateCameraConfiguration(true);
  86656. this._effectiveMaterial.bindView(effect);
  86657. this._effectiveMaterial.bindViewProjection(effect);
  86658. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  86659. this._draw(subMesh, fillMode, instancesCount, true);
  86660. engine.setViewport(scene.activeCamera.viewport);
  86661. scene._switchToAlternateCameraConfiguration(false);
  86662. this._effectiveMaterial.bindView(effect);
  86663. this._effectiveMaterial.bindViewProjection(effect);
  86664. }
  86665. return this;
  86666. };
  86667. /**
  86668. * Registers for this mesh a javascript function called just before the rendering process
  86669. * @param func defines the function to call before rendering this mesh
  86670. * @returns the current mesh
  86671. */
  86672. Mesh.prototype.registerBeforeRender = function (func) {
  86673. this.onBeforeRenderObservable.add(func);
  86674. return this;
  86675. };
  86676. /**
  86677. * Disposes a previously registered javascript function called before the rendering
  86678. * @param func defines the function to remove
  86679. * @returns the current mesh
  86680. */
  86681. Mesh.prototype.unregisterBeforeRender = function (func) {
  86682. this.onBeforeRenderObservable.removeCallback(func);
  86683. return this;
  86684. };
  86685. /**
  86686. * Registers for this mesh a javascript function called just after the rendering is complete
  86687. * @param func defines the function to call after rendering this mesh
  86688. * @returns the current mesh
  86689. */
  86690. Mesh.prototype.registerAfterRender = function (func) {
  86691. this.onAfterRenderObservable.add(func);
  86692. return this;
  86693. };
  86694. /**
  86695. * Disposes a previously registered javascript function called after the rendering.
  86696. * @param func defines the function to remove
  86697. * @returns the current mesh
  86698. */
  86699. Mesh.prototype.unregisterAfterRender = function (func) {
  86700. this.onAfterRenderObservable.removeCallback(func);
  86701. return this;
  86702. };
  86703. /** @hidden */
  86704. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  86705. var scene = this.getScene();
  86706. var batchCache = this._instanceDataStorage.batchCache;
  86707. batchCache.mustReturn = false;
  86708. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  86709. batchCache.visibleInstances[subMeshId] = null;
  86710. if (this._instanceDataStorage.visibleInstances) {
  86711. var visibleInstances = this._instanceDataStorage.visibleInstances;
  86712. var currentRenderId = scene.getRenderId();
  86713. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  86714. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  86715. var selfRenderId = this._renderId;
  86716. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  86717. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  86718. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  86719. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  86720. }
  86721. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  86722. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  86723. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  86724. batchCache.mustReturn = true;
  86725. return batchCache;
  86726. }
  86727. if (currentRenderId !== selfRenderId) {
  86728. batchCache.renderSelf[subMeshId] = false;
  86729. }
  86730. }
  86731. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  86732. }
  86733. return batchCache;
  86734. };
  86735. /** @hidden */
  86736. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  86737. var visibleInstances = batch.visibleInstances[subMesh._id];
  86738. if (!visibleInstances) {
  86739. return this;
  86740. }
  86741. var matricesCount = visibleInstances.length + 1;
  86742. var bufferSize = matricesCount * 16 * 4;
  86743. var instanceStorage = this._instanceDataStorage;
  86744. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  86745. var instancesBuffer = instanceStorage.instancesBuffer;
  86746. while (instanceStorage.instancesBufferSize < bufferSize) {
  86747. instanceStorage.instancesBufferSize *= 2;
  86748. }
  86749. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  86750. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  86751. }
  86752. var offset = 0;
  86753. var instancesCount = 0;
  86754. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  86755. var world = effectiveMesh.getWorldMatrix();
  86756. if (batch.renderSelf[subMesh._id]) {
  86757. world.copyToArray(instanceStorage.instancesData, offset);
  86758. offset += 16;
  86759. instancesCount++;
  86760. }
  86761. if (visibleInstances) {
  86762. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  86763. var instance = visibleInstances[instanceIndex];
  86764. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  86765. offset += 16;
  86766. instancesCount++;
  86767. }
  86768. }
  86769. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  86770. if (instancesBuffer) {
  86771. instancesBuffer.dispose();
  86772. }
  86773. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  86774. instanceStorage.instancesBuffer = instancesBuffer;
  86775. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  86776. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  86777. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  86778. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  86779. }
  86780. else {
  86781. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  86782. }
  86783. this._bind(subMesh, effect, fillMode);
  86784. this._draw(subMesh, fillMode, instancesCount);
  86785. engine.unbindInstanceAttributes();
  86786. return this;
  86787. };
  86788. /** @hidden */
  86789. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  86790. var scene = this.getScene();
  86791. var engine = scene.getEngine();
  86792. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  86793. if (hardwareInstancedRendering) {
  86794. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  86795. }
  86796. else {
  86797. if (batch.renderSelf[subMesh._id]) {
  86798. // Draw
  86799. if (onBeforeDraw) {
  86800. onBeforeDraw(false, effectiveMesh.getWorldMatrix(), effectiveMaterial);
  86801. }
  86802. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  86803. }
  86804. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  86805. if (visibleInstancesForSubMesh) {
  86806. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  86807. var instance = visibleInstancesForSubMesh[instanceIndex];
  86808. // World
  86809. var world = instance.getWorldMatrix();
  86810. if (onBeforeDraw) {
  86811. onBeforeDraw(true, world, effectiveMaterial);
  86812. }
  86813. // Draw
  86814. this._draw(subMesh, fillMode);
  86815. }
  86816. }
  86817. }
  86818. return this;
  86819. };
  86820. /**
  86821. * 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
  86822. * @param subMesh defines the subMesh to render
  86823. * @param enableAlphaMode defines if alpha mode can be changed
  86824. * @returns the current mesh
  86825. */
  86826. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  86827. if (this._checkOcclusionQuery()) {
  86828. return this;
  86829. }
  86830. var scene = this.getScene();
  86831. // Managing instances
  86832. var batch = this._getInstancesRenderList(subMesh._id);
  86833. if (batch.mustReturn) {
  86834. return this;
  86835. }
  86836. // Checking geometry state
  86837. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  86838. return this;
  86839. }
  86840. if (this._onBeforeRenderObservable) {
  86841. this._onBeforeRenderObservable.notifyObservers(this);
  86842. }
  86843. var engine = scene.getEngine();
  86844. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  86845. // Material
  86846. var material = subMesh.getMaterial();
  86847. if (!material) {
  86848. return this;
  86849. }
  86850. this._effectiveMaterial = material;
  86851. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  86852. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  86853. return this;
  86854. }
  86855. }
  86856. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  86857. return this;
  86858. }
  86859. // Alpha mode
  86860. if (enableAlphaMode) {
  86861. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  86862. }
  86863. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  86864. var step = _a[_i];
  86865. step.action(this, subMesh, batch);
  86866. }
  86867. var effect;
  86868. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  86869. effect = subMesh.effect;
  86870. }
  86871. else {
  86872. effect = this._effectiveMaterial.getEffect();
  86873. }
  86874. if (!effect) {
  86875. return this;
  86876. }
  86877. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  86878. var sideOrientation = this.overrideMaterialSideOrientation;
  86879. if (sideOrientation == null) {
  86880. sideOrientation = this._effectiveMaterial.sideOrientation;
  86881. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  86882. 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);
  86883. }
  86884. }
  86885. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  86886. if (this._effectiveMaterial.forceDepthWrite) {
  86887. engine.setDepthWrite(true);
  86888. }
  86889. // Bind
  86890. 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);
  86891. if (this._onBeforeBindObservable) {
  86892. this._onBeforeBindObservable.notifyObservers(this);
  86893. }
  86894. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  86895. this._bind(subMesh, effect, fillMode);
  86896. }
  86897. var world = effectiveMesh.getWorldMatrix();
  86898. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  86899. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  86900. }
  86901. else {
  86902. this._effectiveMaterial.bind(world, this);
  86903. }
  86904. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  86905. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  86906. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  86907. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  86908. }
  86909. // Draw
  86910. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  86911. // Unbind
  86912. this._effectiveMaterial.unbind();
  86913. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  86914. var step = _c[_b];
  86915. step.action(this, subMesh, batch);
  86916. }
  86917. if (this._onAfterRenderObservable) {
  86918. this._onAfterRenderObservable.notifyObservers(this);
  86919. }
  86920. return this;
  86921. };
  86922. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  86923. if (isInstance && effectiveMaterial) {
  86924. effectiveMaterial.bindOnlyWorldMatrix(world);
  86925. }
  86926. };
  86927. /**
  86928. * Renormalize the mesh and patch it up if there are no weights
  86929. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  86930. * However in the case of zero weights then we set just a single influence to 1.
  86931. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  86932. */
  86933. Mesh.prototype.cleanMatrixWeights = function () {
  86934. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  86935. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  86936. this.normalizeSkinWeightsAndExtra();
  86937. }
  86938. else {
  86939. this.normalizeSkinFourWeights();
  86940. }
  86941. }
  86942. };
  86943. // faster 4 weight version.
  86944. Mesh.prototype.normalizeSkinFourWeights = function () {
  86945. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86946. var numWeights = matricesWeights.length;
  86947. for (var a = 0; a < numWeights; a += 4) {
  86948. // accumulate weights
  86949. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  86950. // check for invalid weight and just set it to 1.
  86951. if (t === 0) {
  86952. matricesWeights[a] = 1;
  86953. }
  86954. else {
  86955. // renormalize so everything adds to 1 use reciprical
  86956. var recip = 1 / t;
  86957. matricesWeights[a] *= recip;
  86958. matricesWeights[a + 1] *= recip;
  86959. matricesWeights[a + 2] *= recip;
  86960. matricesWeights[a + 3] *= recip;
  86961. }
  86962. }
  86963. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  86964. };
  86965. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  86966. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  86967. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  86968. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86969. var numWeights = matricesWeights.length;
  86970. for (var a = 0; a < numWeights; a += 4) {
  86971. // accumulate weights
  86972. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  86973. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  86974. // check for invalid weight and just set it to 1.
  86975. if (t === 0) {
  86976. matricesWeights[a] = 1;
  86977. }
  86978. else {
  86979. // renormalize so everything adds to 1 use reciprical
  86980. var recip = 1 / t;
  86981. matricesWeights[a] *= recip;
  86982. matricesWeights[a + 1] *= recip;
  86983. matricesWeights[a + 2] *= recip;
  86984. matricesWeights[a + 3] *= recip;
  86985. // same goes for extras
  86986. matricesWeightsExtra[a] *= recip;
  86987. matricesWeightsExtra[a + 1] *= recip;
  86988. matricesWeightsExtra[a + 2] *= recip;
  86989. matricesWeightsExtra[a + 3] *= recip;
  86990. }
  86991. }
  86992. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  86993. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  86994. };
  86995. /**
  86996. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  86997. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  86998. * the user know there was an issue with importing the mesh
  86999. * @returns a validation object with skinned, valid and report string
  87000. */
  87001. Mesh.prototype.validateSkinning = function () {
  87002. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  87003. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87004. if (matricesWeights === null || this.skeleton == null) {
  87005. return { skinned: false, valid: true, report: "not skinned" };
  87006. }
  87007. var numWeights = matricesWeights.length;
  87008. var numberNotSorted = 0;
  87009. var missingWeights = 0;
  87010. var maxUsedWeights = 0;
  87011. var numberNotNormalized = 0;
  87012. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  87013. var usedWeightCounts = new Array();
  87014. for (var a = 0; a <= numInfluences; a++) {
  87015. usedWeightCounts[a] = 0;
  87016. }
  87017. var toleranceEpsilon = 0.001;
  87018. for (var a = 0; a < numWeights; a += 4) {
  87019. var lastWeight = matricesWeights[a];
  87020. var t = lastWeight;
  87021. var usedWeights = t === 0 ? 0 : 1;
  87022. for (var b = 1; b < numInfluences; b++) {
  87023. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  87024. if (d > lastWeight) {
  87025. numberNotSorted++;
  87026. }
  87027. if (d !== 0) {
  87028. usedWeights++;
  87029. }
  87030. t += d;
  87031. lastWeight = d;
  87032. }
  87033. // count the buffer weights usage
  87034. usedWeightCounts[usedWeights]++;
  87035. // max influences
  87036. if (usedWeights > maxUsedWeights) {
  87037. maxUsedWeights = usedWeights;
  87038. }
  87039. // check for invalid weight and just set it to 1.
  87040. if (t === 0) {
  87041. missingWeights++;
  87042. }
  87043. else {
  87044. // renormalize so everything adds to 1 use reciprical
  87045. var recip = 1 / t;
  87046. var tolerance = 0;
  87047. for (b = 0; b < numInfluences; b++) {
  87048. if (b < 4) {
  87049. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  87050. }
  87051. else {
  87052. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  87053. }
  87054. }
  87055. // arbitary epsilon value for dicdating not normalized
  87056. if (tolerance > toleranceEpsilon) {
  87057. numberNotNormalized++;
  87058. }
  87059. }
  87060. }
  87061. // validate bone indices are in range of the skeleton
  87062. var numBones = this.skeleton.bones.length;
  87063. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  87064. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  87065. var numBadBoneIndices = 0;
  87066. for (var a = 0; a < numWeights; a++) {
  87067. for (var b = 0; b < numInfluences; b++) {
  87068. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  87069. if (index >= numBones || index < 0) {
  87070. numBadBoneIndices++;
  87071. }
  87072. }
  87073. }
  87074. // log mesh stats
  87075. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  87076. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  87077. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  87078. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  87079. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  87080. };
  87081. /** @hidden */
  87082. Mesh.prototype._checkDelayState = function () {
  87083. var scene = this.getScene();
  87084. if (this._geometry) {
  87085. this._geometry.load(scene);
  87086. }
  87087. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  87088. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  87089. this._queueLoad(scene);
  87090. }
  87091. return this;
  87092. };
  87093. Mesh.prototype._queueLoad = function (scene) {
  87094. var _this = this;
  87095. scene._addPendingData(this);
  87096. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  87097. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  87098. if (data instanceof ArrayBuffer) {
  87099. _this._delayLoadingFunction(data, _this);
  87100. }
  87101. else {
  87102. _this._delayLoadingFunction(JSON.parse(data), _this);
  87103. }
  87104. _this.instances.forEach(function (instance) {
  87105. instance._syncSubMeshes();
  87106. });
  87107. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  87108. scene._removePendingData(_this);
  87109. }, function () { }, scene.offlineProvider, getBinaryData);
  87110. return this;
  87111. };
  87112. /**
  87113. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87114. * A mesh is in the frustum if its bounding box intersects the frustum
  87115. * @param frustumPlanes defines the frustum to test
  87116. * @returns true if the mesh is in the frustum planes
  87117. */
  87118. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  87119. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  87120. return false;
  87121. }
  87122. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  87123. return false;
  87124. }
  87125. this._checkDelayState();
  87126. return true;
  87127. };
  87128. /**
  87129. * Sets the mesh material by the material or multiMaterial `id` property
  87130. * @param id is a string identifying the material or the multiMaterial
  87131. * @returns the current mesh
  87132. */
  87133. Mesh.prototype.setMaterialByID = function (id) {
  87134. var materials = this.getScene().materials;
  87135. var index;
  87136. for (index = materials.length - 1; index > -1; index--) {
  87137. if (materials[index].id === id) {
  87138. this.material = materials[index];
  87139. return this;
  87140. }
  87141. }
  87142. // Multi
  87143. var multiMaterials = this.getScene().multiMaterials;
  87144. for (index = multiMaterials.length - 1; index > -1; index--) {
  87145. if (multiMaterials[index].id === id) {
  87146. this.material = multiMaterials[index];
  87147. return this;
  87148. }
  87149. }
  87150. return this;
  87151. };
  87152. /**
  87153. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  87154. * @returns an array of IAnimatable
  87155. */
  87156. Mesh.prototype.getAnimatables = function () {
  87157. var results = new Array();
  87158. if (this.material) {
  87159. results.push(this.material);
  87160. }
  87161. if (this.skeleton) {
  87162. results.push(this.skeleton);
  87163. }
  87164. return results;
  87165. };
  87166. /**
  87167. * Modifies the mesh geometry according to the passed transformation matrix.
  87168. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  87169. * The mesh normals are modified using the same transformation.
  87170. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87171. * @param transform defines the transform matrix to use
  87172. * @see http://doc.babylonjs.com/resources/baking_transformations
  87173. * @returns the current mesh
  87174. */
  87175. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  87176. // Position
  87177. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  87178. return this;
  87179. }
  87180. var submeshes = this.subMeshes.splice(0);
  87181. this._resetPointsArrayCache();
  87182. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87183. var temp = new Array();
  87184. var index;
  87185. for (index = 0; index < data.length; index += 3) {
  87186. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  87187. }
  87188. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  87189. // Normals
  87190. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  87191. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87192. temp = [];
  87193. for (index = 0; index < data.length; index += 3) {
  87194. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  87195. }
  87196. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  87197. }
  87198. // flip faces?
  87199. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  87200. this.flipFaces();
  87201. }
  87202. // Restore submeshes
  87203. this.releaseSubMeshes();
  87204. this.subMeshes = submeshes;
  87205. return this;
  87206. };
  87207. /**
  87208. * Modifies the mesh geometry according to its own current World Matrix.
  87209. * The mesh World Matrix is then reset.
  87210. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  87211. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87212. * @see http://doc.babylonjs.com/resources/baking_transformations
  87213. * @returns the current mesh
  87214. */
  87215. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  87216. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  87217. this.scaling.copyFromFloats(1, 1, 1);
  87218. this.position.copyFromFloats(0, 0, 0);
  87219. this.rotation.copyFromFloats(0, 0, 0);
  87220. //only if quaternion is already set
  87221. if (this.rotationQuaternion) {
  87222. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  87223. }
  87224. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  87225. return this;
  87226. };
  87227. Object.defineProperty(Mesh.prototype, "_positions", {
  87228. // Cache
  87229. /** @hidden */
  87230. get: function () {
  87231. if (this._geometry) {
  87232. return this._geometry._positions;
  87233. }
  87234. return null;
  87235. },
  87236. enumerable: true,
  87237. configurable: true
  87238. });
  87239. /** @hidden */
  87240. Mesh.prototype._resetPointsArrayCache = function () {
  87241. if (this._geometry) {
  87242. this._geometry._resetPointsArrayCache();
  87243. }
  87244. return this;
  87245. };
  87246. /** @hidden */
  87247. Mesh.prototype._generatePointsArray = function () {
  87248. if (this._geometry) {
  87249. return this._geometry._generatePointsArray();
  87250. }
  87251. return false;
  87252. };
  87253. /**
  87254. * Returns a new Mesh object generated from the current mesh properties.
  87255. * This method must not get confused with createInstance()
  87256. * @param name is a string, the name given to the new mesh
  87257. * @param newParent can be any Node object (default `null`)
  87258. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87259. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87260. * @returns a new mesh
  87261. */
  87262. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  87263. if (name === void 0) { name = ""; }
  87264. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  87265. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  87266. };
  87267. /**
  87268. * Releases resources associated with this mesh.
  87269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87271. */
  87272. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  87273. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  87274. this.morphTargetManager = null;
  87275. if (this._geometry) {
  87276. this._geometry.releaseForMesh(this, true);
  87277. }
  87278. if (this._onBeforeDrawObservable) {
  87279. this._onBeforeDrawObservable.clear();
  87280. }
  87281. if (this._onBeforeBindObservable) {
  87282. this._onBeforeBindObservable.clear();
  87283. }
  87284. if (this._onBeforeRenderObservable) {
  87285. this._onBeforeRenderObservable.clear();
  87286. }
  87287. if (this._onAfterRenderObservable) {
  87288. this._onAfterRenderObservable.clear();
  87289. }
  87290. // Sources
  87291. if (this._scene.useClonedMeshhMap) {
  87292. if (this.meshMap) {
  87293. for (var uniqueId in this.meshMap) {
  87294. var mesh = this.meshMap[uniqueId];
  87295. if (mesh) {
  87296. mesh._source = null;
  87297. this.meshMap[uniqueId] = undefined;
  87298. }
  87299. }
  87300. }
  87301. if (this._source && this._source.meshMap) {
  87302. this._source.meshMap[this.uniqueId] = undefined;
  87303. }
  87304. }
  87305. else {
  87306. var meshes = this.getScene().meshes;
  87307. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  87308. var abstractMesh = meshes_1[_i];
  87309. var mesh = abstractMesh;
  87310. if (mesh._source && mesh._source === this) {
  87311. mesh._source = null;
  87312. }
  87313. }
  87314. }
  87315. this._source = null;
  87316. // Instances
  87317. if (this._instanceDataStorage.instancesBuffer) {
  87318. this._instanceDataStorage.instancesBuffer.dispose();
  87319. this._instanceDataStorage.instancesBuffer = null;
  87320. }
  87321. while (this.instances.length) {
  87322. this.instances[0].dispose();
  87323. }
  87324. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  87325. };
  87326. /**
  87327. * Modifies the mesh geometry according to a displacement map.
  87328. * 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.
  87329. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87330. * @param url is a string, the URL from the image file is to be downloaded.
  87331. * @param minHeight is the lower limit of the displacement.
  87332. * @param maxHeight is the upper limit of the displacement.
  87333. * @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.
  87334. * @param uvOffset is an optional vector2 used to offset UV.
  87335. * @param uvScale is an optional vector2 used to scale UV.
  87336. * @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.
  87337. * @returns the Mesh.
  87338. */
  87339. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  87340. var _this = this;
  87341. if (forceUpdate === void 0) { forceUpdate = false; }
  87342. var scene = this.getScene();
  87343. var onload = function (img) {
  87344. // Getting height map data
  87345. var canvas = document.createElement("canvas");
  87346. var context = canvas.getContext("2d");
  87347. var heightMapWidth = img.width;
  87348. var heightMapHeight = img.height;
  87349. canvas.width = heightMapWidth;
  87350. canvas.height = heightMapHeight;
  87351. context.drawImage(img, 0, 0);
  87352. // Create VertexData from map data
  87353. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  87354. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  87355. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  87356. //execute success callback, if set
  87357. if (onSuccess) {
  87358. onSuccess(_this);
  87359. }
  87360. };
  87361. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  87362. return this;
  87363. };
  87364. /**
  87365. * Modifies the mesh geometry according to a displacementMap buffer.
  87366. * 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.
  87367. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87368. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  87369. * @param heightMapWidth is the width of the buffer image.
  87370. * @param heightMapHeight is the height of the buffer image.
  87371. * @param minHeight is the lower limit of the displacement.
  87372. * @param maxHeight is the upper limit of the displacement.
  87373. * @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.
  87374. * @param uvOffset is an optional vector2 used to offset UV.
  87375. * @param uvScale is an optional vector2 used to scale UV.
  87376. * @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.
  87377. * @returns the Mesh.
  87378. */
  87379. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  87380. if (forceUpdate === void 0) { forceUpdate = false; }
  87381. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  87382. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  87383. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  87384. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  87385. return this;
  87386. }
  87387. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  87388. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87389. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  87390. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  87391. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  87392. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  87393. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  87394. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  87395. for (var index = 0; index < positions.length; index += 3) {
  87396. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  87397. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  87398. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  87399. // Compute height
  87400. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  87401. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  87402. var pos = (u + v * heightMapWidth) * 4;
  87403. var r = buffer[pos] / 255.0;
  87404. var g = buffer[pos + 1] / 255.0;
  87405. var b = buffer[pos + 2] / 255.0;
  87406. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  87407. normal.normalize();
  87408. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  87409. position = position.add(normal);
  87410. position.toArray(positions, index);
  87411. }
  87412. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  87413. if (forceUpdate) {
  87414. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  87415. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  87416. }
  87417. else {
  87418. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  87419. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  87420. }
  87421. return this;
  87422. };
  87423. /**
  87424. * Modify the mesh to get a flat shading rendering.
  87425. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  87426. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  87427. * @returns current mesh
  87428. */
  87429. Mesh.prototype.convertToFlatShadedMesh = function () {
  87430. var kinds = this.getVerticesDataKinds();
  87431. var vbs = {};
  87432. var data = {};
  87433. var newdata = {};
  87434. var updatableNormals = false;
  87435. var kindIndex;
  87436. var kind;
  87437. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87438. kind = kinds[kindIndex];
  87439. var vertexBuffer = this.getVertexBuffer(kind);
  87440. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  87441. updatableNormals = vertexBuffer.isUpdatable();
  87442. kinds.splice(kindIndex, 1);
  87443. kindIndex--;
  87444. continue;
  87445. }
  87446. vbs[kind] = vertexBuffer;
  87447. data[kind] = vbs[kind].getData();
  87448. newdata[kind] = [];
  87449. }
  87450. // Save previous submeshes
  87451. var previousSubmeshes = this.subMeshes.slice(0);
  87452. var indices = this.getIndices();
  87453. var totalIndices = this.getTotalIndices();
  87454. // Generating unique vertices per face
  87455. var index;
  87456. for (index = 0; index < totalIndices; index++) {
  87457. var vertexIndex = indices[index];
  87458. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87459. kind = kinds[kindIndex];
  87460. var stride = vbs[kind].getStrideSize();
  87461. for (var offset = 0; offset < stride; offset++) {
  87462. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  87463. }
  87464. }
  87465. }
  87466. // Updating faces & normal
  87467. var normals = [];
  87468. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  87469. for (index = 0; index < totalIndices; index += 3) {
  87470. indices[index] = index;
  87471. indices[index + 1] = index + 1;
  87472. indices[index + 2] = index + 2;
  87473. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  87474. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  87475. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  87476. var p1p2 = p1.subtract(p2);
  87477. var p3p2 = p3.subtract(p2);
  87478. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  87479. // Store same normals for every vertex
  87480. for (var localIndex = 0; localIndex < 3; localIndex++) {
  87481. normals.push(normal.x);
  87482. normals.push(normal.y);
  87483. normals.push(normal.z);
  87484. }
  87485. }
  87486. this.setIndices(indices);
  87487. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  87488. // Updating vertex buffers
  87489. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87490. kind = kinds[kindIndex];
  87491. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  87492. }
  87493. // Updating submeshes
  87494. this.releaseSubMeshes();
  87495. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  87496. var previousOne = previousSubmeshes[submeshIndex];
  87497. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  87498. }
  87499. this.synchronizeInstances();
  87500. return this;
  87501. };
  87502. /**
  87503. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87504. * In other words, more vertices, no more indices and a single bigger VBO.
  87505. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87506. * @returns current mesh
  87507. */
  87508. Mesh.prototype.convertToUnIndexedMesh = function () {
  87509. var kinds = this.getVerticesDataKinds();
  87510. var vbs = {};
  87511. var data = {};
  87512. var newdata = {};
  87513. var kindIndex;
  87514. var kind;
  87515. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87516. kind = kinds[kindIndex];
  87517. var vertexBuffer = this.getVertexBuffer(kind);
  87518. vbs[kind] = vertexBuffer;
  87519. data[kind] = vbs[kind].getData();
  87520. newdata[kind] = [];
  87521. }
  87522. // Save previous submeshes
  87523. var previousSubmeshes = this.subMeshes.slice(0);
  87524. var indices = this.getIndices();
  87525. var totalIndices = this.getTotalIndices();
  87526. // Generating unique vertices per face
  87527. var index;
  87528. for (index = 0; index < totalIndices; index++) {
  87529. var vertexIndex = indices[index];
  87530. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87531. kind = kinds[kindIndex];
  87532. var stride = vbs[kind].getStrideSize();
  87533. for (var offset = 0; offset < stride; offset++) {
  87534. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  87535. }
  87536. }
  87537. }
  87538. // Updating indices
  87539. for (index = 0; index < totalIndices; index += 3) {
  87540. indices[index] = index;
  87541. indices[index + 1] = index + 1;
  87542. indices[index + 2] = index + 2;
  87543. }
  87544. this.setIndices(indices);
  87545. // Updating vertex buffers
  87546. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87547. kind = kinds[kindIndex];
  87548. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  87549. }
  87550. // Updating submeshes
  87551. this.releaseSubMeshes();
  87552. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  87553. var previousOne = previousSubmeshes[submeshIndex];
  87554. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  87555. }
  87556. this._unIndexed = true;
  87557. this.synchronizeInstances();
  87558. return this;
  87559. };
  87560. /**
  87561. * Inverses facet orientations.
  87562. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87563. * @param flipNormals will also inverts the normals
  87564. * @returns current mesh
  87565. */
  87566. Mesh.prototype.flipFaces = function (flipNormals) {
  87567. if (flipNormals === void 0) { flipNormals = false; }
  87568. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  87569. var i;
  87570. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  87571. for (i = 0; i < vertex_data.normals.length; i++) {
  87572. vertex_data.normals[i] *= -1;
  87573. }
  87574. }
  87575. if (vertex_data.indices) {
  87576. var temp;
  87577. for (i = 0; i < vertex_data.indices.length; i += 3) {
  87578. // reassign indices
  87579. temp = vertex_data.indices[i + 1];
  87580. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  87581. vertex_data.indices[i + 2] = temp;
  87582. }
  87583. }
  87584. vertex_data.applyToMesh(this);
  87585. return this;
  87586. };
  87587. // Instances
  87588. /** @hidden */
  87589. Mesh._instancedMeshFactory = function (name, mesh) {
  87590. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  87591. };
  87592. /** @hidden */
  87593. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  87594. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  87595. };
  87596. /**
  87597. * Creates a new InstancedMesh object from the mesh model.
  87598. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87599. * @param name defines the name of the new instance
  87600. * @returns a new InstancedMesh
  87601. */
  87602. Mesh.prototype.createInstance = function (name) {
  87603. return Mesh._instancedMeshFactory(name, this);
  87604. };
  87605. /**
  87606. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  87607. * After this call, all the mesh instances have the same submeshes than the current mesh.
  87608. * @returns the current mesh
  87609. */
  87610. Mesh.prototype.synchronizeInstances = function () {
  87611. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  87612. var instance = this.instances[instanceIndex];
  87613. instance._syncSubMeshes();
  87614. }
  87615. return this;
  87616. };
  87617. /**
  87618. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  87619. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  87620. * This should be used together with the simplification to avoid disappearing triangles.
  87621. * @param successCallback an optional success callback to be called after the optimization finished.
  87622. * @returns the current mesh
  87623. */
  87624. Mesh.prototype.optimizeIndices = function (successCallback) {
  87625. var _this = this;
  87626. var indices = this.getIndices();
  87627. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87628. if (!positions || !indices) {
  87629. return this;
  87630. }
  87631. var vectorPositions = new Array();
  87632. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  87633. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  87634. }
  87635. var dupes = new Array();
  87636. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  87637. var realPos = vectorPositions.length - 1 - iteration;
  87638. var testedPosition = vectorPositions[realPos];
  87639. for (var j = 0; j < realPos; ++j) {
  87640. var againstPosition = vectorPositions[j];
  87641. if (testedPosition.equals(againstPosition)) {
  87642. dupes[realPos] = j;
  87643. break;
  87644. }
  87645. }
  87646. }, function () {
  87647. for (var i = 0; i < indices.length; ++i) {
  87648. indices[i] = dupes[indices[i]] || indices[i];
  87649. }
  87650. //indices are now reordered
  87651. var originalSubMeshes = _this.subMeshes.slice(0);
  87652. _this.setIndices(indices);
  87653. _this.subMeshes = originalSubMeshes;
  87654. if (successCallback) {
  87655. successCallback(_this);
  87656. }
  87657. });
  87658. return this;
  87659. };
  87660. /**
  87661. * Serialize current mesh
  87662. * @param serializationObject defines the object which will receive the serialization data
  87663. */
  87664. Mesh.prototype.serialize = function (serializationObject) {
  87665. serializationObject.name = this.name;
  87666. serializationObject.id = this.id;
  87667. serializationObject.type = this.getClassName();
  87668. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  87669. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  87670. }
  87671. serializationObject.position = this.position.asArray();
  87672. if (this.rotationQuaternion) {
  87673. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  87674. }
  87675. else if (this.rotation) {
  87676. serializationObject.rotation = this.rotation.asArray();
  87677. }
  87678. serializationObject.scaling = this.scaling.asArray();
  87679. if (this._postMultiplyPivotMatrix) {
  87680. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  87681. }
  87682. else {
  87683. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  87684. }
  87685. serializationObject.isEnabled = this.isEnabled(false);
  87686. serializationObject.isVisible = this.isVisible;
  87687. serializationObject.infiniteDistance = this.infiniteDistance;
  87688. serializationObject.pickable = this.isPickable;
  87689. serializationObject.receiveShadows = this.receiveShadows;
  87690. serializationObject.billboardMode = this.billboardMode;
  87691. serializationObject.visibility = this.visibility;
  87692. serializationObject.checkCollisions = this.checkCollisions;
  87693. serializationObject.isBlocker = this.isBlocker;
  87694. // Parent
  87695. if (this.parent) {
  87696. serializationObject.parentId = this.parent.id;
  87697. }
  87698. // Geometry
  87699. serializationObject.isUnIndexed = this.isUnIndexed;
  87700. var geometry = this._geometry;
  87701. if (geometry) {
  87702. var geometryId = geometry.id;
  87703. serializationObject.geometryId = geometryId;
  87704. // SubMeshes
  87705. serializationObject.subMeshes = [];
  87706. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  87707. var subMesh = this.subMeshes[subIndex];
  87708. serializationObject.subMeshes.push({
  87709. materialIndex: subMesh.materialIndex,
  87710. verticesStart: subMesh.verticesStart,
  87711. verticesCount: subMesh.verticesCount,
  87712. indexStart: subMesh.indexStart,
  87713. indexCount: subMesh.indexCount
  87714. });
  87715. }
  87716. }
  87717. // Material
  87718. if (this.material) {
  87719. serializationObject.materialId = this.material.id;
  87720. }
  87721. else {
  87722. this.material = null;
  87723. }
  87724. // Morph targets
  87725. if (this.morphTargetManager) {
  87726. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  87727. }
  87728. // Skeleton
  87729. if (this.skeleton) {
  87730. serializationObject.skeletonId = this.skeleton.id;
  87731. }
  87732. // Physics
  87733. //TODO implement correct serialization for physics impostors.
  87734. var impostor = this.getPhysicsImpostor();
  87735. if (impostor) {
  87736. serializationObject.physicsMass = impostor.getParam("mass");
  87737. serializationObject.physicsFriction = impostor.getParam("friction");
  87738. serializationObject.physicsRestitution = impostor.getParam("mass");
  87739. serializationObject.physicsImpostor = impostor.type;
  87740. }
  87741. // Metadata
  87742. if (this.metadata) {
  87743. serializationObject.metadata = this.metadata;
  87744. }
  87745. // Instances
  87746. serializationObject.instances = [];
  87747. for (var index = 0; index < this.instances.length; index++) {
  87748. var instance = this.instances[index];
  87749. if (instance.doNotSerialize) {
  87750. continue;
  87751. }
  87752. var serializationInstance = {
  87753. name: instance.name,
  87754. id: instance.id,
  87755. position: instance.position.asArray(),
  87756. scaling: instance.scaling.asArray()
  87757. };
  87758. if (instance.parent) {
  87759. serializationInstance.parentId = instance.parent.id;
  87760. }
  87761. if (instance.rotationQuaternion) {
  87762. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  87763. }
  87764. else if (instance.rotation) {
  87765. serializationInstance.rotation = instance.rotation.asArray();
  87766. }
  87767. serializationObject.instances.push(serializationInstance);
  87768. // Animations
  87769. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  87770. serializationInstance.ranges = instance.serializeAnimationRanges();
  87771. }
  87772. //
  87773. // Animations
  87774. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  87775. serializationObject.ranges = this.serializeAnimationRanges();
  87776. // Layer mask
  87777. serializationObject.layerMask = this.layerMask;
  87778. // Alpha
  87779. serializationObject.alphaIndex = this.alphaIndex;
  87780. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  87781. // Overlay
  87782. serializationObject.overlayAlpha = this.overlayAlpha;
  87783. serializationObject.overlayColor = this.overlayColor.asArray();
  87784. serializationObject.renderOverlay = this.renderOverlay;
  87785. // Fog
  87786. serializationObject.applyFog = this.applyFog;
  87787. // Action Manager
  87788. if (this.actionManager) {
  87789. serializationObject.actions = this.actionManager.serialize(this.name);
  87790. }
  87791. };
  87792. /** @hidden */
  87793. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  87794. if (!this.geometry) {
  87795. return;
  87796. }
  87797. this._markSubMeshesAsAttributesDirty();
  87798. var morphTargetManager = this._morphTargetManager;
  87799. if (morphTargetManager && morphTargetManager.vertexCount) {
  87800. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  87801. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  87802. this.morphTargetManager = null;
  87803. return;
  87804. }
  87805. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  87806. var morphTarget = morphTargetManager.getActiveTarget(index);
  87807. var positions = morphTarget.getPositions();
  87808. if (!positions) {
  87809. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  87810. return;
  87811. }
  87812. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  87813. var normals = morphTarget.getNormals();
  87814. if (normals) {
  87815. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  87816. }
  87817. var tangents = morphTarget.getTangents();
  87818. if (tangents) {
  87819. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  87820. }
  87821. }
  87822. }
  87823. else {
  87824. var index = 0;
  87825. // Positions
  87826. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  87827. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  87828. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  87829. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  87830. }
  87831. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  87832. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  87833. }
  87834. index++;
  87835. }
  87836. }
  87837. };
  87838. /**
  87839. * Returns a new Mesh object parsed from the source provided.
  87840. * @param parsedMesh is the source
  87841. * @param scene defines the hosting scene
  87842. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  87843. * @returns a new Mesh
  87844. */
  87845. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  87846. var mesh;
  87847. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  87848. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  87849. }
  87850. else {
  87851. mesh = new Mesh(parsedMesh.name, scene);
  87852. }
  87853. mesh.id = parsedMesh.id;
  87854. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  87855. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  87856. }
  87857. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  87858. if (parsedMesh.metadata !== undefined) {
  87859. mesh.metadata = parsedMesh.metadata;
  87860. }
  87861. if (parsedMesh.rotationQuaternion) {
  87862. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  87863. }
  87864. else if (parsedMesh.rotation) {
  87865. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  87866. }
  87867. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  87868. if (parsedMesh.localMatrix) {
  87869. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  87870. }
  87871. else if (parsedMesh.pivotMatrix) {
  87872. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  87873. }
  87874. mesh.setEnabled(parsedMesh.isEnabled);
  87875. mesh.isVisible = parsedMesh.isVisible;
  87876. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  87877. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  87878. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  87879. if (parsedMesh.applyFog !== undefined) {
  87880. mesh.applyFog = parsedMesh.applyFog;
  87881. }
  87882. if (parsedMesh.pickable !== undefined) {
  87883. mesh.isPickable = parsedMesh.pickable;
  87884. }
  87885. if (parsedMesh.alphaIndex !== undefined) {
  87886. mesh.alphaIndex = parsedMesh.alphaIndex;
  87887. }
  87888. mesh.receiveShadows = parsedMesh.receiveShadows;
  87889. mesh.billboardMode = parsedMesh.billboardMode;
  87890. if (parsedMesh.visibility !== undefined) {
  87891. mesh.visibility = parsedMesh.visibility;
  87892. }
  87893. mesh.checkCollisions = parsedMesh.checkCollisions;
  87894. if (parsedMesh.isBlocker !== undefined) {
  87895. mesh.isBlocker = parsedMesh.isBlocker;
  87896. }
  87897. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  87898. // freezeWorldMatrix
  87899. if (parsedMesh.freezeWorldMatrix) {
  87900. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  87901. }
  87902. // Parent
  87903. if (parsedMesh.parentId) {
  87904. mesh._waitingParentId = parsedMesh.parentId;
  87905. }
  87906. // Actions
  87907. if (parsedMesh.actions !== undefined) {
  87908. mesh._waitingActions = parsedMesh.actions;
  87909. }
  87910. // Overlay
  87911. if (parsedMesh.overlayAlpha !== undefined) {
  87912. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  87913. }
  87914. if (parsedMesh.overlayColor !== undefined) {
  87915. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  87916. }
  87917. if (parsedMesh.renderOverlay !== undefined) {
  87918. mesh.renderOverlay = parsedMesh.renderOverlay;
  87919. }
  87920. // Geometry
  87921. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  87922. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  87923. if (parsedMesh.delayLoadingFile) {
  87924. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  87925. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  87926. 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));
  87927. if (parsedMesh._binaryInfo) {
  87928. mesh._binaryInfo = parsedMesh._binaryInfo;
  87929. }
  87930. mesh._delayInfo = [];
  87931. if (parsedMesh.hasUVs) {
  87932. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  87933. }
  87934. if (parsedMesh.hasUVs2) {
  87935. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  87936. }
  87937. if (parsedMesh.hasUVs3) {
  87938. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  87939. }
  87940. if (parsedMesh.hasUVs4) {
  87941. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  87942. }
  87943. if (parsedMesh.hasUVs5) {
  87944. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  87945. }
  87946. if (parsedMesh.hasUVs6) {
  87947. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  87948. }
  87949. if (parsedMesh.hasColors) {
  87950. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  87951. }
  87952. if (parsedMesh.hasMatricesIndices) {
  87953. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  87954. }
  87955. if (parsedMesh.hasMatricesWeights) {
  87956. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87957. }
  87958. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  87959. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  87960. mesh._checkDelayState();
  87961. }
  87962. }
  87963. else {
  87964. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  87965. }
  87966. // Material
  87967. if (parsedMesh.materialId) {
  87968. mesh.setMaterialByID(parsedMesh.materialId);
  87969. }
  87970. else {
  87971. mesh.material = null;
  87972. }
  87973. // Morph targets
  87974. if (parsedMesh.morphTargetManagerId > -1) {
  87975. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  87976. }
  87977. // Skeleton
  87978. if (parsedMesh.skeletonId > -1) {
  87979. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  87980. if (parsedMesh.numBoneInfluencers) {
  87981. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  87982. }
  87983. }
  87984. // Animations
  87985. if (parsedMesh.animations) {
  87986. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  87987. var parsedAnimation = parsedMesh.animations[animationIndex];
  87988. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  87989. if (internalClass) {
  87990. mesh.animations.push(internalClass.Parse(parsedAnimation));
  87991. }
  87992. }
  87993. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  87994. }
  87995. if (parsedMesh.autoAnimate) {
  87996. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  87997. }
  87998. // Layer Mask
  87999. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  88000. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  88001. }
  88002. else {
  88003. mesh.layerMask = 0x0FFFFFFF;
  88004. }
  88005. // Physics
  88006. if (parsedMesh.physicsImpostor) {
  88007. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  88008. }
  88009. // Instances
  88010. if (parsedMesh.instances) {
  88011. for (var index = 0; index < parsedMesh.instances.length; index++) {
  88012. var parsedInstance = parsedMesh.instances[index];
  88013. var instance = mesh.createInstance(parsedInstance.name);
  88014. if (parsedInstance.id) {
  88015. instance.id = parsedInstance.id;
  88016. }
  88017. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  88018. if (parsedInstance.tags) {
  88019. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  88020. }
  88021. else {
  88022. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  88023. }
  88024. }
  88025. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  88026. if (parsedInstance.parentId) {
  88027. instance._waitingParentId = parsedInstance.parentId;
  88028. }
  88029. if (parsedInstance.rotationQuaternion) {
  88030. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  88031. }
  88032. else if (parsedInstance.rotation) {
  88033. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  88034. }
  88035. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  88036. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  88037. instance.checkCollisions = parsedInstance.checkCollisions;
  88038. }
  88039. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  88040. instance.isPickable = parsedInstance.pickable;
  88041. }
  88042. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  88043. instance.showBoundingBox = parsedInstance.showBoundingBox;
  88044. }
  88045. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  88046. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  88047. }
  88048. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  88049. instance.alphaIndex = parsedInstance.alphaIndex;
  88050. }
  88051. // Physics
  88052. if (parsedInstance.physicsImpostor) {
  88053. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  88054. }
  88055. // Animation
  88056. if (parsedInstance.animations) {
  88057. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  88058. parsedAnimation = parsedInstance.animations[animationIndex];
  88059. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  88060. if (internalClass) {
  88061. instance.animations.push(internalClass.Parse(parsedAnimation));
  88062. }
  88063. }
  88064. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  88065. if (parsedInstance.autoAnimate) {
  88066. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  88067. }
  88068. }
  88069. }
  88070. }
  88071. return mesh;
  88072. };
  88073. /**
  88074. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88075. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88076. * @param name defines the name of the mesh to create
  88077. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88078. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88079. * @param closePath creates a seam between the first and the last points of each path of the path array
  88080. * @param offset is taken in account only if the `pathArray` is containing a single path
  88081. * @param scene defines the hosting scene
  88082. * @param updatable defines if the mesh must be flagged as updatable
  88083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88084. * @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)
  88085. * @returns a new Mesh
  88086. */
  88087. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  88088. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88089. };
  88090. /**
  88091. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88092. * @param name defines the name of the mesh to create
  88093. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88094. * @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
  88095. * @param scene defines the hosting scene
  88096. * @param updatable defines if the mesh must be flagged as updatable
  88097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88098. * @returns a new Mesh
  88099. */
  88100. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  88101. if (scene === void 0) { scene = null; }
  88102. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88103. };
  88104. /**
  88105. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88106. * @param name defines the name of the mesh to create
  88107. * @param size sets the size (float) of each box side (default 1)
  88108. * @param scene defines the hosting scene
  88109. * @param updatable defines if the mesh must be flagged as updatable
  88110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88111. * @returns a new Mesh
  88112. */
  88113. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  88114. if (scene === void 0) { scene = null; }
  88115. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88116. };
  88117. /**
  88118. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88119. * @param name defines the name of the mesh to create
  88120. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88121. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88122. * @param scene defines the hosting scene
  88123. * @param updatable defines if the mesh must be flagged as updatable
  88124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88125. * @returns a new Mesh
  88126. */
  88127. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  88128. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88129. };
  88130. /**
  88131. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88132. * @param name defines the name of the mesh to create
  88133. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88134. * @param diameterTop set the top cap diameter (floats, default 1)
  88135. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  88136. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  88137. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  88138. * @param scene defines the hosting scene
  88139. * @param updatable defines if the mesh must be flagged as updatable
  88140. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88141. * @returns a new Mesh
  88142. */
  88143. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  88144. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88145. };
  88146. // Torus (Code from SharpDX.org)
  88147. /**
  88148. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88149. * @param name defines the name of the mesh to create
  88150. * @param diameter sets the diameter size (float) of the torus (default 1)
  88151. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88152. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88153. * @param scene defines the hosting scene
  88154. * @param updatable defines if the mesh must be flagged as updatable
  88155. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88156. * @returns a new Mesh
  88157. */
  88158. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  88159. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88160. };
  88161. /**
  88162. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88163. * @param name defines the name of the mesh to create
  88164. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88165. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88166. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88167. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88168. * @param p the number of windings on X axis (positive integers, default 2)
  88169. * @param q the number of windings on Y axis (positive integers, default 3)
  88170. * @param scene defines the hosting scene
  88171. * @param updatable defines if the mesh must be flagged as updatable
  88172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88173. * @returns a new Mesh
  88174. */
  88175. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  88176. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88177. };
  88178. /**
  88179. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  88180. * @param name defines the name of the mesh to create
  88181. * @param points is an array successive Vector3
  88182. * @param scene defines the hosting scene
  88183. * @param updatable defines if the mesh must be flagged as updatable
  88184. * @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).
  88185. * @returns a new Mesh
  88186. */
  88187. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  88188. if (scene === void 0) { scene = null; }
  88189. if (updatable === void 0) { updatable = false; }
  88190. if (instance === void 0) { instance = null; }
  88191. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88192. };
  88193. /**
  88194. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88195. * @param name defines the name of the mesh to create
  88196. * @param points is an array successive Vector3
  88197. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88198. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88199. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88200. * @param scene defines the hosting scene
  88201. * @param updatable defines if the mesh must be flagged as updatable
  88202. * @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)
  88203. * @returns a new Mesh
  88204. */
  88205. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  88206. if (scene === void 0) { scene = null; }
  88207. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88208. };
  88209. /**
  88210. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88211. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88212. * 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.
  88213. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88214. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88215. * Remember you can only change the shape positions, not their number when updating a polygon.
  88216. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88217. * @param name defines the name of the mesh to create
  88218. * @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
  88219. * @param scene defines the hosting scene
  88220. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88221. * @param updatable defines if the mesh must be flagged as updatable
  88222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88223. * @param earcutInjection can be used to inject your own earcut reference
  88224. * @returns a new Mesh
  88225. */
  88226. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  88227. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88228. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88229. };
  88230. /**
  88231. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88232. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88233. * @param name defines the name of the mesh to create
  88234. * @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
  88235. * @param depth defines the height of extrusion
  88236. * @param scene defines the hosting scene
  88237. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88238. * @param updatable defines if the mesh must be flagged as updatable
  88239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88240. * @param earcutInjection can be used to inject your own earcut reference
  88241. * @returns a new Mesh
  88242. */
  88243. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  88244. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88245. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88246. };
  88247. /**
  88248. * Creates an extruded shape mesh.
  88249. * 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
  88250. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88251. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88252. * @param name defines the name of the mesh to create
  88253. * @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
  88254. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88255. * @param scale is the value to scale the shape
  88256. * @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
  88257. * @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
  88258. * @param scene defines the hosting scene
  88259. * @param updatable defines if the mesh must be flagged as updatable
  88260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88261. * @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)
  88262. * @returns a new Mesh
  88263. */
  88264. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  88265. if (scene === void 0) { scene = null; }
  88266. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88267. };
  88268. /**
  88269. * Creates an custom extruded shape mesh.
  88270. * The custom extrusion is a parametric shape.
  88271. * It has no predefined shape. Its final shape will depend on the input parameters.
  88272. * Please consider using the same method from the MeshBuilder class instead
  88273. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88274. * @param name defines the name of the mesh to create
  88275. * @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
  88276. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88277. * @param scaleFunction is a custom Javascript function called on each path point
  88278. * @param rotationFunction is a custom Javascript function called on each path point
  88279. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88280. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88281. * @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
  88282. * @param scene defines the hosting scene
  88283. * @param updatable defines if the mesh must be flagged as updatable
  88284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88285. * @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)
  88286. * @returns a new Mesh
  88287. */
  88288. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  88289. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88290. };
  88291. /**
  88292. * Creates lathe mesh.
  88293. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88294. * Please consider using the same method from the MeshBuilder class instead
  88295. * @param name defines the name of the mesh to create
  88296. * @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
  88297. * @param radius is the radius value of the lathe
  88298. * @param tessellation is the side number of the lathe.
  88299. * @param scene defines the hosting scene
  88300. * @param updatable defines if the mesh must be flagged as updatable
  88301. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88302. * @returns a new Mesh
  88303. */
  88304. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  88305. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88306. };
  88307. /**
  88308. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88309. * @param name defines the name of the mesh to create
  88310. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88311. * @param scene defines the hosting scene
  88312. * @param updatable defines if the mesh must be flagged as updatable
  88313. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88314. * @returns a new Mesh
  88315. */
  88316. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  88317. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88318. };
  88319. /**
  88320. * Creates a ground mesh.
  88321. * Please consider using the same method from the MeshBuilder class instead
  88322. * @param name defines the name of the mesh to create
  88323. * @param width set the width of the ground
  88324. * @param height set the height of the ground
  88325. * @param subdivisions sets the number of subdivisions per side
  88326. * @param scene defines the hosting scene
  88327. * @param updatable defines if the mesh must be flagged as updatable
  88328. * @returns a new Mesh
  88329. */
  88330. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  88331. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88332. };
  88333. /**
  88334. * Creates a tiled ground mesh.
  88335. * Please consider using the same method from the MeshBuilder class instead
  88336. * @param name defines the name of the mesh to create
  88337. * @param xmin set the ground minimum X coordinate
  88338. * @param zmin set the ground minimum Y coordinate
  88339. * @param xmax set the ground maximum X coordinate
  88340. * @param zmax set the ground maximum Z coordinate
  88341. * @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
  88342. * @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
  88343. * @param scene defines the hosting scene
  88344. * @param updatable defines if the mesh must be flagged as updatable
  88345. * @returns a new Mesh
  88346. */
  88347. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  88348. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88349. };
  88350. /**
  88351. * Creates a ground mesh from a height map.
  88352. * Please consider using the same method from the MeshBuilder class instead
  88353. * @see http://doc.babylonjs.com/babylon101/height_map
  88354. * @param name defines the name of the mesh to create
  88355. * @param url sets the URL of the height map image resource
  88356. * @param width set the ground width size
  88357. * @param height set the ground height size
  88358. * @param subdivisions sets the number of subdivision per side
  88359. * @param minHeight is the minimum altitude on the ground
  88360. * @param maxHeight is the maximum altitude on the ground
  88361. * @param scene defines the hosting scene
  88362. * @param updatable defines if the mesh must be flagged as updatable
  88363. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88364. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88365. * @returns a new Mesh
  88366. */
  88367. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  88368. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88369. };
  88370. /**
  88371. * Creates a tube mesh.
  88372. * The tube is a parametric shape.
  88373. * It has no predefined shape. Its final shape will depend on the input parameters.
  88374. * Please consider using the same method from the MeshBuilder class instead
  88375. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88376. * @param name defines the name of the mesh to create
  88377. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88378. * @param radius sets the tube radius size
  88379. * @param tessellation is the number of sides on the tubular surface
  88380. * @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
  88381. * @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
  88382. * @param scene defines the hosting scene
  88383. * @param updatable defines if the mesh must be flagged as updatable
  88384. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88385. * @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)
  88386. * @returns a new Mesh
  88387. */
  88388. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  88389. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88390. };
  88391. /**
  88392. * Creates a polyhedron mesh.
  88393. * Please consider using the same method from the MeshBuilder class instead.
  88394. * * 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
  88395. * * The parameter `size` (positive float, default 1) sets the polygon size
  88396. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88397. * * 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`
  88398. * * 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
  88399. * * 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)`)
  88400. * * 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
  88401. * * 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
  88402. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88403. * * 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
  88404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88405. * @param name defines the name of the mesh to create
  88406. * @param options defines the options used to create the mesh
  88407. * @param scene defines the hosting scene
  88408. * @returns a new Mesh
  88409. */
  88410. Mesh.CreatePolyhedron = function (name, options, scene) {
  88411. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88412. };
  88413. /**
  88414. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88415. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88416. * * 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`)
  88417. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88418. * * 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
  88419. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88420. * * 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
  88421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88422. * @param name defines the name of the mesh
  88423. * @param options defines the options used to create the mesh
  88424. * @param scene defines the hosting scene
  88425. * @returns a new Mesh
  88426. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88427. */
  88428. Mesh.CreateIcoSphere = function (name, options, scene) {
  88429. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88430. };
  88431. /**
  88432. * Creates a decal mesh.
  88433. * Please consider using the same method from the MeshBuilder class instead.
  88434. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88435. * @param name defines the name of the mesh
  88436. * @param sourceMesh defines the mesh receiving the decal
  88437. * @param position sets the position of the decal in world coordinates
  88438. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88439. * @param size sets the decal scaling
  88440. * @param angle sets the angle to rotate the decal
  88441. * @returns a new Mesh
  88442. */
  88443. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  88444. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  88445. };
  88446. // Skeletons
  88447. /**
  88448. * Prepare internal position array for software CPU skinning
  88449. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88450. */
  88451. Mesh.prototype.setPositionsForCPUSkinning = function () {
  88452. if (!this._sourcePositions) {
  88453. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88454. if (!source) {
  88455. return this._sourcePositions;
  88456. }
  88457. this._sourcePositions = new Float32Array(source);
  88458. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  88459. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  88460. }
  88461. }
  88462. return this._sourcePositions;
  88463. };
  88464. /**
  88465. * Prepare internal normal array for software CPU skinning
  88466. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88467. */
  88468. Mesh.prototype.setNormalsForCPUSkinning = function () {
  88469. if (!this._sourceNormals) {
  88470. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88471. if (!source) {
  88472. return this._sourceNormals;
  88473. }
  88474. this._sourceNormals = new Float32Array(source);
  88475. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  88476. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  88477. }
  88478. }
  88479. return this._sourceNormals;
  88480. };
  88481. /**
  88482. * Updates the vertex buffer by applying transformation from the bones
  88483. * @param skeleton defines the skeleton to apply to current mesh
  88484. * @returns the current mesh
  88485. */
  88486. Mesh.prototype.applySkeleton = function (skeleton) {
  88487. if (!this.geometry) {
  88488. return this;
  88489. }
  88490. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  88491. return this;
  88492. }
  88493. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  88494. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  88495. return this;
  88496. }
  88497. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  88498. return this;
  88499. }
  88500. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  88501. return this;
  88502. }
  88503. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  88504. return this;
  88505. }
  88506. if (!this._sourcePositions) {
  88507. var submeshes = this.subMeshes.slice();
  88508. this.setPositionsForCPUSkinning();
  88509. this.subMeshes = submeshes;
  88510. }
  88511. if (!this._sourceNormals) {
  88512. this.setNormalsForCPUSkinning();
  88513. }
  88514. // positionsData checks for not being Float32Array will only pass at most once
  88515. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88516. if (!positionsData) {
  88517. return this;
  88518. }
  88519. if (!(positionsData instanceof Float32Array)) {
  88520. positionsData = new Float32Array(positionsData);
  88521. }
  88522. // normalsData checks for not being Float32Array will only pass at most once
  88523. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88524. if (!normalsData) {
  88525. return this;
  88526. }
  88527. if (!(normalsData instanceof Float32Array)) {
  88528. normalsData = new Float32Array(normalsData);
  88529. }
  88530. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  88531. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88532. if (!matricesWeightsData || !matricesIndicesData) {
  88533. return this;
  88534. }
  88535. var needExtras = this.numBoneInfluencers > 4;
  88536. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  88537. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  88538. var skeletonMatrices = skeleton.getTransformMatrices(this);
  88539. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  88540. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  88541. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  88542. var matWeightIdx = 0;
  88543. var inf;
  88544. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  88545. var weight;
  88546. for (inf = 0; inf < 4; inf++) {
  88547. weight = matricesWeightsData[matWeightIdx + inf];
  88548. if (weight > 0) {
  88549. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  88550. finalMatrix.addToSelf(tempMatrix);
  88551. }
  88552. }
  88553. if (needExtras) {
  88554. for (inf = 0; inf < 4; inf++) {
  88555. weight = matricesWeightsExtraData[matWeightIdx + inf];
  88556. if (weight > 0) {
  88557. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  88558. finalMatrix.addToSelf(tempMatrix);
  88559. }
  88560. }
  88561. }
  88562. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  88563. tempVector3.toArray(positionsData, index);
  88564. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  88565. tempVector3.toArray(normalsData, index);
  88566. finalMatrix.reset();
  88567. }
  88568. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  88569. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  88570. return this;
  88571. };
  88572. // Tools
  88573. /**
  88574. * 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
  88575. * @param meshes defines the list of meshes to scan
  88576. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88577. */
  88578. Mesh.MinMax = function (meshes) {
  88579. var minVector = null;
  88580. var maxVector = null;
  88581. meshes.forEach(function (mesh) {
  88582. var boundingInfo = mesh.getBoundingInfo();
  88583. var boundingBox = boundingInfo.boundingBox;
  88584. if (!minVector || !maxVector) {
  88585. minVector = boundingBox.minimumWorld;
  88586. maxVector = boundingBox.maximumWorld;
  88587. }
  88588. else {
  88589. minVector.minimizeInPlace(boundingBox.minimumWorld);
  88590. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  88591. }
  88592. });
  88593. if (!minVector || !maxVector) {
  88594. return {
  88595. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  88596. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  88597. };
  88598. }
  88599. return {
  88600. min: minVector,
  88601. max: maxVector
  88602. };
  88603. };
  88604. /**
  88605. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88606. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88607. * @returns a vector3
  88608. */
  88609. Mesh.Center = function (meshesOrMinMaxVector) {
  88610. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  88611. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  88612. };
  88613. /**
  88614. * Merge the array of meshes into a single mesh for performance reasons.
  88615. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88616. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88617. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88618. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88619. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88620. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88621. * @returns a new mesh
  88622. */
  88623. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  88624. if (disposeSource === void 0) { disposeSource = true; }
  88625. var index;
  88626. if (!allow32BitsIndices) {
  88627. var totalVertices = 0;
  88628. // Counting vertices
  88629. for (index = 0; index < meshes.length; index++) {
  88630. if (meshes[index]) {
  88631. totalVertices += meshes[index].getTotalVertices();
  88632. if (totalVertices > 65536) {
  88633. _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");
  88634. return null;
  88635. }
  88636. }
  88637. }
  88638. }
  88639. if (multiMultiMaterials) {
  88640. var newMultiMaterial = null;
  88641. var subIndex;
  88642. var matIndex;
  88643. subdivideWithSubMeshes = false;
  88644. }
  88645. var materialArray = new Array();
  88646. var materialIndexArray = new Array();
  88647. // Merge
  88648. var vertexData = null;
  88649. var otherVertexData;
  88650. var indiceArray = new Array();
  88651. var source = null;
  88652. for (index = 0; index < meshes.length; index++) {
  88653. if (meshes[index]) {
  88654. var mesh = meshes[index];
  88655. var wm = mesh.computeWorldMatrix(true);
  88656. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  88657. otherVertexData.transform(wm);
  88658. if (vertexData) {
  88659. vertexData.merge(otherVertexData, allow32BitsIndices);
  88660. }
  88661. else {
  88662. vertexData = otherVertexData;
  88663. source = mesh;
  88664. }
  88665. if (subdivideWithSubMeshes) {
  88666. indiceArray.push(mesh.getTotalIndices());
  88667. }
  88668. if (multiMultiMaterials) {
  88669. if (mesh.material) {
  88670. var material = mesh.material;
  88671. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  88672. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  88673. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  88674. materialArray.push(material.subMaterials[matIndex]);
  88675. }
  88676. }
  88677. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  88678. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  88679. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  88680. }
  88681. }
  88682. else {
  88683. if (materialArray.indexOf(material) < 0) {
  88684. materialArray.push(material);
  88685. }
  88686. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  88687. materialIndexArray.push(materialArray.indexOf(material));
  88688. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  88689. }
  88690. }
  88691. }
  88692. else {
  88693. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  88694. materialIndexArray.push(0);
  88695. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  88696. }
  88697. }
  88698. }
  88699. }
  88700. }
  88701. source = source;
  88702. if (!meshSubclass) {
  88703. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  88704. }
  88705. vertexData.applyToMesh(meshSubclass);
  88706. // Setting properties
  88707. meshSubclass.checkCollisions = source.checkCollisions;
  88708. // Cleaning
  88709. if (disposeSource) {
  88710. for (index = 0; index < meshes.length; index++) {
  88711. if (meshes[index]) {
  88712. meshes[index].dispose();
  88713. }
  88714. }
  88715. }
  88716. // Subdivide
  88717. if (subdivideWithSubMeshes || multiMultiMaterials) {
  88718. //-- removal of global submesh
  88719. meshSubclass.releaseSubMeshes();
  88720. index = 0;
  88721. var offset = 0;
  88722. //-- apply subdivision according to index table
  88723. while (index < indiceArray.length) {
  88724. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  88725. offset += indiceArray[index];
  88726. index++;
  88727. }
  88728. }
  88729. if (multiMultiMaterials) {
  88730. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  88731. newMultiMaterial.subMaterials = materialArray;
  88732. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  88733. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  88734. }
  88735. meshSubclass.material = newMultiMaterial;
  88736. }
  88737. else {
  88738. meshSubclass.material = source.material;
  88739. }
  88740. return meshSubclass;
  88741. };
  88742. /** @hidden */
  88743. Mesh.prototype.addInstance = function (instance) {
  88744. instance._indexInSourceMeshInstanceArray = this.instances.length;
  88745. this.instances.push(instance);
  88746. };
  88747. /** @hidden */
  88748. Mesh.prototype.removeInstance = function (instance) {
  88749. // Remove from mesh
  88750. var index = instance._indexInSourceMeshInstanceArray;
  88751. if (index != -1) {
  88752. if (index !== this.instances.length - 1) {
  88753. var last = this.instances[this.instances.length - 1];
  88754. this.instances[index] = last;
  88755. last._indexInSourceMeshInstanceArray = index;
  88756. }
  88757. instance._indexInSourceMeshInstanceArray = -1;
  88758. this.instances.pop();
  88759. }
  88760. };
  88761. // Consts
  88762. /**
  88763. * Mesh side orientation : usually the external or front surface
  88764. */
  88765. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  88766. /**
  88767. * Mesh side orientation : usually the internal or back surface
  88768. */
  88769. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  88770. /**
  88771. * Mesh side orientation : both internal and external or front and back surfaces
  88772. */
  88773. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  88774. /**
  88775. * Mesh side orientation : by default, `FRONTSIDE`
  88776. */
  88777. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  88778. /**
  88779. * Mesh cap setting : no cap
  88780. */
  88781. Mesh.NO_CAP = 0;
  88782. /**
  88783. * Mesh cap setting : one cap at the beginning of the mesh
  88784. */
  88785. Mesh.CAP_START = 1;
  88786. /**
  88787. * Mesh cap setting : one cap at the end of the mesh
  88788. */
  88789. Mesh.CAP_END = 2;
  88790. /**
  88791. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  88792. */
  88793. Mesh.CAP_ALL = 3;
  88794. // Statics
  88795. /** @hidden */
  88796. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  88797. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  88798. };
  88799. return Mesh;
  88800. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  88801. /***/ }),
  88802. /***/ "./Meshes/mesh.vertexData.ts":
  88803. /*!***********************************!*\
  88804. !*** ./Meshes/mesh.vertexData.ts ***!
  88805. \***********************************/
  88806. /*! exports provided: VertexData */
  88807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88808. "use strict";
  88809. __webpack_require__.r(__webpack_exports__);
  88810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  88811. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88812. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88813. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  88814. /**
  88815. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88816. */
  88817. var VertexData = /** @class */ (function () {
  88818. function VertexData() {
  88819. }
  88820. /**
  88821. * Uses the passed data array to set the set the values for the specified kind of data
  88822. * @param data a linear array of floating numbers
  88823. * @param kind the type of data that is being set, eg positions, colors etc
  88824. */
  88825. VertexData.prototype.set = function (data, kind) {
  88826. switch (kind) {
  88827. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  88828. this.positions = data;
  88829. break;
  88830. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  88831. this.normals = data;
  88832. break;
  88833. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  88834. this.tangents = data;
  88835. break;
  88836. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  88837. this.uvs = data;
  88838. break;
  88839. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  88840. this.uvs2 = data;
  88841. break;
  88842. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  88843. this.uvs3 = data;
  88844. break;
  88845. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  88846. this.uvs4 = data;
  88847. break;
  88848. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  88849. this.uvs5 = data;
  88850. break;
  88851. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  88852. this.uvs6 = data;
  88853. break;
  88854. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  88855. this.colors = data;
  88856. break;
  88857. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  88858. this.matricesIndices = data;
  88859. break;
  88860. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  88861. this.matricesWeights = data;
  88862. break;
  88863. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  88864. this.matricesIndicesExtra = data;
  88865. break;
  88866. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  88867. this.matricesWeightsExtra = data;
  88868. break;
  88869. }
  88870. };
  88871. /**
  88872. * Associates the vertexData to the passed Mesh.
  88873. * Sets it as updatable or not (default `false`)
  88874. * @param mesh the mesh the vertexData is applied to
  88875. * @param updatable when used and having the value true allows new data to update the vertexData
  88876. * @returns the VertexData
  88877. */
  88878. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  88879. this._applyTo(mesh, updatable);
  88880. return this;
  88881. };
  88882. /**
  88883. * Associates the vertexData to the passed Geometry.
  88884. * Sets it as updatable or not (default `false`)
  88885. * @param geometry the geometry the vertexData is applied to
  88886. * @param updatable when used and having the value true allows new data to update the vertexData
  88887. * @returns VertexData
  88888. */
  88889. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  88890. this._applyTo(geometry, updatable);
  88891. return this;
  88892. };
  88893. /**
  88894. * Updates the associated mesh
  88895. * @param mesh the mesh to be updated
  88896. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88897. * @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
  88898. * @returns VertexData
  88899. */
  88900. VertexData.prototype.updateMesh = function (mesh) {
  88901. this._update(mesh);
  88902. return this;
  88903. };
  88904. /**
  88905. * Updates the associated geometry
  88906. * @param geometry the geometry to be updated
  88907. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88908. * @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
  88909. * @returns VertexData.
  88910. */
  88911. VertexData.prototype.updateGeometry = function (geometry) {
  88912. this._update(geometry);
  88913. return this;
  88914. };
  88915. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  88916. if (updatable === void 0) { updatable = false; }
  88917. if (this.positions) {
  88918. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  88919. }
  88920. if (this.normals) {
  88921. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  88922. }
  88923. if (this.tangents) {
  88924. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  88925. }
  88926. if (this.uvs) {
  88927. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  88928. }
  88929. if (this.uvs2) {
  88930. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  88931. }
  88932. if (this.uvs3) {
  88933. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  88934. }
  88935. if (this.uvs4) {
  88936. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  88937. }
  88938. if (this.uvs5) {
  88939. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  88940. }
  88941. if (this.uvs6) {
  88942. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  88943. }
  88944. if (this.colors) {
  88945. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  88946. }
  88947. if (this.matricesIndices) {
  88948. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  88949. }
  88950. if (this.matricesWeights) {
  88951. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  88952. }
  88953. if (this.matricesIndicesExtra) {
  88954. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  88955. }
  88956. if (this.matricesWeightsExtra) {
  88957. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  88958. }
  88959. if (this.indices) {
  88960. meshOrGeometry.setIndices(this.indices, null, updatable);
  88961. }
  88962. else {
  88963. meshOrGeometry.setIndices([], null);
  88964. }
  88965. return this;
  88966. };
  88967. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  88968. if (this.positions) {
  88969. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  88970. }
  88971. if (this.normals) {
  88972. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  88973. }
  88974. if (this.tangents) {
  88975. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  88976. }
  88977. if (this.uvs) {
  88978. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  88979. }
  88980. if (this.uvs2) {
  88981. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  88982. }
  88983. if (this.uvs3) {
  88984. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  88985. }
  88986. if (this.uvs4) {
  88987. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  88988. }
  88989. if (this.uvs5) {
  88990. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  88991. }
  88992. if (this.uvs6) {
  88993. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  88994. }
  88995. if (this.colors) {
  88996. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  88997. }
  88998. if (this.matricesIndices) {
  88999. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  89000. }
  89001. if (this.matricesWeights) {
  89002. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  89003. }
  89004. if (this.matricesIndicesExtra) {
  89005. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  89006. }
  89007. if (this.matricesWeightsExtra) {
  89008. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  89009. }
  89010. if (this.indices) {
  89011. meshOrGeometry.setIndices(this.indices, null);
  89012. }
  89013. return this;
  89014. };
  89015. /**
  89016. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89017. * @param matrix the transforming matrix
  89018. * @returns the VertexData
  89019. */
  89020. VertexData.prototype.transform = function (matrix) {
  89021. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  89022. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89023. var index;
  89024. if (this.positions) {
  89025. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89026. for (index = 0; index < this.positions.length; index += 3) {
  89027. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  89028. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  89029. this.positions[index] = transformed.x;
  89030. this.positions[index + 1] = transformed.y;
  89031. this.positions[index + 2] = transformed.z;
  89032. }
  89033. }
  89034. if (this.normals) {
  89035. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89036. for (index = 0; index < this.normals.length; index += 3) {
  89037. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  89038. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  89039. this.normals[index] = transformed.x;
  89040. this.normals[index + 1] = transformed.y;
  89041. this.normals[index + 2] = transformed.z;
  89042. }
  89043. }
  89044. if (this.tangents) {
  89045. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  89046. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  89047. for (index = 0; index < this.tangents.length; index += 4) {
  89048. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  89049. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  89050. this.tangents[index] = tangentTransformed.x;
  89051. this.tangents[index + 1] = tangentTransformed.y;
  89052. this.tangents[index + 2] = tangentTransformed.z;
  89053. this.tangents[index + 3] = tangentTransformed.w;
  89054. }
  89055. }
  89056. if (flip && this.indices) {
  89057. for (index = 0; index < this.indices.length; index += 3) {
  89058. var tmp = this.indices[index + 1];
  89059. this.indices[index + 1] = this.indices[index + 2];
  89060. this.indices[index + 2] = tmp;
  89061. }
  89062. }
  89063. return this;
  89064. };
  89065. /**
  89066. * Merges the passed VertexData into the current one
  89067. * @param other the VertexData to be merged into the current one
  89068. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89069. * @returns the modified VertexData
  89070. */
  89071. VertexData.prototype.merge = function (other, use32BitsIndices) {
  89072. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  89073. this._validate();
  89074. other._validate();
  89075. if (!this.normals !== !other.normals ||
  89076. !this.tangents !== !other.tangents ||
  89077. !this.uvs !== !other.uvs ||
  89078. !this.uvs2 !== !other.uvs2 ||
  89079. !this.uvs3 !== !other.uvs3 ||
  89080. !this.uvs4 !== !other.uvs4 ||
  89081. !this.uvs5 !== !other.uvs5 ||
  89082. !this.uvs6 !== !other.uvs6 ||
  89083. !this.colors !== !other.colors ||
  89084. !this.matricesIndices !== !other.matricesIndices ||
  89085. !this.matricesWeights !== !other.matricesWeights ||
  89086. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  89087. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  89088. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  89089. }
  89090. if (other.indices) {
  89091. if (!this.indices) {
  89092. this.indices = [];
  89093. }
  89094. var offset = this.positions ? this.positions.length / 3 : 0;
  89095. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  89096. if (isSrcTypedArray) {
  89097. var len = this.indices.length + other.indices.length;
  89098. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  89099. temp.set(this.indices);
  89100. var decal = this.indices.length;
  89101. for (var index = 0; index < other.indices.length; index++) {
  89102. temp[decal + index] = other.indices[index] + offset;
  89103. }
  89104. this.indices = temp;
  89105. }
  89106. else {
  89107. for (var index = 0; index < other.indices.length; index++) {
  89108. this.indices.push(other.indices[index] + offset);
  89109. }
  89110. }
  89111. }
  89112. this.positions = this._mergeElement(this.positions, other.positions);
  89113. this.normals = this._mergeElement(this.normals, other.normals);
  89114. this.tangents = this._mergeElement(this.tangents, other.tangents);
  89115. this.uvs = this._mergeElement(this.uvs, other.uvs);
  89116. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  89117. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  89118. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  89119. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  89120. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  89121. this.colors = this._mergeElement(this.colors, other.colors);
  89122. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  89123. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  89124. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  89125. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  89126. return this;
  89127. };
  89128. VertexData.prototype._mergeElement = function (source, other) {
  89129. if (!source) {
  89130. return other;
  89131. }
  89132. if (!other) {
  89133. return source;
  89134. }
  89135. var len = other.length + source.length;
  89136. var isSrcTypedArray = source instanceof Float32Array;
  89137. var isOthTypedArray = other instanceof Float32Array;
  89138. // use non-loop method when the source is Float32Array
  89139. if (isSrcTypedArray) {
  89140. var ret32 = new Float32Array(len);
  89141. ret32.set(source);
  89142. ret32.set(other, source.length);
  89143. return ret32;
  89144. // source is number[], when other is also use concat
  89145. }
  89146. else if (!isOthTypedArray) {
  89147. return source.concat(other);
  89148. // source is a number[], but other is a Float32Array, loop required
  89149. }
  89150. else {
  89151. var ret = source.slice(0); // copy source to a separate array
  89152. for (var i = 0, len = other.length; i < len; i++) {
  89153. ret.push(other[i]);
  89154. }
  89155. return ret;
  89156. }
  89157. };
  89158. VertexData.prototype._validate = function () {
  89159. if (!this.positions) {
  89160. throw new Error("Positions are required");
  89161. }
  89162. var getElementCount = function (kind, values) {
  89163. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  89164. if ((values.length % stride) !== 0) {
  89165. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  89166. }
  89167. return values.length / stride;
  89168. };
  89169. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  89170. var validateElementCount = function (kind, values) {
  89171. var elementCount = getElementCount(kind, values);
  89172. if (elementCount !== positionsElementCount) {
  89173. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  89174. }
  89175. };
  89176. if (this.normals) {
  89177. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  89178. }
  89179. if (this.tangents) {
  89180. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  89181. }
  89182. if (this.uvs) {
  89183. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  89184. }
  89185. if (this.uvs2) {
  89186. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  89187. }
  89188. if (this.uvs3) {
  89189. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  89190. }
  89191. if (this.uvs4) {
  89192. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  89193. }
  89194. if (this.uvs5) {
  89195. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  89196. }
  89197. if (this.uvs6) {
  89198. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  89199. }
  89200. if (this.colors) {
  89201. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  89202. }
  89203. if (this.matricesIndices) {
  89204. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  89205. }
  89206. if (this.matricesWeights) {
  89207. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  89208. }
  89209. if (this.matricesIndicesExtra) {
  89210. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  89211. }
  89212. if (this.matricesWeightsExtra) {
  89213. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  89214. }
  89215. };
  89216. /**
  89217. * Serializes the VertexData
  89218. * @returns a serialized object
  89219. */
  89220. VertexData.prototype.serialize = function () {
  89221. var serializationObject = this.serialize();
  89222. if (this.positions) {
  89223. serializationObject.positions = this.positions;
  89224. }
  89225. if (this.normals) {
  89226. serializationObject.normals = this.normals;
  89227. }
  89228. if (this.tangents) {
  89229. serializationObject.tangents = this.tangents;
  89230. }
  89231. if (this.uvs) {
  89232. serializationObject.uvs = this.uvs;
  89233. }
  89234. if (this.uvs2) {
  89235. serializationObject.uvs2 = this.uvs2;
  89236. }
  89237. if (this.uvs3) {
  89238. serializationObject.uvs3 = this.uvs3;
  89239. }
  89240. if (this.uvs4) {
  89241. serializationObject.uvs4 = this.uvs4;
  89242. }
  89243. if (this.uvs5) {
  89244. serializationObject.uvs5 = this.uvs5;
  89245. }
  89246. if (this.uvs6) {
  89247. serializationObject.uvs6 = this.uvs6;
  89248. }
  89249. if (this.colors) {
  89250. serializationObject.colors = this.colors;
  89251. }
  89252. if (this.matricesIndices) {
  89253. serializationObject.matricesIndices = this.matricesIndices;
  89254. serializationObject.matricesIndices._isExpanded = true;
  89255. }
  89256. if (this.matricesWeights) {
  89257. serializationObject.matricesWeights = this.matricesWeights;
  89258. }
  89259. if (this.matricesIndicesExtra) {
  89260. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  89261. serializationObject.matricesIndicesExtra._isExpanded = true;
  89262. }
  89263. if (this.matricesWeightsExtra) {
  89264. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  89265. }
  89266. serializationObject.indices = this.indices;
  89267. return serializationObject;
  89268. };
  89269. // Statics
  89270. /**
  89271. * Extracts the vertexData from a mesh
  89272. * @param mesh the mesh from which to extract the VertexData
  89273. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89274. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89275. * @returns the object VertexData associated to the passed mesh
  89276. */
  89277. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  89278. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  89279. };
  89280. /**
  89281. * Extracts the vertexData from the geometry
  89282. * @param geometry the geometry from which to extract the VertexData
  89283. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89284. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89285. * @returns the object VertexData associated to the passed mesh
  89286. */
  89287. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  89288. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  89289. };
  89290. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  89291. var result = new VertexData();
  89292. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  89293. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  89294. }
  89295. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  89296. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  89297. }
  89298. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  89299. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  89300. }
  89301. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  89302. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  89303. }
  89304. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  89305. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  89306. }
  89307. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  89308. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  89309. }
  89310. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  89311. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  89312. }
  89313. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  89314. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  89315. }
  89316. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  89317. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  89318. }
  89319. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  89320. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  89321. }
  89322. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  89323. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  89324. }
  89325. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  89326. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  89327. }
  89328. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  89329. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  89330. }
  89331. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  89332. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  89333. }
  89334. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  89335. return result;
  89336. };
  89337. /**
  89338. * Creates the VertexData for a Ribbon
  89339. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89340. * * pathArray array of paths, each of which an array of successive Vector3
  89341. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89342. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89343. * * 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
  89344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89345. * * 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)
  89346. * * 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)
  89347. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89348. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89349. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89350. * @returns the VertexData of the ribbon
  89351. */
  89352. VertexData.CreateRibbon = function (options) {
  89353. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  89354. };
  89355. /**
  89356. * Creates the VertexData for a box
  89357. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89358. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89359. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89360. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89361. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89362. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89363. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89365. * * 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)
  89366. * * 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)
  89367. * @returns the VertexData of the box
  89368. */
  89369. VertexData.CreateBox = function (options) {
  89370. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  89371. };
  89372. /**
  89373. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89374. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89375. * * segments sets the number of horizontal strips optional, default 32
  89376. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89377. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89378. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89379. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89380. * * 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
  89381. * * 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
  89382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89383. * * 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)
  89384. * * 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)
  89385. * @returns the VertexData of the ellipsoid
  89386. */
  89387. VertexData.CreateSphere = function (options) {
  89388. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  89389. };
  89390. /**
  89391. * Creates the VertexData for a cylinder, cone or prism
  89392. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89393. * * height sets the height (y direction) of the cylinder, optional, default 2
  89394. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89395. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89396. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89397. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89398. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89399. * * 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
  89400. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89401. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89402. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89403. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89405. * * 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)
  89406. * * 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)
  89407. * @returns the VertexData of the cylinder, cone or prism
  89408. */
  89409. VertexData.CreateCylinder = function (options) {
  89410. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  89411. };
  89412. /**
  89413. * Creates the VertexData for a torus
  89414. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89415. * * diameter the diameter of the torus, optional default 1
  89416. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89417. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89419. * * 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)
  89420. * * 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)
  89421. * @returns the VertexData of the torus
  89422. */
  89423. VertexData.CreateTorus = function (options) {
  89424. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  89425. };
  89426. /**
  89427. * Creates the VertexData of the LineSystem
  89428. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89429. * - lines an array of lines, each line being an array of successive Vector3
  89430. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89431. * @returns the VertexData of the LineSystem
  89432. */
  89433. VertexData.CreateLineSystem = function (options) {
  89434. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  89435. };
  89436. /**
  89437. * Create the VertexData for a DashedLines
  89438. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89439. * - points an array successive Vector3
  89440. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89441. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89442. * - dashNb the intended total number of dashes, optional, default 200
  89443. * @returns the VertexData for the DashedLines
  89444. */
  89445. VertexData.CreateDashedLines = function (options) {
  89446. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  89447. };
  89448. /**
  89449. * Creates the VertexData for a Ground
  89450. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89451. * - width the width (x direction) of the ground, optional, default 1
  89452. * - height the height (z direction) of the ground, optional, default 1
  89453. * - subdivisions the number of subdivisions per side, optional, default 1
  89454. * @returns the VertexData of the Ground
  89455. */
  89456. VertexData.CreateGround = function (options) {
  89457. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  89458. };
  89459. /**
  89460. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89461. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89462. * * xmin the ground minimum X coordinate, optional, default -1
  89463. * * zmin the ground minimum Z coordinate, optional, default -1
  89464. * * xmax the ground maximum X coordinate, optional, default 1
  89465. * * zmax the ground maximum Z coordinate, optional, default 1
  89466. * * 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}
  89467. * * 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}
  89468. * @returns the VertexData of the TiledGround
  89469. */
  89470. VertexData.CreateTiledGround = function (options) {
  89471. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  89472. };
  89473. /**
  89474. * Creates the VertexData of the Ground designed from a heightmap
  89475. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89476. * * width the width (x direction) of the ground
  89477. * * height the height (z direction) of the ground
  89478. * * subdivisions the number of subdivisions per side
  89479. * * minHeight the minimum altitude on the ground, optional, default 0
  89480. * * maxHeight the maximum altitude on the ground, optional default 1
  89481. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89482. * * buffer the array holding the image color data
  89483. * * bufferWidth the width of image
  89484. * * bufferHeight the height of image
  89485. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89486. * @returns the VertexData of the Ground designed from a heightmap
  89487. */
  89488. VertexData.CreateGroundFromHeightMap = function (options) {
  89489. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  89490. };
  89491. /**
  89492. * Creates the VertexData for a Plane
  89493. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89494. * * size sets the width and height of the plane to the value of size, optional default 1
  89495. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89496. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89498. * * 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)
  89499. * * 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)
  89500. * @returns the VertexData of the box
  89501. */
  89502. VertexData.CreatePlane = function (options) {
  89503. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  89504. };
  89505. /**
  89506. * Creates the VertexData of the Disc or regular Polygon
  89507. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89508. * * radius the radius of the disc, optional default 0.5
  89509. * * tessellation the number of polygon sides, optional, default 64
  89510. * * 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
  89511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89512. * * 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)
  89513. * * 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)
  89514. * @returns the VertexData of the box
  89515. */
  89516. VertexData.CreateDisc = function (options) {
  89517. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  89518. };
  89519. /**
  89520. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89521. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89522. * @param polygon a mesh built from polygonTriangulation.build()
  89523. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89524. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89525. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89526. * @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)
  89527. * @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)
  89528. * @returns the VertexData of the Polygon
  89529. */
  89530. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  89531. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  89532. };
  89533. /**
  89534. * Creates the VertexData of the IcoSphere
  89535. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89536. * * radius the radius of the IcoSphere, optional default 1
  89537. * * radiusX allows stretching in the x direction, optional, default radius
  89538. * * radiusY allows stretching in the y direction, optional, default radius
  89539. * * radiusZ allows stretching in the z direction, optional, default radius
  89540. * * flat when true creates a flat shaded mesh, optional, default true
  89541. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89543. * * 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)
  89544. * * 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)
  89545. * @returns the VertexData of the IcoSphere
  89546. */
  89547. VertexData.CreateIcoSphere = function (options) {
  89548. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  89549. };
  89550. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  89551. /**
  89552. * Creates the VertexData for a Polyhedron
  89553. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89554. * * type provided types are:
  89555. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89556. * * 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)
  89557. * * size the size of the IcoSphere, optional default 1
  89558. * * sizeX allows stretching in the x direction, optional, default size
  89559. * * sizeY allows stretching in the y direction, optional, default size
  89560. * * sizeZ allows stretching in the z direction, optional, default size
  89561. * * 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
  89562. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89563. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89564. * * flat when true creates a flat shaded mesh, optional, default true
  89565. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89566. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89567. * * 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)
  89568. * * 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)
  89569. * @returns the VertexData of the Polyhedron
  89570. */
  89571. VertexData.CreatePolyhedron = function (options) {
  89572. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  89573. };
  89574. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  89575. /**
  89576. * Creates the VertexData for a TorusKnot
  89577. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89578. * * radius the radius of the torus knot, optional, default 2
  89579. * * tube the thickness of the tube, optional, default 0.5
  89580. * * radialSegments the number of sides on each tube segments, optional, default 32
  89581. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89582. * * p the number of windings around the z axis, optional, default 2
  89583. * * q the number of windings around the x axis, optional, default 3
  89584. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89585. * * 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)
  89586. * * 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)
  89587. * @returns the VertexData of the Torus Knot
  89588. */
  89589. VertexData.CreateTorusKnot = function (options) {
  89590. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  89591. };
  89592. // Tools
  89593. /**
  89594. * Compute normals for given positions and indices
  89595. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89596. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89597. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89598. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89599. * * facetNormals : optional array of facet normals (vector3)
  89600. * * facetPositions : optional array of facet positions (vector3)
  89601. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89602. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89603. * * bInfo : optional bounding info, required for facetPartitioning computation
  89604. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89605. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89606. * * useRightHandedSystem: optional boolean to for right handed system computation
  89607. * * depthSort : optional boolean to enable the facet depth sort computation
  89608. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89609. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89610. */
  89611. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  89612. // temporary scalar variables
  89613. var index = 0; // facet index
  89614. var p1p2x = 0.0; // p1p2 vector x coordinate
  89615. var p1p2y = 0.0; // p1p2 vector y coordinate
  89616. var p1p2z = 0.0; // p1p2 vector z coordinate
  89617. var p3p2x = 0.0; // p3p2 vector x coordinate
  89618. var p3p2y = 0.0; // p3p2 vector y coordinate
  89619. var p3p2z = 0.0; // p3p2 vector z coordinate
  89620. var faceNormalx = 0.0; // facet normal x coordinate
  89621. var faceNormaly = 0.0; // facet normal y coordinate
  89622. var faceNormalz = 0.0; // facet normal z coordinate
  89623. var length = 0.0; // facet normal length before normalization
  89624. var v1x = 0; // vector1 x index in the positions array
  89625. var v1y = 0; // vector1 y index in the positions array
  89626. var v1z = 0; // vector1 z index in the positions array
  89627. var v2x = 0; // vector2 x index in the positions array
  89628. var v2y = 0; // vector2 y index in the positions array
  89629. var v2z = 0; // vector2 z index in the positions array
  89630. var v3x = 0; // vector3 x index in the positions array
  89631. var v3y = 0; // vector3 y index in the positions array
  89632. var v3z = 0; // vector3 z index in the positions array
  89633. var computeFacetNormals = false;
  89634. var computeFacetPositions = false;
  89635. var computeFacetPartitioning = false;
  89636. var computeDepthSort = false;
  89637. var faceNormalSign = 1;
  89638. var ratio = 0;
  89639. var distanceTo = null;
  89640. if (options) {
  89641. computeFacetNormals = (options.facetNormals) ? true : false;
  89642. computeFacetPositions = (options.facetPositions) ? true : false;
  89643. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  89644. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  89645. ratio = options.ratio || 0;
  89646. computeDepthSort = (options.depthSort) ? true : false;
  89647. distanceTo = (options.distanceTo);
  89648. if (computeDepthSort) {
  89649. if (distanceTo === undefined) {
  89650. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89651. }
  89652. var depthSortedFacets = options.depthSortedFacets;
  89653. }
  89654. }
  89655. // facetPartitioning reinit if needed
  89656. var xSubRatio = 0;
  89657. var ySubRatio = 0;
  89658. var zSubRatio = 0;
  89659. var subSq = 0;
  89660. if (computeFacetPartitioning && options && options.bbSize) {
  89661. var ox = 0; // X partitioning index for facet position
  89662. var oy = 0; // Y partinioning index for facet position
  89663. var oz = 0; // Z partinioning index for facet position
  89664. var b1x = 0; // X partitioning index for facet v1 vertex
  89665. var b1y = 0; // Y partitioning index for facet v1 vertex
  89666. var b1z = 0; // z partitioning index for facet v1 vertex
  89667. var b2x = 0; // X partitioning index for facet v2 vertex
  89668. var b2y = 0; // Y partitioning index for facet v2 vertex
  89669. var b2z = 0; // Z partitioning index for facet v2 vertex
  89670. var b3x = 0; // X partitioning index for facet v3 vertex
  89671. var b3y = 0; // Y partitioning index for facet v3 vertex
  89672. var b3z = 0; // Z partitioning index for facet v3 vertex
  89673. var block_idx_o = 0; // facet barycenter block index
  89674. var block_idx_v1 = 0; // v1 vertex block index
  89675. var block_idx_v2 = 0; // v2 vertex block index
  89676. var block_idx_v3 = 0; // v3 vertex block index
  89677. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  89678. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  89679. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  89680. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  89681. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  89682. subSq = options.subDiv.max * options.subDiv.max;
  89683. options.facetPartitioning.length = 0;
  89684. }
  89685. // reset the normals
  89686. for (index = 0; index < positions.length; index++) {
  89687. normals[index] = 0.0;
  89688. }
  89689. // Loop : 1 indice triplet = 1 facet
  89690. var nbFaces = (indices.length / 3) | 0;
  89691. for (index = 0; index < nbFaces; index++) {
  89692. // get the indexes of the coordinates of each vertex of the facet
  89693. v1x = indices[index * 3] * 3;
  89694. v1y = v1x + 1;
  89695. v1z = v1x + 2;
  89696. v2x = indices[index * 3 + 1] * 3;
  89697. v2y = v2x + 1;
  89698. v2z = v2x + 2;
  89699. v3x = indices[index * 3 + 2] * 3;
  89700. v3y = v3x + 1;
  89701. v3z = v3x + 2;
  89702. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  89703. p1p2y = positions[v1y] - positions[v2y];
  89704. p1p2z = positions[v1z] - positions[v2z];
  89705. p3p2x = positions[v3x] - positions[v2x];
  89706. p3p2y = positions[v3y] - positions[v2y];
  89707. p3p2z = positions[v3z] - positions[v2z];
  89708. // compute the face normal with the cross product
  89709. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  89710. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  89711. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  89712. // normalize this normal and store it in the array facetData
  89713. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  89714. length = (length === 0) ? 1.0 : length;
  89715. faceNormalx /= length;
  89716. faceNormaly /= length;
  89717. faceNormalz /= length;
  89718. if (computeFacetNormals && options) {
  89719. options.facetNormals[index].x = faceNormalx;
  89720. options.facetNormals[index].y = faceNormaly;
  89721. options.facetNormals[index].z = faceNormalz;
  89722. }
  89723. if (computeFacetPositions && options) {
  89724. // compute and the facet barycenter coordinates in the array facetPositions
  89725. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  89726. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  89727. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  89728. }
  89729. if (computeFacetPartitioning && options) {
  89730. // store the facet indexes in arrays in the main facetPartitioning array :
  89731. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  89732. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  89733. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  89734. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  89735. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  89736. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  89737. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  89738. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  89739. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  89740. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  89741. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  89742. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  89743. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  89744. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  89745. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  89746. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  89747. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  89748. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  89749. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  89750. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  89751. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  89752. // push each facet index in each block containing the vertex
  89753. options.facetPartitioning[block_idx_v1].push(index);
  89754. if (block_idx_v2 != block_idx_v1) {
  89755. options.facetPartitioning[block_idx_v2].push(index);
  89756. }
  89757. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  89758. options.facetPartitioning[block_idx_v3].push(index);
  89759. }
  89760. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  89761. options.facetPartitioning[block_idx_o].push(index);
  89762. }
  89763. }
  89764. if (computeDepthSort && options && options.facetPositions) {
  89765. var dsf = depthSortedFacets[index];
  89766. dsf.ind = index * 3;
  89767. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  89768. }
  89769. // compute the normals anyway
  89770. normals[v1x] += faceNormalx; // accumulate all the normals per face
  89771. normals[v1y] += faceNormaly;
  89772. normals[v1z] += faceNormalz;
  89773. normals[v2x] += faceNormalx;
  89774. normals[v2y] += faceNormaly;
  89775. normals[v2z] += faceNormalz;
  89776. normals[v3x] += faceNormalx;
  89777. normals[v3y] += faceNormaly;
  89778. normals[v3z] += faceNormalz;
  89779. }
  89780. // last normalization of each normal
  89781. for (index = 0; index < normals.length / 3; index++) {
  89782. faceNormalx = normals[index * 3];
  89783. faceNormaly = normals[index * 3 + 1];
  89784. faceNormalz = normals[index * 3 + 2];
  89785. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  89786. length = (length === 0) ? 1.0 : length;
  89787. faceNormalx /= length;
  89788. faceNormaly /= length;
  89789. faceNormalz /= length;
  89790. normals[index * 3] = faceNormalx;
  89791. normals[index * 3 + 1] = faceNormaly;
  89792. normals[index * 3 + 2] = faceNormalz;
  89793. }
  89794. };
  89795. /** @hidden */
  89796. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  89797. var li = indices.length;
  89798. var ln = normals.length;
  89799. var i;
  89800. var n;
  89801. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  89802. switch (sideOrientation) {
  89803. case VertexData.FRONTSIDE:
  89804. // nothing changed
  89805. break;
  89806. case VertexData.BACKSIDE:
  89807. var tmp;
  89808. // indices
  89809. for (i = 0; i < li; i += 3) {
  89810. tmp = indices[i];
  89811. indices[i] = indices[i + 2];
  89812. indices[i + 2] = tmp;
  89813. }
  89814. // normals
  89815. for (n = 0; n < ln; n++) {
  89816. normals[n] = -normals[n];
  89817. }
  89818. break;
  89819. case VertexData.DOUBLESIDE:
  89820. // positions
  89821. var lp = positions.length;
  89822. var l = lp / 3;
  89823. for (var p = 0; p < lp; p++) {
  89824. positions[lp + p] = positions[p];
  89825. }
  89826. // indices
  89827. for (i = 0; i < li; i += 3) {
  89828. indices[i + li] = indices[i + 2] + l;
  89829. indices[i + 1 + li] = indices[i + 1] + l;
  89830. indices[i + 2 + li] = indices[i] + l;
  89831. }
  89832. // normals
  89833. for (n = 0; n < ln; n++) {
  89834. normals[ln + n] = -normals[n];
  89835. }
  89836. // uvs
  89837. var lu = uvs.length;
  89838. var u = 0;
  89839. for (u = 0; u < lu; u++) {
  89840. uvs[u + lu] = uvs[u];
  89841. }
  89842. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  89843. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  89844. u = 0;
  89845. for (i = 0; i < lu / 2; i++) {
  89846. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  89847. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  89848. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  89849. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  89850. u += 2;
  89851. }
  89852. break;
  89853. }
  89854. };
  89855. /**
  89856. * Applies VertexData created from the imported parameters to the geometry
  89857. * @param parsedVertexData the parsed data from an imported file
  89858. * @param geometry the geometry to apply the VertexData to
  89859. */
  89860. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  89861. var vertexData = new VertexData();
  89862. // positions
  89863. var positions = parsedVertexData.positions;
  89864. if (positions) {
  89865. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  89866. }
  89867. // normals
  89868. var normals = parsedVertexData.normals;
  89869. if (normals) {
  89870. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  89871. }
  89872. // tangents
  89873. var tangents = parsedVertexData.tangents;
  89874. if (tangents) {
  89875. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  89876. }
  89877. // uvs
  89878. var uvs = parsedVertexData.uvs;
  89879. if (uvs) {
  89880. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  89881. }
  89882. // uv2s
  89883. var uv2s = parsedVertexData.uv2s;
  89884. if (uv2s) {
  89885. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  89886. }
  89887. // uv3s
  89888. var uv3s = parsedVertexData.uv3s;
  89889. if (uv3s) {
  89890. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  89891. }
  89892. // uv4s
  89893. var uv4s = parsedVertexData.uv4s;
  89894. if (uv4s) {
  89895. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  89896. }
  89897. // uv5s
  89898. var uv5s = parsedVertexData.uv5s;
  89899. if (uv5s) {
  89900. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  89901. }
  89902. // uv6s
  89903. var uv6s = parsedVertexData.uv6s;
  89904. if (uv6s) {
  89905. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  89906. }
  89907. // colors
  89908. var colors = parsedVertexData.colors;
  89909. if (colors) {
  89910. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  89911. }
  89912. // matricesIndices
  89913. var matricesIndices = parsedVertexData.matricesIndices;
  89914. if (matricesIndices) {
  89915. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  89916. }
  89917. // matricesWeights
  89918. var matricesWeights = parsedVertexData.matricesWeights;
  89919. if (matricesWeights) {
  89920. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  89921. }
  89922. // indices
  89923. var indices = parsedVertexData.indices;
  89924. if (indices) {
  89925. vertexData.indices = indices;
  89926. }
  89927. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  89928. };
  89929. /**
  89930. * Mesh side orientation : usually the external or front surface
  89931. */
  89932. VertexData.FRONTSIDE = 0;
  89933. /**
  89934. * Mesh side orientation : usually the internal or back surface
  89935. */
  89936. VertexData.BACKSIDE = 1;
  89937. /**
  89938. * Mesh side orientation : both internal and external or front and back surfaces
  89939. */
  89940. VertexData.DOUBLESIDE = 2;
  89941. /**
  89942. * Mesh side orientation : by default, `FRONTSIDE`
  89943. */
  89944. VertexData.DEFAULTSIDE = 0;
  89945. return VertexData;
  89946. }());
  89947. /***/ }),
  89948. /***/ "./Meshes/meshBuilder.ts":
  89949. /*!*******************************!*\
  89950. !*** ./Meshes/meshBuilder.ts ***!
  89951. \*******************************/
  89952. /*! exports provided: MeshBuilder */
  89953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89954. "use strict";
  89955. __webpack_require__.r(__webpack_exports__);
  89956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  89957. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  89958. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  89959. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  89960. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  89961. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  89962. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  89963. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  89964. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  89965. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  89966. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  89967. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  89968. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  89969. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  89970. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  89971. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  89972. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  89973. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  89974. /**
  89975. * Class containing static functions to help procedurally build meshes
  89976. */
  89977. var MeshBuilder = /** @class */ (function () {
  89978. function MeshBuilder() {
  89979. }
  89980. /**
  89981. * Creates a box mesh
  89982. * * The parameter `size` sets the size (float) of each box side (default 1)
  89983. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  89984. * * 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)
  89985. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  89986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89987. * * 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
  89988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89989. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  89990. * @param name defines the name of the mesh
  89991. * @param options defines the options used to create the mesh
  89992. * @param scene defines the hosting scene
  89993. * @returns the box mesh
  89994. */
  89995. MeshBuilder.CreateBox = function (name, options, scene) {
  89996. if (scene === void 0) { scene = null; }
  89997. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  89998. };
  89999. /**
  90000. * Creates a sphere mesh
  90001. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  90002. * * 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`)
  90003. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  90004. * * 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
  90005. * * 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)
  90006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90007. * * 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
  90008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90009. * @param name defines the name of the mesh
  90010. * @param options defines the options used to create the mesh
  90011. * @param scene defines the hosting scene
  90012. * @returns the sphere mesh
  90013. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  90014. */
  90015. MeshBuilder.CreateSphere = function (name, options, scene) {
  90016. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  90017. };
  90018. /**
  90019. * Creates a plane polygonal mesh. By default, this is a disc
  90020. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90021. * * 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
  90022. * * 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
  90023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90024. * * 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
  90025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90026. * @param name defines the name of the mesh
  90027. * @param options defines the options used to create the mesh
  90028. * @param scene defines the hosting scene
  90029. * @returns the plane polygonal mesh
  90030. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90031. */
  90032. MeshBuilder.CreateDisc = function (name, options, scene) {
  90033. if (scene === void 0) { scene = null; }
  90034. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  90035. };
  90036. /**
  90037. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90038. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90039. * * 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`)
  90040. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90041. * * 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
  90042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90043. * * 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
  90044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90045. * @param name defines the name of the mesh
  90046. * @param options defines the options used to create the mesh
  90047. * @param scene defines the hosting scene
  90048. * @returns the icosahedron mesh
  90049. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90050. */
  90051. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  90052. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  90053. };
  90054. /**
  90055. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  90056. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  90057. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  90058. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  90059. * * 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
  90060. * * 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
  90061. * * 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
  90062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90063. * * 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
  90064. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90065. * * 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
  90066. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  90067. * * 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
  90068. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  90069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90070. * @param name defines the name of the mesh
  90071. * @param options defines the options used to create the mesh
  90072. * @param scene defines the hosting scene
  90073. * @returns the ribbon mesh
  90074. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  90075. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90076. */
  90077. MeshBuilder.CreateRibbon = function (name, options, scene) {
  90078. if (scene === void 0) { scene = null; }
  90079. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  90080. };
  90081. /**
  90082. * Creates a cylinder or a cone mesh
  90083. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  90084. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  90085. * * 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.
  90086. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  90087. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  90088. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  90089. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  90090. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  90091. * * 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).
  90092. * * 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
  90093. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  90094. * * 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
  90095. * * 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.
  90096. * * If `enclose` is false, a ring surface is one element.
  90097. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  90098. * * 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
  90099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90100. * * 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
  90101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90102. * @param name defines the name of the mesh
  90103. * @param options defines the options used to create the mesh
  90104. * @param scene defines the hosting scene
  90105. * @returns the cylinder mesh
  90106. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  90107. */
  90108. MeshBuilder.CreateCylinder = function (name, options, scene) {
  90109. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  90110. };
  90111. /**
  90112. * Creates a torus mesh
  90113. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  90114. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  90115. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  90116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90117. * * 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
  90118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90119. * @param name defines the name of the mesh
  90120. * @param options defines the options used to create the mesh
  90121. * @param scene defines the hosting scene
  90122. * @returns the torus mesh
  90123. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  90124. */
  90125. MeshBuilder.CreateTorus = function (name, options, scene) {
  90126. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  90127. };
  90128. /**
  90129. * Creates a torus knot mesh
  90130. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  90131. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  90132. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  90133. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  90134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90135. * * 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
  90136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90137. * @param name defines the name of the mesh
  90138. * @param options defines the options used to create the mesh
  90139. * @param scene defines the hosting scene
  90140. * @returns the torus knot mesh
  90141. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  90142. */
  90143. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  90144. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  90145. };
  90146. /**
  90147. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  90148. * * 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
  90149. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  90150. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  90151. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  90152. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  90153. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  90154. * * 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
  90155. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  90156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  90158. * @param name defines the name of the new line system
  90159. * @param options defines the options used to create the line system
  90160. * @param scene defines the hosting scene
  90161. * @returns a new line system mesh
  90162. */
  90163. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  90164. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  90165. };
  90166. /**
  90167. * Creates a line mesh
  90168. * 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
  90169. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  90170. * * The parameter `points` is an array successive Vector3
  90171. * * 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
  90172. * * The optional parameter `colors` is an array of successive Color4, one per line point
  90173. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  90174. * * When updating an instance, remember that only point positions can change, not the number of points
  90175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  90177. * @param name defines the name of the new line system
  90178. * @param options defines the options used to create the line system
  90179. * @param scene defines the hosting scene
  90180. * @returns a new line mesh
  90181. */
  90182. MeshBuilder.CreateLines = function (name, options, scene) {
  90183. if (scene === void 0) { scene = null; }
  90184. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  90185. };
  90186. /**
  90187. * Creates a dashed line mesh
  90188. * * 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
  90189. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  90190. * * The parameter `points` is an array successive Vector3
  90191. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  90192. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  90193. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90194. * * 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
  90195. * * When updating an instance, remember that only point positions can change, not the number of points
  90196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90197. * @param name defines the name of the mesh
  90198. * @param options defines the options used to create the mesh
  90199. * @param scene defines the hosting scene
  90200. * @returns the dashed line mesh
  90201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  90202. */
  90203. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  90204. if (scene === void 0) { scene = null; }
  90205. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  90206. };
  90207. /**
  90208. * 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.
  90209. * * 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.
  90210. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  90211. * * 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.
  90212. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  90213. * * 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
  90214. * * 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
  90215. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  90216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90217. * * 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
  90218. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  90219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90220. * @param name defines the name of the mesh
  90221. * @param options defines the options used to create the mesh
  90222. * @param scene defines the hosting scene
  90223. * @returns the extruded shape mesh
  90224. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90226. */
  90227. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  90228. if (scene === void 0) { scene = null; }
  90229. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  90230. };
  90231. /**
  90232. * Creates an custom extruded shape mesh.
  90233. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  90234. * * 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.
  90235. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  90236. * * 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
  90237. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  90238. * * 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
  90239. * * It must returns a float value that will be the scale value applied to the shape on each path point
  90240. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90241. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  90242. * * 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
  90243. * * 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
  90244. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  90245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90246. * * 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
  90247. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90249. * @param name defines the name of the mesh
  90250. * @param options defines the options used to create the mesh
  90251. * @param scene defines the hosting scene
  90252. * @returns the custom extruded shape mesh
  90253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  90254. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90256. */
  90257. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  90258. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  90259. };
  90260. /**
  90261. * Creates lathe mesh.
  90262. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  90263. * * 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
  90264. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  90265. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  90266. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  90267. * * 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
  90268. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  90269. * * 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
  90270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90271. * * 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
  90272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90274. * @param name defines the name of the mesh
  90275. * @param options defines the options used to create the mesh
  90276. * @param scene defines the hosting scene
  90277. * @returns the lathe mesh
  90278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  90279. */
  90280. MeshBuilder.CreateLathe = function (name, options, scene) {
  90281. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  90282. };
  90283. /**
  90284. * Creates a plane mesh
  90285. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  90286. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  90287. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  90288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90289. * * 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
  90290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90291. * @param name defines the name of the mesh
  90292. * @param options defines the options used to create the mesh
  90293. * @param scene defines the hosting scene
  90294. * @returns the plane mesh
  90295. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  90296. */
  90297. MeshBuilder.CreatePlane = function (name, options, scene) {
  90298. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  90299. };
  90300. /**
  90301. * Creates a ground mesh
  90302. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  90303. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  90304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90305. * @param name defines the name of the mesh
  90306. * @param options defines the options used to create the mesh
  90307. * @param scene defines the hosting scene
  90308. * @returns the ground mesh
  90309. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  90310. */
  90311. MeshBuilder.CreateGround = function (name, options, scene) {
  90312. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  90313. };
  90314. /**
  90315. * Creates a tiled ground mesh
  90316. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  90317. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  90318. * * 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
  90319. * * 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
  90320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90321. * @param name defines the name of the mesh
  90322. * @param options defines the options used to create the mesh
  90323. * @param scene defines the hosting scene
  90324. * @returns the tiled ground mesh
  90325. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  90326. */
  90327. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  90328. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  90329. };
  90330. /**
  90331. * Creates a ground mesh from a height map
  90332. * * The parameter `url` sets the URL of the height map image resource.
  90333. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  90334. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  90335. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  90336. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  90337. * * 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.
  90338. * * 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).
  90339. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90341. * @param name defines the name of the mesh
  90342. * @param url defines the url to the height map
  90343. * @param options defines the options used to create the mesh
  90344. * @param scene defines the hosting scene
  90345. * @returns the ground mesh
  90346. * @see https://doc.babylonjs.com/babylon101/height_map
  90347. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  90348. */
  90349. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  90350. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  90351. };
  90352. /**
  90353. * Creates a polygon mesh
  90354. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  90355. * * 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
  90356. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90358. * * 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)
  90359. * * Remember you can only change the shape positions, not their number when updating a polygon
  90360. * @param name defines the name of the mesh
  90361. * @param options defines the options used to create the mesh
  90362. * @param scene defines the hosting scene
  90363. * @param earcutInjection can be used to inject your own earcut reference
  90364. * @returns the polygon mesh
  90365. */
  90366. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  90367. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90368. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  90369. };
  90370. /**
  90371. * Creates an extruded polygon mesh, with depth in the Y direction.
  90372. * * 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)
  90373. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  90374. * @param name defines the name of the mesh
  90375. * @param options defines the options used to create the mesh
  90376. * @param scene defines the hosting scene
  90377. * @param earcutInjection can be used to inject your own earcut reference
  90378. * @returns the polygon mesh
  90379. */
  90380. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  90381. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90382. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  90383. };
  90384. /**
  90385. * Creates a tube mesh.
  90386. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  90387. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  90388. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  90389. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  90390. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  90391. * * 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)
  90392. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  90393. * * 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
  90394. * * 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
  90395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90396. * * 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
  90397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  90398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90399. * @param name defines the name of the mesh
  90400. * @param options defines the options used to create the mesh
  90401. * @param scene defines the hosting scene
  90402. * @returns the tube mesh
  90403. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  90404. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  90405. */
  90406. MeshBuilder.CreateTube = function (name, options, scene) {
  90407. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  90408. };
  90409. /**
  90410. * Creates a polyhedron mesh
  90411. * * 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
  90412. * * The parameter `size` (positive float, default 1) sets the polygon size
  90413. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90414. * * 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`
  90415. * * 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
  90416. * * 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)`)
  90417. * * 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
  90418. * * 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
  90419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90420. * * 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
  90421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90422. * @param name defines the name of the mesh
  90423. * @param options defines the options used to create the mesh
  90424. * @param scene defines the hosting scene
  90425. * @returns the polyhedron mesh
  90426. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  90427. */
  90428. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  90429. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  90430. };
  90431. /**
  90432. * Creates a decal mesh.
  90433. * 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
  90434. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  90435. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  90436. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  90437. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  90438. * @param name defines the name of the mesh
  90439. * @param sourceMesh defines the mesh where the decal must be applied
  90440. * @param options defines the options used to create the mesh
  90441. * @param scene defines the hosting scene
  90442. * @returns the decal mesh
  90443. * @see https://doc.babylonjs.com/how_to/decals
  90444. */
  90445. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  90446. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  90447. };
  90448. return MeshBuilder;
  90449. }());
  90450. /***/ }),
  90451. /***/ "./Meshes/meshSimplification.ts":
  90452. /*!**************************************!*\
  90453. !*** ./Meshes/meshSimplification.ts ***!
  90454. \**************************************/
  90455. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  90456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90457. "use strict";
  90458. __webpack_require__.r(__webpack_exports__);
  90459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  90460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  90461. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  90462. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90463. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  90464. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  90465. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  90466. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  90467. /**
  90468. * Class used to specify simplification options
  90469. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  90470. */
  90471. var SimplificationSettings = /** @class */ (function () {
  90472. /**
  90473. * Creates a SimplificationSettings
  90474. * @param quality expected quality
  90475. * @param distance distance when this optimized version should be used
  90476. * @param optimizeMesh already optimized mesh
  90477. */
  90478. function SimplificationSettings(
  90479. /** expected quality */
  90480. quality,
  90481. /** distance when this optimized version should be used */
  90482. distance,
  90483. /** already optimized mesh */
  90484. optimizeMesh) {
  90485. this.quality = quality;
  90486. this.distance = distance;
  90487. this.optimizeMesh = optimizeMesh;
  90488. }
  90489. return SimplificationSettings;
  90490. }());
  90491. /**
  90492. * Queue used to order the simplification tasks
  90493. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  90494. */
  90495. var SimplificationQueue = /** @class */ (function () {
  90496. /**
  90497. * Creates a new queue
  90498. */
  90499. function SimplificationQueue() {
  90500. this.running = false;
  90501. this._simplificationArray = [];
  90502. }
  90503. /**
  90504. * Adds a new simplification task
  90505. * @param task defines a task to add
  90506. */
  90507. SimplificationQueue.prototype.addTask = function (task) {
  90508. this._simplificationArray.push(task);
  90509. };
  90510. /**
  90511. * Execute next task
  90512. */
  90513. SimplificationQueue.prototype.executeNext = function () {
  90514. var task = this._simplificationArray.pop();
  90515. if (task) {
  90516. this.running = true;
  90517. this.runSimplification(task);
  90518. }
  90519. else {
  90520. this.running = false;
  90521. }
  90522. };
  90523. /**
  90524. * Execute a simplification task
  90525. * @param task defines the task to run
  90526. */
  90527. SimplificationQueue.prototype.runSimplification = function (task) {
  90528. var _this = this;
  90529. if (task.parallelProcessing) {
  90530. //parallel simplifier
  90531. task.settings.forEach(function (setting) {
  90532. var simplifier = _this.getSimplifier(task);
  90533. simplifier.simplify(setting, function (newMesh) {
  90534. task.mesh.addLODLevel(setting.distance, newMesh);
  90535. newMesh.isVisible = true;
  90536. //check if it is the last
  90537. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  90538. //all done, run the success callback.
  90539. task.successCallback();
  90540. }
  90541. _this.executeNext();
  90542. });
  90543. });
  90544. }
  90545. else {
  90546. //single simplifier.
  90547. var simplifier = this.getSimplifier(task);
  90548. var runDecimation = function (setting, callback) {
  90549. simplifier.simplify(setting, function (newMesh) {
  90550. task.mesh.addLODLevel(setting.distance, newMesh);
  90551. newMesh.isVisible = true;
  90552. //run the next quality level
  90553. callback();
  90554. });
  90555. };
  90556. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  90557. runDecimation(task.settings[loop.index], function () {
  90558. loop.executeNext();
  90559. });
  90560. }, function () {
  90561. //execution ended, run the success callback.
  90562. if (task.successCallback) {
  90563. task.successCallback();
  90564. }
  90565. _this.executeNext();
  90566. });
  90567. }
  90568. };
  90569. SimplificationQueue.prototype.getSimplifier = function (task) {
  90570. switch (task.simplificationType) {
  90571. case SimplificationType.QUADRATIC:
  90572. default:
  90573. return new QuadraticErrorSimplification(task.mesh);
  90574. }
  90575. };
  90576. return SimplificationQueue;
  90577. }());
  90578. /**
  90579. * The implemented types of simplification
  90580. * At the moment only Quadratic Error Decimation is implemented
  90581. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  90582. */
  90583. var SimplificationType;
  90584. (function (SimplificationType) {
  90585. /** Quadratic error decimation */
  90586. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  90587. })(SimplificationType || (SimplificationType = {}));
  90588. var DecimationTriangle = /** @class */ (function () {
  90589. function DecimationTriangle(vertices) {
  90590. this.vertices = vertices;
  90591. this.error = new Array(4);
  90592. this.deleted = false;
  90593. this.isDirty = false;
  90594. this.deletePending = false;
  90595. this.borderFactor = 0;
  90596. }
  90597. return DecimationTriangle;
  90598. }());
  90599. var DecimationVertex = /** @class */ (function () {
  90600. function DecimationVertex(position, id) {
  90601. this.position = position;
  90602. this.id = id;
  90603. this.isBorder = true;
  90604. this.q = new QuadraticMatrix();
  90605. this.triangleCount = 0;
  90606. this.triangleStart = 0;
  90607. this.originalOffsets = [];
  90608. }
  90609. DecimationVertex.prototype.updatePosition = function (newPosition) {
  90610. this.position.copyFrom(newPosition);
  90611. };
  90612. return DecimationVertex;
  90613. }());
  90614. var QuadraticMatrix = /** @class */ (function () {
  90615. function QuadraticMatrix(data) {
  90616. this.data = new Array(10);
  90617. for (var i = 0; i < 10; ++i) {
  90618. if (data && data[i]) {
  90619. this.data[i] = data[i];
  90620. }
  90621. else {
  90622. this.data[i] = 0;
  90623. }
  90624. }
  90625. }
  90626. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  90627. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  90628. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  90629. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  90630. return det;
  90631. };
  90632. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  90633. for (var i = 0; i < 10; ++i) {
  90634. this.data[i] += matrix.data[i];
  90635. }
  90636. };
  90637. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  90638. for (var i = 0; i < 10; ++i) {
  90639. this.data[i] += data[i];
  90640. }
  90641. };
  90642. QuadraticMatrix.prototype.add = function (matrix) {
  90643. var m = new QuadraticMatrix();
  90644. for (var i = 0; i < 10; ++i) {
  90645. m.data[i] = this.data[i] + matrix.data[i];
  90646. }
  90647. return m;
  90648. };
  90649. QuadraticMatrix.FromData = function (a, b, c, d) {
  90650. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  90651. };
  90652. //returning an array to avoid garbage collection
  90653. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  90654. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  90655. };
  90656. return QuadraticMatrix;
  90657. }());
  90658. var Reference = /** @class */ (function () {
  90659. function Reference(vertexId, triangleId) {
  90660. this.vertexId = vertexId;
  90661. this.triangleId = triangleId;
  90662. }
  90663. return Reference;
  90664. }());
  90665. /**
  90666. * An implementation of the Quadratic Error simplification algorithm.
  90667. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  90668. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  90669. * @author RaananW
  90670. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  90671. */
  90672. var QuadraticErrorSimplification = /** @class */ (function () {
  90673. function QuadraticErrorSimplification(_mesh) {
  90674. this._mesh = _mesh;
  90675. this.syncIterations = 5000;
  90676. this.aggressiveness = 7;
  90677. this.decimationIterations = 100;
  90678. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  90679. }
  90680. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  90681. var _this = this;
  90682. this.initDecimatedMesh();
  90683. //iterating through the submeshes array, one after the other.
  90684. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  90685. _this.initWithMesh(loop.index, function () {
  90686. _this.runDecimation(settings, loop.index, function () {
  90687. loop.executeNext();
  90688. });
  90689. }, settings.optimizeMesh);
  90690. }, function () {
  90691. setTimeout(function () {
  90692. successCallback(_this._reconstructedMesh);
  90693. }, 0);
  90694. });
  90695. };
  90696. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  90697. var _this = this;
  90698. var targetCount = ~~(this.triangles.length * settings.quality);
  90699. var deletedTriangles = 0;
  90700. var triangleCount = this.triangles.length;
  90701. var iterationFunction = function (iteration, callback) {
  90702. setTimeout(function () {
  90703. if (iteration % 5 === 0) {
  90704. _this.updateMesh(iteration === 0);
  90705. }
  90706. for (var i = 0; i < _this.triangles.length; ++i) {
  90707. _this.triangles[i].isDirty = false;
  90708. }
  90709. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  90710. var trianglesIterator = function (i) {
  90711. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  90712. var t = _this.triangles[tIdx];
  90713. if (!t) {
  90714. return;
  90715. }
  90716. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  90717. return;
  90718. }
  90719. for (var j = 0; j < 3; ++j) {
  90720. if (t.error[j] < threshold) {
  90721. var deleted0 = [];
  90722. var deleted1 = [];
  90723. var v0 = t.vertices[j];
  90724. var v1 = t.vertices[(j + 1) % 3];
  90725. if (v0.isBorder || v1.isBorder) {
  90726. continue;
  90727. }
  90728. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90729. // var n = Vector3.Zero();
  90730. // var uv = Vector2.Zero();
  90731. // var color = new Color4(0, 0, 0, 1);
  90732. _this.calculateError(v0, v1, p);
  90733. var delTr = new Array();
  90734. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  90735. continue;
  90736. }
  90737. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  90738. continue;
  90739. }
  90740. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  90741. continue;
  90742. }
  90743. var uniqueArray = new Array();
  90744. delTr.forEach(function (deletedT) {
  90745. if (uniqueArray.indexOf(deletedT) === -1) {
  90746. deletedT.deletePending = true;
  90747. uniqueArray.push(deletedT);
  90748. }
  90749. });
  90750. if (uniqueArray.length % 2 !== 0) {
  90751. continue;
  90752. }
  90753. v0.q = v1.q.add(v0.q);
  90754. v0.updatePosition(p);
  90755. var tStart = _this.references.length;
  90756. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  90757. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  90758. var tCount = _this.references.length - tStart;
  90759. if (tCount <= v0.triangleCount) {
  90760. if (tCount) {
  90761. for (var c = 0; c < tCount; c++) {
  90762. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  90763. }
  90764. }
  90765. }
  90766. else {
  90767. v0.triangleStart = tStart;
  90768. }
  90769. v0.triangleCount = tCount;
  90770. break;
  90771. }
  90772. }
  90773. };
  90774. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  90775. }, 0);
  90776. };
  90777. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  90778. if (triangleCount - deletedTriangles <= targetCount) {
  90779. loop.breakLoop();
  90780. }
  90781. else {
  90782. iterationFunction(loop.index, function () {
  90783. loop.executeNext();
  90784. });
  90785. }
  90786. }, function () {
  90787. setTimeout(function () {
  90788. //reconstruct this part of the mesh
  90789. _this.reconstructMesh(submeshIndex);
  90790. successCallback();
  90791. }, 0);
  90792. });
  90793. };
  90794. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  90795. var _this = this;
  90796. this.vertices = [];
  90797. this.triangles = [];
  90798. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  90799. var indices = this._mesh.getIndices();
  90800. var submesh = this._mesh.subMeshes[submeshIndex];
  90801. var findInVertices = function (positionToSearch) {
  90802. if (optimizeMesh) {
  90803. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  90804. if (_this.vertices[ii].position.equals(positionToSearch)) {
  90805. return _this.vertices[ii];
  90806. }
  90807. }
  90808. }
  90809. return null;
  90810. };
  90811. var vertexReferences = [];
  90812. var vertexInit = function (i) {
  90813. if (!positionData) {
  90814. return;
  90815. }
  90816. var offset = i + submesh.verticesStart;
  90817. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  90818. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  90819. vertex.originalOffsets.push(offset);
  90820. if (vertex.id === _this.vertices.length) {
  90821. _this.vertices.push(vertex);
  90822. }
  90823. vertexReferences.push(vertex.id);
  90824. };
  90825. //var totalVertices = mesh.getTotalVertices();
  90826. var totalVertices = submesh.verticesCount;
  90827. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  90828. var indicesInit = function (i) {
  90829. if (!indices) {
  90830. return;
  90831. }
  90832. var offset = (submesh.indexStart / 3) + i;
  90833. var pos = (offset * 3);
  90834. var i0 = indices[pos + 0];
  90835. var i1 = indices[pos + 1];
  90836. var i2 = indices[pos + 2];
  90837. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  90838. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  90839. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  90840. var triangle = new DecimationTriangle([v0, v1, v2]);
  90841. triangle.originalOffset = pos;
  90842. _this.triangles.push(triangle);
  90843. };
  90844. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  90845. _this.init(callback);
  90846. });
  90847. });
  90848. };
  90849. QuadraticErrorSimplification.prototype.init = function (callback) {
  90850. var _this = this;
  90851. var triangleInit1 = function (i) {
  90852. var t = _this.triangles[i];
  90853. 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();
  90854. for (var j = 0; j < 3; j++) {
  90855. 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))));
  90856. }
  90857. };
  90858. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  90859. var triangleInit2 = function (i) {
  90860. var t = _this.triangles[i];
  90861. for (var j = 0; j < 3; ++j) {
  90862. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  90863. }
  90864. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  90865. };
  90866. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  90867. callback();
  90868. });
  90869. });
  90870. };
  90871. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  90872. var newTriangles = [];
  90873. var i;
  90874. for (i = 0; i < this.vertices.length; ++i) {
  90875. this.vertices[i].triangleCount = 0;
  90876. }
  90877. var t;
  90878. var j;
  90879. for (i = 0; i < this.triangles.length; ++i) {
  90880. if (!this.triangles[i].deleted) {
  90881. t = this.triangles[i];
  90882. for (j = 0; j < 3; ++j) {
  90883. t.vertices[j].triangleCount = 1;
  90884. }
  90885. newTriangles.push(t);
  90886. }
  90887. }
  90888. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  90889. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  90890. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  90891. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  90892. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  90893. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  90894. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  90895. var vertexCount = 0;
  90896. for (i = 0; i < this.vertices.length; ++i) {
  90897. var vertex = this.vertices[i];
  90898. vertex.id = vertexCount;
  90899. if (vertex.triangleCount) {
  90900. vertex.originalOffsets.forEach(function (originalOffset) {
  90901. if (!normalData) {
  90902. return;
  90903. }
  90904. newPositionData.push(vertex.position.x);
  90905. newPositionData.push(vertex.position.y);
  90906. newPositionData.push(vertex.position.z);
  90907. newNormalData.push(normalData[originalOffset * 3]);
  90908. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  90909. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  90910. if (uvs && uvs.length) {
  90911. newUVsData.push(uvs[(originalOffset * 2)]);
  90912. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  90913. }
  90914. else if (colorsData && colorsData.length) {
  90915. newColorsData.push(colorsData[(originalOffset * 4)]);
  90916. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  90917. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  90918. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  90919. }
  90920. ++vertexCount;
  90921. });
  90922. }
  90923. }
  90924. var startingIndex = this._reconstructedMesh.getTotalIndices();
  90925. var startingVertex = this._reconstructedMesh.getTotalVertices();
  90926. var submeshesArray = this._reconstructedMesh.subMeshes;
  90927. this._reconstructedMesh.subMeshes = [];
  90928. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  90929. var originalIndices = this._mesh.getIndices();
  90930. for (i = 0; i < newTriangles.length; ++i) {
  90931. t = newTriangles[i]; //now get the new referencing point for each vertex
  90932. [0, 1, 2].forEach(function (idx) {
  90933. var id = originalIndices[t.originalOffset + idx];
  90934. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  90935. if (offset < 0) {
  90936. offset = 0;
  90937. }
  90938. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  90939. });
  90940. }
  90941. //overwriting the old vertex buffers and indices.
  90942. this._reconstructedMesh.setIndices(newIndicesArray);
  90943. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  90944. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  90945. if (newUVsData.length > 0) {
  90946. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  90947. }
  90948. if (newColorsData.length > 0) {
  90949. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  90950. }
  90951. //create submesh
  90952. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  90953. if (submeshIndex > 0) {
  90954. this._reconstructedMesh.subMeshes = [];
  90955. submeshesArray.forEach(function (submesh) {
  90956. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  90957. });
  90958. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  90959. }
  90960. };
  90961. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  90962. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  90963. this._reconstructedMesh.material = this._mesh.material;
  90964. this._reconstructedMesh.parent = this._mesh.parent;
  90965. this._reconstructedMesh.isVisible = false;
  90966. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  90967. };
  90968. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  90969. for (var i = 0; i < vertex1.triangleCount; ++i) {
  90970. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  90971. if (t.deleted) {
  90972. continue;
  90973. }
  90974. var s = this.references[vertex1.triangleStart + i].vertexId;
  90975. var v1 = t.vertices[(s + 1) % 3];
  90976. var v2 = t.vertices[(s + 2) % 3];
  90977. if ((v1 === vertex2 || v2 === vertex2)) {
  90978. deletedArray[i] = true;
  90979. delTr.push(t);
  90980. continue;
  90981. }
  90982. var d1 = v1.position.subtract(point);
  90983. d1 = d1.normalize();
  90984. var d2 = v2.position.subtract(point);
  90985. d2 = d2.normalize();
  90986. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  90987. return true;
  90988. }
  90989. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  90990. deletedArray[i] = false;
  90991. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  90992. return true;
  90993. }
  90994. }
  90995. return false;
  90996. };
  90997. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  90998. var newDeleted = deletedTriangles;
  90999. for (var i = 0; i < vertex.triangleCount; ++i) {
  91000. var ref = this.references[vertex.triangleStart + i];
  91001. var t = this.triangles[ref.triangleId];
  91002. if (t.deleted) {
  91003. continue;
  91004. }
  91005. if (deletedArray[i] && t.deletePending) {
  91006. t.deleted = true;
  91007. newDeleted++;
  91008. continue;
  91009. }
  91010. t.vertices[ref.vertexId] = origVertex;
  91011. t.isDirty = true;
  91012. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  91013. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  91014. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  91015. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  91016. this.references.push(ref);
  91017. }
  91018. return newDeleted;
  91019. };
  91020. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  91021. for (var i = 0; i < this.vertices.length; ++i) {
  91022. var vCount = [];
  91023. var vId = [];
  91024. var v = this.vertices[i];
  91025. var j;
  91026. for (j = 0; j < v.triangleCount; ++j) {
  91027. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  91028. for (var ii = 0; ii < 3; ii++) {
  91029. var ofs = 0;
  91030. var vv = triangle.vertices[ii];
  91031. while (ofs < vCount.length) {
  91032. if (vId[ofs] === vv.id) {
  91033. break;
  91034. }
  91035. ++ofs;
  91036. }
  91037. if (ofs === vCount.length) {
  91038. vCount.push(1);
  91039. vId.push(vv.id);
  91040. }
  91041. else {
  91042. vCount[ofs]++;
  91043. }
  91044. }
  91045. }
  91046. for (j = 0; j < vCount.length; ++j) {
  91047. if (vCount[j] === 1) {
  91048. this.vertices[vId[j]].isBorder = true;
  91049. }
  91050. else {
  91051. this.vertices[vId[j]].isBorder = false;
  91052. }
  91053. }
  91054. }
  91055. };
  91056. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  91057. if (identifyBorders === void 0) { identifyBorders = false; }
  91058. var i;
  91059. if (!identifyBorders) {
  91060. var newTrianglesVector = [];
  91061. for (i = 0; i < this.triangles.length; ++i) {
  91062. if (!this.triangles[i].deleted) {
  91063. newTrianglesVector.push(this.triangles[i]);
  91064. }
  91065. }
  91066. this.triangles = newTrianglesVector;
  91067. }
  91068. for (i = 0; i < this.vertices.length; ++i) {
  91069. this.vertices[i].triangleCount = 0;
  91070. this.vertices[i].triangleStart = 0;
  91071. }
  91072. var t;
  91073. var j;
  91074. var v;
  91075. for (i = 0; i < this.triangles.length; ++i) {
  91076. t = this.triangles[i];
  91077. for (j = 0; j < 3; ++j) {
  91078. v = t.vertices[j];
  91079. v.triangleCount++;
  91080. }
  91081. }
  91082. var tStart = 0;
  91083. for (i = 0; i < this.vertices.length; ++i) {
  91084. this.vertices[i].triangleStart = tStart;
  91085. tStart += this.vertices[i].triangleCount;
  91086. this.vertices[i].triangleCount = 0;
  91087. }
  91088. var newReferences = new Array(this.triangles.length * 3);
  91089. for (i = 0; i < this.triangles.length; ++i) {
  91090. t = this.triangles[i];
  91091. for (j = 0; j < 3; ++j) {
  91092. v = t.vertices[j];
  91093. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  91094. v.triangleCount++;
  91095. }
  91096. }
  91097. this.references = newReferences;
  91098. if (identifyBorders) {
  91099. this.identifyBorder();
  91100. }
  91101. };
  91102. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  91103. var x = point.x;
  91104. var y = point.y;
  91105. var z = point.z;
  91106. 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
  91107. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  91108. };
  91109. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  91110. var q = vertex1.q.add(vertex2.q);
  91111. var border = vertex1.isBorder && vertex2.isBorder;
  91112. var error = 0;
  91113. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  91114. if (qDet !== 0 && !border) {
  91115. if (!pointResult) {
  91116. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91117. }
  91118. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  91119. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  91120. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  91121. error = this.vertexError(q, pointResult);
  91122. }
  91123. else {
  91124. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  91125. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  91126. var error1 = this.vertexError(q, vertex1.position);
  91127. var error2 = this.vertexError(q, vertex2.position);
  91128. var error3 = this.vertexError(q, p3);
  91129. error = Math.min(error1, error2, error3);
  91130. if (error === error1) {
  91131. if (pointResult) {
  91132. pointResult.copyFrom(vertex1.position);
  91133. }
  91134. }
  91135. else if (error === error2) {
  91136. if (pointResult) {
  91137. pointResult.copyFrom(vertex2.position);
  91138. }
  91139. }
  91140. else {
  91141. if (pointResult) {
  91142. pointResult.copyFrom(p3);
  91143. }
  91144. }
  91145. }
  91146. return error;
  91147. };
  91148. return QuadraticErrorSimplification;
  91149. }());
  91150. /***/ }),
  91151. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  91152. /*!****************************************************!*\
  91153. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  91154. \****************************************************/
  91155. /*! exports provided: SimplicationQueueSceneComponent */
  91156. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91157. "use strict";
  91158. __webpack_require__.r(__webpack_exports__);
  91159. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  91160. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  91161. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  91162. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  91163. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  91164. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  91165. get: function () {
  91166. if (!this._simplificationQueue) {
  91167. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  91168. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  91169. if (!component) {
  91170. component = new SimplicationQueueSceneComponent(this);
  91171. this._addComponent(component);
  91172. }
  91173. }
  91174. return this._simplificationQueue;
  91175. },
  91176. set: function (value) {
  91177. this._simplificationQueue = value;
  91178. },
  91179. enumerable: true,
  91180. configurable: true
  91181. });
  91182. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  91183. if (parallelProcessing === void 0) { parallelProcessing = true; }
  91184. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  91185. this.getScene().simplificationQueue.addTask({
  91186. settings: settings,
  91187. parallelProcessing: parallelProcessing,
  91188. mesh: this,
  91189. simplificationType: simplificationType,
  91190. successCallback: successCallback
  91191. });
  91192. return this;
  91193. };
  91194. /**
  91195. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  91196. * created in a scene
  91197. */
  91198. var SimplicationQueueSceneComponent = /** @class */ (function () {
  91199. /**
  91200. * Creates a new instance of the component for the given scene
  91201. * @param scene Defines the scene to register the component in
  91202. */
  91203. function SimplicationQueueSceneComponent(scene) {
  91204. /**
  91205. * The component name helpfull to identify the component in the list of scene components.
  91206. */
  91207. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  91208. this.scene = scene;
  91209. }
  91210. /**
  91211. * Registers the component in a given scene
  91212. */
  91213. SimplicationQueueSceneComponent.prototype.register = function () {
  91214. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  91215. };
  91216. /**
  91217. * Rebuilds the elements related to this component in case of
  91218. * context lost for instance.
  91219. */
  91220. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  91221. // Nothing to do for this component
  91222. };
  91223. /**
  91224. * Disposes the component and the associated ressources
  91225. */
  91226. SimplicationQueueSceneComponent.prototype.dispose = function () {
  91227. // Nothing to do for this component
  91228. };
  91229. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  91230. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  91231. this.scene._simplificationQueue.executeNext();
  91232. }
  91233. };
  91234. return SimplicationQueueSceneComponent;
  91235. }());
  91236. /***/ }),
  91237. /***/ "./Meshes/polygonMesh.ts":
  91238. /*!*******************************!*\
  91239. !*** ./Meshes/polygonMesh.ts ***!
  91240. \*******************************/
  91241. /*! exports provided: Polygon, PolygonMeshBuilder */
  91242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91243. "use strict";
  91244. __webpack_require__.r(__webpack_exports__);
  91245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  91246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  91247. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91248. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91249. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  91250. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  91251. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  91252. /**
  91253. * Vector2 wth index property
  91254. */
  91255. var IndexedVector2 = /** @class */ (function (_super) {
  91256. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  91257. function IndexedVector2(original,
  91258. /** Index of the vector2 */
  91259. index) {
  91260. var _this = _super.call(this, original.x, original.y) || this;
  91261. _this.index = index;
  91262. return _this;
  91263. }
  91264. return IndexedVector2;
  91265. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  91266. /**
  91267. * Defines points to create a polygon
  91268. */
  91269. var PolygonPoints = /** @class */ (function () {
  91270. function PolygonPoints() {
  91271. this.elements = new Array();
  91272. }
  91273. PolygonPoints.prototype.add = function (originalPoints) {
  91274. var _this = this;
  91275. var result = new Array();
  91276. originalPoints.forEach(function (point) {
  91277. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  91278. var newPoint = new IndexedVector2(point, _this.elements.length);
  91279. result.push(newPoint);
  91280. _this.elements.push(newPoint);
  91281. }
  91282. });
  91283. return result;
  91284. };
  91285. PolygonPoints.prototype.computeBounds = function () {
  91286. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  91287. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  91288. this.elements.forEach(function (point) {
  91289. // x
  91290. if (point.x < lmin.x) {
  91291. lmin.x = point.x;
  91292. }
  91293. else if (point.x > lmax.x) {
  91294. lmax.x = point.x;
  91295. }
  91296. // y
  91297. if (point.y < lmin.y) {
  91298. lmin.y = point.y;
  91299. }
  91300. else if (point.y > lmax.y) {
  91301. lmax.y = point.y;
  91302. }
  91303. });
  91304. return {
  91305. min: lmin,
  91306. max: lmax,
  91307. width: lmax.x - lmin.x,
  91308. height: lmax.y - lmin.y
  91309. };
  91310. };
  91311. return PolygonPoints;
  91312. }());
  91313. /**
  91314. * Polygon
  91315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91316. */
  91317. var Polygon = /** @class */ (function () {
  91318. function Polygon() {
  91319. }
  91320. /**
  91321. * Creates a rectangle
  91322. * @param xmin bottom X coord
  91323. * @param ymin bottom Y coord
  91324. * @param xmax top X coord
  91325. * @param ymax top Y coord
  91326. * @returns points that make the resulting rectation
  91327. */
  91328. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  91329. return [
  91330. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  91331. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  91332. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  91333. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  91334. ];
  91335. };
  91336. /**
  91337. * Creates a circle
  91338. * @param radius radius of circle
  91339. * @param cx scale in x
  91340. * @param cy scale in y
  91341. * @param numberOfSides number of sides that make up the circle
  91342. * @returns points that make the resulting circle
  91343. */
  91344. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  91345. if (cx === void 0) { cx = 0; }
  91346. if (cy === void 0) { cy = 0; }
  91347. if (numberOfSides === void 0) { numberOfSides = 32; }
  91348. var result = new Array();
  91349. var angle = 0;
  91350. var increment = (Math.PI * 2) / numberOfSides;
  91351. for (var i = 0; i < numberOfSides; i++) {
  91352. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  91353. angle -= increment;
  91354. }
  91355. return result;
  91356. };
  91357. /**
  91358. * Creates a polygon from input string
  91359. * @param input Input polygon data
  91360. * @returns the parsed points
  91361. */
  91362. Polygon.Parse = function (input) {
  91363. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  91364. var i, result = [];
  91365. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  91366. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  91367. }
  91368. return result;
  91369. };
  91370. /**
  91371. * Starts building a polygon from x and y coordinates
  91372. * @param x x coordinate
  91373. * @param y y coordinate
  91374. * @returns the started path2
  91375. */
  91376. Polygon.StartingAt = function (x, y) {
  91377. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  91378. };
  91379. return Polygon;
  91380. }());
  91381. /**
  91382. * Builds a polygon
  91383. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  91384. */
  91385. var PolygonMeshBuilder = /** @class */ (function () {
  91386. /**
  91387. * Creates a PolygonMeshBuilder
  91388. * @param name name of the builder
  91389. * @param contours Path of the polygon
  91390. * @param scene scene to add to
  91391. * @param earcutInjection can be used to inject your own earcut reference
  91392. */
  91393. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  91394. if (earcutInjection === void 0) { earcutInjection = earcut; }
  91395. this._points = new PolygonPoints();
  91396. this._outlinepoints = new PolygonPoints();
  91397. this._holes = new Array();
  91398. this._epoints = new Array();
  91399. this._eholes = new Array();
  91400. this.bjsEarcut = earcutInjection;
  91401. this._name = name;
  91402. this._scene = scene;
  91403. var points;
  91404. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  91405. points = contours.getPoints();
  91406. }
  91407. else {
  91408. points = contours;
  91409. }
  91410. this._addToepoint(points);
  91411. this._points.add(points);
  91412. this._outlinepoints.add(points);
  91413. if (typeof this.bjsEarcut === 'undefined') {
  91414. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  91415. }
  91416. }
  91417. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  91418. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  91419. var p = points_1[_i];
  91420. this._epoints.push(p.x, p.y);
  91421. }
  91422. };
  91423. /**
  91424. * Adds a whole within the polygon
  91425. * @param hole Array of points defining the hole
  91426. * @returns this
  91427. */
  91428. PolygonMeshBuilder.prototype.addHole = function (hole) {
  91429. this._points.add(hole);
  91430. var holepoints = new PolygonPoints();
  91431. holepoints.add(hole);
  91432. this._holes.push(holepoints);
  91433. this._eholes.push(this._epoints.length / 2);
  91434. this._addToepoint(hole);
  91435. return this;
  91436. };
  91437. /**
  91438. * Creates the polygon
  91439. * @param updatable If the mesh should be updatable
  91440. * @param depth The depth of the mesh created
  91441. * @returns the created mesh
  91442. */
  91443. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  91444. var _this = this;
  91445. if (updatable === void 0) { updatable = false; }
  91446. if (depth === void 0) { depth = 0; }
  91447. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  91448. var normals = new Array();
  91449. var positions = new Array();
  91450. var uvs = new Array();
  91451. var bounds = this._points.computeBounds();
  91452. this._points.elements.forEach(function (p) {
  91453. normals.push(0, 1.0, 0);
  91454. positions.push(p.x, 0, p.y);
  91455. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  91456. });
  91457. var indices = new Array();
  91458. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  91459. for (var i = 0; i < res.length; i++) {
  91460. indices.push(res[i]);
  91461. }
  91462. if (depth > 0) {
  91463. var positionscount = (positions.length / 3); //get the current pointcount
  91464. this._points.elements.forEach(function (p) {
  91465. normals.push(0, -1.0, 0);
  91466. positions.push(p.x, -depth, p.y);
  91467. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  91468. });
  91469. var totalCount = indices.length;
  91470. for (var i = 0; i < totalCount; i += 3) {
  91471. var i0 = indices[i + 0];
  91472. var i1 = indices[i + 1];
  91473. var i2 = indices[i + 2];
  91474. indices.push(i2 + positionscount);
  91475. indices.push(i1 + positionscount);
  91476. indices.push(i0 + positionscount);
  91477. }
  91478. //Add the sides
  91479. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  91480. this._holes.forEach(function (hole) {
  91481. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  91482. });
  91483. }
  91484. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  91485. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  91486. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  91487. result.setIndices(indices);
  91488. return result;
  91489. };
  91490. /**
  91491. * Adds a side to the polygon
  91492. * @param positions points that make the polygon
  91493. * @param normals normals of the polygon
  91494. * @param uvs uvs of the polygon
  91495. * @param indices indices of the polygon
  91496. * @param bounds bounds of the polygon
  91497. * @param points points of the polygon
  91498. * @param depth depth of the polygon
  91499. * @param flip flip of the polygon
  91500. */
  91501. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  91502. var StartIndex = positions.length / 3;
  91503. var ulength = 0;
  91504. for (var i = 0; i < points.elements.length; i++) {
  91505. var p = points.elements[i];
  91506. var p1;
  91507. if ((i + 1) > points.elements.length - 1) {
  91508. p1 = points.elements[0];
  91509. }
  91510. else {
  91511. p1 = points.elements[i + 1];
  91512. }
  91513. positions.push(p.x, 0, p.y);
  91514. positions.push(p.x, -depth, p.y);
  91515. positions.push(p1.x, 0, p1.y);
  91516. positions.push(p1.x, -depth, p1.y);
  91517. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  91518. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  91519. var v3 = v2.subtract(v1);
  91520. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  91521. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  91522. vn = vn.normalize();
  91523. uvs.push(ulength / bounds.width, 0);
  91524. uvs.push(ulength / bounds.width, 1);
  91525. ulength += v3.length();
  91526. uvs.push((ulength / bounds.width), 0);
  91527. uvs.push((ulength / bounds.width), 1);
  91528. if (!flip) {
  91529. normals.push(-vn.x, -vn.y, -vn.z);
  91530. normals.push(-vn.x, -vn.y, -vn.z);
  91531. normals.push(-vn.x, -vn.y, -vn.z);
  91532. normals.push(-vn.x, -vn.y, -vn.z);
  91533. indices.push(StartIndex);
  91534. indices.push(StartIndex + 1);
  91535. indices.push(StartIndex + 2);
  91536. indices.push(StartIndex + 1);
  91537. indices.push(StartIndex + 3);
  91538. indices.push(StartIndex + 2);
  91539. }
  91540. else {
  91541. normals.push(vn.x, vn.y, vn.z);
  91542. normals.push(vn.x, vn.y, vn.z);
  91543. normals.push(vn.x, vn.y, vn.z);
  91544. normals.push(vn.x, vn.y, vn.z);
  91545. indices.push(StartIndex);
  91546. indices.push(StartIndex + 2);
  91547. indices.push(StartIndex + 1);
  91548. indices.push(StartIndex + 1);
  91549. indices.push(StartIndex + 2);
  91550. indices.push(StartIndex + 3);
  91551. }
  91552. StartIndex += 4;
  91553. }
  91554. };
  91555. return PolygonMeshBuilder;
  91556. }());
  91557. /***/ }),
  91558. /***/ "./Meshes/subMesh.ts":
  91559. /*!***************************!*\
  91560. !*** ./Meshes/subMesh.ts ***!
  91561. \***************************/
  91562. /*! exports provided: BaseSubMesh, SubMesh */
  91563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91564. "use strict";
  91565. __webpack_require__.r(__webpack_exports__);
  91566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  91567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  91568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91569. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  91570. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  91571. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  91572. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  91573. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  91574. /**
  91575. * Base class for submeshes
  91576. */
  91577. var BaseSubMesh = /** @class */ (function () {
  91578. function BaseSubMesh() {
  91579. }
  91580. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  91581. /**
  91582. * Gets associated effect
  91583. */
  91584. get: function () {
  91585. return this._materialEffect;
  91586. },
  91587. enumerable: true,
  91588. configurable: true
  91589. });
  91590. /**
  91591. * Sets associated effect (effect used to render this submesh)
  91592. * @param effect defines the effect to associate with
  91593. * @param defines defines the set of defines used to compile this effect
  91594. */
  91595. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  91596. if (defines === void 0) { defines = null; }
  91597. if (this._materialEffect === effect) {
  91598. if (!effect) {
  91599. this._materialDefines = null;
  91600. }
  91601. return;
  91602. }
  91603. this._materialDefines = defines;
  91604. this._materialEffect = effect;
  91605. };
  91606. return BaseSubMesh;
  91607. }());
  91608. /**
  91609. * Defines a subdivision inside a mesh
  91610. */
  91611. var SubMesh = /** @class */ (function (_super) {
  91612. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  91613. /**
  91614. * Creates a new submesh
  91615. * @param materialIndex defines the material index to use
  91616. * @param verticesStart defines vertex index start
  91617. * @param verticesCount defines vertices count
  91618. * @param indexStart defines index start
  91619. * @param indexCount defines indices count
  91620. * @param mesh defines the parent mesh
  91621. * @param renderingMesh defines an optional rendering mesh
  91622. * @param createBoundingBox defines if bounding box should be created for this submesh
  91623. */
  91624. function SubMesh(
  91625. /** the material index to use */
  91626. materialIndex,
  91627. /** vertex index start */
  91628. verticesStart,
  91629. /** vertices count */
  91630. verticesCount,
  91631. /** index start */
  91632. indexStart,
  91633. /** indices count */
  91634. indexCount, mesh, renderingMesh, createBoundingBox) {
  91635. if (createBoundingBox === void 0) { createBoundingBox = true; }
  91636. var _this = _super.call(this) || this;
  91637. _this.materialIndex = materialIndex;
  91638. _this.verticesStart = verticesStart;
  91639. _this.verticesCount = verticesCount;
  91640. _this.indexStart = indexStart;
  91641. _this.indexCount = indexCount;
  91642. /** @hidden */
  91643. _this._renderId = 0;
  91644. _this._mesh = mesh;
  91645. _this._renderingMesh = renderingMesh || mesh;
  91646. mesh.subMeshes.push(_this);
  91647. _this._trianglePlanes = [];
  91648. _this._id = mesh.subMeshes.length - 1;
  91649. if (createBoundingBox) {
  91650. _this.refreshBoundingInfo();
  91651. mesh.computeWorldMatrix(true);
  91652. }
  91653. return _this;
  91654. }
  91655. /**
  91656. * Add a new submesh to a mesh
  91657. * @param materialIndex defines the material index to use
  91658. * @param verticesStart defines vertex index start
  91659. * @param verticesCount defines vertices count
  91660. * @param indexStart defines index start
  91661. * @param indexCount defines indices count
  91662. * @param mesh defines the parent mesh
  91663. * @param renderingMesh defines an optional rendering mesh
  91664. * @param createBoundingBox defines if bounding box should be created for this submesh
  91665. * @returns the new submesh
  91666. */
  91667. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  91668. if (createBoundingBox === void 0) { createBoundingBox = true; }
  91669. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  91670. };
  91671. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  91672. /**
  91673. * Returns true if this submesh covers the entire parent mesh
  91674. * @ignorenaming
  91675. */
  91676. get: function () {
  91677. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  91678. },
  91679. enumerable: true,
  91680. configurable: true
  91681. });
  91682. /**
  91683. * Returns the submesh BoudingInfo object
  91684. * @returns current bounding info (or mesh's one if the submesh is global)
  91685. */
  91686. SubMesh.prototype.getBoundingInfo = function () {
  91687. if (this.IsGlobal) {
  91688. return this._mesh.getBoundingInfo();
  91689. }
  91690. return this._boundingInfo;
  91691. };
  91692. /**
  91693. * Sets the submesh BoundingInfo
  91694. * @param boundingInfo defines the new bounding info to use
  91695. * @returns the SubMesh
  91696. */
  91697. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  91698. this._boundingInfo = boundingInfo;
  91699. return this;
  91700. };
  91701. /**
  91702. * Returns the mesh of the current submesh
  91703. * @return the parent mesh
  91704. */
  91705. SubMesh.prototype.getMesh = function () {
  91706. return this._mesh;
  91707. };
  91708. /**
  91709. * Returns the rendering mesh of the submesh
  91710. * @returns the rendering mesh (could be different from parent mesh)
  91711. */
  91712. SubMesh.prototype.getRenderingMesh = function () {
  91713. return this._renderingMesh;
  91714. };
  91715. /**
  91716. * Returns the submesh material
  91717. * @returns null or the current material
  91718. */
  91719. SubMesh.prototype.getMaterial = function () {
  91720. var rootMaterial = this._renderingMesh.material;
  91721. if (rootMaterial === null || rootMaterial === undefined) {
  91722. return this._mesh.getScene().defaultMaterial;
  91723. }
  91724. else if (rootMaterial.getSubMaterial) {
  91725. var multiMaterial = rootMaterial;
  91726. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  91727. if (this._currentMaterial !== effectiveMaterial) {
  91728. this._currentMaterial = effectiveMaterial;
  91729. this._materialDefines = null;
  91730. }
  91731. return effectiveMaterial;
  91732. }
  91733. return rootMaterial;
  91734. };
  91735. // Methods
  91736. /**
  91737. * Sets a new updated BoundingInfo object to the submesh
  91738. * @returns the SubMesh
  91739. */
  91740. SubMesh.prototype.refreshBoundingInfo = function () {
  91741. this._lastColliderWorldVertices = null;
  91742. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  91743. return this;
  91744. }
  91745. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  91746. if (!data) {
  91747. this._boundingInfo = this._mesh.getBoundingInfo();
  91748. return this;
  91749. }
  91750. var indices = this._renderingMesh.getIndices();
  91751. var extend;
  91752. //is this the only submesh?
  91753. if (this.indexStart === 0 && this.indexCount === indices.length) {
  91754. var boundingInfo = this._renderingMesh.getBoundingInfo();
  91755. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  91756. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  91757. }
  91758. else {
  91759. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  91760. }
  91761. if (this._boundingInfo) {
  91762. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  91763. }
  91764. else {
  91765. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  91766. }
  91767. return this;
  91768. };
  91769. /** @hidden */
  91770. SubMesh.prototype._checkCollision = function (collider) {
  91771. var boundingInfo = this.getBoundingInfo();
  91772. return boundingInfo._checkCollision(collider);
  91773. };
  91774. /**
  91775. * Updates the submesh BoundingInfo
  91776. * @param world defines the world matrix to use to update the bounding info
  91777. * @returns the submesh
  91778. */
  91779. SubMesh.prototype.updateBoundingInfo = function (world) {
  91780. var boundingInfo = this.getBoundingInfo();
  91781. if (!boundingInfo) {
  91782. this.refreshBoundingInfo();
  91783. boundingInfo = this.getBoundingInfo();
  91784. }
  91785. boundingInfo.update(world);
  91786. return this;
  91787. };
  91788. /**
  91789. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  91790. * @param frustumPlanes defines the frustum planes
  91791. * @returns true if the submesh is intersecting with the frustum
  91792. */
  91793. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  91794. var boundingInfo = this.getBoundingInfo();
  91795. if (!boundingInfo) {
  91796. return false;
  91797. }
  91798. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  91799. };
  91800. /**
  91801. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  91802. * @param frustumPlanes defines the frustum planes
  91803. * @returns true if the submesh is inside the frustum
  91804. */
  91805. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  91806. var boundingInfo = this.getBoundingInfo();
  91807. if (!boundingInfo) {
  91808. return false;
  91809. }
  91810. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  91811. };
  91812. /**
  91813. * Renders the submesh
  91814. * @param enableAlphaMode defines if alpha needs to be used
  91815. * @returns the submesh
  91816. */
  91817. SubMesh.prototype.render = function (enableAlphaMode) {
  91818. this._renderingMesh.render(this, enableAlphaMode);
  91819. return this;
  91820. };
  91821. /**
  91822. * @hidden
  91823. */
  91824. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  91825. if (!this._linesIndexBuffer) {
  91826. var linesIndices = [];
  91827. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  91828. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  91829. }
  91830. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  91831. this._linesIndexCount = linesIndices.length;
  91832. }
  91833. return this._linesIndexBuffer;
  91834. };
  91835. /**
  91836. * Checks if the submesh intersects with a ray
  91837. * @param ray defines the ray to test
  91838. * @returns true is the passed ray intersects the submesh bounding box
  91839. */
  91840. SubMesh.prototype.canIntersects = function (ray) {
  91841. var boundingInfo = this.getBoundingInfo();
  91842. if (!boundingInfo) {
  91843. return false;
  91844. }
  91845. return ray.intersectsBox(boundingInfo.boundingBox);
  91846. };
  91847. /**
  91848. * Intersects current submesh with a ray
  91849. * @param ray defines the ray to test
  91850. * @param positions defines mesh's positions array
  91851. * @param indices defines mesh's indices array
  91852. * @param fastCheck defines if only bounding info should be used
  91853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91854. * @returns intersection info or null if no intersection
  91855. */
  91856. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  91857. var material = this.getMaterial();
  91858. if (!material) {
  91859. return null;
  91860. }
  91861. switch (material.fillMode) {
  91862. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  91863. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  91864. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  91865. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  91866. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  91867. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  91868. return null;
  91869. }
  91870. // LineMesh first as it's also a Mesh...
  91871. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  91872. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  91873. }
  91874. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  91875. };
  91876. /** @hidden */
  91877. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  91878. var intersectInfo = null;
  91879. // Line test
  91880. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  91881. var p0 = positions[indices[index]];
  91882. var p1 = positions[indices[index + 1]];
  91883. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  91884. if (length < 0) {
  91885. continue;
  91886. }
  91887. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  91888. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  91889. intersectInfo.faceId = index / 2;
  91890. if (fastCheck) {
  91891. break;
  91892. }
  91893. }
  91894. }
  91895. return intersectInfo;
  91896. };
  91897. /** @hidden */
  91898. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  91899. var intersectInfo = null;
  91900. // Triangles test
  91901. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  91902. var p0 = positions[indices[index]];
  91903. var p1 = positions[indices[index + 1]];
  91904. var p2 = positions[indices[index + 2]];
  91905. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  91906. continue;
  91907. }
  91908. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  91909. if (currentIntersectInfo) {
  91910. if (currentIntersectInfo.distance < 0) {
  91911. continue;
  91912. }
  91913. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  91914. intersectInfo = currentIntersectInfo;
  91915. intersectInfo.faceId = index / 3;
  91916. if (fastCheck) {
  91917. break;
  91918. }
  91919. }
  91920. }
  91921. }
  91922. return intersectInfo;
  91923. };
  91924. /** @hidden */
  91925. SubMesh.prototype._rebuild = function () {
  91926. if (this._linesIndexBuffer) {
  91927. this._linesIndexBuffer = null;
  91928. }
  91929. };
  91930. // Clone
  91931. /**
  91932. * Creates a new submesh from the passed mesh
  91933. * @param newMesh defines the new hosting mesh
  91934. * @param newRenderingMesh defines an optional rendering mesh
  91935. * @returns the new submesh
  91936. */
  91937. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  91938. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  91939. if (!this.IsGlobal) {
  91940. var boundingInfo = this.getBoundingInfo();
  91941. if (!boundingInfo) {
  91942. return result;
  91943. }
  91944. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  91945. }
  91946. return result;
  91947. };
  91948. // Dispose
  91949. /**
  91950. * Release associated resources
  91951. */
  91952. SubMesh.prototype.dispose = function () {
  91953. if (this._linesIndexBuffer) {
  91954. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  91955. this._linesIndexBuffer = null;
  91956. }
  91957. // Remove from mesh
  91958. var index = this._mesh.subMeshes.indexOf(this);
  91959. this._mesh.subMeshes.splice(index, 1);
  91960. };
  91961. /**
  91962. * Gets the class name
  91963. * @returns the string "SubMesh".
  91964. */
  91965. SubMesh.prototype.getClassName = function () {
  91966. return "SubMesh";
  91967. };
  91968. // Statics
  91969. /**
  91970. * Creates a new submesh from indices data
  91971. * @param materialIndex the index of the main mesh material
  91972. * @param startIndex the index where to start the copy in the mesh indices array
  91973. * @param indexCount the number of indices to copy then from the startIndex
  91974. * @param mesh the main mesh to create the submesh from
  91975. * @param renderingMesh the optional rendering mesh
  91976. * @returns a new submesh
  91977. */
  91978. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  91979. var minVertexIndex = Number.MAX_VALUE;
  91980. var maxVertexIndex = -Number.MAX_VALUE;
  91981. var whatWillRender = (renderingMesh || mesh);
  91982. var indices = whatWillRender.getIndices();
  91983. for (var index = startIndex; index < startIndex + indexCount; index++) {
  91984. var vertexIndex = indices[index];
  91985. if (vertexIndex < minVertexIndex) {
  91986. minVertexIndex = vertexIndex;
  91987. }
  91988. if (vertexIndex > maxVertexIndex) {
  91989. maxVertexIndex = vertexIndex;
  91990. }
  91991. }
  91992. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  91993. };
  91994. return SubMesh;
  91995. }(BaseSubMesh));
  91996. /***/ }),
  91997. /***/ "./Meshes/trailMesh.ts":
  91998. /*!*****************************!*\
  91999. !*** ./Meshes/trailMesh.ts ***!
  92000. \*****************************/
  92001. /*! exports provided: TrailMesh */
  92002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92003. "use strict";
  92004. __webpack_require__.r(__webpack_exports__);
  92005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  92006. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92007. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  92008. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92009. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92010. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  92011. /**
  92012. * Class used to create a trail following a mesh
  92013. */
  92014. var TrailMesh = /** @class */ (function (_super) {
  92015. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  92016. /**
  92017. * @constructor
  92018. * @param name The value used by scene.getMeshByName() to do a lookup.
  92019. * @param generator The mesh to generate a trail.
  92020. * @param scene The scene to add this mesh to.
  92021. * @param diameter Diameter of trailing mesh. Default is 1.
  92022. * @param length Length of trailing mesh. Default is 60.
  92023. * @param autoStart Automatically start trailing mesh. Default true.
  92024. */
  92025. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  92026. if (diameter === void 0) { diameter = 1; }
  92027. if (length === void 0) { length = 60; }
  92028. if (autoStart === void 0) { autoStart = true; }
  92029. var _this = _super.call(this, name, scene) || this;
  92030. _this._sectionPolygonPointsCount = 4;
  92031. _this._running = false;
  92032. _this._autoStart = autoStart;
  92033. _this._generator = generator;
  92034. _this._diameter = diameter;
  92035. _this._length = length;
  92036. _this._sectionVectors = [];
  92037. _this._sectionNormalVectors = [];
  92038. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  92039. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  92040. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  92041. }
  92042. _this._createMesh();
  92043. return _this;
  92044. }
  92045. /**
  92046. * "TrailMesh"
  92047. * @returns "TrailMesh"
  92048. */
  92049. TrailMesh.prototype.getClassName = function () {
  92050. return "TrailMesh";
  92051. };
  92052. TrailMesh.prototype._createMesh = function () {
  92053. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  92054. var positions = [];
  92055. var normals = [];
  92056. var indices = [];
  92057. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  92058. if (this._generator._boundingInfo) {
  92059. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  92060. }
  92061. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  92062. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  92063. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  92064. }
  92065. for (var i = 1; i <= this._length; i++) {
  92066. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  92067. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  92068. }
  92069. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  92070. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  92071. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  92072. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  92073. }
  92074. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  92075. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  92076. }
  92077. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  92078. data.positions = positions;
  92079. data.normals = normals;
  92080. data.indices = indices;
  92081. data.applyToMesh(this, true);
  92082. if (this._autoStart) {
  92083. this.start();
  92084. }
  92085. };
  92086. /**
  92087. * Start trailing mesh.
  92088. */
  92089. TrailMesh.prototype.start = function () {
  92090. var _this = this;
  92091. if (!this._running) {
  92092. this._running = true;
  92093. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  92094. _this.update();
  92095. });
  92096. }
  92097. };
  92098. /**
  92099. * Stop trailing mesh.
  92100. */
  92101. TrailMesh.prototype.stop = function () {
  92102. if (this._beforeRenderObserver && this._running) {
  92103. this._running = false;
  92104. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  92105. }
  92106. };
  92107. /**
  92108. * Update trailing mesh geometry.
  92109. */
  92110. TrailMesh.prototype.update = function () {
  92111. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  92112. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  92113. var wm = this._generator.getWorldMatrix();
  92114. if (positions && normals) {
  92115. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  92116. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  92117. }
  92118. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  92119. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  92120. }
  92121. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  92122. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  92123. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  92124. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  92125. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  92126. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  92127. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  92128. }
  92129. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  92130. positions[l + 3 * i] = this._sectionVectors[i].x;
  92131. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  92132. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  92133. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  92134. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  92135. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  92136. }
  92137. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  92138. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  92139. }
  92140. };
  92141. /**
  92142. * Returns a new TrailMesh object.
  92143. * @param name is a string, the name given to the new mesh
  92144. * @param newGenerator use new generator object for cloned trail mesh
  92145. * @returns a new mesh
  92146. */
  92147. TrailMesh.prototype.clone = function (name, newGenerator) {
  92148. if (name === void 0) { name = ""; }
  92149. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  92150. };
  92151. /**
  92152. * Serializes this trail mesh
  92153. * @param serializationObject object to write serialization to
  92154. */
  92155. TrailMesh.prototype.serialize = function (serializationObject) {
  92156. _super.prototype.serialize.call(this, serializationObject);
  92157. };
  92158. /**
  92159. * Parses a serialized trail mesh
  92160. * @param parsedMesh the serialized mesh
  92161. * @param scene the scene to create the trail mesh in
  92162. * @returns the created trail mesh
  92163. */
  92164. TrailMesh.Parse = function (parsedMesh, scene) {
  92165. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  92166. };
  92167. return TrailMesh;
  92168. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  92169. /***/ }),
  92170. /***/ "./Meshes/transformNode.ts":
  92171. /*!*********************************!*\
  92172. !*** ./Meshes/transformNode.ts ***!
  92173. \*********************************/
  92174. /*! exports provided: TransformNode */
  92175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92176. "use strict";
  92177. __webpack_require__.r(__webpack_exports__);
  92178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  92179. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92180. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  92181. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  92182. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92183. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  92184. /**
  92185. * 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.
  92186. * @see https://doc.babylonjs.com/how_to/transformnode
  92187. */
  92188. var TransformNode = /** @class */ (function (_super) {
  92189. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  92190. function TransformNode(name, scene, isPure) {
  92191. if (scene === void 0) { scene = null; }
  92192. if (isPure === void 0) { isPure = true; }
  92193. var _this = _super.call(this, name, scene) || this;
  92194. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  92195. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  92196. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  92197. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  92198. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  92199. // Properties
  92200. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92201. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92202. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  92203. _this._isDirty = false;
  92204. /**
  92205. * Set the billboard mode. Default is 0.
  92206. *
  92207. * | Value | Type | Description |
  92208. * | --- | --- | --- |
  92209. * | 0 | BILLBOARDMODE_NONE | |
  92210. * | 1 | BILLBOARDMODE_X | |
  92211. * | 2 | BILLBOARDMODE_Y | |
  92212. * | 4 | BILLBOARDMODE_Z | |
  92213. * | 7 | BILLBOARDMODE_ALL | |
  92214. *
  92215. */
  92216. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  92217. /**
  92218. * 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
  92219. */
  92220. _this.scalingDeterminant = 1;
  92221. /**
  92222. * Sets the distance of the object to max, often used by skybox
  92223. */
  92224. _this.infiniteDistance = false;
  92225. /**
  92226. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92227. * By default the system will update normals to compensate
  92228. */
  92229. _this.ignoreNonUniformScaling = false;
  92230. /** @hidden */
  92231. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  92232. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92233. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  92234. _this._postMultiplyPivotMatrix = false;
  92235. _this._tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  92236. _this._isWorldMatrixFrozen = false;
  92237. /** @hidden */
  92238. _this._indexInSceneTransformNodesArray = -1;
  92239. /**
  92240. * An event triggered after the world matrix is updated
  92241. */
  92242. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  92243. _this._nonUniformScaling = false;
  92244. if (isPure) {
  92245. _this.getScene().addTransformNode(_this);
  92246. }
  92247. return _this;
  92248. }
  92249. /**
  92250. * Gets a string identifying the name of the class
  92251. * @returns "TransformNode" string
  92252. */
  92253. TransformNode.prototype.getClassName = function () {
  92254. return "TransformNode";
  92255. };
  92256. Object.defineProperty(TransformNode.prototype, "position", {
  92257. /**
  92258. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92259. */
  92260. get: function () {
  92261. return this._position;
  92262. },
  92263. set: function (newPosition) {
  92264. this._position = newPosition;
  92265. this._isDirty = true;
  92266. },
  92267. enumerable: true,
  92268. configurable: true
  92269. });
  92270. Object.defineProperty(TransformNode.prototype, "rotation", {
  92271. /**
  92272. * 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)).
  92273. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92274. */
  92275. get: function () {
  92276. return this._rotation;
  92277. },
  92278. set: function (newRotation) {
  92279. this._rotation = newRotation;
  92280. this._isDirty = true;
  92281. },
  92282. enumerable: true,
  92283. configurable: true
  92284. });
  92285. Object.defineProperty(TransformNode.prototype, "scaling", {
  92286. /**
  92287. * 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)).
  92288. */
  92289. get: function () {
  92290. return this._scaling;
  92291. },
  92292. set: function (newScaling) {
  92293. this._scaling = newScaling;
  92294. this._isDirty = true;
  92295. },
  92296. enumerable: true,
  92297. configurable: true
  92298. });
  92299. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  92300. /**
  92301. * 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).
  92302. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92303. */
  92304. get: function () {
  92305. return this._rotationQuaternion;
  92306. },
  92307. set: function (quaternion) {
  92308. this._rotationQuaternion = quaternion;
  92309. //reset the rotation vector.
  92310. if (quaternion) {
  92311. this.rotation.setAll(0.0);
  92312. }
  92313. },
  92314. enumerable: true,
  92315. configurable: true
  92316. });
  92317. Object.defineProperty(TransformNode.prototype, "forward", {
  92318. /**
  92319. * The forward direction of that transform in world space.
  92320. */
  92321. get: function () {
  92322. 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()));
  92323. },
  92324. enumerable: true,
  92325. configurable: true
  92326. });
  92327. Object.defineProperty(TransformNode.prototype, "up", {
  92328. /**
  92329. * The up direction of that transform in world space.
  92330. */
  92331. get: function () {
  92332. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  92333. },
  92334. enumerable: true,
  92335. configurable: true
  92336. });
  92337. Object.defineProperty(TransformNode.prototype, "right", {
  92338. /**
  92339. * The right direction of that transform in world space.
  92340. */
  92341. get: function () {
  92342. 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()));
  92343. },
  92344. enumerable: true,
  92345. configurable: true
  92346. });
  92347. /**
  92348. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92349. * @param matrix the matrix to copy the pose from
  92350. * @returns this TransformNode.
  92351. */
  92352. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  92353. this._poseMatrix.copyFrom(matrix);
  92354. return this;
  92355. };
  92356. /**
  92357. * Returns the mesh Pose matrix.
  92358. * @returns the pose matrix
  92359. */
  92360. TransformNode.prototype.getPoseMatrix = function () {
  92361. return this._poseMatrix;
  92362. };
  92363. /** @hidden */
  92364. TransformNode.prototype._isSynchronized = function () {
  92365. if (this._isDirty) {
  92366. return false;
  92367. }
  92368. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  92369. return false;
  92370. }
  92371. if (this._cache.pivotMatrixUpdated) {
  92372. return false;
  92373. }
  92374. if (this.infiniteDistance) {
  92375. return false;
  92376. }
  92377. if (!this._cache.position.equals(this._position)) {
  92378. return false;
  92379. }
  92380. if (this._rotationQuaternion) {
  92381. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  92382. return false;
  92383. }
  92384. }
  92385. if (!this._cache.rotation.equals(this._rotation)) {
  92386. return false;
  92387. }
  92388. if (!this._cache.scaling.equals(this._scaling)) {
  92389. return false;
  92390. }
  92391. return true;
  92392. };
  92393. /** @hidden */
  92394. TransformNode.prototype._initCache = function () {
  92395. _super.prototype._initCache.call(this);
  92396. this._cache.localMatrixUpdated = false;
  92397. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92398. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92399. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92400. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  92401. this._cache.billboardMode = -1;
  92402. this._cache.infiniteDistance = false;
  92403. };
  92404. /**
  92405. * Flag the transform node as dirty (Forcing it to update everything)
  92406. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92407. * @returns this transform node
  92408. */
  92409. TransformNode.prototype.markAsDirty = function (property) {
  92410. if (property === "rotation") {
  92411. this.rotationQuaternion = null;
  92412. }
  92413. this._currentRenderId = Number.MAX_VALUE;
  92414. this._isDirty = true;
  92415. return this;
  92416. };
  92417. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  92418. /**
  92419. * Returns the current mesh absolute position.
  92420. * Returns a Vector3.
  92421. */
  92422. get: function () {
  92423. return this._absolutePosition;
  92424. },
  92425. enumerable: true,
  92426. configurable: true
  92427. });
  92428. /**
  92429. * Sets a new matrix to apply before all other transformation
  92430. * @param matrix defines the transform matrix
  92431. * @returns the current TransformNode
  92432. */
  92433. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  92434. return this.setPivotMatrix(matrix, false);
  92435. };
  92436. /**
  92437. * Sets a new pivot matrix to the current node
  92438. * @param matrix defines the new pivot matrix to use
  92439. * @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
  92440. * @returns the current TransformNode
  92441. */
  92442. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  92443. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  92444. this._pivotMatrix.copyFrom(matrix);
  92445. this._cache.pivotMatrixUpdated = true;
  92446. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  92447. if (this._postMultiplyPivotMatrix) {
  92448. if (!this._pivotMatrixInverse) {
  92449. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  92450. }
  92451. else {
  92452. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  92453. }
  92454. }
  92455. return this;
  92456. };
  92457. /**
  92458. * Returns the mesh pivot matrix.
  92459. * Default : Identity.
  92460. * @returns the matrix
  92461. */
  92462. TransformNode.prototype.getPivotMatrix = function () {
  92463. return this._pivotMatrix;
  92464. };
  92465. /**
  92466. * Prevents the World matrix to be computed any longer.
  92467. * @returns the TransformNode.
  92468. */
  92469. TransformNode.prototype.freezeWorldMatrix = function () {
  92470. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  92471. this.computeWorldMatrix(true);
  92472. this._isWorldMatrixFrozen = true;
  92473. return this;
  92474. };
  92475. /**
  92476. * Allows back the World matrix computation.
  92477. * @returns the TransformNode.
  92478. */
  92479. TransformNode.prototype.unfreezeWorldMatrix = function () {
  92480. this._isWorldMatrixFrozen = false;
  92481. this.computeWorldMatrix(true);
  92482. return this;
  92483. };
  92484. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  92485. /**
  92486. * True if the World matrix has been frozen.
  92487. */
  92488. get: function () {
  92489. return this._isWorldMatrixFrozen;
  92490. },
  92491. enumerable: true,
  92492. configurable: true
  92493. });
  92494. /**
  92495. * Retuns the mesh absolute position in the World.
  92496. * @returns a Vector3.
  92497. */
  92498. TransformNode.prototype.getAbsolutePosition = function () {
  92499. this.computeWorldMatrix();
  92500. return this._absolutePosition;
  92501. };
  92502. /**
  92503. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92504. * @param absolutePosition the absolute position to set
  92505. * @returns the TransformNode.
  92506. */
  92507. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  92508. if (!absolutePosition) {
  92509. return this;
  92510. }
  92511. var absolutePositionX;
  92512. var absolutePositionY;
  92513. var absolutePositionZ;
  92514. if (absolutePosition.x === undefined) {
  92515. if (arguments.length < 3) {
  92516. return this;
  92517. }
  92518. absolutePositionX = arguments[0];
  92519. absolutePositionY = arguments[1];
  92520. absolutePositionZ = arguments[2];
  92521. }
  92522. else {
  92523. absolutePositionX = absolutePosition.x;
  92524. absolutePositionY = absolutePosition.y;
  92525. absolutePositionZ = absolutePosition.z;
  92526. }
  92527. if (this.parent) {
  92528. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92529. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  92530. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  92531. }
  92532. else {
  92533. this.position.x = absolutePositionX;
  92534. this.position.y = absolutePositionY;
  92535. this.position.z = absolutePositionZ;
  92536. }
  92537. return this;
  92538. };
  92539. /**
  92540. * Sets the mesh position in its local space.
  92541. * @param vector3 the position to set in localspace
  92542. * @returns the TransformNode.
  92543. */
  92544. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  92545. this.computeWorldMatrix();
  92546. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  92547. return this;
  92548. };
  92549. /**
  92550. * Returns the mesh position in the local space from the current World matrix values.
  92551. * @returns a new Vector3.
  92552. */
  92553. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  92554. this.computeWorldMatrix();
  92555. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92556. this._localMatrix.invertToRef(invLocalWorldMatrix);
  92557. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  92558. };
  92559. /**
  92560. * Translates the mesh along the passed Vector3 in its local space.
  92561. * @param vector3 the distance to translate in localspace
  92562. * @returns the TransformNode.
  92563. */
  92564. TransformNode.prototype.locallyTranslate = function (vector3) {
  92565. this.computeWorldMatrix(true);
  92566. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  92567. return this;
  92568. };
  92569. /**
  92570. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92571. * @param targetPoint the position (must be in same space as current mesh) to look at
  92572. * @param yawCor optional yaw (y-axis) correction in radians
  92573. * @param pitchCor optional pitch (x-axis) correction in radians
  92574. * @param rollCor optional roll (z-axis) correction in radians
  92575. * @param space the choosen space of the target
  92576. * @returns the TransformNode.
  92577. */
  92578. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  92579. if (yawCor === void 0) { yawCor = 0; }
  92580. if (pitchCor === void 0) { pitchCor = 0; }
  92581. if (rollCor === void 0) { rollCor = 0; }
  92582. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  92583. var dv = TransformNode._lookAtVectorCache;
  92584. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  92585. targetPoint.subtractToRef(pos, dv);
  92586. this.setDirection(dv, yawCor, pitchCor, rollCor);
  92587. // Correct for parent's rotation offset
  92588. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  92589. if (this.rotationQuaternion) {
  92590. // Get local rotation matrix of the looking object
  92591. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92592. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  92593. // Offset rotation by parent's inverted rotation matrix to correct in world space
  92594. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  92595. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  92596. parentRotationMatrix.invert();
  92597. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  92598. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  92599. }
  92600. else {
  92601. // Get local rotation matrix of the looking object
  92602. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  92603. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  92604. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92605. quaternionRotation.toRotationMatrix(rotationMatrix);
  92606. // Offset rotation by parent's inverted rotation matrix to correct in world space
  92607. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  92608. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  92609. parentRotationMatrix.invert();
  92610. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  92611. quaternionRotation.fromRotationMatrix(rotationMatrix);
  92612. quaternionRotation.toEulerAnglesToRef(this.rotation);
  92613. }
  92614. }
  92615. return this;
  92616. };
  92617. /**
  92618. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92619. * This Vector3 is expressed in the World space.
  92620. * @param localAxis axis to rotate
  92621. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92622. */
  92623. TransformNode.prototype.getDirection = function (localAxis) {
  92624. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92625. this.getDirectionToRef(localAxis, result);
  92626. return result;
  92627. };
  92628. /**
  92629. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92630. * localAxis is expressed in the mesh local space.
  92631. * result is computed in the Wordl space from the mesh World matrix.
  92632. * @param localAxis axis to rotate
  92633. * @param result the resulting transformnode
  92634. * @returns this TransformNode.
  92635. */
  92636. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  92637. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  92638. return this;
  92639. };
  92640. /**
  92641. * Sets this transform node rotation to the given local axis.
  92642. * @param localAxis the axis in local space
  92643. * @param yawCor optional yaw (y-axis) correction in radians
  92644. * @param pitchCor optional pitch (x-axis) correction in radians
  92645. * @param rollCor optional roll (z-axis) correction in radians
  92646. * @returns this TransformNode
  92647. */
  92648. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  92649. if (yawCor === void 0) { yawCor = 0; }
  92650. if (pitchCor === void 0) { pitchCor = 0; }
  92651. if (rollCor === void 0) { rollCor = 0; }
  92652. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  92653. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  92654. var pitch = -Math.atan2(localAxis.y, len);
  92655. if (this.rotationQuaternion) {
  92656. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  92657. }
  92658. else {
  92659. this.rotation.x = pitch + pitchCor;
  92660. this.rotation.y = yaw + yawCor;
  92661. this.rotation.z = rollCor;
  92662. }
  92663. return this;
  92664. };
  92665. /**
  92666. * Sets a new pivot point to the current node
  92667. * @param point defines the new pivot point to use
  92668. * @param space defines if the point is in world or local space (local by default)
  92669. * @returns the current TransformNode
  92670. */
  92671. TransformNode.prototype.setPivotPoint = function (point, space) {
  92672. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  92673. if (this.getScene().getRenderId() == 0) {
  92674. this.computeWorldMatrix(true);
  92675. }
  92676. var wm = this.getWorldMatrix();
  92677. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  92678. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92679. wm.invertToRef(tmat);
  92680. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  92681. }
  92682. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  92683. };
  92684. /**
  92685. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92686. * @returns the pivot point
  92687. */
  92688. TransformNode.prototype.getPivotPoint = function () {
  92689. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92690. this.getPivotPointToRef(point);
  92691. return point;
  92692. };
  92693. /**
  92694. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92695. * @param result the vector3 to store the result
  92696. * @returns this TransformNode.
  92697. */
  92698. TransformNode.prototype.getPivotPointToRef = function (result) {
  92699. result.x = -this._pivotMatrix.m[12];
  92700. result.y = -this._pivotMatrix.m[13];
  92701. result.z = -this._pivotMatrix.m[14];
  92702. return this;
  92703. };
  92704. /**
  92705. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92706. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92707. */
  92708. TransformNode.prototype.getAbsolutePivotPoint = function () {
  92709. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92710. this.getAbsolutePivotPointToRef(point);
  92711. return point;
  92712. };
  92713. /**
  92714. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92715. * @param result vector3 to store the result
  92716. * @returns this TransformNode.
  92717. */
  92718. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  92719. result.x = this._pivotMatrix.m[12];
  92720. result.y = this._pivotMatrix.m[13];
  92721. result.z = this._pivotMatrix.m[14];
  92722. this.getPivotPointToRef(result);
  92723. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  92724. return this;
  92725. };
  92726. /**
  92727. * Defines the passed node as the parent of the current node.
  92728. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92729. * @param node the node ot set as the parent
  92730. * @returns this TransformNode.
  92731. */
  92732. TransformNode.prototype.setParent = function (node) {
  92733. if (!node && !this.parent) {
  92734. return this;
  92735. }
  92736. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  92737. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  92738. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  92739. if (!node) {
  92740. if (this.parent && this.parent.computeWorldMatrix) {
  92741. this.parent.computeWorldMatrix(true);
  92742. }
  92743. this.computeWorldMatrix(true);
  92744. this.getWorldMatrix().decompose(scale, quatRotation, position);
  92745. }
  92746. else {
  92747. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92748. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  92749. this.computeWorldMatrix(true);
  92750. node.computeWorldMatrix(true);
  92751. node.getWorldMatrix().invertToRef(invParentMatrix);
  92752. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  92753. diffMatrix.decompose(scale, quatRotation, position);
  92754. }
  92755. if (this.rotationQuaternion) {
  92756. this.rotationQuaternion.copyFrom(quatRotation);
  92757. }
  92758. else {
  92759. quatRotation.toEulerAnglesToRef(this.rotation);
  92760. }
  92761. this.scaling.copyFrom(scale);
  92762. this.position.copyFrom(position);
  92763. this.parent = node;
  92764. return this;
  92765. };
  92766. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  92767. /**
  92768. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92769. */
  92770. get: function () {
  92771. return this._nonUniformScaling;
  92772. },
  92773. enumerable: true,
  92774. configurable: true
  92775. });
  92776. /** @hidden */
  92777. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  92778. if (this._nonUniformScaling === value) {
  92779. return false;
  92780. }
  92781. this._nonUniformScaling = value;
  92782. return true;
  92783. };
  92784. /**
  92785. * Attach the current TransformNode to another TransformNode associated with a bone
  92786. * @param bone Bone affecting the TransformNode
  92787. * @param affectedTransformNode TransformNode associated with the bone
  92788. * @returns this object
  92789. */
  92790. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  92791. this._transformToBoneReferal = affectedTransformNode;
  92792. this.parent = bone;
  92793. if (bone.getWorldMatrix().determinant() < 0) {
  92794. this.scalingDeterminant *= -1;
  92795. }
  92796. return this;
  92797. };
  92798. /**
  92799. * Detach the transform node if its associated with a bone
  92800. * @returns this object
  92801. */
  92802. TransformNode.prototype.detachFromBone = function () {
  92803. if (!this.parent) {
  92804. return this;
  92805. }
  92806. if (this.parent.getWorldMatrix().determinant() < 0) {
  92807. this.scalingDeterminant *= -1;
  92808. }
  92809. this._transformToBoneReferal = null;
  92810. this.parent = null;
  92811. return this;
  92812. };
  92813. /**
  92814. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92815. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92816. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92817. * The passed axis is also normalized.
  92818. * @param axis the axis to rotate around
  92819. * @param amount the amount to rotate in radians
  92820. * @param space Space to rotate in (Default: local)
  92821. * @returns the TransformNode.
  92822. */
  92823. TransformNode.prototype.rotate = function (axis, amount, space) {
  92824. axis.normalize();
  92825. if (!this.rotationQuaternion) {
  92826. this.rotationQuaternion = this.rotation.toQuaternion();
  92827. this.rotation.setAll(0);
  92828. }
  92829. var rotationQuaternion;
  92830. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  92831. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  92832. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  92833. }
  92834. else {
  92835. if (this.parent) {
  92836. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92837. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  92838. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  92839. }
  92840. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  92841. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  92842. }
  92843. return this;
  92844. };
  92845. /**
  92846. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92847. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92848. * The passed axis is also normalized. .
  92849. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92850. * @param point the point to rotate around
  92851. * @param axis the axis to rotate around
  92852. * @param amount the amount to rotate in radians
  92853. * @returns the TransformNode
  92854. */
  92855. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  92856. axis.normalize();
  92857. if (!this.rotationQuaternion) {
  92858. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  92859. this.rotation.setAll(0);
  92860. }
  92861. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  92862. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  92863. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  92864. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  92865. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  92866. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  92867. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  92868. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  92869. point.subtractToRef(this.position, tmpVector);
  92870. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  92871. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  92872. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  92873. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  92874. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  92875. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  92876. this.position.addInPlace(finalTranslation);
  92877. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  92878. return this;
  92879. };
  92880. /**
  92881. * Translates the mesh along the axis vector for the passed distance in the given space.
  92882. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92883. * @param axis the axis to translate in
  92884. * @param distance the distance to translate
  92885. * @param space Space to rotate in (Default: local)
  92886. * @returns the TransformNode.
  92887. */
  92888. TransformNode.prototype.translate = function (axis, distance, space) {
  92889. var displacementVector = axis.scale(distance);
  92890. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  92891. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  92892. this.setPositionWithLocalVector(tempV3);
  92893. }
  92894. else {
  92895. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  92896. }
  92897. return this;
  92898. };
  92899. /**
  92900. * Adds a rotation step to the mesh current rotation.
  92901. * x, y, z are Euler angles expressed in radians.
  92902. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92903. * This means this rotation is made in the mesh local space only.
  92904. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92905. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92906. * ```javascript
  92907. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92908. * ```
  92909. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92910. * 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.
  92911. * @param x Rotation to add
  92912. * @param y Rotation to add
  92913. * @param z Rotation to add
  92914. * @returns the TransformNode.
  92915. */
  92916. TransformNode.prototype.addRotation = function (x, y, z) {
  92917. var rotationQuaternion;
  92918. if (this.rotationQuaternion) {
  92919. rotationQuaternion = this.rotationQuaternion;
  92920. }
  92921. else {
  92922. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  92923. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  92924. }
  92925. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  92926. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  92927. rotationQuaternion.multiplyInPlace(accumulation);
  92928. if (!this.rotationQuaternion) {
  92929. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  92930. }
  92931. return this;
  92932. };
  92933. /**
  92934. * Computes the world matrix of the node
  92935. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92936. * @returns the world matrix
  92937. */
  92938. TransformNode.prototype.computeWorldMatrix = function (force) {
  92939. if (this._isWorldMatrixFrozen) {
  92940. return this._worldMatrix;
  92941. }
  92942. if (!force && this.isSynchronized()) {
  92943. this._currentRenderId = this.getScene().getRenderId();
  92944. return this._worldMatrix;
  92945. }
  92946. this._updateCache();
  92947. this._cache.position.copyFrom(this.position);
  92948. this._cache.scaling.copyFrom(this.scaling);
  92949. this._cache.pivotMatrixUpdated = false;
  92950. this._cache.billboardMode = this.billboardMode;
  92951. this._cache.infiniteDistance = this.infiniteDistance;
  92952. this._currentRenderId = this.getScene().getRenderId();
  92953. this._childRenderId = this.getScene().getRenderId();
  92954. this._isDirty = false;
  92955. // Scaling
  92956. _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]);
  92957. // Rotation
  92958. //rotate, if quaternion is set and rotation was used
  92959. if (this.rotationQuaternion) {
  92960. var len = this.rotation.length();
  92961. if (len) {
  92962. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  92963. this.rotation.copyFromFloats(0, 0, 0);
  92964. }
  92965. }
  92966. if (this.rotationQuaternion) {
  92967. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  92968. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  92969. }
  92970. else {
  92971. _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]);
  92972. this._cache.rotation.copyFrom(this.rotation);
  92973. }
  92974. // Translation
  92975. var camera = this.getScene().activeCamera;
  92976. if (this.infiniteDistance && !this.parent && camera) {
  92977. var cameraWorldMatrix = camera.getWorldMatrix();
  92978. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  92979. _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]);
  92980. }
  92981. else {
  92982. _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]);
  92983. }
  92984. // Composing transformations
  92985. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  92986. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._tempMatrix);
  92987. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  92988. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  92989. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  92990. // Need to decompose each rotation here
  92991. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[3];
  92992. if (this.parent && this.parent.getWorldMatrix) {
  92993. if (this._transformToBoneReferal) {
  92994. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  92995. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6], currentPosition);
  92996. }
  92997. else {
  92998. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  92999. }
  93000. }
  93001. else {
  93002. currentPosition.copyFrom(this.position);
  93003. }
  93004. currentPosition.subtractInPlace(camera.globalPosition);
  93005. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  93006. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  93007. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  93008. }
  93009. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  93010. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  93011. }
  93012. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  93013. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  93014. }
  93015. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93016. }
  93017. else {
  93018. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  93019. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  93020. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  93021. }
  93022. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(this._tempMatrix);
  93023. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._tempMatrix);
  93024. }
  93025. // Post multiply inverse of pivotMatrix
  93026. if (this._postMultiplyPivotMatrix) {
  93027. this._tempMatrix.multiplyToRef(this._pivotMatrixInverse, this._tempMatrix);
  93028. }
  93029. // Local world
  93030. this._tempMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2], this._localMatrix);
  93031. // Parent
  93032. if (this.parent && this.parent.getWorldMatrix) {
  93033. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  93034. if (this._transformToBoneReferal) {
  93035. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  93036. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  93037. }
  93038. else {
  93039. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].copyFrom(this.parent.getWorldMatrix());
  93040. }
  93041. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  93042. _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[7], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  93043. this._worldMatrix.copyFrom(this._localMatrix);
  93044. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  93045. }
  93046. else {
  93047. if (this._transformToBoneReferal) {
  93048. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  93049. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  93050. }
  93051. else {
  93052. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  93053. }
  93054. }
  93055. this._markSyncedWithParent();
  93056. }
  93057. else {
  93058. this._worldMatrix.copyFrom(this._localMatrix);
  93059. }
  93060. // Normal matrix
  93061. if (!this.ignoreNonUniformScaling) {
  93062. if (this.scaling.isNonUniform) {
  93063. this._updateNonUniformScalingState(true);
  93064. }
  93065. else if (this.parent && this.parent._nonUniformScaling) {
  93066. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  93067. }
  93068. else {
  93069. this._updateNonUniformScalingState(false);
  93070. }
  93071. }
  93072. else {
  93073. this._updateNonUniformScalingState(false);
  93074. }
  93075. this._afterComputeWorldMatrix();
  93076. // Absolute position
  93077. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  93078. // Callbacks
  93079. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  93080. if (!this._poseMatrix) {
  93081. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  93082. }
  93083. // Cache the determinant
  93084. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  93085. return this._worldMatrix;
  93086. };
  93087. TransformNode.prototype._afterComputeWorldMatrix = function () {
  93088. };
  93089. /**
  93090. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93091. * @param func callback function to add
  93092. *
  93093. * @returns the TransformNode.
  93094. */
  93095. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  93096. this.onAfterWorldMatrixUpdateObservable.add(func);
  93097. return this;
  93098. };
  93099. /**
  93100. * Removes a registered callback function.
  93101. * @param func callback function to remove
  93102. * @returns the TransformNode.
  93103. */
  93104. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  93105. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  93106. return this;
  93107. };
  93108. /**
  93109. * Gets the position of the current mesh in camera space
  93110. * @param camera defines the camera to use
  93111. * @returns a position
  93112. */
  93113. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  93114. if (camera === void 0) { camera = null; }
  93115. if (!camera) {
  93116. camera = this.getScene().activeCamera;
  93117. }
  93118. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  93119. };
  93120. /**
  93121. * Returns the distance from the mesh to the active camera
  93122. * @param camera defines the camera to use
  93123. * @returns the distance
  93124. */
  93125. TransformNode.prototype.getDistanceToCamera = function (camera) {
  93126. if (camera === void 0) { camera = null; }
  93127. if (!camera) {
  93128. camera = this.getScene().activeCamera;
  93129. }
  93130. return this.absolutePosition.subtract(camera.position).length();
  93131. };
  93132. /**
  93133. * Clone the current transform node
  93134. * @param name Name of the new clone
  93135. * @param newParent New parent for the clone
  93136. * @param doNotCloneChildren Do not clone children hierarchy
  93137. * @returns the new transform node
  93138. */
  93139. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  93140. var _this = this;
  93141. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  93142. result.name = name;
  93143. result.id = name;
  93144. if (newParent) {
  93145. result.parent = newParent;
  93146. }
  93147. if (!doNotCloneChildren) {
  93148. // Children
  93149. var directDescendants = this.getDescendants(true);
  93150. for (var index = 0; index < directDescendants.length; index++) {
  93151. var child = directDescendants[index];
  93152. if (child.clone) {
  93153. child.clone(name + "." + child.name, result);
  93154. }
  93155. }
  93156. }
  93157. return result;
  93158. };
  93159. /**
  93160. * Serializes the objects information.
  93161. * @param currentSerializationObject defines the object to serialize in
  93162. * @returns the serialized object
  93163. */
  93164. TransformNode.prototype.serialize = function (currentSerializationObject) {
  93165. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  93166. serializationObject.type = this.getClassName();
  93167. // Parent
  93168. if (this.parent) {
  93169. serializationObject.parentId = this.parent.id;
  93170. }
  93171. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  93172. serializationObject.isEnabled = this.isEnabled();
  93173. // Parent
  93174. if (this.parent) {
  93175. serializationObject.parentId = this.parent.id;
  93176. }
  93177. return serializationObject;
  93178. };
  93179. // Statics
  93180. /**
  93181. * Returns a new TransformNode object parsed from the source provided.
  93182. * @param parsedTransformNode is the source.
  93183. * @param scene the scne the object belongs to
  93184. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93185. * @returns a new TransformNode object parsed from the source provided.
  93186. */
  93187. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  93188. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  93189. if (parsedTransformNode.localMatrix) {
  93190. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  93191. }
  93192. else if (parsedTransformNode.pivotMatrix) {
  93193. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  93194. }
  93195. transformNode.setEnabled(parsedTransformNode.isEnabled);
  93196. // Parent
  93197. if (parsedTransformNode.parentId) {
  93198. transformNode._waitingParentId = parsedTransformNode.parentId;
  93199. }
  93200. return transformNode;
  93201. };
  93202. /**
  93203. * Get all child-transformNodes of this node
  93204. * @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
  93205. * @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
  93206. * @returns an array of TransformNode
  93207. */
  93208. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  93209. var results = [];
  93210. this._getDescendants(results, directDescendantsOnly, function (node) {
  93211. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  93212. });
  93213. return results;
  93214. };
  93215. /**
  93216. * Releases resources associated with this transform node.
  93217. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93218. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93219. */
  93220. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  93221. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  93222. // Animations
  93223. this.getScene().stopAnimation(this);
  93224. // Remove from scene
  93225. this.getScene().removeTransformNode(this);
  93226. this.onAfterWorldMatrixUpdateObservable.clear();
  93227. if (doNotRecurse) {
  93228. var transformNodes = this.getChildTransformNodes(true);
  93229. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  93230. var transformNode = transformNodes_1[_i];
  93231. transformNode.parent = null;
  93232. transformNode.computeWorldMatrix(true);
  93233. }
  93234. }
  93235. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  93236. };
  93237. // Statics
  93238. /**
  93239. * Object will not rotate to face the camera
  93240. */
  93241. TransformNode.BILLBOARDMODE_NONE = 0;
  93242. /**
  93243. * Object will rotate to face the camera but only on the x axis
  93244. */
  93245. TransformNode.BILLBOARDMODE_X = 1;
  93246. /**
  93247. * Object will rotate to face the camera but only on the y axis
  93248. */
  93249. TransformNode.BILLBOARDMODE_Y = 2;
  93250. /**
  93251. * Object will rotate to face the camera but only on the z axis
  93252. */
  93253. TransformNode.BILLBOARDMODE_Z = 4;
  93254. /**
  93255. * Object will rotate to face the camera
  93256. */
  93257. TransformNode.BILLBOARDMODE_ALL = 7;
  93258. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  93259. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  93260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  93262. ], TransformNode.prototype, "_position", void 0);
  93263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  93265. ], TransformNode.prototype, "_rotation", void 0);
  93266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  93268. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  93269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  93271. ], TransformNode.prototype, "_scaling", void 0);
  93272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  93274. ], TransformNode.prototype, "billboardMode", void 0);
  93275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  93277. ], TransformNode.prototype, "scalingDeterminant", void 0);
  93278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  93280. ], TransformNode.prototype, "infiniteDistance", void 0);
  93281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  93282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  93283. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  93284. return TransformNode;
  93285. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  93286. /***/ }),
  93287. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  93288. /*!***************************************************************!*\
  93289. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  93290. \***************************************************************/
  93291. /*! exports provided: CubeMapToSphericalPolynomialTools */
  93292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93293. "use strict";
  93294. __webpack_require__.r(__webpack_exports__);
  93295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  93296. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  93297. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  93298. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  93299. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  93300. var FileFaceOrientation = /** @class */ (function () {
  93301. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  93302. this.name = name;
  93303. this.worldAxisForNormal = worldAxisForNormal;
  93304. this.worldAxisForFileX = worldAxisForFileX;
  93305. this.worldAxisForFileY = worldAxisForFileY;
  93306. }
  93307. return FileFaceOrientation;
  93308. }());
  93309. /**
  93310. * Helper class dealing with the extraction of spherical polynomial dataArray
  93311. * from a cube map.
  93312. */
  93313. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  93314. function CubeMapToSphericalPolynomialTools() {
  93315. }
  93316. /**
  93317. * Converts a texture to the according Spherical Polynomial data.
  93318. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93319. *
  93320. * @param texture The texture to extract the information from.
  93321. * @return The Spherical Polynomial data.
  93322. */
  93323. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  93324. if (!texture.isCube) {
  93325. // Only supports cube Textures currently.
  93326. return null;
  93327. }
  93328. var size = texture.getSize().width;
  93329. var right = texture.readPixels(0);
  93330. var left = texture.readPixels(1);
  93331. var up;
  93332. var down;
  93333. if (texture.isRenderTarget) {
  93334. up = texture.readPixels(3);
  93335. down = texture.readPixels(2);
  93336. }
  93337. else {
  93338. up = texture.readPixels(2);
  93339. down = texture.readPixels(3);
  93340. }
  93341. var front = texture.readPixels(4);
  93342. var back = texture.readPixels(5);
  93343. var gammaSpace = texture.gammaSpace;
  93344. // Always read as RGBA.
  93345. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  93346. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93347. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  93348. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  93349. }
  93350. var cubeInfo = {
  93351. size: size,
  93352. right: right,
  93353. left: left,
  93354. up: up,
  93355. down: down,
  93356. front: front,
  93357. back: back,
  93358. format: format,
  93359. type: type,
  93360. gammaSpace: gammaSpace,
  93361. };
  93362. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  93363. };
  93364. /**
  93365. * Converts a cubemap to the according Spherical Polynomial data.
  93366. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93367. *
  93368. * @param cubeInfo The Cube map to extract the information from.
  93369. * @return The Spherical Polynomial data.
  93370. */
  93371. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  93372. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  93373. var totalSolidAngle = 0.0;
  93374. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  93375. var du = 2.0 / cubeInfo.size;
  93376. var dv = du;
  93377. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  93378. var minUV = du * 0.5 - 1.0;
  93379. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  93380. var fileFace = this.FileFaces[faceIndex];
  93381. var dataArray = cubeInfo[fileFace.name];
  93382. var v = minUV;
  93383. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  93384. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  93385. // Because SP is still linear, so summation is fine in that basis.
  93386. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  93387. for (var y = 0; y < cubeInfo.size; y++) {
  93388. var u = minUV;
  93389. for (var x = 0; x < cubeInfo.size; x++) {
  93390. // World direction (not normalised)
  93391. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  93392. worldDirection.normalize();
  93393. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  93394. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  93395. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  93396. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  93397. // Handle Integer types.
  93398. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  93399. r /= 255;
  93400. g /= 255;
  93401. b /= 255;
  93402. }
  93403. // Handle Gamma space textures.
  93404. if (cubeInfo.gammaSpace) {
  93405. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  93406. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  93407. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  93408. }
  93409. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  93410. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  93411. totalSolidAngle += deltaSolidAngle;
  93412. u += du;
  93413. }
  93414. v += dv;
  93415. }
  93416. }
  93417. // Solid angle for entire sphere is 4*pi
  93418. var sphereSolidAngle = 4.0 * Math.PI;
  93419. // Adjust the solid angle to allow for how many faces we processed.
  93420. var facesProcessed = 6.0;
  93421. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  93422. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  93423. // This is needed because the numerical integration over the cube uses a
  93424. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  93425. // and also to compensate for accumulative error due to float precision in the summation.
  93426. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  93427. sphericalHarmonics.scale(correctionFactor);
  93428. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  93429. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  93430. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  93431. };
  93432. CubeMapToSphericalPolynomialTools.FileFaces = [
  93433. 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)),
  93434. 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)),
  93435. 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)),
  93436. 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)),
  93437. 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)),
  93438. 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
  93439. ];
  93440. return CubeMapToSphericalPolynomialTools;
  93441. }());
  93442. /***/ }),
  93443. /***/ "./Misc/HighDynamicRange/hdr.ts":
  93444. /*!**************************************!*\
  93445. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  93446. \**************************************/
  93447. /*! exports provided: HDRTools */
  93448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93449. "use strict";
  93450. __webpack_require__.r(__webpack_exports__);
  93451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  93452. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  93453. /**
  93454. * This groups tools to convert HDR texture to native colors array.
  93455. */
  93456. var HDRTools = /** @class */ (function () {
  93457. function HDRTools() {
  93458. }
  93459. HDRTools.Ldexp = function (mantissa, exponent) {
  93460. if (exponent > 1023) {
  93461. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  93462. }
  93463. if (exponent < -1074) {
  93464. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  93465. }
  93466. return mantissa * Math.pow(2, exponent);
  93467. };
  93468. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  93469. if (exponent > 0) { /*nonzero pixel*/
  93470. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  93471. float32array[index + 0] = red * exponent;
  93472. float32array[index + 1] = green * exponent;
  93473. float32array[index + 2] = blue * exponent;
  93474. }
  93475. else {
  93476. float32array[index + 0] = 0;
  93477. float32array[index + 1] = 0;
  93478. float32array[index + 2] = 0;
  93479. }
  93480. };
  93481. HDRTools.readStringLine = function (uint8array, startIndex) {
  93482. var line = "";
  93483. var character = "";
  93484. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  93485. character = String.fromCharCode(uint8array[i]);
  93486. if (character == "\n") {
  93487. break;
  93488. }
  93489. line += character;
  93490. }
  93491. return line;
  93492. };
  93493. /**
  93494. * Reads header information from an RGBE texture stored in a native array.
  93495. * More information on this format are available here:
  93496. * https://en.wikipedia.org/wiki/RGBE_image_format
  93497. *
  93498. * @param uint8array The binary file stored in native array.
  93499. * @return The header information.
  93500. */
  93501. HDRTools.RGBE_ReadHeader = function (uint8array) {
  93502. var height = 0;
  93503. var width = 0;
  93504. var line = this.readStringLine(uint8array, 0);
  93505. if (line[0] != '#' || line[1] != '?') {
  93506. throw "Bad HDR Format.";
  93507. }
  93508. var endOfHeader = false;
  93509. var findFormat = false;
  93510. var lineIndex = 0;
  93511. do {
  93512. lineIndex += (line.length + 1);
  93513. line = this.readStringLine(uint8array, lineIndex);
  93514. if (line == "FORMAT=32-bit_rle_rgbe") {
  93515. findFormat = true;
  93516. }
  93517. else if (line.length == 0) {
  93518. endOfHeader = true;
  93519. }
  93520. } while (!endOfHeader);
  93521. if (!findFormat) {
  93522. throw "HDR Bad header format, unsupported FORMAT";
  93523. }
  93524. lineIndex += (line.length + 1);
  93525. line = this.readStringLine(uint8array, lineIndex);
  93526. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  93527. var match = sizeRegexp.exec(line);
  93528. // TODO. Support +Y and -X if needed.
  93529. if (!match || match.length < 3) {
  93530. throw "HDR Bad header format, no size";
  93531. }
  93532. width = parseInt(match[2]);
  93533. height = parseInt(match[1]);
  93534. if (width < 8 || width > 0x7fff) {
  93535. throw "HDR Bad header format, unsupported size";
  93536. }
  93537. lineIndex += (line.length + 1);
  93538. return {
  93539. height: height,
  93540. width: width,
  93541. dataPosition: lineIndex
  93542. };
  93543. };
  93544. /**
  93545. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  93546. * This RGBE texture needs to store the information as a panorama.
  93547. *
  93548. * More information on this format are available here:
  93549. * https://en.wikipedia.org/wiki/RGBE_image_format
  93550. *
  93551. * @param buffer The binary file stored in an array buffer.
  93552. * @param size The expected size of the extracted cubemap.
  93553. * @return The Cube Map information.
  93554. */
  93555. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  93556. var uint8array = new Uint8Array(buffer);
  93557. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  93558. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  93559. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  93560. return cubeMapData;
  93561. };
  93562. /**
  93563. * Returns the pixels data extracted from an RGBE texture.
  93564. * This pixels will be stored left to right up to down in the R G B order in one array.
  93565. *
  93566. * More information on this format are available here:
  93567. * https://en.wikipedia.org/wiki/RGBE_image_format
  93568. *
  93569. * @param uint8array The binary file stored in an array buffer.
  93570. * @param hdrInfo The header information of the file.
  93571. * @return The pixels data in RGB right to left up to down order.
  93572. */
  93573. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  93574. // Keep for multi format supports.
  93575. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  93576. };
  93577. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  93578. var num_scanlines = hdrInfo.height;
  93579. var scanline_width = hdrInfo.width;
  93580. var a, b, c, d, count;
  93581. var dataIndex = hdrInfo.dataPosition;
  93582. var index = 0, endIndex = 0, i = 0;
  93583. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  93584. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  93585. // 3 channels of 4 bytes per pixel in float.
  93586. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  93587. var resultArray = new Float32Array(resultBuffer);
  93588. // read in each successive scanline
  93589. while (num_scanlines > 0) {
  93590. a = uint8array[dataIndex++];
  93591. b = uint8array[dataIndex++];
  93592. c = uint8array[dataIndex++];
  93593. d = uint8array[dataIndex++];
  93594. if (a != 2 || b != 2 || (c & 0x80)) {
  93595. // this file is not run length encoded
  93596. throw "HDR Bad header format, not RLE";
  93597. }
  93598. if (((c << 8) | d) != scanline_width) {
  93599. throw "HDR Bad header format, wrong scan line width";
  93600. }
  93601. index = 0;
  93602. // read each of the four channels for the scanline into the buffer
  93603. for (i = 0; i < 4; i++) {
  93604. endIndex = (i + 1) * scanline_width;
  93605. while (index < endIndex) {
  93606. a = uint8array[dataIndex++];
  93607. b = uint8array[dataIndex++];
  93608. if (a > 128) {
  93609. // a run of the same value
  93610. count = a - 128;
  93611. if ((count == 0) || (count > endIndex - index)) {
  93612. throw "HDR Bad Format, bad scanline data (run)";
  93613. }
  93614. while (count-- > 0) {
  93615. scanLineArray[index++] = b;
  93616. }
  93617. }
  93618. else {
  93619. // a non-run
  93620. count = a;
  93621. if ((count == 0) || (count > endIndex - index)) {
  93622. throw "HDR Bad Format, bad scanline data (non-run)";
  93623. }
  93624. scanLineArray[index++] = b;
  93625. if (--count > 0) {
  93626. for (var j = 0; j < count; j++) {
  93627. scanLineArray[index++] = uint8array[dataIndex++];
  93628. }
  93629. }
  93630. }
  93631. }
  93632. }
  93633. // now convert data from buffer into floats
  93634. for (i = 0; i < scanline_width; i++) {
  93635. a = scanLineArray[i];
  93636. b = scanLineArray[i + scanline_width];
  93637. c = scanLineArray[i + 2 * scanline_width];
  93638. d = scanLineArray[i + 3 * scanline_width];
  93639. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  93640. }
  93641. num_scanlines--;
  93642. }
  93643. return resultArray;
  93644. };
  93645. return HDRTools;
  93646. }());
  93647. /***/ }),
  93648. /***/ "./Misc/HighDynamicRange/index.ts":
  93649. /*!****************************************!*\
  93650. !*** ./Misc/HighDynamicRange/index.ts ***!
  93651. \****************************************/
  93652. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  93653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93654. "use strict";
  93655. __webpack_require__.r(__webpack_exports__);
  93656. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  93657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  93658. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  93659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  93660. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  93661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  93662. /***/ }),
  93663. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  93664. /*!****************************************************!*\
  93665. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  93666. \****************************************************/
  93667. /*! exports provided: PanoramaToCubeMapTools */
  93668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93669. "use strict";
  93670. __webpack_require__.r(__webpack_exports__);
  93671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  93672. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  93673. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  93674. /**
  93675. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93676. */
  93677. var PanoramaToCubeMapTools = /** @class */ (function () {
  93678. function PanoramaToCubeMapTools() {
  93679. }
  93680. /**
  93681. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93682. *
  93683. * @param float32Array The source data.
  93684. * @param inputWidth The width of the input panorama.
  93685. * @param inputHeight The height of the input panorama.
  93686. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93687. * @return The cubemap data
  93688. */
  93689. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  93690. if (!float32Array) {
  93691. throw "ConvertPanoramaToCubemap: input cannot be null";
  93692. }
  93693. if (float32Array.length != inputWidth * inputHeight * 3) {
  93694. throw "ConvertPanoramaToCubemap: input size is wrong";
  93695. }
  93696. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  93697. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  93698. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  93699. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  93700. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  93701. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  93702. return {
  93703. front: textureFront,
  93704. back: textureBack,
  93705. left: textureLeft,
  93706. right: textureRight,
  93707. up: textureUp,
  93708. down: textureDown,
  93709. size: size,
  93710. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  93711. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  93712. gammaSpace: false,
  93713. };
  93714. };
  93715. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  93716. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  93717. var textureArray = new Float32Array(buffer);
  93718. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  93719. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  93720. var dy = 1 / texSize;
  93721. var fy = 0;
  93722. for (var y = 0; y < texSize; y++) {
  93723. var xv1 = faceData[0];
  93724. var xv2 = faceData[2];
  93725. for (var x = 0; x < texSize; x++) {
  93726. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  93727. v.normalize();
  93728. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  93729. // 3 channels per pixels
  93730. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  93731. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  93732. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  93733. xv1 = xv1.add(rotDX1);
  93734. xv2 = xv2.add(rotDX2);
  93735. }
  93736. fy += dy;
  93737. }
  93738. return textureArray;
  93739. };
  93740. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  93741. var theta = Math.atan2(vDir.z, vDir.x);
  93742. var phi = Math.acos(vDir.y);
  93743. while (theta < -Math.PI) {
  93744. theta += 2 * Math.PI;
  93745. }
  93746. while (theta > Math.PI) {
  93747. theta -= 2 * Math.PI;
  93748. }
  93749. var dx = theta / Math.PI;
  93750. var dy = phi / Math.PI;
  93751. // recenter.
  93752. dx = dx * 0.5 + 0.5;
  93753. var px = Math.round(dx * inputWidth);
  93754. if (px < 0) {
  93755. px = 0;
  93756. }
  93757. else if (px >= inputWidth) {
  93758. px = inputWidth - 1;
  93759. }
  93760. var py = Math.round(dy * inputHeight);
  93761. if (py < 0) {
  93762. py = 0;
  93763. }
  93764. else if (py >= inputHeight) {
  93765. py = inputHeight - 1;
  93766. }
  93767. var inputY = (inputHeight - py - 1);
  93768. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  93769. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  93770. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  93771. return {
  93772. r: r,
  93773. g: g,
  93774. b: b
  93775. };
  93776. };
  93777. PanoramaToCubeMapTools.FACE_FRONT = [
  93778. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  93779. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  93780. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  93781. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  93782. ];
  93783. PanoramaToCubeMapTools.FACE_BACK = [
  93784. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  93785. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  93786. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  93787. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  93788. ];
  93789. PanoramaToCubeMapTools.FACE_RIGHT = [
  93790. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  93791. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  93792. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  93793. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  93794. ];
  93795. PanoramaToCubeMapTools.FACE_LEFT = [
  93796. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  93797. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  93798. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  93799. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  93800. ];
  93801. PanoramaToCubeMapTools.FACE_DOWN = [
  93802. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  93803. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  93804. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  93805. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  93806. ];
  93807. PanoramaToCubeMapTools.FACE_UP = [
  93808. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  93809. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  93810. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  93811. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  93812. ];
  93813. return PanoramaToCubeMapTools;
  93814. }());
  93815. /***/ }),
  93816. /***/ "./Misc/andOrNotEvaluator.ts":
  93817. /*!***********************************!*\
  93818. !*** ./Misc/andOrNotEvaluator.ts ***!
  93819. \***********************************/
  93820. /*! exports provided: AndOrNotEvaluator */
  93821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93822. "use strict";
  93823. __webpack_require__.r(__webpack_exports__);
  93824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  93825. /**
  93826. * Class used to evalaute queries containing `and` and `or` operators
  93827. */
  93828. var AndOrNotEvaluator = /** @class */ (function () {
  93829. function AndOrNotEvaluator() {
  93830. }
  93831. /**
  93832. * Evaluate a query
  93833. * @param query defines the query to evaluate
  93834. * @param evaluateCallback defines the callback used to filter result
  93835. * @returns true if the query matches
  93836. */
  93837. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  93838. if (!query.match(/\([^\(\)]*\)/g)) {
  93839. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  93840. }
  93841. else {
  93842. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  93843. // remove parenthesis
  93844. r = r.slice(1, r.length - 1);
  93845. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  93846. });
  93847. }
  93848. if (query === "true") {
  93849. return true;
  93850. }
  93851. if (query === "false") {
  93852. return false;
  93853. }
  93854. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  93855. };
  93856. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  93857. evaluateCallback = evaluateCallback || (function (r) {
  93858. return r === "true" ? true : false;
  93859. });
  93860. var result;
  93861. var or = parenthesisContent.split("||");
  93862. for (var i in or) {
  93863. if (or.hasOwnProperty(i)) {
  93864. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  93865. var and = ori.split("&&");
  93866. if (and.length > 1) {
  93867. for (var j = 0; j < and.length; ++j) {
  93868. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  93869. if (andj !== "true" && andj !== "false") {
  93870. if (andj[0] === "!") {
  93871. result = !evaluateCallback(andj.substring(1));
  93872. }
  93873. else {
  93874. result = evaluateCallback(andj);
  93875. }
  93876. }
  93877. else {
  93878. result = andj === "true" ? true : false;
  93879. }
  93880. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  93881. ori = "false";
  93882. break;
  93883. }
  93884. }
  93885. }
  93886. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  93887. result = true;
  93888. break;
  93889. }
  93890. // result equals false (or undefined)
  93891. if (ori !== "true" && ori !== "false") {
  93892. if (ori[0] === "!") {
  93893. result = !evaluateCallback(ori.substring(1));
  93894. }
  93895. else {
  93896. result = evaluateCallback(ori);
  93897. }
  93898. }
  93899. else {
  93900. result = ori === "true" ? true : false;
  93901. }
  93902. }
  93903. }
  93904. // the whole parenthesis scope is replaced by 'true' or 'false'
  93905. return result ? "true" : "false";
  93906. };
  93907. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  93908. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  93909. // remove whitespaces
  93910. r = r.replace(/[\s]/g, function () { return ""; });
  93911. return r.length % 2 ? "!" : "";
  93912. });
  93913. booleanString = booleanString.trim();
  93914. if (booleanString === "!true") {
  93915. booleanString = "false";
  93916. }
  93917. else if (booleanString === "!false") {
  93918. booleanString = "true";
  93919. }
  93920. return booleanString;
  93921. };
  93922. return AndOrNotEvaluator;
  93923. }());
  93924. /***/ }),
  93925. /***/ "./Misc/arrayTools.ts":
  93926. /*!****************************!*\
  93927. !*** ./Misc/arrayTools.ts ***!
  93928. \****************************/
  93929. /*! exports provided: ArrayTools */
  93930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93931. "use strict";
  93932. __webpack_require__.r(__webpack_exports__);
  93933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  93934. /**
  93935. * Class containing a set of static utilities functions for arrays.
  93936. */
  93937. var ArrayTools = /** @class */ (function () {
  93938. function ArrayTools() {
  93939. }
  93940. /**
  93941. * Returns an array of the given size filled with element built from the given constructor and the paramters
  93942. * @param size the number of element to construct and put in the array
  93943. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  93944. * @returns a new array filled with new objects
  93945. */
  93946. ArrayTools.BuildArray = function (size, itemBuilder) {
  93947. var a = [];
  93948. for (var i = 0; i < size; ++i) {
  93949. a.push(itemBuilder());
  93950. }
  93951. return a;
  93952. };
  93953. return ArrayTools;
  93954. }());
  93955. /***/ }),
  93956. /***/ "./Misc/assetsManager.ts":
  93957. /*!*******************************!*\
  93958. !*** ./Misc/assetsManager.ts ***!
  93959. \*******************************/
  93960. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  93961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93962. "use strict";
  93963. __webpack_require__.r(__webpack_exports__);
  93964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  93965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  93966. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  93967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  93968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  93969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  93970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  93971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  93972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  93973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  93974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  93975. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93976. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  93977. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93978. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  93979. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  93980. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  93981. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  93982. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93983. /**
  93984. * Defines the list of states available for a task inside a AssetsManager
  93985. */
  93986. var AssetTaskState;
  93987. (function (AssetTaskState) {
  93988. /**
  93989. * Initialization
  93990. */
  93991. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  93992. /**
  93993. * Running
  93994. */
  93995. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  93996. /**
  93997. * Done
  93998. */
  93999. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  94000. /**
  94001. * Error
  94002. */
  94003. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  94004. })(AssetTaskState || (AssetTaskState = {}));
  94005. /**
  94006. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  94007. */
  94008. var AbstractAssetTask = /** @class */ (function () {
  94009. /**
  94010. * Creates a new AssetsManager
  94011. * @param name defines the name of the task
  94012. */
  94013. function AbstractAssetTask(
  94014. /**
  94015. * Task name
  94016. */ name) {
  94017. this.name = name;
  94018. this._isCompleted = false;
  94019. this._taskState = AssetTaskState.INIT;
  94020. }
  94021. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  94022. /**
  94023. * Get if the task is completed
  94024. */
  94025. get: function () {
  94026. return this._isCompleted;
  94027. },
  94028. enumerable: true,
  94029. configurable: true
  94030. });
  94031. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  94032. /**
  94033. * Gets the current state of the task
  94034. */
  94035. get: function () {
  94036. return this._taskState;
  94037. },
  94038. enumerable: true,
  94039. configurable: true
  94040. });
  94041. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  94042. /**
  94043. * Gets the current error object (if task is in error)
  94044. */
  94045. get: function () {
  94046. return this._errorObject;
  94047. },
  94048. enumerable: true,
  94049. configurable: true
  94050. });
  94051. /**
  94052. * Internal only
  94053. * @hidden
  94054. */
  94055. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  94056. if (this._errorObject) {
  94057. return;
  94058. }
  94059. this._errorObject = {
  94060. message: message,
  94061. exception: exception
  94062. };
  94063. };
  94064. /**
  94065. * Execute the current task
  94066. * @param scene defines the scene where you want your assets to be loaded
  94067. * @param onSuccess is a callback called when the task is successfully executed
  94068. * @param onError is a callback called if an error occurs
  94069. */
  94070. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  94071. var _this = this;
  94072. this._taskState = AssetTaskState.RUNNING;
  94073. this.runTask(scene, function () {
  94074. _this.onDoneCallback(onSuccess, onError);
  94075. }, function (msg, exception) {
  94076. _this.onErrorCallback(onError, msg, exception);
  94077. });
  94078. };
  94079. /**
  94080. * Execute the current task
  94081. * @param scene defines the scene where you want your assets to be loaded
  94082. * @param onSuccess is a callback called when the task is successfully executed
  94083. * @param onError is a callback called if an error occurs
  94084. */
  94085. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94086. throw new Error("runTask is not implemented");
  94087. };
  94088. /**
  94089. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  94090. * This can be used with failed tasks that have the reason for failure fixed.
  94091. */
  94092. AbstractAssetTask.prototype.reset = function () {
  94093. this._taskState = AssetTaskState.INIT;
  94094. };
  94095. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  94096. this._taskState = AssetTaskState.ERROR;
  94097. this._errorObject = {
  94098. message: message,
  94099. exception: exception
  94100. };
  94101. if (this.onError) {
  94102. this.onError(this, message, exception);
  94103. }
  94104. onError();
  94105. };
  94106. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  94107. try {
  94108. this._taskState = AssetTaskState.DONE;
  94109. this._isCompleted = true;
  94110. if (this.onSuccess) {
  94111. this.onSuccess(this);
  94112. }
  94113. onSuccess();
  94114. }
  94115. catch (e) {
  94116. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  94117. }
  94118. };
  94119. return AbstractAssetTask;
  94120. }());
  94121. /**
  94122. * Class used to share progress information about assets loading
  94123. */
  94124. var AssetsProgressEvent = /** @class */ (function () {
  94125. /**
  94126. * Creates a AssetsProgressEvent
  94127. * @param remainingCount defines the number of remaining tasks to process
  94128. * @param totalCount defines the total number of tasks
  94129. * @param task defines the task that was just processed
  94130. */
  94131. function AssetsProgressEvent(remainingCount, totalCount, task) {
  94132. this.remainingCount = remainingCount;
  94133. this.totalCount = totalCount;
  94134. this.task = task;
  94135. }
  94136. return AssetsProgressEvent;
  94137. }());
  94138. /**
  94139. * Define a task used by AssetsManager to load meshes
  94140. */
  94141. var MeshAssetTask = /** @class */ (function (_super) {
  94142. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  94143. /**
  94144. * Creates a new MeshAssetTask
  94145. * @param name defines the name of the task
  94146. * @param meshesNames defines the list of mesh's names you want to load
  94147. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  94148. * @param sceneFilename defines the filename of the scene to load from
  94149. */
  94150. function MeshAssetTask(
  94151. /**
  94152. * Defines the name of the task
  94153. */
  94154. name,
  94155. /**
  94156. * Defines the list of mesh's names you want to load
  94157. */
  94158. meshesNames,
  94159. /**
  94160. * Defines the root url to use as a base to load your meshes and associated resources
  94161. */
  94162. rootUrl,
  94163. /**
  94164. * Defines the filename of the scene to load from
  94165. */
  94166. sceneFilename) {
  94167. var _this = _super.call(this, name) || this;
  94168. _this.name = name;
  94169. _this.meshesNames = meshesNames;
  94170. _this.rootUrl = rootUrl;
  94171. _this.sceneFilename = sceneFilename;
  94172. return _this;
  94173. }
  94174. /**
  94175. * Execute the current task
  94176. * @param scene defines the scene where you want your assets to be loaded
  94177. * @param onSuccess is a callback called when the task is successfully executed
  94178. * @param onError is a callback called if an error occurs
  94179. */
  94180. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94181. var _this = this;
  94182. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  94183. _this.loadedMeshes = meshes;
  94184. _this.loadedParticleSystems = particleSystems;
  94185. _this.loadedSkeletons = skeletons;
  94186. _this.loadedAnimationGroups = animationGroups;
  94187. onSuccess();
  94188. }, null, function (scene, message, exception) {
  94189. onError(message, exception);
  94190. });
  94191. };
  94192. return MeshAssetTask;
  94193. }(AbstractAssetTask));
  94194. /**
  94195. * Define a task used by AssetsManager to load text content
  94196. */
  94197. var TextFileAssetTask = /** @class */ (function (_super) {
  94198. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  94199. /**
  94200. * Creates a new TextFileAssetTask object
  94201. * @param name defines the name of the task
  94202. * @param url defines the location of the file to load
  94203. */
  94204. function TextFileAssetTask(
  94205. /**
  94206. * Defines the name of the task
  94207. */
  94208. name,
  94209. /**
  94210. * Defines the location of the file to load
  94211. */
  94212. url) {
  94213. var _this = _super.call(this, name) || this;
  94214. _this.name = name;
  94215. _this.url = url;
  94216. return _this;
  94217. }
  94218. /**
  94219. * Execute the current task
  94220. * @param scene defines the scene where you want your assets to be loaded
  94221. * @param onSuccess is a callback called when the task is successfully executed
  94222. * @param onError is a callback called if an error occurs
  94223. */
  94224. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94225. var _this = this;
  94226. scene._loadFile(this.url, function (data) {
  94227. _this.text = data;
  94228. onSuccess();
  94229. }, undefined, false, false, function (request, exception) {
  94230. if (request) {
  94231. onError(request.status + " " + request.statusText, exception);
  94232. }
  94233. });
  94234. };
  94235. return TextFileAssetTask;
  94236. }(AbstractAssetTask));
  94237. /**
  94238. * Define a task used by AssetsManager to load binary data
  94239. */
  94240. var BinaryFileAssetTask = /** @class */ (function (_super) {
  94241. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  94242. /**
  94243. * Creates a new BinaryFileAssetTask object
  94244. * @param name defines the name of the new task
  94245. * @param url defines the location of the file to load
  94246. */
  94247. function BinaryFileAssetTask(
  94248. /**
  94249. * Defines the name of the task
  94250. */
  94251. name,
  94252. /**
  94253. * Defines the location of the file to load
  94254. */
  94255. url) {
  94256. var _this = _super.call(this, name) || this;
  94257. _this.name = name;
  94258. _this.url = url;
  94259. return _this;
  94260. }
  94261. /**
  94262. * Execute the current task
  94263. * @param scene defines the scene where you want your assets to be loaded
  94264. * @param onSuccess is a callback called when the task is successfully executed
  94265. * @param onError is a callback called if an error occurs
  94266. */
  94267. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94268. var _this = this;
  94269. scene._loadFile(this.url, function (data) {
  94270. _this.data = data;
  94271. onSuccess();
  94272. }, undefined, true, true, function (request, exception) {
  94273. if (request) {
  94274. onError(request.status + " " + request.statusText, exception);
  94275. }
  94276. });
  94277. };
  94278. return BinaryFileAssetTask;
  94279. }(AbstractAssetTask));
  94280. /**
  94281. * Define a task used by AssetsManager to load images
  94282. */
  94283. var ImageAssetTask = /** @class */ (function (_super) {
  94284. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  94285. /**
  94286. * Creates a new ImageAssetTask
  94287. * @param name defines the name of the task
  94288. * @param url defines the location of the image to load
  94289. */
  94290. function ImageAssetTask(
  94291. /**
  94292. * Defines the name of the task
  94293. */
  94294. name,
  94295. /**
  94296. * Defines the location of the image to load
  94297. */
  94298. url) {
  94299. var _this = _super.call(this, name) || this;
  94300. _this.name = name;
  94301. _this.url = url;
  94302. return _this;
  94303. }
  94304. /**
  94305. * Execute the current task
  94306. * @param scene defines the scene where you want your assets to be loaded
  94307. * @param onSuccess is a callback called when the task is successfully executed
  94308. * @param onError is a callback called if an error occurs
  94309. */
  94310. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94311. var _this = this;
  94312. var img = new Image();
  94313. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  94314. img.onload = function () {
  94315. _this.image = img;
  94316. onSuccess();
  94317. };
  94318. img.onerror = function (err) {
  94319. onError("Error loading image", err);
  94320. };
  94321. img.src = this.url;
  94322. };
  94323. return ImageAssetTask;
  94324. }(AbstractAssetTask));
  94325. /**
  94326. * Define a task used by AssetsManager to load 2D textures
  94327. */
  94328. var TextureAssetTask = /** @class */ (function (_super) {
  94329. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  94330. /**
  94331. * Creates a new TextureAssetTask object
  94332. * @param name defines the name of the task
  94333. * @param url defines the location of the file to load
  94334. * @param noMipmap defines if mipmap should not be generated (default is false)
  94335. * @param invertY defines if texture must be inverted on Y axis (default is false)
  94336. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94337. */
  94338. function TextureAssetTask(
  94339. /**
  94340. * Defines the name of the task
  94341. */
  94342. name,
  94343. /**
  94344. * Defines the location of the file to load
  94345. */
  94346. url,
  94347. /**
  94348. * Defines if mipmap should not be generated (default is false)
  94349. */
  94350. noMipmap,
  94351. /**
  94352. * Defines if texture must be inverted on Y axis (default is false)
  94353. */
  94354. invertY,
  94355. /**
  94356. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94357. */
  94358. samplingMode) {
  94359. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  94360. var _this = _super.call(this, name) || this;
  94361. _this.name = name;
  94362. _this.url = url;
  94363. _this.noMipmap = noMipmap;
  94364. _this.invertY = invertY;
  94365. _this.samplingMode = samplingMode;
  94366. return _this;
  94367. }
  94368. /**
  94369. * Execute the current task
  94370. * @param scene defines the scene where you want your assets to be loaded
  94371. * @param onSuccess is a callback called when the task is successfully executed
  94372. * @param onError is a callback called if an error occurs
  94373. */
  94374. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94375. var onload = function () {
  94376. onSuccess();
  94377. };
  94378. var onerror = function (message, exception) {
  94379. onError(message, exception);
  94380. };
  94381. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  94382. };
  94383. return TextureAssetTask;
  94384. }(AbstractAssetTask));
  94385. /**
  94386. * Define a task used by AssetsManager to load cube textures
  94387. */
  94388. var CubeTextureAssetTask = /** @class */ (function (_super) {
  94389. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  94390. /**
  94391. * Creates a new CubeTextureAssetTask
  94392. * @param name defines the name of the task
  94393. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  94394. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  94395. * @param noMipmap defines if mipmaps should not be generated (default is false)
  94396. * @param files defines the explicit list of files (undefined by default)
  94397. */
  94398. function CubeTextureAssetTask(
  94399. /**
  94400. * Defines the name of the task
  94401. */
  94402. name,
  94403. /**
  94404. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  94405. */
  94406. url,
  94407. /**
  94408. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  94409. */
  94410. extensions,
  94411. /**
  94412. * Defines if mipmaps should not be generated (default is false)
  94413. */
  94414. noMipmap,
  94415. /**
  94416. * Defines the explicit list of files (undefined by default)
  94417. */
  94418. files) {
  94419. var _this = _super.call(this, name) || this;
  94420. _this.name = name;
  94421. _this.url = url;
  94422. _this.extensions = extensions;
  94423. _this.noMipmap = noMipmap;
  94424. _this.files = files;
  94425. return _this;
  94426. }
  94427. /**
  94428. * Execute the current task
  94429. * @param scene defines the scene where you want your assets to be loaded
  94430. * @param onSuccess is a callback called when the task is successfully executed
  94431. * @param onError is a callback called if an error occurs
  94432. */
  94433. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  94434. var onload = function () {
  94435. onSuccess();
  94436. };
  94437. var onerror = function (message, exception) {
  94438. onError(message, exception);
  94439. };
  94440. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  94441. };
  94442. return CubeTextureAssetTask;
  94443. }(AbstractAssetTask));
  94444. /**
  94445. * Define a task used by AssetsManager to load HDR cube textures
  94446. */
  94447. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  94448. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  94449. /**
  94450. * Creates a new HDRCubeTextureAssetTask object
  94451. * @param name defines the name of the task
  94452. * @param url defines the location of the file to load
  94453. * @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.
  94454. * @param noMipmap defines if mipmaps should not be generated (default is false)
  94455. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  94456. * @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)
  94457. * @param reserved Internal use only
  94458. */
  94459. function HDRCubeTextureAssetTask(
  94460. /**
  94461. * Defines the name of the task
  94462. */
  94463. name,
  94464. /**
  94465. * Defines the location of the file to load
  94466. */
  94467. url,
  94468. /**
  94469. * Defines the desired size (the more it increases the longer the generation will be)
  94470. */
  94471. size,
  94472. /**
  94473. * Defines if mipmaps should not be generated (default is false)
  94474. */
  94475. noMipmap,
  94476. /**
  94477. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  94478. */
  94479. generateHarmonics,
  94480. /**
  94481. * 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)
  94482. */
  94483. gammaSpace,
  94484. /**
  94485. * Internal Use Only
  94486. */
  94487. reserved) {
  94488. if (noMipmap === void 0) { noMipmap = false; }
  94489. if (generateHarmonics === void 0) { generateHarmonics = true; }
  94490. if (gammaSpace === void 0) { gammaSpace = false; }
  94491. if (reserved === void 0) { reserved = false; }
  94492. var _this = _super.call(this, name) || this;
  94493. _this.name = name;
  94494. _this.url = url;
  94495. _this.size = size;
  94496. _this.noMipmap = noMipmap;
  94497. _this.generateHarmonics = generateHarmonics;
  94498. _this.gammaSpace = gammaSpace;
  94499. _this.reserved = reserved;
  94500. return _this;
  94501. }
  94502. /**
  94503. * Execute the current task
  94504. * @param scene defines the scene where you want your assets to be loaded
  94505. * @param onSuccess is a callback called when the task is successfully executed
  94506. * @param onError is a callback called if an error occurs
  94507. */
  94508. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  94509. var onload = function () {
  94510. onSuccess();
  94511. };
  94512. var onerror = function (message, exception) {
  94513. onError(message, exception);
  94514. };
  94515. 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);
  94516. };
  94517. return HDRCubeTextureAssetTask;
  94518. }(AbstractAssetTask));
  94519. /**
  94520. * This class can be used to easily import assets into a scene
  94521. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  94522. */
  94523. var AssetsManager = /** @class */ (function () {
  94524. /**
  94525. * Creates a new AssetsManager
  94526. * @param scene defines the scene to work on
  94527. */
  94528. function AssetsManager(scene) {
  94529. this._isLoading = false;
  94530. this._tasks = new Array();
  94531. this._waitingTasksCount = 0;
  94532. this._totalTasksCount = 0;
  94533. /**
  94534. * Observable called when all tasks are processed
  94535. */
  94536. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  94537. /**
  94538. * Observable called when a task had an error
  94539. */
  94540. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  94541. /**
  94542. * Observable called when a task is successful
  94543. */
  94544. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  94545. /**
  94546. * Observable called when a task is done (whatever the result is)
  94547. */
  94548. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  94549. /**
  94550. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  94551. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94552. */
  94553. this.useDefaultLoadingScreen = true;
  94554. this._scene = scene;
  94555. }
  94556. /**
  94557. * Add a MeshAssetTask to the list of active tasks
  94558. * @param taskName defines the name of the new task
  94559. * @param meshesNames defines the name of meshes to load
  94560. * @param rootUrl defines the root url to use to locate files
  94561. * @param sceneFilename defines the filename of the scene file
  94562. * @returns a new MeshAssetTask object
  94563. */
  94564. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  94565. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  94566. this._tasks.push(task);
  94567. return task;
  94568. };
  94569. /**
  94570. * Add a TextFileAssetTask to the list of active tasks
  94571. * @param taskName defines the name of the new task
  94572. * @param url defines the url of the file to load
  94573. * @returns a new TextFileAssetTask object
  94574. */
  94575. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  94576. var task = new TextFileAssetTask(taskName, url);
  94577. this._tasks.push(task);
  94578. return task;
  94579. };
  94580. /**
  94581. * Add a BinaryFileAssetTask to the list of active tasks
  94582. * @param taskName defines the name of the new task
  94583. * @param url defines the url of the file to load
  94584. * @returns a new BinaryFileAssetTask object
  94585. */
  94586. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  94587. var task = new BinaryFileAssetTask(taskName, url);
  94588. this._tasks.push(task);
  94589. return task;
  94590. };
  94591. /**
  94592. * Add a ImageAssetTask to the list of active tasks
  94593. * @param taskName defines the name of the new task
  94594. * @param url defines the url of the file to load
  94595. * @returns a new ImageAssetTask object
  94596. */
  94597. AssetsManager.prototype.addImageTask = function (taskName, url) {
  94598. var task = new ImageAssetTask(taskName, url);
  94599. this._tasks.push(task);
  94600. return task;
  94601. };
  94602. /**
  94603. * Add a TextureAssetTask to the list of active tasks
  94604. * @param taskName defines the name of the new task
  94605. * @param url defines the url of the file to load
  94606. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  94607. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  94608. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  94609. * @returns a new TextureAssetTask object
  94610. */
  94611. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  94612. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  94613. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  94614. this._tasks.push(task);
  94615. return task;
  94616. };
  94617. /**
  94618. * Add a CubeTextureAssetTask to the list of active tasks
  94619. * @param taskName defines the name of the new task
  94620. * @param url defines the url of the file to load
  94621. * @param extensions defines the extension to use to load the cube map (can be null)
  94622. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  94623. * @param files defines the list of files to load (can be null)
  94624. * @returns a new CubeTextureAssetTask object
  94625. */
  94626. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  94627. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  94628. this._tasks.push(task);
  94629. return task;
  94630. };
  94631. /**
  94632. *
  94633. * Add a HDRCubeTextureAssetTask to the list of active tasks
  94634. * @param taskName defines the name of the new task
  94635. * @param url defines the url of the file to load
  94636. * @param size defines the size you want for the cubemap (can be null)
  94637. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  94638. * @param generateHarmonics defines if you want to automatically generate (true by default)
  94639. * @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)
  94640. * @param reserved Internal use only
  94641. * @returns a new HDRCubeTextureAssetTask object
  94642. */
  94643. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  94644. if (noMipmap === void 0) { noMipmap = false; }
  94645. if (generateHarmonics === void 0) { generateHarmonics = true; }
  94646. if (gammaSpace === void 0) { gammaSpace = false; }
  94647. if (reserved === void 0) { reserved = false; }
  94648. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  94649. this._tasks.push(task);
  94650. return task;
  94651. };
  94652. /**
  94653. * Remove a task from the assets manager.
  94654. * @param task the task to remove
  94655. */
  94656. AssetsManager.prototype.removeTask = function (task) {
  94657. var index = this._tasks.indexOf(task);
  94658. if (index > -1) {
  94659. this._tasks.splice(index, 1);
  94660. }
  94661. };
  94662. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  94663. this._waitingTasksCount--;
  94664. try {
  94665. if (this.onProgress) {
  94666. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  94667. }
  94668. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  94669. }
  94670. catch (e) {
  94671. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  94672. console.log(e);
  94673. }
  94674. if (this._waitingTasksCount === 0) {
  94675. try {
  94676. if (this.onFinish) {
  94677. this.onFinish(this._tasks);
  94678. }
  94679. // Let's remove successfull tasks
  94680. var currentTasks = this._tasks.slice();
  94681. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  94682. var task = currentTasks_1[_i];
  94683. if (task.taskState === AssetTaskState.DONE) {
  94684. var index = this._tasks.indexOf(task);
  94685. if (index > -1) {
  94686. this._tasks.splice(index, 1);
  94687. }
  94688. }
  94689. }
  94690. this.onTasksDoneObservable.notifyObservers(this._tasks);
  94691. }
  94692. catch (e) {
  94693. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  94694. console.log(e);
  94695. }
  94696. this._isLoading = false;
  94697. this._scene.getEngine().hideLoadingUI();
  94698. }
  94699. };
  94700. AssetsManager.prototype._runTask = function (task) {
  94701. var _this = this;
  94702. var done = function () {
  94703. try {
  94704. if (_this.onTaskSuccess) {
  94705. _this.onTaskSuccess(task);
  94706. }
  94707. _this.onTaskSuccessObservable.notifyObservers(task);
  94708. _this._decreaseWaitingTasksCount(task);
  94709. }
  94710. catch (e) {
  94711. error("Error executing task success callbacks", e);
  94712. }
  94713. };
  94714. var error = function (message, exception) {
  94715. task._setErrorObject(message, exception);
  94716. if (_this.onTaskError) {
  94717. _this.onTaskError(task);
  94718. }
  94719. _this.onTaskErrorObservable.notifyObservers(task);
  94720. _this._decreaseWaitingTasksCount(task);
  94721. };
  94722. task.run(this._scene, done, error);
  94723. };
  94724. /**
  94725. * Reset the AssetsManager and remove all tasks
  94726. * @return the current instance of the AssetsManager
  94727. */
  94728. AssetsManager.prototype.reset = function () {
  94729. this._isLoading = false;
  94730. this._tasks = new Array();
  94731. return this;
  94732. };
  94733. /**
  94734. * Start the loading process
  94735. * @return the current instance of the AssetsManager
  94736. */
  94737. AssetsManager.prototype.load = function () {
  94738. if (this._isLoading) {
  94739. return this;
  94740. }
  94741. this._isLoading = true;
  94742. this._waitingTasksCount = this._tasks.length;
  94743. this._totalTasksCount = this._tasks.length;
  94744. if (this._waitingTasksCount === 0) {
  94745. this._isLoading = false;
  94746. if (this.onFinish) {
  94747. this.onFinish(this._tasks);
  94748. }
  94749. this.onTasksDoneObservable.notifyObservers(this._tasks);
  94750. return this;
  94751. }
  94752. if (this.useDefaultLoadingScreen) {
  94753. this._scene.getEngine().displayLoadingUI();
  94754. }
  94755. for (var index = 0; index < this._tasks.length; index++) {
  94756. var task = this._tasks[index];
  94757. if (task.taskState === AssetTaskState.INIT) {
  94758. this._runTask(task);
  94759. }
  94760. }
  94761. return this;
  94762. };
  94763. return AssetsManager;
  94764. }());
  94765. /***/ }),
  94766. /***/ "./Misc/dds.ts":
  94767. /*!*********************!*\
  94768. !*** ./Misc/dds.ts ***!
  94769. \*********************/
  94770. /*! exports provided: DDSTools */
  94771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94772. "use strict";
  94773. __webpack_require__.r(__webpack_exports__);
  94774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  94775. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  94776. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  94777. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  94778. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  94779. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  94780. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94781. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  94782. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  94783. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  94784. // All values and structures referenced from:
  94785. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  94786. var DDS_MAGIC = 0x20534444;
  94787. var
  94788. //DDSD_CAPS = 0x1,
  94789. //DDSD_HEIGHT = 0x2,
  94790. //DDSD_WIDTH = 0x4,
  94791. //DDSD_PITCH = 0x8,
  94792. //DDSD_PIXELFORMAT = 0x1000,
  94793. DDSD_MIPMAPCOUNT = 0x20000;
  94794. //DDSD_LINEARSIZE = 0x80000,
  94795. //DDSD_DEPTH = 0x800000;
  94796. // var DDSCAPS_COMPLEX = 0x8,
  94797. // DDSCAPS_MIPMAP = 0x400000,
  94798. // DDSCAPS_TEXTURE = 0x1000;
  94799. var DDSCAPS2_CUBEMAP = 0x200;
  94800. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  94801. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  94802. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  94803. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  94804. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  94805. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  94806. // DDSCAPS2_VOLUME = 0x200000;
  94807. var
  94808. //DDPF_ALPHAPIXELS = 0x1,
  94809. //DDPF_ALPHA = 0x2,
  94810. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  94811. //DDPF_YUV = 0x200,
  94812. DDPF_LUMINANCE = 0x20000;
  94813. function FourCCToInt32(value) {
  94814. return value.charCodeAt(0) +
  94815. (value.charCodeAt(1) << 8) +
  94816. (value.charCodeAt(2) << 16) +
  94817. (value.charCodeAt(3) << 24);
  94818. }
  94819. function Int32ToFourCC(value) {
  94820. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  94821. }
  94822. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  94823. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  94824. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  94825. var FOURCC_DX10 = FourCCToInt32("DX10");
  94826. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  94827. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  94828. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  94829. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  94830. var headerLengthInt = 31; // The header length in 32 bit ints
  94831. // Offsets into the header array
  94832. var off_magic = 0;
  94833. var off_size = 1;
  94834. var off_flags = 2;
  94835. var off_height = 3;
  94836. var off_width = 4;
  94837. var off_mipmapCount = 7;
  94838. var off_pfFlags = 20;
  94839. var off_pfFourCC = 21;
  94840. var off_RGBbpp = 22;
  94841. var off_RMask = 23;
  94842. var off_GMask = 24;
  94843. var off_BMask = 25;
  94844. var off_AMask = 26;
  94845. // var off_caps1 = 27;
  94846. var off_caps2 = 28;
  94847. // var off_caps3 = 29;
  94848. // var off_caps4 = 30;
  94849. var off_dxgiFormat = 32;
  94850. /**
  94851. * Class used to provide DDS decompression tools
  94852. */
  94853. var DDSTools = /** @class */ (function () {
  94854. function DDSTools() {
  94855. }
  94856. /**
  94857. * Gets DDS information from an array buffer
  94858. * @param arrayBuffer defines the array buffer to read data from
  94859. * @returns the DDS information
  94860. */
  94861. DDSTools.GetDDSInfo = function (arrayBuffer) {
  94862. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  94863. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  94864. var mipmapCount = 1;
  94865. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  94866. mipmapCount = Math.max(1, header[off_mipmapCount]);
  94867. }
  94868. var fourCC = header[off_pfFourCC];
  94869. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  94870. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94871. switch (fourCC) {
  94872. case FOURCC_D3DFMT_R16G16B16A16F:
  94873. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94874. break;
  94875. case FOURCC_D3DFMT_R32G32B32A32F:
  94876. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  94877. break;
  94878. case FOURCC_DX10:
  94879. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  94880. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94881. break;
  94882. }
  94883. }
  94884. return {
  94885. width: header[off_width],
  94886. height: header[off_height],
  94887. mipmapCount: mipmapCount,
  94888. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  94889. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  94890. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  94891. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  94892. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  94893. dxgiFormat: dxgiFormat,
  94894. textureType: textureType
  94895. };
  94896. };
  94897. DDSTools._ToHalfFloat = function (value) {
  94898. if (!DDSTools._FloatView) {
  94899. DDSTools._FloatView = new Float32Array(1);
  94900. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  94901. }
  94902. DDSTools._FloatView[0] = value;
  94903. var x = DDSTools._Int32View[0];
  94904. var bits = (x >> 16) & 0x8000; /* Get the sign */
  94905. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  94906. var e = (x >> 23) & 0xff; /* Using int is faster here */
  94907. /* If zero, or denormal, or exponent underflows too much for a denormal
  94908. * half, return signed zero. */
  94909. if (e < 103) {
  94910. return bits;
  94911. }
  94912. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  94913. if (e > 142) {
  94914. bits |= 0x7c00;
  94915. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  94916. * not Inf, so make sure we set one mantissa bit too. */
  94917. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  94918. return bits;
  94919. }
  94920. /* If exponent underflows but not too much, return a denormal */
  94921. if (e < 113) {
  94922. m |= 0x0800;
  94923. /* Extra rounding may overflow and set mantissa to 0 and exponent
  94924. * to 1, which is OK. */
  94925. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  94926. return bits;
  94927. }
  94928. bits |= ((e - 112) << 10) | (m >> 1);
  94929. bits += m & 1;
  94930. return bits;
  94931. };
  94932. DDSTools._FromHalfFloat = function (value) {
  94933. var s = (value & 0x8000) >> 15;
  94934. var e = (value & 0x7C00) >> 10;
  94935. var f = value & 0x03FF;
  94936. if (e === 0) {
  94937. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  94938. }
  94939. else if (e == 0x1F) {
  94940. return f ? NaN : ((s ? -1 : 1) * Infinity);
  94941. }
  94942. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  94943. };
  94944. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  94945. var destArray = new Float32Array(dataLength);
  94946. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  94947. var index = 0;
  94948. for (var y = 0; y < height; y++) {
  94949. for (var x = 0; x < width; x++) {
  94950. var srcPos = (x + y * width) * 4;
  94951. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  94952. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  94953. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  94954. if (DDSTools.StoreLODInAlphaChannel) {
  94955. destArray[index + 3] = lod;
  94956. }
  94957. else {
  94958. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  94959. }
  94960. index += 4;
  94961. }
  94962. }
  94963. return destArray;
  94964. };
  94965. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  94966. if (DDSTools.StoreLODInAlphaChannel) {
  94967. var destArray = new Uint16Array(dataLength);
  94968. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  94969. var index = 0;
  94970. for (var y = 0; y < height; y++) {
  94971. for (var x = 0; x < width; x++) {
  94972. var srcPos = (x + y * width) * 4;
  94973. destArray[index] = srcData[srcPos];
  94974. destArray[index + 1] = srcData[srcPos + 1];
  94975. destArray[index + 2] = srcData[srcPos + 2];
  94976. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  94977. index += 4;
  94978. }
  94979. }
  94980. return destArray;
  94981. }
  94982. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  94983. };
  94984. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  94985. if (DDSTools.StoreLODInAlphaChannel) {
  94986. var destArray = new Float32Array(dataLength);
  94987. var srcData = new Float32Array(arrayBuffer, dataOffset);
  94988. var index = 0;
  94989. for (var y = 0; y < height; y++) {
  94990. for (var x = 0; x < width; x++) {
  94991. var srcPos = (x + y * width) * 4;
  94992. destArray[index] = srcData[srcPos];
  94993. destArray[index + 1] = srcData[srcPos + 1];
  94994. destArray[index + 2] = srcData[srcPos + 2];
  94995. destArray[index + 3] = lod;
  94996. index += 4;
  94997. }
  94998. }
  94999. return destArray;
  95000. }
  95001. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  95002. };
  95003. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95004. var destArray = new Uint8Array(dataLength);
  95005. var srcData = new Float32Array(arrayBuffer, dataOffset);
  95006. var index = 0;
  95007. for (var y = 0; y < height; y++) {
  95008. for (var x = 0; x < width; x++) {
  95009. var srcPos = (x + y * width) * 4;
  95010. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  95011. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  95012. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  95013. if (DDSTools.StoreLODInAlphaChannel) {
  95014. destArray[index + 3] = lod;
  95015. }
  95016. else {
  95017. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  95018. }
  95019. index += 4;
  95020. }
  95021. }
  95022. return destArray;
  95023. };
  95024. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  95025. var destArray = new Uint8Array(dataLength);
  95026. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  95027. var index = 0;
  95028. for (var y = 0; y < height; y++) {
  95029. for (var x = 0; x < width; x++) {
  95030. var srcPos = (x + y * width) * 4;
  95031. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  95032. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  95033. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  95034. if (DDSTools.StoreLODInAlphaChannel) {
  95035. destArray[index + 3] = lod;
  95036. }
  95037. else {
  95038. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  95039. }
  95040. index += 4;
  95041. }
  95042. }
  95043. return destArray;
  95044. };
  95045. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  95046. var byteArray = new Uint8Array(dataLength);
  95047. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  95048. var index = 0;
  95049. for (var y = 0; y < height; y++) {
  95050. for (var x = 0; x < width; x++) {
  95051. var srcPos = (x + y * width) * 4;
  95052. byteArray[index] = srcData[srcPos + rOffset];
  95053. byteArray[index + 1] = srcData[srcPos + gOffset];
  95054. byteArray[index + 2] = srcData[srcPos + bOffset];
  95055. byteArray[index + 3] = srcData[srcPos + aOffset];
  95056. index += 4;
  95057. }
  95058. }
  95059. return byteArray;
  95060. };
  95061. DDSTools._ExtractLongWordOrder = function (value) {
  95062. if (value === 0 || value === 255 || value === -16777216) {
  95063. return 0;
  95064. }
  95065. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  95066. };
  95067. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  95068. var byteArray = new Uint8Array(dataLength);
  95069. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  95070. var index = 0;
  95071. for (var y = 0; y < height; y++) {
  95072. for (var x = 0; x < width; x++) {
  95073. var srcPos = (x + y * width) * 3;
  95074. byteArray[index] = srcData[srcPos + rOffset];
  95075. byteArray[index + 1] = srcData[srcPos + gOffset];
  95076. byteArray[index + 2] = srcData[srcPos + bOffset];
  95077. index += 3;
  95078. }
  95079. }
  95080. return byteArray;
  95081. };
  95082. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  95083. var byteArray = new Uint8Array(dataLength);
  95084. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  95085. var index = 0;
  95086. for (var y = 0; y < height; y++) {
  95087. for (var x = 0; x < width; x++) {
  95088. var srcPos = (x + y * width);
  95089. byteArray[index] = srcData[srcPos];
  95090. index++;
  95091. }
  95092. }
  95093. return byteArray;
  95094. };
  95095. /**
  95096. * Uploads DDS Levels to a Babylon Texture
  95097. * @hidden
  95098. */
  95099. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  95100. if (lodIndex === void 0) { lodIndex = -1; }
  95101. var sphericalPolynomialFaces = null;
  95102. if (info.sphericalPolynomial) {
  95103. sphericalPolynomialFaces = new Array();
  95104. }
  95105. var ext = engine.getCaps().s3tc;
  95106. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  95107. var fourCC, width, height, dataLength = 0, dataOffset;
  95108. var byteArray, mipmapCount, mip;
  95109. var internalCompressedFormat = 0;
  95110. var blockBytes = 1;
  95111. if (header[off_magic] !== DDS_MAGIC) {
  95112. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  95113. return;
  95114. }
  95115. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  95116. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  95117. return;
  95118. }
  95119. if (info.isCompressed && !ext) {
  95120. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  95121. return;
  95122. }
  95123. var bpp = header[off_RGBbpp];
  95124. dataOffset = header[off_size] + 4;
  95125. var computeFormats = false;
  95126. if (info.isFourCC) {
  95127. fourCC = header[off_pfFourCC];
  95128. switch (fourCC) {
  95129. case FOURCC_DXT1:
  95130. blockBytes = 8;
  95131. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  95132. break;
  95133. case FOURCC_DXT3:
  95134. blockBytes = 16;
  95135. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  95136. break;
  95137. case FOURCC_DXT5:
  95138. blockBytes = 16;
  95139. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  95140. break;
  95141. case FOURCC_D3DFMT_R16G16B16A16F:
  95142. computeFormats = true;
  95143. break;
  95144. case FOURCC_D3DFMT_R32G32B32A32F:
  95145. computeFormats = true;
  95146. break;
  95147. case FOURCC_DX10:
  95148. // There is an additionnal header so dataOffset need to be changed
  95149. dataOffset += 5 * 4; // 5 uints
  95150. var supported = false;
  95151. switch (info.dxgiFormat) {
  95152. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  95153. computeFormats = true;
  95154. supported = true;
  95155. break;
  95156. case DXGI_FORMAT_B8G8R8X8_UNORM:
  95157. info.isRGB = true;
  95158. info.isFourCC = false;
  95159. bpp = 32;
  95160. supported = true;
  95161. break;
  95162. }
  95163. if (supported) {
  95164. break;
  95165. }
  95166. default:
  95167. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  95168. return;
  95169. }
  95170. }
  95171. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  95172. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  95173. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  95174. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  95175. if (computeFormats) {
  95176. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  95177. }
  95178. mipmapCount = 1;
  95179. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  95180. mipmapCount = Math.max(1, header[off_mipmapCount]);
  95181. }
  95182. for (var face = 0; face < faces; face++) {
  95183. width = header[off_width];
  95184. height = header[off_height];
  95185. for (mip = 0; mip < mipmapCount; ++mip) {
  95186. if (lodIndex === -1 || lodIndex === mip) {
  95187. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  95188. var i = (lodIndex === -1) ? mip : 0;
  95189. if (!info.isCompressed && info.isFourCC) {
  95190. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  95191. dataLength = width * height * 4;
  95192. var floatArray = null;
  95193. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  95194. if (bpp === 128) {
  95195. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95196. if (sphericalPolynomialFaces && i == 0) {
  95197. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  95198. }
  95199. }
  95200. else if (bpp === 64) {
  95201. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95202. if (sphericalPolynomialFaces && i == 0) {
  95203. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  95204. }
  95205. }
  95206. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95207. }
  95208. else {
  95209. if (bpp === 128) {
  95210. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  95211. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95212. if (sphericalPolynomialFaces && i == 0) {
  95213. sphericalPolynomialFaces.push(floatArray);
  95214. }
  95215. }
  95216. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  95217. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  95218. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95219. if (sphericalPolynomialFaces && i == 0) {
  95220. sphericalPolynomialFaces.push(floatArray);
  95221. }
  95222. }
  95223. else { // 64
  95224. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  95225. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  95226. if (sphericalPolynomialFaces && i == 0) {
  95227. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  95228. }
  95229. }
  95230. }
  95231. if (floatArray) {
  95232. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  95233. }
  95234. }
  95235. else if (info.isRGB) {
  95236. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95237. if (bpp === 24) {
  95238. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  95239. dataLength = width * height * 3;
  95240. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  95241. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  95242. }
  95243. else { // 32
  95244. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  95245. dataLength = width * height * 4;
  95246. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  95247. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  95248. }
  95249. }
  95250. else if (info.isLuminance) {
  95251. var unpackAlignment = engine._getUnpackAlignement();
  95252. var unpaddedRowSize = width;
  95253. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  95254. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  95255. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  95256. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  95257. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95258. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  95259. }
  95260. else {
  95261. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  95262. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  95263. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95264. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  95265. }
  95266. }
  95267. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  95268. width *= 0.5;
  95269. height *= 0.5;
  95270. width = Math.max(1.0, width);
  95271. height = Math.max(1.0, height);
  95272. }
  95273. if (currentFace !== undefined) {
  95274. // Loading a single face
  95275. break;
  95276. }
  95277. }
  95278. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  95279. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  95280. size: header[off_width],
  95281. right: sphericalPolynomialFaces[0],
  95282. left: sphericalPolynomialFaces[1],
  95283. up: sphericalPolynomialFaces[2],
  95284. down: sphericalPolynomialFaces[3],
  95285. front: sphericalPolynomialFaces[4],
  95286. back: sphericalPolynomialFaces[5],
  95287. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  95288. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  95289. gammaSpace: false,
  95290. });
  95291. }
  95292. else {
  95293. info.sphericalPolynomial = undefined;
  95294. }
  95295. };
  95296. /**
  95297. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  95298. */
  95299. DDSTools.StoreLODInAlphaChannel = false;
  95300. return DDSTools;
  95301. }());
  95302. /**
  95303. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  95304. * @param rootUrl defines the url where the file to load is located
  95305. * @param scene defines the current scene
  95306. * @param lodScale defines scale to apply to the mip map selection
  95307. * @param lodOffset defines offset to apply to the mip map selection
  95308. * @param onLoad defines an optional callback raised when the texture is loaded
  95309. * @param onError defines an optional callback raised if there is an issue to load the texture
  95310. * @param format defines the format of the data
  95311. * @param forcedExtension defines the extension to use to pick the right loader
  95312. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  95313. * @returns the cube texture as an InternalTexture
  95314. */
  95315. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  95316. var _this = this;
  95317. if (onLoad === void 0) { onLoad = null; }
  95318. if (onError === void 0) { onError = null; }
  95319. if (forcedExtension === void 0) { forcedExtension = null; }
  95320. if (createPolynomials === void 0) { createPolynomials = true; }
  95321. var callback = function (loadData) {
  95322. if (!loadData) {
  95323. if (onLoad) {
  95324. onLoad(null);
  95325. }
  95326. return;
  95327. }
  95328. var texture = loadData.texture;
  95329. if (!createPolynomials) {
  95330. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  95331. }
  95332. else if (loadData.info.sphericalPolynomial) {
  95333. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  95334. }
  95335. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  95336. if (_this.getCaps().textureLOD) {
  95337. // Do not add extra process if texture lod is supported.
  95338. if (onLoad) {
  95339. onLoad(texture);
  95340. }
  95341. return;
  95342. }
  95343. var mipSlices = 3;
  95344. var gl = _this._gl;
  95345. var width = loadData.width;
  95346. if (!width) {
  95347. return;
  95348. }
  95349. var textures = [];
  95350. for (var i = 0; i < mipSlices; i++) {
  95351. //compute LOD from even spacing in smoothness (matching shader calculation)
  95352. var smoothness = i / (mipSlices - 1);
  95353. var roughness = 1 - smoothness;
  95354. var minLODIndex = lodOffset; // roughness = 0
  95355. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  95356. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  95357. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  95358. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  95359. glTextureFromLod.type = texture.type;
  95360. glTextureFromLod.format = texture.format;
  95361. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  95362. glTextureFromLod.height = glTextureFromLod.width;
  95363. glTextureFromLod.isCube = true;
  95364. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  95365. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  95366. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  95367. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  95368. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  95369. if (loadData.isDDS) {
  95370. var info = loadData.info;
  95371. var data = loadData.data;
  95372. _this._unpackFlipY(info.isCompressed);
  95373. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  95374. }
  95375. else {
  95376. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  95377. }
  95378. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  95379. // Wrap in a base texture for easy binding.
  95380. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  95381. lodTexture.isCube = true;
  95382. lodTexture._texture = glTextureFromLod;
  95383. glTextureFromLod.isReady = true;
  95384. textures.push(lodTexture);
  95385. }
  95386. texture._lodTextureHigh = textures[2];
  95387. texture._lodTextureMid = textures[1];
  95388. texture._lodTextureLow = textures[0];
  95389. if (onLoad) {
  95390. onLoad(texture);
  95391. }
  95392. };
  95393. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  95394. };
  95395. /***/ }),
  95396. /***/ "./Misc/decorators.ts":
  95397. /*!****************************!*\
  95398. !*** ./Misc/decorators.ts ***!
  95399. \****************************/
  95400. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  95401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95402. "use strict";
  95403. __webpack_require__.r(__webpack_exports__);
  95404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  95405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  95406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  95407. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  95408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  95409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  95410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  95411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  95412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  95413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  95414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  95415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  95416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  95417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  95418. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  95419. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95420. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  95421. var __decoratorInitialStore = {};
  95422. var __mergedStore = {};
  95423. var _copySource = function (creationFunction, source, instanciate) {
  95424. var destination = creationFunction();
  95425. // Tags
  95426. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  95427. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  95428. }
  95429. var classStore = getMergedStore(destination);
  95430. // Properties
  95431. for (var property in classStore) {
  95432. var propertyDescriptor = classStore[property];
  95433. var sourceProperty = source[property];
  95434. var propertyType = propertyDescriptor.type;
  95435. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  95436. switch (propertyType) {
  95437. case 0: // Value
  95438. case 6: // Mesh reference
  95439. case 11: // Camera reference
  95440. destination[property] = sourceProperty;
  95441. break;
  95442. case 1: // Texture
  95443. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  95444. break;
  95445. case 2: // Color3
  95446. case 3: // FresnelParameters
  95447. case 4: // Vector2
  95448. case 5: // Vector3
  95449. case 7: // Color Curves
  95450. case 10: // Quaternion
  95451. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  95452. break;
  95453. }
  95454. }
  95455. }
  95456. return destination;
  95457. };
  95458. function getDirectStore(target) {
  95459. var classKey = target.getClassName();
  95460. if (!__decoratorInitialStore[classKey]) {
  95461. __decoratorInitialStore[classKey] = {};
  95462. }
  95463. return __decoratorInitialStore[classKey];
  95464. }
  95465. /**
  95466. * Return the list of properties flagged as serializable
  95467. * @param target: host object
  95468. */
  95469. function getMergedStore(target) {
  95470. var classKey = target.getClassName();
  95471. if (__mergedStore[classKey]) {
  95472. return __mergedStore[classKey];
  95473. }
  95474. __mergedStore[classKey] = {};
  95475. var store = __mergedStore[classKey];
  95476. var currentTarget = target;
  95477. var currentKey = classKey;
  95478. while (currentKey) {
  95479. var initialStore = __decoratorInitialStore[currentKey];
  95480. for (var property in initialStore) {
  95481. store[property] = initialStore[property];
  95482. }
  95483. var parent_1 = void 0;
  95484. var done = false;
  95485. do {
  95486. parent_1 = Object.getPrototypeOf(currentTarget);
  95487. if (!parent_1.getClassName) {
  95488. done = true;
  95489. break;
  95490. }
  95491. if (parent_1.getClassName() !== currentKey) {
  95492. break;
  95493. }
  95494. currentTarget = parent_1;
  95495. } while (parent_1);
  95496. if (done) {
  95497. break;
  95498. }
  95499. currentKey = parent_1.getClassName();
  95500. currentTarget = parent_1;
  95501. }
  95502. return store;
  95503. }
  95504. function generateSerializableMember(type, sourceName) {
  95505. return function (target, propertyKey) {
  95506. var classStore = getDirectStore(target);
  95507. if (!classStore[propertyKey]) {
  95508. classStore[propertyKey] = { type: type, sourceName: sourceName };
  95509. }
  95510. };
  95511. }
  95512. function generateExpandMember(setCallback, targetKey) {
  95513. if (targetKey === void 0) { targetKey = null; }
  95514. return function (target, propertyKey) {
  95515. var key = targetKey || ("_" + propertyKey);
  95516. Object.defineProperty(target, propertyKey, {
  95517. get: function () {
  95518. return this[key];
  95519. },
  95520. set: function (value) {
  95521. if (this[key] === value) {
  95522. return;
  95523. }
  95524. this[key] = value;
  95525. target[setCallback].apply(this);
  95526. },
  95527. enumerable: true,
  95528. configurable: true
  95529. });
  95530. };
  95531. }
  95532. function expandToProperty(callback, targetKey) {
  95533. if (targetKey === void 0) { targetKey = null; }
  95534. return generateExpandMember(callback, targetKey);
  95535. }
  95536. function serialize(sourceName) {
  95537. return generateSerializableMember(0, sourceName); // value member
  95538. }
  95539. function serializeAsTexture(sourceName) {
  95540. return generateSerializableMember(1, sourceName); // texture member
  95541. }
  95542. function serializeAsColor3(sourceName) {
  95543. return generateSerializableMember(2, sourceName); // color3 member
  95544. }
  95545. function serializeAsFresnelParameters(sourceName) {
  95546. return generateSerializableMember(3, sourceName); // fresnel parameters member
  95547. }
  95548. function serializeAsVector2(sourceName) {
  95549. return generateSerializableMember(4, sourceName); // vector2 member
  95550. }
  95551. function serializeAsVector3(sourceName) {
  95552. return generateSerializableMember(5, sourceName); // vector3 member
  95553. }
  95554. function serializeAsMeshReference(sourceName) {
  95555. return generateSerializableMember(6, sourceName); // mesh reference member
  95556. }
  95557. function serializeAsColorCurves(sourceName) {
  95558. return generateSerializableMember(7, sourceName); // color curves
  95559. }
  95560. function serializeAsColor4(sourceName) {
  95561. return generateSerializableMember(8, sourceName); // color 4
  95562. }
  95563. function serializeAsImageProcessingConfiguration(sourceName) {
  95564. return generateSerializableMember(9, sourceName); // image processing
  95565. }
  95566. function serializeAsQuaternion(sourceName) {
  95567. return generateSerializableMember(10, sourceName); // quaternion member
  95568. }
  95569. /**
  95570. * Decorator used to define property that can be serialized as reference to a camera
  95571. * @param sourceName defines the name of the property to decorate
  95572. */
  95573. function serializeAsCameraReference(sourceName) {
  95574. return generateSerializableMember(11, sourceName); // camera reference member
  95575. }
  95576. /**
  95577. * Class used to help serialization objects
  95578. */
  95579. var SerializationHelper = /** @class */ (function () {
  95580. function SerializationHelper() {
  95581. }
  95582. /**
  95583. * Appends the serialized animations from the source animations
  95584. * @param source Source containing the animations
  95585. * @param destination Target to store the animations
  95586. */
  95587. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  95588. if (source.animations) {
  95589. destination.animations = [];
  95590. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  95591. var animation = source.animations[animationIndex];
  95592. destination.animations.push(animation.serialize());
  95593. }
  95594. }
  95595. };
  95596. /**
  95597. * Static function used to serialized a specific entity
  95598. * @param entity defines the entity to serialize
  95599. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95600. * @returns a JSON compatible object representing the serialization of the entity
  95601. */
  95602. SerializationHelper.Serialize = function (entity, serializationObject) {
  95603. if (!serializationObject) {
  95604. serializationObject = {};
  95605. }
  95606. // Tags
  95607. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  95608. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  95609. }
  95610. var serializedProperties = getMergedStore(entity);
  95611. // Properties
  95612. for (var property in serializedProperties) {
  95613. var propertyDescriptor = serializedProperties[property];
  95614. var targetPropertyName = propertyDescriptor.sourceName || property;
  95615. var propertyType = propertyDescriptor.type;
  95616. var sourceProperty = entity[property];
  95617. if (sourceProperty !== undefined && sourceProperty !== null) {
  95618. switch (propertyType) {
  95619. case 0: // Value
  95620. serializationObject[targetPropertyName] = sourceProperty;
  95621. break;
  95622. case 1: // Texture
  95623. serializationObject[targetPropertyName] = sourceProperty.serialize();
  95624. break;
  95625. case 2: // Color3
  95626. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95627. break;
  95628. case 3: // FresnelParameters
  95629. serializationObject[targetPropertyName] = sourceProperty.serialize();
  95630. break;
  95631. case 4: // Vector2
  95632. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95633. break;
  95634. case 5: // Vector3
  95635. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95636. break;
  95637. case 6: // Mesh reference
  95638. serializationObject[targetPropertyName] = sourceProperty.id;
  95639. break;
  95640. case 7: // Color Curves
  95641. serializationObject[targetPropertyName] = sourceProperty.serialize();
  95642. break;
  95643. case 8: // Color 4
  95644. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95645. break;
  95646. case 9: // Image Processing
  95647. serializationObject[targetPropertyName] = sourceProperty.serialize();
  95648. break;
  95649. case 10: // Quaternion
  95650. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95651. break;
  95652. case 11: // Camera reference
  95653. serializationObject[targetPropertyName] = sourceProperty.id;
  95654. break;
  95655. }
  95656. }
  95657. }
  95658. return serializationObject;
  95659. };
  95660. /**
  95661. * Creates a new entity from a serialization data object
  95662. * @param creationFunction defines a function used to instanciated the new entity
  95663. * @param source defines the source serialization data
  95664. * @param scene defines the hosting scene
  95665. * @param rootUrl defines the root url for resources
  95666. * @returns a new entity
  95667. */
  95668. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  95669. if (rootUrl === void 0) { rootUrl = null; }
  95670. var destination = creationFunction();
  95671. if (!rootUrl) {
  95672. rootUrl = "";
  95673. }
  95674. // Tags
  95675. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  95676. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  95677. }
  95678. var classStore = getMergedStore(destination);
  95679. // Properties
  95680. for (var property in classStore) {
  95681. var propertyDescriptor = classStore[property];
  95682. var sourceProperty = source[propertyDescriptor.sourceName || property];
  95683. var propertyType = propertyDescriptor.type;
  95684. if (sourceProperty !== undefined && sourceProperty !== null) {
  95685. var dest = destination;
  95686. switch (propertyType) {
  95687. case 0: // Value
  95688. dest[property] = sourceProperty;
  95689. break;
  95690. case 1: // Texture
  95691. if (scene) {
  95692. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  95693. }
  95694. break;
  95695. case 2: // Color3
  95696. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  95697. break;
  95698. case 3: // FresnelParameters
  95699. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  95700. break;
  95701. case 4: // Vector2
  95702. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  95703. break;
  95704. case 5: // Vector3
  95705. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  95706. break;
  95707. case 6: // Mesh reference
  95708. if (scene) {
  95709. dest[property] = scene.getLastMeshByID(sourceProperty);
  95710. }
  95711. break;
  95712. case 7: // Color Curves
  95713. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  95714. break;
  95715. case 8: // Color 4
  95716. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  95717. break;
  95718. case 9: // Image Processing
  95719. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  95720. break;
  95721. case 10: // Quaternion
  95722. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  95723. break;
  95724. case 11: // Camera reference
  95725. if (scene) {
  95726. dest[property] = scene.getCameraByID(sourceProperty);
  95727. }
  95728. break;
  95729. }
  95730. }
  95731. }
  95732. return destination;
  95733. };
  95734. /**
  95735. * Clones an object
  95736. * @param creationFunction defines the function used to instanciate the new object
  95737. * @param source defines the source object
  95738. * @returns the cloned object
  95739. */
  95740. SerializationHelper.Clone = function (creationFunction, source) {
  95741. return _copySource(creationFunction, source, false);
  95742. };
  95743. /**
  95744. * Instanciates a new object based on a source one (some data will be shared between both object)
  95745. * @param creationFunction defines the function used to instanciate the new object
  95746. * @param source defines the source object
  95747. * @returns the new object
  95748. */
  95749. SerializationHelper.Instanciate = function (creationFunction, source) {
  95750. return _copySource(creationFunction, source, true);
  95751. };
  95752. /** hidden */
  95753. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  95754. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  95755. };
  95756. /** hidden */
  95757. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  95758. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  95759. };
  95760. /** hidden */
  95761. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  95762. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  95763. };
  95764. /** hidden */
  95765. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  95766. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  95767. };
  95768. return SerializationHelper;
  95769. }());
  95770. /***/ }),
  95771. /***/ "./Misc/deepCopier.ts":
  95772. /*!****************************!*\
  95773. !*** ./Misc/deepCopier.ts ***!
  95774. \****************************/
  95775. /*! exports provided: DeepCopier */
  95776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95777. "use strict";
  95778. __webpack_require__.r(__webpack_exports__);
  95779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  95780. var cloneValue = function (source, destinationObject) {
  95781. if (!source) {
  95782. return null;
  95783. }
  95784. if (source.getClassName && source.getClassName() === "Mesh") {
  95785. return null;
  95786. }
  95787. if (source.getClassName && source.getClassName() === "SubMesh") {
  95788. return source.clone(destinationObject);
  95789. }
  95790. else if (source.clone) {
  95791. return source.clone();
  95792. }
  95793. return null;
  95794. };
  95795. /**
  95796. * Class containing a set of static utilities functions for deep copy.
  95797. */
  95798. var DeepCopier = /** @class */ (function () {
  95799. function DeepCopier() {
  95800. }
  95801. /**
  95802. * Tries to copy an object by duplicating every property
  95803. * @param source defines the source object
  95804. * @param destination defines the target object
  95805. * @param doNotCopyList defines a list of properties to avoid
  95806. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  95807. */
  95808. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  95809. for (var prop in source) {
  95810. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  95811. continue;
  95812. }
  95813. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  95814. continue;
  95815. }
  95816. var sourceValue = source[prop];
  95817. var typeOfSourceValue = typeof sourceValue;
  95818. if (typeOfSourceValue === "function") {
  95819. continue;
  95820. }
  95821. try {
  95822. if (typeOfSourceValue === "object") {
  95823. if (sourceValue instanceof Array) {
  95824. destination[prop] = [];
  95825. if (sourceValue.length > 0) {
  95826. if (typeof sourceValue[0] == "object") {
  95827. for (var index = 0; index < sourceValue.length; index++) {
  95828. var clonedValue = cloneValue(sourceValue[index], destination);
  95829. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  95830. destination[prop].push(clonedValue);
  95831. }
  95832. }
  95833. }
  95834. else {
  95835. destination[prop] = sourceValue.slice(0);
  95836. }
  95837. }
  95838. }
  95839. else {
  95840. destination[prop] = cloneValue(sourceValue, destination);
  95841. }
  95842. }
  95843. else {
  95844. destination[prop] = sourceValue;
  95845. }
  95846. }
  95847. catch (e) {
  95848. // Just ignore error (it could be because of a read-only property)
  95849. }
  95850. }
  95851. };
  95852. return DeepCopier;
  95853. }());
  95854. /***/ }),
  95855. /***/ "./Misc/deferred.ts":
  95856. /*!**************************!*\
  95857. !*** ./Misc/deferred.ts ***!
  95858. \**************************/
  95859. /*! exports provided: Deferred */
  95860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95861. "use strict";
  95862. __webpack_require__.r(__webpack_exports__);
  95863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  95864. /**
  95865. * Wrapper class for promise with external resolve and reject.
  95866. */
  95867. var Deferred = /** @class */ (function () {
  95868. /**
  95869. * Constructor for this deferred object.
  95870. */
  95871. function Deferred() {
  95872. var _this = this;
  95873. this.promise = new Promise(function (resolve, reject) {
  95874. _this._resolve = resolve;
  95875. _this._reject = reject;
  95876. });
  95877. }
  95878. Object.defineProperty(Deferred.prototype, "resolve", {
  95879. /**
  95880. * The resolve method of the promise associated with this deferred object.
  95881. */
  95882. get: function () {
  95883. return this._resolve;
  95884. },
  95885. enumerable: true,
  95886. configurable: true
  95887. });
  95888. Object.defineProperty(Deferred.prototype, "reject", {
  95889. /**
  95890. * The reject method of the promise associated with this deferred object.
  95891. */
  95892. get: function () {
  95893. return this._reject;
  95894. },
  95895. enumerable: true,
  95896. configurable: true
  95897. });
  95898. return Deferred;
  95899. }());
  95900. /***/ }),
  95901. /***/ "./Misc/devTools.ts":
  95902. /*!**************************!*\
  95903. !*** ./Misc/devTools.ts ***!
  95904. \**************************/
  95905. /*! exports provided: _DevTools */
  95906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95907. "use strict";
  95908. __webpack_require__.r(__webpack_exports__);
  95909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  95910. /** @hidden */
  95911. var _DevTools = /** @class */ (function () {
  95912. function _DevTools() {
  95913. }
  95914. _DevTools.WarnImport = function (name) {
  95915. return name + " needs to be imported before as it contains a side-effect required by your code.";
  95916. };
  95917. return _DevTools;
  95918. }());
  95919. /***/ }),
  95920. /***/ "./Misc/domManagement.ts":
  95921. /*!*******************************!*\
  95922. !*** ./Misc/domManagement.ts ***!
  95923. \*******************************/
  95924. /*! exports provided: DomManagement */
  95925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95926. "use strict";
  95927. __webpack_require__.r(__webpack_exports__);
  95928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  95929. /**
  95930. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  95931. * Babylon.js
  95932. */
  95933. var DomManagement = /** @class */ (function () {
  95934. function DomManagement() {
  95935. }
  95936. /**
  95937. * Checks if the window object exists
  95938. * @returns true if the window object exists
  95939. */
  95940. DomManagement.IsWindowObjectExist = function () {
  95941. return (typeof window) !== "undefined";
  95942. };
  95943. /**
  95944. * Extracts text content from a DOM element hierarchy
  95945. * @param element defines the root element
  95946. * @returns a string
  95947. */
  95948. DomManagement.GetDOMTextContent = function (element) {
  95949. var result = "";
  95950. var child = element.firstChild;
  95951. while (child) {
  95952. if (child.nodeType === 3) {
  95953. result += child.textContent;
  95954. }
  95955. child = (child.nextSibling);
  95956. }
  95957. return result;
  95958. };
  95959. return DomManagement;
  95960. }());
  95961. /***/ }),
  95962. /***/ "./Misc/environmentTextureTools.ts":
  95963. /*!*****************************************!*\
  95964. !*** ./Misc/environmentTextureTools.ts ***!
  95965. \*****************************************/
  95966. /*! exports provided: EnvironmentTextureTools */
  95967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95968. "use strict";
  95969. __webpack_require__.r(__webpack_exports__);
  95970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  95971. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95972. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95973. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  95974. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  95975. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  95976. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  95977. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95978. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  95979. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  95980. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  95981. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  95982. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  95983. /**
  95984. * Sets of helpers addressing the serialization and deserialization of environment texture
  95985. * stored in a BabylonJS env file.
  95986. * Those files are usually stored as .env files.
  95987. */
  95988. var EnvironmentTextureTools = /** @class */ (function () {
  95989. function EnvironmentTextureTools() {
  95990. }
  95991. /**
  95992. * Gets the environment info from an env file.
  95993. * @param data The array buffer containing the .env bytes.
  95994. * @returns the environment file info (the json header) if successfully parsed.
  95995. */
  95996. EnvironmentTextureTools.GetEnvInfo = function (data) {
  95997. var dataView = new DataView(data);
  95998. var pos = 0;
  95999. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  96000. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  96001. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  96002. return null;
  96003. }
  96004. }
  96005. // Read json manifest - collect characters up to null terminator
  96006. var manifestString = '';
  96007. var charCode = 0x00;
  96008. while ((charCode = dataView.getUint8(pos++))) {
  96009. manifestString += String.fromCharCode(charCode);
  96010. }
  96011. var manifest = JSON.parse(manifestString);
  96012. if (manifest.specular) {
  96013. // Extend the header with the position of the payload.
  96014. manifest.specular.specularDataPosition = pos;
  96015. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  96016. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  96017. }
  96018. return manifest;
  96019. };
  96020. /**
  96021. * Creates an environment texture from a loaded cube texture.
  96022. * @param texture defines the cube texture to convert in env file
  96023. * @return a promise containing the environment data if succesfull.
  96024. */
  96025. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  96026. var _this = this;
  96027. var internalTexture = texture.getInternalTexture();
  96028. if (!internalTexture) {
  96029. return Promise.reject("The cube texture is invalid.");
  96030. }
  96031. if (!texture._prefiltered) {
  96032. return Promise.reject("The cube texture is invalid (not prefiltered).");
  96033. }
  96034. var engine = internalTexture.getEngine();
  96035. if (engine && engine.premultipliedAlpha) {
  96036. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  96037. }
  96038. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  96039. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  96040. }
  96041. var canvas = engine.getRenderingCanvas();
  96042. if (!canvas) {
  96043. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  96044. }
  96045. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  96046. if (!engine.getCaps().textureFloatRender) {
  96047. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96048. if (!engine.getCaps().textureHalfFloatRender) {
  96049. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  96050. }
  96051. }
  96052. var cubeWidth = internalTexture.width;
  96053. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  96054. var specularTextures = {};
  96055. var promises = [];
  96056. // Read and collect all mipmaps data from the cube.
  96057. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  96058. mipmapsCount = Math.round(mipmapsCount);
  96059. var _loop_1 = function (i) {
  96060. var faceWidth = Math.pow(2, mipmapsCount - i);
  96061. var _loop_2 = function (face) {
  96062. var data = texture.readPixels(face, i);
  96063. // Creates a temp texture with the face data.
  96064. 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);
  96065. // And rgbdEncode them.
  96066. var promise = new Promise(function (resolve, reject) {
  96067. 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);
  96068. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  96069. rgbdPostProcess.onApply = function (effect) {
  96070. effect._bindTexture("textureSampler", tempTexture);
  96071. };
  96072. // As the process needs to happen on the main canvas, keep track of the current size
  96073. var currentW = engine.getRenderWidth();
  96074. var currentH = engine.getRenderHeight();
  96075. // Set the desired size for the texture
  96076. engine.setSize(faceWidth, faceWidth);
  96077. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  96078. // Reading datas from WebGL
  96079. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  96080. var fileReader = new FileReader();
  96081. fileReader.onload = function (event) {
  96082. var arrayBuffer = event.target.result;
  96083. specularTextures[i * 6 + face] = arrayBuffer;
  96084. resolve();
  96085. };
  96086. fileReader.readAsArrayBuffer(blob);
  96087. });
  96088. // Reapply the previous canvas size
  96089. engine.setSize(currentW, currentH);
  96090. });
  96091. });
  96092. promises.push(promise);
  96093. };
  96094. // All faces of the cube.
  96095. for (var face = 0; face < 6; face++) {
  96096. _loop_2(face);
  96097. }
  96098. };
  96099. for (var i = 0; i <= mipmapsCount; i++) {
  96100. _loop_1(i);
  96101. }
  96102. // Once all the textures haves been collected as RGBD stored in PNGs
  96103. return Promise.all(promises).then(function () {
  96104. // We can delete the hosting scene keeping track of all the creation objects
  96105. hostingScene.dispose();
  96106. // Creates the json header for the env texture
  96107. var info = {
  96108. version: 1,
  96109. width: cubeWidth,
  96110. irradiance: _this._CreateEnvTextureIrradiance(texture),
  96111. specular: {
  96112. mipmaps: [],
  96113. lodGenerationScale: texture.lodGenerationScale
  96114. }
  96115. };
  96116. // Sets the specular image data information
  96117. var position = 0;
  96118. for (var i = 0; i <= mipmapsCount; i++) {
  96119. for (var face = 0; face < 6; face++) {
  96120. var byteLength = specularTextures[i * 6 + face].byteLength;
  96121. info.specular.mipmaps.push({
  96122. length: byteLength,
  96123. position: position
  96124. });
  96125. position += byteLength;
  96126. }
  96127. }
  96128. // Encode the JSON as an array buffer
  96129. var infoString = JSON.stringify(info);
  96130. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  96131. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  96132. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  96133. infoView[i] = infoString.charCodeAt(i);
  96134. }
  96135. // Ends up with a null terminator for easier parsing
  96136. infoView[infoString.length] = 0x00;
  96137. // Computes the final required size and creates the storage
  96138. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  96139. var finalBuffer = new ArrayBuffer(totalSize);
  96140. var finalBufferView = new Uint8Array(finalBuffer);
  96141. var dataView = new DataView(finalBuffer);
  96142. // Copy the magic bytes identifying the file in
  96143. var pos = 0;
  96144. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  96145. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  96146. }
  96147. // Add the json info
  96148. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  96149. pos += infoBuffer.byteLength;
  96150. // Finally inserts the texture data
  96151. for (var i = 0; i <= mipmapsCount; i++) {
  96152. for (var face = 0; face < 6; face++) {
  96153. var dataBuffer = specularTextures[i * 6 + face];
  96154. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  96155. pos += dataBuffer.byteLength;
  96156. }
  96157. }
  96158. // Voila
  96159. return finalBuffer;
  96160. });
  96161. };
  96162. /**
  96163. * Creates a JSON representation of the spherical data.
  96164. * @param texture defines the texture containing the polynomials
  96165. * @return the JSON representation of the spherical info
  96166. */
  96167. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  96168. var polynmials = texture.sphericalPolynomial;
  96169. if (polynmials == null) {
  96170. return null;
  96171. }
  96172. return {
  96173. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  96174. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  96175. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  96176. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  96177. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  96178. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  96179. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  96180. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  96181. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  96182. };
  96183. };
  96184. /**
  96185. * Uploads the texture info contained in the env file to the GPU.
  96186. * @param texture defines the internal texture to upload to
  96187. * @param arrayBuffer defines the buffer cotaining the data to load
  96188. * @param info defines the texture info retrieved through the GetEnvInfo method
  96189. * @returns a promise
  96190. */
  96191. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  96192. if (info.version !== 1) {
  96193. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  96194. }
  96195. var specularInfo = info.specular;
  96196. if (!specularInfo) {
  96197. // Nothing else parsed so far
  96198. return Promise.resolve();
  96199. }
  96200. // Double checks the enclosed info
  96201. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  96202. mipmapsCount = Math.round(mipmapsCount) + 1;
  96203. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  96204. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  96205. }
  96206. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  96207. var imageData = new Array(mipmapsCount);
  96208. for (var i = 0; i < mipmapsCount; i++) {
  96209. imageData[i] = new Array(6);
  96210. for (var face = 0; face < 6; face++) {
  96211. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  96212. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  96213. }
  96214. }
  96215. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  96216. };
  96217. /**
  96218. * Uploads the levels of image data to the GPU.
  96219. * @param texture defines the internal texture to upload to
  96220. * @param imageData defines the array buffer views of image data [mipmap][face]
  96221. * @returns a promise
  96222. */
  96223. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  96224. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  96225. throw new Error("Texture size must be a power of two");
  96226. }
  96227. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  96228. // Gets everything ready.
  96229. var engine = texture.getEngine();
  96230. var expandTexture = false;
  96231. var generateNonLODTextures = false;
  96232. var rgbdPostProcess = null;
  96233. var cubeRtt = null;
  96234. var lodTextures = null;
  96235. var caps = engine.getCaps();
  96236. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  96237. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96238. texture.generateMipMaps = true;
  96239. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  96240. // Add extra process if texture lod is not supported
  96241. if (!caps.textureLOD) {
  96242. expandTexture = false;
  96243. generateNonLODTextures = true;
  96244. lodTextures = {};
  96245. }
  96246. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  96247. else if (engine.webGLVersion < 2) {
  96248. expandTexture = false;
  96249. }
  96250. // If half float available we can uncompress the texture
  96251. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  96252. expandTexture = true;
  96253. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96254. }
  96255. // If full float available we can uncompress the texture
  96256. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  96257. expandTexture = true;
  96258. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  96259. }
  96260. // Expand the texture if possible
  96261. if (expandTexture) {
  96262. // Simply run through the decode PP
  96263. 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);
  96264. texture._isRGBD = false;
  96265. texture.invertY = false;
  96266. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  96267. generateDepthBuffer: false,
  96268. generateMipMaps: true,
  96269. generateStencilBuffer: false,
  96270. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  96271. type: texture.type,
  96272. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  96273. });
  96274. }
  96275. else {
  96276. texture._isRGBD = true;
  96277. texture.invertY = true;
  96278. // In case of missing support, applies the same patch than DDS files.
  96279. if (generateNonLODTextures) {
  96280. var mipSlices = 3;
  96281. var scale = texture._lodGenerationScale;
  96282. var offset = texture._lodGenerationOffset;
  96283. for (var i = 0; i < mipSlices; i++) {
  96284. //compute LOD from even spacing in smoothness (matching shader calculation)
  96285. var smoothness = i / (mipSlices - 1);
  96286. var roughness = 1 - smoothness;
  96287. var minLODIndex = offset; // roughness = 0
  96288. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  96289. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  96290. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  96291. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  96292. glTextureFromLod.isCube = true;
  96293. glTextureFromLod.invertY = true;
  96294. glTextureFromLod.generateMipMaps = false;
  96295. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  96296. // Wrap in a base texture for easy binding.
  96297. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  96298. lodTexture.isCube = true;
  96299. lodTexture._texture = glTextureFromLod;
  96300. lodTextures[mipmapIndex] = lodTexture;
  96301. switch (i) {
  96302. case 0:
  96303. texture._lodTextureLow = lodTexture;
  96304. break;
  96305. case 1:
  96306. texture._lodTextureMid = lodTexture;
  96307. break;
  96308. case 2:
  96309. texture._lodTextureHigh = lodTexture;
  96310. break;
  96311. }
  96312. }
  96313. }
  96314. }
  96315. var promises = [];
  96316. var _loop_3 = function (i) {
  96317. var _loop_4 = function (face) {
  96318. // Constructs an image element from image data
  96319. var bytes = imageData[i][face];
  96320. var blob = new Blob([bytes], { type: 'image/png' });
  96321. var url = URL.createObjectURL(blob);
  96322. var image = new Image();
  96323. image.src = url;
  96324. // Enqueue promise to upload to the texture.
  96325. var promise = new Promise(function (resolve, reject) {
  96326. image.onload = function () {
  96327. if (expandTexture) {
  96328. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  96329. reject(message);
  96330. }, image);
  96331. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  96332. // Uncompress the data to a RTT
  96333. rgbdPostProcess.onApply = function (effect) {
  96334. effect._bindTexture("textureSampler", tempTexture_1);
  96335. effect.setFloat2("scale", 1, 1);
  96336. };
  96337. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  96338. // Cleanup
  96339. engine.restoreDefaultFramebuffer();
  96340. tempTexture_1.dispose();
  96341. window.URL.revokeObjectURL(url);
  96342. resolve();
  96343. });
  96344. }
  96345. else {
  96346. engine._uploadImageToTexture(texture, image, face, i);
  96347. // Upload the face to the non lod texture support
  96348. if (generateNonLODTextures) {
  96349. var lodTexture = lodTextures[i];
  96350. if (lodTexture) {
  96351. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  96352. }
  96353. }
  96354. resolve();
  96355. }
  96356. };
  96357. image.onerror = function (error) {
  96358. reject(error);
  96359. };
  96360. });
  96361. promises.push(promise);
  96362. };
  96363. // All faces
  96364. for (var face = 0; face < 6; face++) {
  96365. _loop_4(face);
  96366. }
  96367. };
  96368. // All mipmaps up to provided number of images
  96369. for (var i = 0; i < imageData.length; i++) {
  96370. _loop_3(i);
  96371. }
  96372. // Fill remaining mipmaps with black textures.
  96373. if (imageData.length < mipmapsCount) {
  96374. var data = void 0;
  96375. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  96376. var dataLength = size * size * 4;
  96377. switch (texture.type) {
  96378. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  96379. data = new Uint8Array(dataLength);
  96380. break;
  96381. }
  96382. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  96383. data = new Uint16Array(dataLength);
  96384. break;
  96385. }
  96386. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  96387. data = new Float32Array(dataLength);
  96388. break;
  96389. }
  96390. }
  96391. for (var i = imageData.length; i < mipmapsCount; i++) {
  96392. for (var face = 0; face < 6; face++) {
  96393. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  96394. }
  96395. }
  96396. }
  96397. // Once all done, finishes the cleanup and return
  96398. return Promise.all(promises).then(function () {
  96399. // Release temp RTT.
  96400. if (cubeRtt) {
  96401. engine._releaseFramebufferObjects(cubeRtt);
  96402. cubeRtt._swapAndDie(texture);
  96403. }
  96404. // Release temp Post Process.
  96405. if (rgbdPostProcess) {
  96406. rgbdPostProcess.dispose();
  96407. }
  96408. // Flag internal texture as ready in case they are in use.
  96409. if (generateNonLODTextures) {
  96410. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  96411. texture._lodTextureHigh._texture.isReady = true;
  96412. }
  96413. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  96414. texture._lodTextureMid._texture.isReady = true;
  96415. }
  96416. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  96417. texture._lodTextureLow._texture.isReady = true;
  96418. }
  96419. }
  96420. });
  96421. };
  96422. /**
  96423. * Uploads spherical polynomials information to the texture.
  96424. * @param texture defines the texture we are trying to upload the information to
  96425. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  96426. */
  96427. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  96428. if (info.version !== 1) {
  96429. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  96430. }
  96431. var irradianceInfo = info.irradiance;
  96432. if (!irradianceInfo) {
  96433. return;
  96434. }
  96435. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  96436. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  96437. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  96438. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  96439. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  96440. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  96441. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  96442. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  96443. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  96444. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  96445. texture._sphericalPolynomial = sp;
  96446. };
  96447. /** @hidden */
  96448. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  96449. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  96450. internalTexture._bufferViewArrayArray = data;
  96451. internalTexture._lodGenerationScale = lodScale;
  96452. internalTexture._lodGenerationOffset = lodOffset;
  96453. internalTexture._sphericalPolynomial = sphericalPolynomial;
  96454. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  96455. internalTexture.isReady = true;
  96456. });
  96457. };
  96458. /**
  96459. * Magic number identifying the env file.
  96460. */
  96461. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  96462. return EnvironmentTextureTools;
  96463. }());
  96464. // References the dependencies.
  96465. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  96466. /***/ }),
  96467. /***/ "./Misc/filesInput.ts":
  96468. /*!****************************!*\
  96469. !*** ./Misc/filesInput.ts ***!
  96470. \****************************/
  96471. /*! exports provided: FilesInput */
  96472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96473. "use strict";
  96474. __webpack_require__.r(__webpack_exports__);
  96475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  96476. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  96477. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96478. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  96479. /**
  96480. * Class used to help managing file picking and drag'n'drop
  96481. */
  96482. var FilesInput = /** @class */ (function () {
  96483. /**
  96484. * Creates a new FilesInput
  96485. * @param engine defines the rendering engine
  96486. * @param scene defines the hosting scene
  96487. * @param sceneLoadedCallback callback called when scene is loaded
  96488. * @param progressCallback callback called to track progress
  96489. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  96490. * @param textureLoadingCallback callback called when a texture is loading
  96491. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  96492. * @param onReloadCallback callback called when a reload is requested
  96493. * @param errorCallback callback call if an error occurs
  96494. */
  96495. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  96496. /**
  96497. * Callback called when a file is processed
  96498. */
  96499. this.onProcessFileCallback = function () { return true; };
  96500. this._engine = engine;
  96501. this._currentScene = scene;
  96502. this._sceneLoadedCallback = sceneLoadedCallback;
  96503. this._progressCallback = progressCallback;
  96504. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  96505. this._textureLoadingCallback = textureLoadingCallback;
  96506. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  96507. this._onReloadCallback = onReloadCallback;
  96508. this._errorCallback = errorCallback;
  96509. }
  96510. Object.defineProperty(FilesInput, "FilesToLoad", {
  96511. /**
  96512. * List of files ready to be loaded
  96513. */
  96514. get: function () {
  96515. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  96516. },
  96517. enumerable: true,
  96518. configurable: true
  96519. });
  96520. /**
  96521. * Calls this function to listen to drag'n'drop events on a specific DOM element
  96522. * @param elementToMonitor defines the DOM element to track
  96523. */
  96524. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  96525. var _this = this;
  96526. if (elementToMonitor) {
  96527. this._elementToMonitor = elementToMonitor;
  96528. this._dragEnterHandler = function (e) { _this.drag(e); };
  96529. this._dragOverHandler = function (e) { _this.drag(e); };
  96530. this._dropHandler = function (e) { _this.drop(e); };
  96531. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  96532. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  96533. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  96534. }
  96535. };
  96536. /**
  96537. * Release all associated resources
  96538. */
  96539. FilesInput.prototype.dispose = function () {
  96540. if (!this._elementToMonitor) {
  96541. return;
  96542. }
  96543. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  96544. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  96545. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  96546. };
  96547. FilesInput.prototype.renderFunction = function () {
  96548. if (this._additionalRenderLoopLogicCallback) {
  96549. this._additionalRenderLoopLogicCallback();
  96550. }
  96551. if (this._currentScene) {
  96552. if (this._textureLoadingCallback) {
  96553. var remaining = this._currentScene.getWaitingItemsCount();
  96554. if (remaining > 0) {
  96555. this._textureLoadingCallback(remaining);
  96556. }
  96557. }
  96558. this._currentScene.render();
  96559. }
  96560. };
  96561. FilesInput.prototype.drag = function (e) {
  96562. e.stopPropagation();
  96563. e.preventDefault();
  96564. };
  96565. FilesInput.prototype.drop = function (eventDrop) {
  96566. eventDrop.stopPropagation();
  96567. eventDrop.preventDefault();
  96568. this.loadFiles(eventDrop);
  96569. };
  96570. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  96571. var _this = this;
  96572. var reader = folder.createReader();
  96573. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  96574. reader.readEntries(function (entries) {
  96575. remaining.count += entries.length;
  96576. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  96577. var entry = entries_1[_i];
  96578. if (entry.isFile) {
  96579. entry.file(function (file) {
  96580. file.correctName = relativePath + file.name;
  96581. files.push(file);
  96582. if (--remaining.count === 0) {
  96583. callback();
  96584. }
  96585. });
  96586. }
  96587. else if (entry.isDirectory) {
  96588. _this._traverseFolder(entry, files, remaining, callback);
  96589. }
  96590. }
  96591. if (--remaining.count) {
  96592. callback();
  96593. }
  96594. });
  96595. };
  96596. FilesInput.prototype._processFiles = function (files) {
  96597. for (var i = 0; i < files.length; i++) {
  96598. var name = files[i].correctName.toLowerCase();
  96599. var extension = name.split('.').pop();
  96600. if (!this.onProcessFileCallback(files[i], name, extension)) {
  96601. continue;
  96602. }
  96603. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  96604. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  96605. this._sceneFileToLoad = files[i];
  96606. }
  96607. FilesInput.FilesToLoad[name] = files[i];
  96608. }
  96609. };
  96610. /**
  96611. * Load files from a drop event
  96612. * @param event defines the drop event to use as source
  96613. */
  96614. FilesInput.prototype.loadFiles = function (event) {
  96615. var _this = this;
  96616. // Handling data transfer via drag'n'drop
  96617. if (event && event.dataTransfer && event.dataTransfer.files) {
  96618. this._filesToLoad = event.dataTransfer.files;
  96619. }
  96620. // Handling files from input files
  96621. if (event && event.target && event.target.files) {
  96622. this._filesToLoad = event.target.files;
  96623. }
  96624. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  96625. return;
  96626. }
  96627. if (this._startingProcessingFilesCallback) {
  96628. this._startingProcessingFilesCallback(this._filesToLoad);
  96629. }
  96630. if (this._filesToLoad && this._filesToLoad.length > 0) {
  96631. var files_1 = new Array();
  96632. var folders = [];
  96633. var items = event.dataTransfer ? event.dataTransfer.items : null;
  96634. for (var i = 0; i < this._filesToLoad.length; i++) {
  96635. var fileToLoad = this._filesToLoad[i];
  96636. var name_1 = fileToLoad.name.toLowerCase();
  96637. var entry = void 0;
  96638. fileToLoad.correctName = name_1;
  96639. if (items) {
  96640. var item = items[i];
  96641. if (item.getAsEntry) {
  96642. entry = item.getAsEntry();
  96643. }
  96644. else if (item.webkitGetAsEntry) {
  96645. entry = item.webkitGetAsEntry();
  96646. }
  96647. }
  96648. if (!entry) {
  96649. files_1.push(fileToLoad);
  96650. }
  96651. else {
  96652. if (entry.isDirectory) {
  96653. folders.push(entry);
  96654. }
  96655. else {
  96656. files_1.push(fileToLoad);
  96657. }
  96658. }
  96659. }
  96660. if (folders.length === 0) {
  96661. this._processFiles(files_1);
  96662. this._processReload();
  96663. }
  96664. else {
  96665. var remaining = { count: folders.length };
  96666. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  96667. var folder = folders_1[_i];
  96668. this._traverseFolder(folder, files_1, remaining, function () {
  96669. _this._processFiles(files_1);
  96670. if (remaining.count === 0) {
  96671. _this._processReload();
  96672. }
  96673. });
  96674. }
  96675. }
  96676. }
  96677. };
  96678. FilesInput.prototype._processReload = function () {
  96679. if (this._onReloadCallback) {
  96680. this._onReloadCallback(this._sceneFileToLoad);
  96681. }
  96682. else {
  96683. this.reload();
  96684. }
  96685. };
  96686. /**
  96687. * Reload the current scene from the loaded files
  96688. */
  96689. FilesInput.prototype.reload = function () {
  96690. var _this = this;
  96691. // If a scene file has been provided
  96692. if (this._sceneFileToLoad) {
  96693. if (this._currentScene) {
  96694. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  96695. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  96696. }
  96697. this._engine.stopRenderLoop();
  96698. }
  96699. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  96700. if (_this._progressCallback) {
  96701. _this._progressCallback(progress);
  96702. }
  96703. }).then(function (scene) {
  96704. if (_this._currentScene) {
  96705. _this._currentScene.dispose();
  96706. }
  96707. _this._currentScene = scene;
  96708. if (_this._sceneLoadedCallback) {
  96709. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  96710. }
  96711. // Wait for textures and shaders to be ready
  96712. _this._currentScene.executeWhenReady(function () {
  96713. _this._engine.runRenderLoop(function () {
  96714. _this.renderFunction();
  96715. });
  96716. });
  96717. }).catch(function (error) {
  96718. if (_this._errorCallback) {
  96719. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  96720. }
  96721. });
  96722. }
  96723. else {
  96724. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  96725. }
  96726. };
  96727. return FilesInput;
  96728. }());
  96729. /***/ }),
  96730. /***/ "./Misc/filesInputStore.ts":
  96731. /*!*********************************!*\
  96732. !*** ./Misc/filesInputStore.ts ***!
  96733. \*********************************/
  96734. /*! exports provided: FilesInputStore */
  96735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96736. "use strict";
  96737. __webpack_require__.r(__webpack_exports__);
  96738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  96739. /**
  96740. * Class used to help managing file picking and drag'n'drop
  96741. * File Storage
  96742. */
  96743. var FilesInputStore = /** @class */ (function () {
  96744. function FilesInputStore() {
  96745. }
  96746. /**
  96747. * List of files ready to be loaded
  96748. */
  96749. FilesInputStore.FilesToLoad = {};
  96750. return FilesInputStore;
  96751. }());
  96752. /***/ }),
  96753. /***/ "./Misc/index.ts":
  96754. /*!***********************!*\
  96755. !*** ./Misc/index.ts ***!
  96756. \***********************/
  96757. /*! 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 */
  96758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96759. "use strict";
  96760. __webpack_require__.r(__webpack_exports__);
  96761. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  96762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  96763. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  96764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  96765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  96766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  96767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  96768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  96769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  96770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  96771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  96772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  96773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  96774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  96775. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  96776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  96777. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  96778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  96779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  96780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  96781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  96782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  96783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  96784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  96785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  96786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  96787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  96788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  96789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  96790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  96791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  96792. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  96793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  96794. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  96795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  96796. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  96797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  96798. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  96799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  96800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  96801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  96802. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  96803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  96804. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  96806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  96807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  96808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  96809. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  96810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  96811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  96812. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  96813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  96814. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  96815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  96816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  96817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  96818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  96819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  96820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  96821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  96822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  96823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  96824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  96825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  96826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  96827. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  96828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  96829. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  96830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  96831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  96832. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  96833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  96834. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  96835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  96836. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  96837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  96838. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  96839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  96840. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  96842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  96843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  96844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  96845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  96846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  96847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  96848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  96849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  96850. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  96851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  96852. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  96853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  96854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  96855. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  96856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  96857. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  96858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  96859. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  96860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  96861. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  96862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  96863. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  96864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  96865. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  96866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  96867. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  96868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  96869. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  96870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  96871. /* empty/unused harmony star reexport */
  96872. /***/ }),
  96873. /***/ "./Misc/khronosTextureContainer.ts":
  96874. /*!*****************************************!*\
  96875. !*** ./Misc/khronosTextureContainer.ts ***!
  96876. \*****************************************/
  96877. /*! exports provided: KhronosTextureContainer */
  96878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96879. "use strict";
  96880. __webpack_require__.r(__webpack_exports__);
  96881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  96882. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96883. /**
  96884. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96885. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96886. */
  96887. var KhronosTextureContainer = /** @class */ (function () {
  96888. /**
  96889. * Creates a new KhronosTextureContainer
  96890. * @param arrayBuffer contents of the KTX container file
  96891. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  96892. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  96893. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  96894. */
  96895. function KhronosTextureContainer(
  96896. /** contents of the KTX container file */
  96897. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  96898. this.arrayBuffer = arrayBuffer;
  96899. /**
  96900. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  96901. */
  96902. this.isInvalid = false;
  96903. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  96904. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  96905. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  96906. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  96907. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  96908. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  96909. this.isInvalid = true;
  96910. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  96911. return;
  96912. }
  96913. // load the reset of the header in native 32 bit uint
  96914. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  96915. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  96916. var endianness = headerDataView.getUint32(0, true);
  96917. var littleEndian = endianness === 0x04030201;
  96918. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  96919. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  96920. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  96921. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  96922. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  96923. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  96924. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  96925. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  96926. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  96927. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  96928. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  96929. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  96930. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  96931. if (this.glType !== 0) {
  96932. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  96933. return;
  96934. }
  96935. else {
  96936. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  96937. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  96938. }
  96939. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  96940. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  96941. return;
  96942. }
  96943. if (this.numberOfArrayElements !== 0) {
  96944. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  96945. return;
  96946. }
  96947. if (this.numberOfFaces !== facesExpected) {
  96948. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  96949. return;
  96950. }
  96951. // we now have a completely validated file, so could use existence of loadType as success
  96952. // would need to make this more elaborate & adjust checks above to support more than one load type
  96953. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  96954. }
  96955. /**
  96956. * Uploads KTX content to a Babylon Texture.
  96957. * It is assumed that the texture has already been created & is currently bound
  96958. * @hidden
  96959. */
  96960. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  96961. switch (this.loadType) {
  96962. case KhronosTextureContainer.COMPRESSED_2D:
  96963. this._upload2DCompressedLevels(texture, loadMipmaps);
  96964. break;
  96965. case KhronosTextureContainer.TEX_2D:
  96966. case KhronosTextureContainer.COMPRESSED_3D:
  96967. case KhronosTextureContainer.TEX_3D:
  96968. }
  96969. };
  96970. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  96971. // initialize width & height for level 1
  96972. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  96973. var width = this.pixelWidth;
  96974. var height = this.pixelHeight;
  96975. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  96976. for (var level = 0; level < mipmapCount; level++) {
  96977. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  96978. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  96979. for (var face = 0; face < this.numberOfFaces; face++) {
  96980. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  96981. var engine = texture.getEngine();
  96982. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  96983. dataOffset += imageSize; // add size of the image for the next face/mipmap
  96984. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  96985. }
  96986. width = Math.max(1.0, width * 0.5);
  96987. height = Math.max(1.0, height * 0.5);
  96988. }
  96989. };
  96990. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  96991. // load types
  96992. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  96993. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  96994. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  96995. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  96996. return KhronosTextureContainer;
  96997. }());
  96998. /***/ }),
  96999. /***/ "./Misc/logger.ts":
  97000. /*!************************!*\
  97001. !*** ./Misc/logger.ts ***!
  97002. \************************/
  97003. /*! exports provided: Logger */
  97004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97005. "use strict";
  97006. __webpack_require__.r(__webpack_exports__);
  97007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  97008. /**
  97009. * Logger used througouht the application to allow configuration of
  97010. * the log level required for the messages.
  97011. */
  97012. var Logger = /** @class */ (function () {
  97013. function Logger() {
  97014. }
  97015. Logger._AddLogEntry = function (entry) {
  97016. Logger._LogCache = entry + Logger._LogCache;
  97017. if (Logger.OnNewCacheEntry) {
  97018. Logger.OnNewCacheEntry(entry);
  97019. }
  97020. };
  97021. Logger._FormatMessage = function (message) {
  97022. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  97023. var date = new Date();
  97024. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  97025. };
  97026. Logger._LogDisabled = function (message) {
  97027. // nothing to do
  97028. };
  97029. Logger._LogEnabled = function (message) {
  97030. var formattedMessage = Logger._FormatMessage(message);
  97031. console.log("BJS - " + formattedMessage);
  97032. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  97033. Logger._AddLogEntry(entry);
  97034. };
  97035. Logger._WarnDisabled = function (message) {
  97036. // nothing to do
  97037. };
  97038. Logger._WarnEnabled = function (message) {
  97039. var formattedMessage = Logger._FormatMessage(message);
  97040. console.warn("BJS - " + formattedMessage);
  97041. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  97042. Logger._AddLogEntry(entry);
  97043. };
  97044. Logger._ErrorDisabled = function (message) {
  97045. // nothing to do
  97046. };
  97047. Logger._ErrorEnabled = function (message) {
  97048. Logger.errorsCount++;
  97049. var formattedMessage = Logger._FormatMessage(message);
  97050. console.error("BJS - " + formattedMessage);
  97051. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  97052. Logger._AddLogEntry(entry);
  97053. };
  97054. Object.defineProperty(Logger, "LogCache", {
  97055. /**
  97056. * Gets current log cache (list of logs)
  97057. */
  97058. get: function () {
  97059. return Logger._LogCache;
  97060. },
  97061. enumerable: true,
  97062. configurable: true
  97063. });
  97064. /**
  97065. * Clears the log cache
  97066. */
  97067. Logger.ClearLogCache = function () {
  97068. Logger._LogCache = "";
  97069. Logger.errorsCount = 0;
  97070. };
  97071. Object.defineProperty(Logger, "LogLevels", {
  97072. /**
  97073. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97074. */
  97075. set: function (level) {
  97076. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  97077. Logger.Log = Logger._LogEnabled;
  97078. }
  97079. else {
  97080. Logger.Log = Logger._LogDisabled;
  97081. }
  97082. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  97083. Logger.Warn = Logger._WarnEnabled;
  97084. }
  97085. else {
  97086. Logger.Warn = Logger._WarnDisabled;
  97087. }
  97088. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  97089. Logger.Error = Logger._ErrorEnabled;
  97090. }
  97091. else {
  97092. Logger.Error = Logger._ErrorDisabled;
  97093. }
  97094. },
  97095. enumerable: true,
  97096. configurable: true
  97097. });
  97098. /**
  97099. * No log
  97100. */
  97101. Logger.NoneLogLevel = 0;
  97102. /**
  97103. * Only message logs
  97104. */
  97105. Logger.MessageLogLevel = 1;
  97106. /**
  97107. * Only warning logs
  97108. */
  97109. Logger.WarningLogLevel = 2;
  97110. /**
  97111. * Only error logs
  97112. */
  97113. Logger.ErrorLogLevel = 4;
  97114. /**
  97115. * All logs
  97116. */
  97117. Logger.AllLogLevel = 7;
  97118. Logger._LogCache = "";
  97119. /**
  97120. * Gets a value indicating the number of loading errors
  97121. * @ignorenaming
  97122. */
  97123. Logger.errorsCount = 0;
  97124. /**
  97125. * Log a message to the console
  97126. */
  97127. Logger.Log = Logger._LogEnabled;
  97128. /**
  97129. * Write a warning message to the console
  97130. */
  97131. Logger.Warn = Logger._WarnEnabled;
  97132. /**
  97133. * Write an error message to the console
  97134. */
  97135. Logger.Error = Logger._ErrorEnabled;
  97136. return Logger;
  97137. }());
  97138. /***/ }),
  97139. /***/ "./Misc/observable.ts":
  97140. /*!****************************!*\
  97141. !*** ./Misc/observable.ts ***!
  97142. \****************************/
  97143. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  97144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97145. "use strict";
  97146. __webpack_require__.r(__webpack_exports__);
  97147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  97148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  97149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  97150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  97151. /**
  97152. * A class serves as a medium between the observable and its observers
  97153. */
  97154. var EventState = /** @class */ (function () {
  97155. /**
  97156. * Create a new EventState
  97157. * @param mask defines the mask associated with this state
  97158. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  97159. * @param target defines the original target of the state
  97160. * @param currentTarget defines the current target of the state
  97161. */
  97162. function EventState(mask, skipNextObservers, target, currentTarget) {
  97163. if (skipNextObservers === void 0) { skipNextObservers = false; }
  97164. this.initalize(mask, skipNextObservers, target, currentTarget);
  97165. }
  97166. /**
  97167. * Initialize the current event state
  97168. * @param mask defines the mask associated with this state
  97169. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  97170. * @param target defines the original target of the state
  97171. * @param currentTarget defines the current target of the state
  97172. * @returns the current event state
  97173. */
  97174. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  97175. if (skipNextObservers === void 0) { skipNextObservers = false; }
  97176. this.mask = mask;
  97177. this.skipNextObservers = skipNextObservers;
  97178. this.target = target;
  97179. this.currentTarget = currentTarget;
  97180. return this;
  97181. };
  97182. return EventState;
  97183. }());
  97184. /**
  97185. * Represent an Observer registered to a given Observable object.
  97186. */
  97187. var Observer = /** @class */ (function () {
  97188. /**
  97189. * Creates a new observer
  97190. * @param callback defines the callback to call when the observer is notified
  97191. * @param mask defines the mask of the observer (used to filter notifications)
  97192. * @param scope defines the current scope used to restore the JS context
  97193. */
  97194. function Observer(
  97195. /**
  97196. * Defines the callback to call when the observer is notified
  97197. */
  97198. callback,
  97199. /**
  97200. * Defines the mask of the observer (used to filter notifications)
  97201. */
  97202. mask,
  97203. /**
  97204. * Defines the current scope used to restore the JS context
  97205. */
  97206. scope) {
  97207. if (scope === void 0) { scope = null; }
  97208. this.callback = callback;
  97209. this.mask = mask;
  97210. this.scope = scope;
  97211. /** @hidden */
  97212. this._willBeUnregistered = false;
  97213. /**
  97214. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  97215. */
  97216. this.unregisterOnNextCall = false;
  97217. }
  97218. return Observer;
  97219. }());
  97220. /**
  97221. * Represent a list of observers registered to multiple Observables object.
  97222. */
  97223. var MultiObserver = /** @class */ (function () {
  97224. function MultiObserver() {
  97225. }
  97226. /**
  97227. * Release associated resources
  97228. */
  97229. MultiObserver.prototype.dispose = function () {
  97230. if (this._observers && this._observables) {
  97231. for (var index = 0; index < this._observers.length; index++) {
  97232. this._observables[index].remove(this._observers[index]);
  97233. }
  97234. }
  97235. this._observers = null;
  97236. this._observables = null;
  97237. };
  97238. /**
  97239. * Raise a callback when one of the observable will notify
  97240. * @param observables defines a list of observables to watch
  97241. * @param callback defines the callback to call on notification
  97242. * @param mask defines the mask used to filter notifications
  97243. * @param scope defines the current scope used to restore the JS context
  97244. * @returns the new MultiObserver
  97245. */
  97246. MultiObserver.Watch = function (observables, callback, mask, scope) {
  97247. if (mask === void 0) { mask = -1; }
  97248. if (scope === void 0) { scope = null; }
  97249. var result = new MultiObserver();
  97250. result._observers = new Array();
  97251. result._observables = observables;
  97252. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  97253. var observable = observables_1[_i];
  97254. var observer = observable.add(callback, mask, false, scope);
  97255. if (observer) {
  97256. result._observers.push(observer);
  97257. }
  97258. }
  97259. return result;
  97260. };
  97261. return MultiObserver;
  97262. }());
  97263. /**
  97264. * The Observable class is a simple implementation of the Observable pattern.
  97265. *
  97266. * 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.
  97267. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  97268. * 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).
  97269. * 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.
  97270. */
  97271. var Observable = /** @class */ (function () {
  97272. /**
  97273. * Creates a new observable
  97274. * @param onObserverAdded defines a callback to call when a new observer is added
  97275. */
  97276. function Observable(onObserverAdded) {
  97277. this._observers = new Array();
  97278. this._eventState = new EventState(0);
  97279. if (onObserverAdded) {
  97280. this._onObserverAdded = onObserverAdded;
  97281. }
  97282. }
  97283. /**
  97284. * Create a new Observer with the specified callback
  97285. * @param callback the callback that will be executed for that Observer
  97286. * @param mask the mask used to filter observers
  97287. * @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.
  97288. * @param scope optional scope for the callback to be called from
  97289. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  97290. * @returns the new observer created for the callback
  97291. */
  97292. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  97293. if (mask === void 0) { mask = -1; }
  97294. if (insertFirst === void 0) { insertFirst = false; }
  97295. if (scope === void 0) { scope = null; }
  97296. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  97297. if (!callback) {
  97298. return null;
  97299. }
  97300. var observer = new Observer(callback, mask, scope);
  97301. observer.unregisterOnNextCall = unregisterOnFirstCall;
  97302. if (insertFirst) {
  97303. this._observers.unshift(observer);
  97304. }
  97305. else {
  97306. this._observers.push(observer);
  97307. }
  97308. if (this._onObserverAdded) {
  97309. this._onObserverAdded(observer);
  97310. }
  97311. return observer;
  97312. };
  97313. /**
  97314. * Create a new Observer with the specified callback and unregisters after the next notification
  97315. * @param callback the callback that will be executed for that Observer
  97316. * @returns the new observer created for the callback
  97317. */
  97318. Observable.prototype.addOnce = function (callback) {
  97319. return this.add(callback, undefined, undefined, undefined, true);
  97320. };
  97321. /**
  97322. * Remove an Observer from the Observable object
  97323. * @param observer the instance of the Observer to remove
  97324. * @returns false if it doesn't belong to this Observable
  97325. */
  97326. Observable.prototype.remove = function (observer) {
  97327. if (!observer) {
  97328. return false;
  97329. }
  97330. var index = this._observers.indexOf(observer);
  97331. if (index !== -1) {
  97332. this._deferUnregister(observer);
  97333. return true;
  97334. }
  97335. return false;
  97336. };
  97337. /**
  97338. * Remove a callback from the Observable object
  97339. * @param callback the callback to remove
  97340. * @param scope optional scope. If used only the callbacks with this scope will be removed
  97341. * @returns false if it doesn't belong to this Observable
  97342. */
  97343. Observable.prototype.removeCallback = function (callback, scope) {
  97344. for (var index = 0; index < this._observers.length; index++) {
  97345. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  97346. this._deferUnregister(this._observers[index]);
  97347. return true;
  97348. }
  97349. }
  97350. return false;
  97351. };
  97352. Observable.prototype._deferUnregister = function (observer) {
  97353. var _this = this;
  97354. observer.unregisterOnNextCall = false;
  97355. observer._willBeUnregistered = true;
  97356. setTimeout(function () {
  97357. _this._remove(observer);
  97358. }, 0);
  97359. };
  97360. // This should only be called when not iterating over _observers to avoid callback skipping.
  97361. // Removes an observer from the _observer Array.
  97362. Observable.prototype._remove = function (observer) {
  97363. if (!observer) {
  97364. return false;
  97365. }
  97366. var index = this._observers.indexOf(observer);
  97367. if (index !== -1) {
  97368. this._observers.splice(index, 1);
  97369. return true;
  97370. }
  97371. return false;
  97372. };
  97373. /**
  97374. * Notify all Observers by calling their respective callback with the given data
  97375. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  97376. * @param eventData defines the data to send to all observers
  97377. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  97378. * @param target defines the original target of the state
  97379. * @param currentTarget defines the current target of the state
  97380. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  97381. */
  97382. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  97383. if (mask === void 0) { mask = -1; }
  97384. if (!this._observers.length) {
  97385. return true;
  97386. }
  97387. var state = this._eventState;
  97388. state.mask = mask;
  97389. state.target = target;
  97390. state.currentTarget = currentTarget;
  97391. state.skipNextObservers = false;
  97392. state.lastReturnValue = eventData;
  97393. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  97394. var obs = _a[_i];
  97395. if (obs._willBeUnregistered) {
  97396. continue;
  97397. }
  97398. if (obs.mask & mask) {
  97399. if (obs.scope) {
  97400. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  97401. }
  97402. else {
  97403. state.lastReturnValue = obs.callback(eventData, state);
  97404. }
  97405. if (obs.unregisterOnNextCall) {
  97406. this._deferUnregister(obs);
  97407. }
  97408. }
  97409. if (state.skipNextObservers) {
  97410. return false;
  97411. }
  97412. }
  97413. return true;
  97414. };
  97415. /**
  97416. * Calling this will execute each callback, expecting it to be a promise or return a value.
  97417. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  97418. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  97419. * and it is crucial that all callbacks will be executed.
  97420. * The order of the callbacks is kept, callbacks are not executed parallel.
  97421. *
  97422. * @param eventData The data to be sent to each callback
  97423. * @param mask is used to filter observers defaults to -1
  97424. * @param target defines the callback target (see EventState)
  97425. * @param currentTarget defines he current object in the bubbling phase
  97426. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  97427. */
  97428. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  97429. var _this = this;
  97430. if (mask === void 0) { mask = -1; }
  97431. // create an empty promise
  97432. var p = Promise.resolve(eventData);
  97433. // no observers? return this promise.
  97434. if (!this._observers.length) {
  97435. return p;
  97436. }
  97437. var state = this._eventState;
  97438. state.mask = mask;
  97439. state.target = target;
  97440. state.currentTarget = currentTarget;
  97441. state.skipNextObservers = false;
  97442. // execute one callback after another (not using Promise.all, the order is important)
  97443. this._observers.forEach(function (obs) {
  97444. if (state.skipNextObservers) {
  97445. return;
  97446. }
  97447. if (obs._willBeUnregistered) {
  97448. return;
  97449. }
  97450. if (obs.mask & mask) {
  97451. if (obs.scope) {
  97452. p = p.then(function (lastReturnedValue) {
  97453. state.lastReturnValue = lastReturnedValue;
  97454. return obs.callback.apply(obs.scope, [eventData, state]);
  97455. });
  97456. }
  97457. else {
  97458. p = p.then(function (lastReturnedValue) {
  97459. state.lastReturnValue = lastReturnedValue;
  97460. return obs.callback(eventData, state);
  97461. });
  97462. }
  97463. if (obs.unregisterOnNextCall) {
  97464. _this._deferUnregister(obs);
  97465. }
  97466. }
  97467. });
  97468. // return the eventData
  97469. return p.then(function () { return eventData; });
  97470. };
  97471. /**
  97472. * Notify a specific observer
  97473. * @param observer defines the observer to notify
  97474. * @param eventData defines the data to be sent to each callback
  97475. * @param mask is used to filter observers defaults to -1
  97476. */
  97477. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  97478. if (mask === void 0) { mask = -1; }
  97479. var state = this._eventState;
  97480. state.mask = mask;
  97481. state.skipNextObservers = false;
  97482. observer.callback(eventData, state);
  97483. };
  97484. /**
  97485. * Gets a boolean indicating if the observable has at least one observer
  97486. * @returns true is the Observable has at least one Observer registered
  97487. */
  97488. Observable.prototype.hasObservers = function () {
  97489. return this._observers.length > 0;
  97490. };
  97491. /**
  97492. * Clear the list of observers
  97493. */
  97494. Observable.prototype.clear = function () {
  97495. this._observers = new Array();
  97496. this._onObserverAdded = null;
  97497. };
  97498. /**
  97499. * Clone the current observable
  97500. * @returns a new observable
  97501. */
  97502. Observable.prototype.clone = function () {
  97503. var result = new Observable();
  97504. result._observers = this._observers.slice(0);
  97505. return result;
  97506. };
  97507. /**
  97508. * Does this observable handles observer registered with a given mask
  97509. * @param mask defines the mask to be tested
  97510. * @return whether or not one observer registered with the given mask is handeled
  97511. **/
  97512. Observable.prototype.hasSpecificMask = function (mask) {
  97513. if (mask === void 0) { mask = -1; }
  97514. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  97515. var obs = _a[_i];
  97516. if (obs.mask & mask || obs.mask === mask) {
  97517. return true;
  97518. }
  97519. }
  97520. return false;
  97521. };
  97522. return Observable;
  97523. }());
  97524. /***/ }),
  97525. /***/ "./Misc/performanceMonitor.ts":
  97526. /*!************************************!*\
  97527. !*** ./Misc/performanceMonitor.ts ***!
  97528. \************************************/
  97529. /*! exports provided: PerformanceMonitor, RollingAverage */
  97530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97531. "use strict";
  97532. __webpack_require__.r(__webpack_exports__);
  97533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  97534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  97535. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  97536. /**
  97537. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97538. */
  97539. var PerformanceMonitor = /** @class */ (function () {
  97540. /**
  97541. * constructor
  97542. * @param frameSampleSize The number of samples required to saturate the sliding window
  97543. */
  97544. function PerformanceMonitor(frameSampleSize) {
  97545. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  97546. this._enabled = true;
  97547. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  97548. }
  97549. /**
  97550. * Samples current frame
  97551. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97552. */
  97553. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  97554. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  97555. if (!this._enabled) {
  97556. return;
  97557. }
  97558. if (this._lastFrameTimeMs != null) {
  97559. var dt = timeMs - this._lastFrameTimeMs;
  97560. this._rollingFrameTime.add(dt);
  97561. }
  97562. this._lastFrameTimeMs = timeMs;
  97563. };
  97564. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  97565. /**
  97566. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97567. */
  97568. get: function () {
  97569. return this._rollingFrameTime.average;
  97570. },
  97571. enumerable: true,
  97572. configurable: true
  97573. });
  97574. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  97575. /**
  97576. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97577. */
  97578. get: function () {
  97579. return this._rollingFrameTime.variance;
  97580. },
  97581. enumerable: true,
  97582. configurable: true
  97583. });
  97584. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  97585. /**
  97586. * Returns the frame time of the most recent frame
  97587. */
  97588. get: function () {
  97589. return this._rollingFrameTime.history(0);
  97590. },
  97591. enumerable: true,
  97592. configurable: true
  97593. });
  97594. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  97595. /**
  97596. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97597. */
  97598. get: function () {
  97599. return 1000.0 / this._rollingFrameTime.average;
  97600. },
  97601. enumerable: true,
  97602. configurable: true
  97603. });
  97604. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  97605. /**
  97606. * Returns the average framerate in frames per second using the most recent frame time
  97607. */
  97608. get: function () {
  97609. var history = this._rollingFrameTime.history(0);
  97610. if (history === 0) {
  97611. return 0;
  97612. }
  97613. return 1000.0 / history;
  97614. },
  97615. enumerable: true,
  97616. configurable: true
  97617. });
  97618. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  97619. /**
  97620. * Returns true if enough samples have been taken to completely fill the sliding window
  97621. */
  97622. get: function () {
  97623. return this._rollingFrameTime.isSaturated();
  97624. },
  97625. enumerable: true,
  97626. configurable: true
  97627. });
  97628. /**
  97629. * Enables contributions to the sliding window sample set
  97630. */
  97631. PerformanceMonitor.prototype.enable = function () {
  97632. this._enabled = true;
  97633. };
  97634. /**
  97635. * Disables contributions to the sliding window sample set
  97636. * Samples will not be interpolated over the disabled period
  97637. */
  97638. PerformanceMonitor.prototype.disable = function () {
  97639. this._enabled = false;
  97640. //clear last sample to avoid interpolating over the disabled period when next enabled
  97641. this._lastFrameTimeMs = null;
  97642. };
  97643. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  97644. /**
  97645. * Returns true if sampling is enabled
  97646. */
  97647. get: function () {
  97648. return this._enabled;
  97649. },
  97650. enumerable: true,
  97651. configurable: true
  97652. });
  97653. /**
  97654. * Resets performance monitor
  97655. */
  97656. PerformanceMonitor.prototype.reset = function () {
  97657. //clear last sample to avoid interpolating over the disabled period when next enabled
  97658. this._lastFrameTimeMs = null;
  97659. //wipe record
  97660. this._rollingFrameTime.reset();
  97661. };
  97662. return PerformanceMonitor;
  97663. }());
  97664. /**
  97665. * RollingAverage
  97666. *
  97667. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97668. */
  97669. var RollingAverage = /** @class */ (function () {
  97670. /**
  97671. * constructor
  97672. * @param length The number of samples required to saturate the sliding window
  97673. */
  97674. function RollingAverage(length) {
  97675. this._samples = new Array(length);
  97676. this.reset();
  97677. }
  97678. /**
  97679. * Adds a sample to the sample set
  97680. * @param v The sample value
  97681. */
  97682. RollingAverage.prototype.add = function (v) {
  97683. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  97684. var delta;
  97685. //we need to check if we've already wrapped round
  97686. if (this.isSaturated()) {
  97687. //remove bottom of stack from mean
  97688. var bottomValue = this._samples[this._pos];
  97689. delta = bottomValue - this.average;
  97690. this.average -= delta / (this._sampleCount - 1);
  97691. this._m2 -= delta * (bottomValue - this.average);
  97692. }
  97693. else {
  97694. this._sampleCount++;
  97695. }
  97696. //add new value to mean
  97697. delta = v - this.average;
  97698. this.average += delta / (this._sampleCount);
  97699. this._m2 += delta * (v - this.average);
  97700. //set the new variance
  97701. this.variance = this._m2 / (this._sampleCount - 1);
  97702. this._samples[this._pos] = v;
  97703. this._pos++;
  97704. this._pos %= this._samples.length; //positive wrap around
  97705. };
  97706. /**
  97707. * Returns previously added values or null if outside of history or outside the sliding window domain
  97708. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97709. * @return Value previously recorded with add() or null if outside of range
  97710. */
  97711. RollingAverage.prototype.history = function (i) {
  97712. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  97713. return 0;
  97714. }
  97715. var i0 = this._wrapPosition(this._pos - 1.0);
  97716. return this._samples[this._wrapPosition(i0 - i)];
  97717. };
  97718. /**
  97719. * Returns true if enough samples have been taken to completely fill the sliding window
  97720. * @return true if sample-set saturated
  97721. */
  97722. RollingAverage.prototype.isSaturated = function () {
  97723. return this._sampleCount >= this._samples.length;
  97724. };
  97725. /**
  97726. * Resets the rolling average (equivalent to 0 samples taken so far)
  97727. */
  97728. RollingAverage.prototype.reset = function () {
  97729. this.average = 0;
  97730. this.variance = 0;
  97731. this._sampleCount = 0;
  97732. this._pos = 0;
  97733. this._m2 = 0;
  97734. };
  97735. /**
  97736. * Wraps a value around the sample range boundaries
  97737. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97738. * @return Wrapped position in sample range
  97739. */
  97740. RollingAverage.prototype._wrapPosition = function (i) {
  97741. var max = this._samples.length;
  97742. return ((i % max) + max) % max;
  97743. };
  97744. return RollingAverage;
  97745. }());
  97746. /***/ }),
  97747. /***/ "./Misc/pivotTools.ts":
  97748. /*!****************************!*\
  97749. !*** ./Misc/pivotTools.ts ***!
  97750. \****************************/
  97751. /*! exports provided: PivotTools */
  97752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97753. "use strict";
  97754. __webpack_require__.r(__webpack_exports__);
  97755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  97756. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  97757. /**
  97758. * Class containing a set of static utilities functions for managing Pivots
  97759. * @hidden
  97760. */
  97761. var PivotTools = /** @class */ (function () {
  97762. function PivotTools() {
  97763. }
  97764. /** @hidden */
  97765. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  97766. if (mesh && PivotTools._PivotCached === 0) {
  97767. // Save old pivot and set pivot to 0,0,0
  97768. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  97769. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  97770. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  97771. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  97772. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  97773. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  97774. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  97775. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  97776. }
  97777. }
  97778. PivotTools._PivotCached++;
  97779. };
  97780. /** @hidden */
  97781. PivotTools._RestorePivotPoint = function (mesh) {
  97782. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  97783. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  97784. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  97785. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  97786. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  97787. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  97788. }
  97789. this._PivotCached--;
  97790. };
  97791. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  97792. // store/remove pivot point should only be applied during their outermost calls
  97793. PivotTools._PivotCached = 0;
  97794. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  97795. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  97796. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  97797. return PivotTools;
  97798. }());
  97799. /***/ }),
  97800. /***/ "./Misc/precisionDate.ts":
  97801. /*!*******************************!*\
  97802. !*** ./Misc/precisionDate.ts ***!
  97803. \*******************************/
  97804. /*! exports provided: PrecisionDate */
  97805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97806. "use strict";
  97807. __webpack_require__.r(__webpack_exports__);
  97808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  97809. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  97810. /**
  97811. * Class containing a set of static utilities functions for precision date
  97812. */
  97813. var PrecisionDate = /** @class */ (function () {
  97814. function PrecisionDate() {
  97815. }
  97816. Object.defineProperty(PrecisionDate, "Now", {
  97817. /**
  97818. * Gets either window.performance.now() if supported or Date.now() else
  97819. */
  97820. get: function () {
  97821. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  97822. return window.performance.now();
  97823. }
  97824. return Date.now();
  97825. },
  97826. enumerable: true,
  97827. configurable: true
  97828. });
  97829. return PrecisionDate;
  97830. }());
  97831. /***/ }),
  97832. /***/ "./Misc/promise.ts":
  97833. /*!*************************!*\
  97834. !*** ./Misc/promise.ts ***!
  97835. \*************************/
  97836. /*! exports provided: PromisePolyfill */
  97837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97838. "use strict";
  97839. __webpack_require__.r(__webpack_exports__);
  97840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  97841. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97842. var PromiseStates;
  97843. (function (PromiseStates) {
  97844. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  97845. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  97846. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  97847. })(PromiseStates || (PromiseStates = {}));
  97848. var FulFillmentAgregator = /** @class */ (function () {
  97849. function FulFillmentAgregator() {
  97850. this.count = 0;
  97851. this.target = 0;
  97852. this.results = [];
  97853. }
  97854. return FulFillmentAgregator;
  97855. }());
  97856. var InternalPromise = /** @class */ (function () {
  97857. function InternalPromise(resolver) {
  97858. var _this = this;
  97859. this._state = PromiseStates.Pending;
  97860. this._children = new Array();
  97861. this._rejectWasConsumed = false;
  97862. if (!resolver) {
  97863. return;
  97864. }
  97865. try {
  97866. resolver(function (value) {
  97867. _this._resolve(value);
  97868. }, function (reason) {
  97869. _this._reject(reason);
  97870. });
  97871. }
  97872. catch (e) {
  97873. this._reject(e);
  97874. }
  97875. }
  97876. Object.defineProperty(InternalPromise.prototype, "_result", {
  97877. get: function () {
  97878. return this._resultValue;
  97879. },
  97880. set: function (value) {
  97881. this._resultValue = value;
  97882. if (this._parent && this._parent._result === undefined) {
  97883. this._parent._result = value;
  97884. }
  97885. },
  97886. enumerable: true,
  97887. configurable: true
  97888. });
  97889. InternalPromise.prototype.catch = function (onRejected) {
  97890. return this.then(undefined, onRejected);
  97891. };
  97892. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  97893. var _this = this;
  97894. var newPromise = new InternalPromise();
  97895. newPromise._onFulfilled = onFulfilled;
  97896. newPromise._onRejected = onRejected;
  97897. // Composition
  97898. this._children.push(newPromise);
  97899. newPromise._parent = this;
  97900. if (this._state !== PromiseStates.Pending) {
  97901. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  97902. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  97903. var returnedValue = newPromise._resolve(_this._result);
  97904. if (returnedValue !== undefined && returnedValue !== null) {
  97905. if (returnedValue._state !== undefined) {
  97906. var returnedPromise = returnedValue;
  97907. newPromise._children.push(returnedPromise);
  97908. returnedPromise._parent = newPromise;
  97909. newPromise = returnedPromise;
  97910. }
  97911. else {
  97912. newPromise._result = returnedValue;
  97913. }
  97914. }
  97915. }
  97916. else {
  97917. newPromise._reject(_this._reason);
  97918. }
  97919. });
  97920. }
  97921. return newPromise;
  97922. };
  97923. InternalPromise.prototype._moveChildren = function (children) {
  97924. var _this = this;
  97925. var _a;
  97926. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  97927. this._children.forEach(function (child) {
  97928. child._parent = _this;
  97929. });
  97930. if (this._state === PromiseStates.Fulfilled) {
  97931. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  97932. var child = _b[_i];
  97933. child._resolve(this._result);
  97934. }
  97935. }
  97936. else if (this._state === PromiseStates.Rejected) {
  97937. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  97938. var child = _d[_c];
  97939. child._reject(this._reason);
  97940. }
  97941. }
  97942. };
  97943. InternalPromise.prototype._resolve = function (value) {
  97944. try {
  97945. this._state = PromiseStates.Fulfilled;
  97946. var returnedValue = null;
  97947. if (this._onFulfilled) {
  97948. returnedValue = this._onFulfilled(value);
  97949. }
  97950. if (returnedValue !== undefined && returnedValue !== null) {
  97951. if (returnedValue._state !== undefined) {
  97952. // Transmit children
  97953. var returnedPromise = returnedValue;
  97954. returnedPromise._parent = this;
  97955. returnedPromise._moveChildren(this._children);
  97956. value = returnedPromise._result;
  97957. }
  97958. else {
  97959. value = returnedValue;
  97960. }
  97961. }
  97962. this._result = value;
  97963. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  97964. var child = _a[_i];
  97965. child._resolve(value);
  97966. }
  97967. this._children.length = 0;
  97968. delete this._onFulfilled;
  97969. delete this._onRejected;
  97970. }
  97971. catch (e) {
  97972. this._reject(e, true);
  97973. }
  97974. };
  97975. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  97976. if (onLocalThrow === void 0) { onLocalThrow = false; }
  97977. this._state = PromiseStates.Rejected;
  97978. this._reason = reason;
  97979. if (this._onRejected && !onLocalThrow) {
  97980. try {
  97981. this._onRejected(reason);
  97982. this._rejectWasConsumed = true;
  97983. }
  97984. catch (e) {
  97985. reason = e;
  97986. }
  97987. }
  97988. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  97989. var child = _a[_i];
  97990. if (this._rejectWasConsumed) {
  97991. child._resolve(null);
  97992. }
  97993. else {
  97994. child._reject(reason);
  97995. }
  97996. }
  97997. this._children.length = 0;
  97998. delete this._onFulfilled;
  97999. delete this._onRejected;
  98000. };
  98001. InternalPromise.resolve = function (value) {
  98002. var newPromise = new InternalPromise();
  98003. newPromise._resolve(value);
  98004. return newPromise;
  98005. };
  98006. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  98007. promise.then(function (value) {
  98008. agregator.results[index] = value;
  98009. agregator.count++;
  98010. if (agregator.count === agregator.target) {
  98011. agregator.rootPromise._resolve(agregator.results);
  98012. }
  98013. return null;
  98014. }, function (reason) {
  98015. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  98016. agregator.rootPromise._reject(reason);
  98017. }
  98018. });
  98019. };
  98020. InternalPromise.all = function (promises) {
  98021. var newPromise = new InternalPromise();
  98022. var agregator = new FulFillmentAgregator();
  98023. agregator.target = promises.length;
  98024. agregator.rootPromise = newPromise;
  98025. if (promises.length) {
  98026. for (var index = 0; index < promises.length; index++) {
  98027. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  98028. }
  98029. }
  98030. else {
  98031. newPromise._resolve([]);
  98032. }
  98033. return newPromise;
  98034. };
  98035. InternalPromise.race = function (promises) {
  98036. var newPromise = new InternalPromise();
  98037. if (promises.length) {
  98038. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  98039. var promise = promises_1[_i];
  98040. promise.then(function (value) {
  98041. if (newPromise) {
  98042. newPromise._resolve(value);
  98043. newPromise = null;
  98044. }
  98045. return null;
  98046. }, function (reason) {
  98047. if (newPromise) {
  98048. newPromise._reject(reason);
  98049. newPromise = null;
  98050. }
  98051. });
  98052. }
  98053. }
  98054. return newPromise;
  98055. };
  98056. return InternalPromise;
  98057. }());
  98058. /**
  98059. * Helper class that provides a small promise polyfill
  98060. */
  98061. var PromisePolyfill = /** @class */ (function () {
  98062. function PromisePolyfill() {
  98063. }
  98064. /**
  98065. * Static function used to check if the polyfill is required
  98066. * If this is the case then the function will inject the polyfill to window.Promise
  98067. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98068. */
  98069. PromisePolyfill.Apply = function (force) {
  98070. if (force === void 0) { force = false; }
  98071. if (force || typeof Promise === 'undefined') {
  98072. var root = window;
  98073. root.Promise = InternalPromise;
  98074. }
  98075. };
  98076. return PromisePolyfill;
  98077. }());
  98078. /***/ }),
  98079. /***/ "./Misc/sceneOptimizer.ts":
  98080. /*!********************************!*\
  98081. !*** ./Misc/sceneOptimizer.ts ***!
  98082. \********************************/
  98083. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  98084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98085. "use strict";
  98086. __webpack_require__.r(__webpack_exports__);
  98087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  98088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  98089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  98090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  98091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  98092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  98093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  98094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  98095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  98096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  98097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  98098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  98099. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98100. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  98101. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  98102. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  98103. /**
  98104. * Defines the root class used to create scene optimization to use with SceneOptimizer
  98105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98106. */
  98107. var SceneOptimization = /** @class */ (function () {
  98108. /**
  98109. * Creates the SceneOptimization object
  98110. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  98111. * @param desc defines the description associated with the optimization
  98112. */
  98113. function SceneOptimization(
  98114. /**
  98115. * Defines the priority of this optimization (0 by default which means first in the list)
  98116. */
  98117. priority) {
  98118. if (priority === void 0) { priority = 0; }
  98119. this.priority = priority;
  98120. }
  98121. /**
  98122. * Gets a string describing the action executed by the current optimization
  98123. * @returns description string
  98124. */
  98125. SceneOptimization.prototype.getDescription = function () {
  98126. return "";
  98127. };
  98128. /**
  98129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98130. * @param scene defines the current scene where to apply this optimization
  98131. * @param optimizer defines the current optimizer
  98132. * @returns true if everything that can be done was applied
  98133. */
  98134. SceneOptimization.prototype.apply = function (scene, optimizer) {
  98135. return true;
  98136. };
  98137. return SceneOptimization;
  98138. }());
  98139. /**
  98140. * Defines an optimization used to reduce the size of render target textures
  98141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98142. */
  98143. var TextureOptimization = /** @class */ (function (_super) {
  98144. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  98145. /**
  98146. * Creates the TextureOptimization object
  98147. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  98148. * @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
  98149. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  98150. */
  98151. function TextureOptimization(
  98152. /**
  98153. * Defines the priority of this optimization (0 by default which means first in the list)
  98154. */
  98155. priority,
  98156. /**
  98157. * 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
  98158. */
  98159. maximumSize,
  98160. /**
  98161. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  98162. */
  98163. step) {
  98164. if (priority === void 0) { priority = 0; }
  98165. if (maximumSize === void 0) { maximumSize = 1024; }
  98166. if (step === void 0) { step = 0.5; }
  98167. var _this = _super.call(this, priority) || this;
  98168. _this.priority = priority;
  98169. _this.maximumSize = maximumSize;
  98170. _this.step = step;
  98171. return _this;
  98172. }
  98173. /**
  98174. * Gets a string describing the action executed by the current optimization
  98175. * @returns description string
  98176. */
  98177. TextureOptimization.prototype.getDescription = function () {
  98178. return "Reducing render target texture size to " + this.maximumSize;
  98179. };
  98180. /**
  98181. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98182. * @param scene defines the current scene where to apply this optimization
  98183. * @param optimizer defines the current optimizer
  98184. * @returns true if everything that can be done was applied
  98185. */
  98186. TextureOptimization.prototype.apply = function (scene, optimizer) {
  98187. var allDone = true;
  98188. for (var index = 0; index < scene.textures.length; index++) {
  98189. var texture = scene.textures[index];
  98190. if (!texture.canRescale || texture.getContext) {
  98191. continue;
  98192. }
  98193. var currentSize = texture.getSize();
  98194. var maxDimension = Math.max(currentSize.width, currentSize.height);
  98195. if (maxDimension > this.maximumSize) {
  98196. texture.scale(this.step);
  98197. allDone = false;
  98198. }
  98199. }
  98200. return allDone;
  98201. };
  98202. return TextureOptimization;
  98203. }(SceneOptimization));
  98204. /**
  98205. * Defines an optimization used to increase or decrease the rendering resolution
  98206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98207. */
  98208. var HardwareScalingOptimization = /** @class */ (function (_super) {
  98209. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  98210. /**
  98211. * Creates the HardwareScalingOptimization object
  98212. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  98213. * @param maximumScale defines the maximum scale to use (2 by default)
  98214. * @param step defines the step to use between two passes (0.5 by default)
  98215. */
  98216. function HardwareScalingOptimization(
  98217. /**
  98218. * Defines the priority of this optimization (0 by default which means first in the list)
  98219. */
  98220. priority,
  98221. /**
  98222. * Defines the maximum scale to use (2 by default)
  98223. */
  98224. maximumScale,
  98225. /**
  98226. * Defines the step to use between two passes (0.5 by default)
  98227. */
  98228. step) {
  98229. if (priority === void 0) { priority = 0; }
  98230. if (maximumScale === void 0) { maximumScale = 2; }
  98231. if (step === void 0) { step = 0.25; }
  98232. var _this = _super.call(this, priority) || this;
  98233. _this.priority = priority;
  98234. _this.maximumScale = maximumScale;
  98235. _this.step = step;
  98236. _this._currentScale = -1;
  98237. _this._directionOffset = 1;
  98238. return _this;
  98239. }
  98240. /**
  98241. * Gets a string describing the action executed by the current optimization
  98242. * @return description string
  98243. */
  98244. HardwareScalingOptimization.prototype.getDescription = function () {
  98245. return "Setting hardware scaling level to " + this._currentScale;
  98246. };
  98247. /**
  98248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98249. * @param scene defines the current scene where to apply this optimization
  98250. * @param optimizer defines the current optimizer
  98251. * @returns true if everything that can be done was applied
  98252. */
  98253. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  98254. if (this._currentScale === -1) {
  98255. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  98256. if (this._currentScale > this.maximumScale) {
  98257. this._directionOffset = -1;
  98258. }
  98259. }
  98260. this._currentScale += this._directionOffset * this.step;
  98261. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  98262. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  98263. };
  98264. return HardwareScalingOptimization;
  98265. }(SceneOptimization));
  98266. /**
  98267. * Defines an optimization used to remove shadows
  98268. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98269. */
  98270. var ShadowsOptimization = /** @class */ (function (_super) {
  98271. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  98272. function ShadowsOptimization() {
  98273. return _super !== null && _super.apply(this, arguments) || this;
  98274. }
  98275. /**
  98276. * Gets a string describing the action executed by the current optimization
  98277. * @return description string
  98278. */
  98279. ShadowsOptimization.prototype.getDescription = function () {
  98280. return "Turning shadows on/off";
  98281. };
  98282. /**
  98283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98284. * @param scene defines the current scene where to apply this optimization
  98285. * @param optimizer defines the current optimizer
  98286. * @returns true if everything that can be done was applied
  98287. */
  98288. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  98289. scene.shadowsEnabled = optimizer.isInImprovementMode;
  98290. return true;
  98291. };
  98292. return ShadowsOptimization;
  98293. }(SceneOptimization));
  98294. /**
  98295. * Defines an optimization used to turn post-processes off
  98296. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98297. */
  98298. var PostProcessesOptimization = /** @class */ (function (_super) {
  98299. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  98300. function PostProcessesOptimization() {
  98301. return _super !== null && _super.apply(this, arguments) || this;
  98302. }
  98303. /**
  98304. * Gets a string describing the action executed by the current optimization
  98305. * @return description string
  98306. */
  98307. PostProcessesOptimization.prototype.getDescription = function () {
  98308. return "Turning post-processes on/off";
  98309. };
  98310. /**
  98311. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98312. * @param scene defines the current scene where to apply this optimization
  98313. * @param optimizer defines the current optimizer
  98314. * @returns true if everything that can be done was applied
  98315. */
  98316. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  98317. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  98318. return true;
  98319. };
  98320. return PostProcessesOptimization;
  98321. }(SceneOptimization));
  98322. /**
  98323. * Defines an optimization used to turn lens flares off
  98324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98325. */
  98326. var LensFlaresOptimization = /** @class */ (function (_super) {
  98327. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  98328. function LensFlaresOptimization() {
  98329. return _super !== null && _super.apply(this, arguments) || this;
  98330. }
  98331. /**
  98332. * Gets a string describing the action executed by the current optimization
  98333. * @return description string
  98334. */
  98335. LensFlaresOptimization.prototype.getDescription = function () {
  98336. return "Turning lens flares on/off";
  98337. };
  98338. /**
  98339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98340. * @param scene defines the current scene where to apply this optimization
  98341. * @param optimizer defines the current optimizer
  98342. * @returns true if everything that can be done was applied
  98343. */
  98344. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  98345. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  98346. return true;
  98347. };
  98348. return LensFlaresOptimization;
  98349. }(SceneOptimization));
  98350. /**
  98351. * Defines an optimization based on user defined callback.
  98352. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98353. */
  98354. var CustomOptimization = /** @class */ (function (_super) {
  98355. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  98356. function CustomOptimization() {
  98357. return _super !== null && _super.apply(this, arguments) || this;
  98358. }
  98359. /**
  98360. * Gets a string describing the action executed by the current optimization
  98361. * @returns description string
  98362. */
  98363. CustomOptimization.prototype.getDescription = function () {
  98364. if (this.onGetDescription) {
  98365. return this.onGetDescription();
  98366. }
  98367. return "Running user defined callback";
  98368. };
  98369. /**
  98370. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98371. * @param scene defines the current scene where to apply this optimization
  98372. * @param optimizer defines the current optimizer
  98373. * @returns true if everything that can be done was applied
  98374. */
  98375. CustomOptimization.prototype.apply = function (scene, optimizer) {
  98376. if (this.onApply) {
  98377. return this.onApply(scene, optimizer);
  98378. }
  98379. return true;
  98380. };
  98381. return CustomOptimization;
  98382. }(SceneOptimization));
  98383. /**
  98384. * Defines an optimization used to turn particles off
  98385. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98386. */
  98387. var ParticlesOptimization = /** @class */ (function (_super) {
  98388. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  98389. function ParticlesOptimization() {
  98390. return _super !== null && _super.apply(this, arguments) || this;
  98391. }
  98392. /**
  98393. * Gets a string describing the action executed by the current optimization
  98394. * @return description string
  98395. */
  98396. ParticlesOptimization.prototype.getDescription = function () {
  98397. return "Turning particles on/off";
  98398. };
  98399. /**
  98400. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98401. * @param scene defines the current scene where to apply this optimization
  98402. * @param optimizer defines the current optimizer
  98403. * @returns true if everything that can be done was applied
  98404. */
  98405. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  98406. scene.particlesEnabled = optimizer.isInImprovementMode;
  98407. return true;
  98408. };
  98409. return ParticlesOptimization;
  98410. }(SceneOptimization));
  98411. /**
  98412. * Defines an optimization used to turn render targets off
  98413. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98414. */
  98415. var RenderTargetsOptimization = /** @class */ (function (_super) {
  98416. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  98417. function RenderTargetsOptimization() {
  98418. return _super !== null && _super.apply(this, arguments) || this;
  98419. }
  98420. /**
  98421. * Gets a string describing the action executed by the current optimization
  98422. * @return description string
  98423. */
  98424. RenderTargetsOptimization.prototype.getDescription = function () {
  98425. return "Turning render targets off";
  98426. };
  98427. /**
  98428. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98429. * @param scene defines the current scene where to apply this optimization
  98430. * @param optimizer defines the current optimizer
  98431. * @returns true if everything that can be done was applied
  98432. */
  98433. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  98434. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  98435. return true;
  98436. };
  98437. return RenderTargetsOptimization;
  98438. }(SceneOptimization));
  98439. /**
  98440. * Defines an optimization used to merge meshes with compatible materials
  98441. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98442. */
  98443. var MergeMeshesOptimization = /** @class */ (function (_super) {
  98444. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  98445. function MergeMeshesOptimization() {
  98446. var _this = _super !== null && _super.apply(this, arguments) || this;
  98447. _this._canBeMerged = function (abstractMesh) {
  98448. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  98449. return false;
  98450. }
  98451. var mesh = abstractMesh;
  98452. if (mesh.isDisposed()) {
  98453. return false;
  98454. }
  98455. if (!mesh.isVisible || !mesh.isEnabled()) {
  98456. return false;
  98457. }
  98458. if (mesh.instances.length > 0) {
  98459. return false;
  98460. }
  98461. if (mesh.skeleton || mesh.hasLODLevels) {
  98462. return false;
  98463. }
  98464. return true;
  98465. };
  98466. return _this;
  98467. }
  98468. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  98469. /**
  98470. * Gets or sets a boolean which defines if optimization octree has to be updated
  98471. */
  98472. get: function () {
  98473. return MergeMeshesOptimization._UpdateSelectionTree;
  98474. },
  98475. /**
  98476. * Gets or sets a boolean which defines if optimization octree has to be updated
  98477. */
  98478. set: function (value) {
  98479. MergeMeshesOptimization._UpdateSelectionTree = value;
  98480. },
  98481. enumerable: true,
  98482. configurable: true
  98483. });
  98484. /**
  98485. * Gets a string describing the action executed by the current optimization
  98486. * @return description string
  98487. */
  98488. MergeMeshesOptimization.prototype.getDescription = function () {
  98489. return "Merging similar meshes together";
  98490. };
  98491. /**
  98492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98493. * @param scene defines the current scene where to apply this optimization
  98494. * @param optimizer defines the current optimizer
  98495. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  98496. * @returns true if everything that can be done was applied
  98497. */
  98498. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  98499. var globalPool = scene.meshes.slice(0);
  98500. var globalLength = globalPool.length;
  98501. for (var index = 0; index < globalLength; index++) {
  98502. var currentPool = new Array();
  98503. var current = globalPool[index];
  98504. // Checks
  98505. if (!this._canBeMerged(current)) {
  98506. continue;
  98507. }
  98508. currentPool.push(current);
  98509. // Find compatible meshes
  98510. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  98511. var otherMesh = globalPool[subIndex];
  98512. if (!this._canBeMerged(otherMesh)) {
  98513. continue;
  98514. }
  98515. if (otherMesh.material !== current.material) {
  98516. continue;
  98517. }
  98518. if (otherMesh.checkCollisions !== current.checkCollisions) {
  98519. continue;
  98520. }
  98521. currentPool.push(otherMesh);
  98522. globalLength--;
  98523. globalPool.splice(subIndex, 1);
  98524. subIndex--;
  98525. }
  98526. if (currentPool.length < 2) {
  98527. continue;
  98528. }
  98529. // Merge meshes
  98530. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  98531. }
  98532. // Call the octree system optimization if it is defined.
  98533. var sceneAsAny = scene;
  98534. if (sceneAsAny.createOrUpdateSelectionOctree) {
  98535. if (updateSelectionTree != undefined) {
  98536. if (updateSelectionTree) {
  98537. sceneAsAny.createOrUpdateSelectionOctree();
  98538. }
  98539. }
  98540. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  98541. sceneAsAny.createOrUpdateSelectionOctree();
  98542. }
  98543. }
  98544. return true;
  98545. };
  98546. MergeMeshesOptimization._UpdateSelectionTree = false;
  98547. return MergeMeshesOptimization;
  98548. }(SceneOptimization));
  98549. /**
  98550. * Defines a list of options used by SceneOptimizer
  98551. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98552. */
  98553. var SceneOptimizerOptions = /** @class */ (function () {
  98554. /**
  98555. * Creates a new list of options used by SceneOptimizer
  98556. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  98557. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  98558. */
  98559. function SceneOptimizerOptions(
  98560. /**
  98561. * Defines the target frame rate to reach (60 by default)
  98562. */
  98563. targetFrameRate,
  98564. /**
  98565. * Defines the interval between two checkes (2000ms by default)
  98566. */
  98567. trackerDuration) {
  98568. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  98569. if (trackerDuration === void 0) { trackerDuration = 2000; }
  98570. this.targetFrameRate = targetFrameRate;
  98571. this.trackerDuration = trackerDuration;
  98572. /**
  98573. * Gets the list of optimizations to apply
  98574. */
  98575. this.optimizations = new Array();
  98576. }
  98577. /**
  98578. * Add a new optimization
  98579. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  98580. * @returns the current SceneOptimizerOptions
  98581. */
  98582. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  98583. this.optimizations.push(optimization);
  98584. return this;
  98585. };
  98586. /**
  98587. * Add a new custom optimization
  98588. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  98589. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  98590. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  98591. * @returns the current SceneOptimizerOptions
  98592. */
  98593. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  98594. if (priority === void 0) { priority = 0; }
  98595. var optimization = new CustomOptimization(priority);
  98596. optimization.onApply = onApply;
  98597. optimization.onGetDescription = onGetDescription;
  98598. this.optimizations.push(optimization);
  98599. return this;
  98600. };
  98601. /**
  98602. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  98603. * @param targetFrameRate defines the target frame rate (60 by default)
  98604. * @returns a SceneOptimizerOptions object
  98605. */
  98606. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  98607. var result = new SceneOptimizerOptions(targetFrameRate);
  98608. var priority = 0;
  98609. result.addOptimization(new MergeMeshesOptimization(priority));
  98610. result.addOptimization(new ShadowsOptimization(priority));
  98611. result.addOptimization(new LensFlaresOptimization(priority));
  98612. // Next priority
  98613. priority++;
  98614. result.addOptimization(new PostProcessesOptimization(priority));
  98615. result.addOptimization(new ParticlesOptimization(priority));
  98616. // Next priority
  98617. priority++;
  98618. result.addOptimization(new TextureOptimization(priority, 1024));
  98619. return result;
  98620. };
  98621. /**
  98622. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  98623. * @param targetFrameRate defines the target frame rate (60 by default)
  98624. * @returns a SceneOptimizerOptions object
  98625. */
  98626. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  98627. var result = new SceneOptimizerOptions(targetFrameRate);
  98628. var priority = 0;
  98629. result.addOptimization(new MergeMeshesOptimization(priority));
  98630. result.addOptimization(new ShadowsOptimization(priority));
  98631. result.addOptimization(new LensFlaresOptimization(priority));
  98632. // Next priority
  98633. priority++;
  98634. result.addOptimization(new PostProcessesOptimization(priority));
  98635. result.addOptimization(new ParticlesOptimization(priority));
  98636. // Next priority
  98637. priority++;
  98638. result.addOptimization(new TextureOptimization(priority, 512));
  98639. // Next priority
  98640. priority++;
  98641. result.addOptimization(new RenderTargetsOptimization(priority));
  98642. // Next priority
  98643. priority++;
  98644. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  98645. return result;
  98646. };
  98647. /**
  98648. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  98649. * @param targetFrameRate defines the target frame rate (60 by default)
  98650. * @returns a SceneOptimizerOptions object
  98651. */
  98652. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  98653. var result = new SceneOptimizerOptions(targetFrameRate);
  98654. var priority = 0;
  98655. result.addOptimization(new MergeMeshesOptimization(priority));
  98656. result.addOptimization(new ShadowsOptimization(priority));
  98657. result.addOptimization(new LensFlaresOptimization(priority));
  98658. // Next priority
  98659. priority++;
  98660. result.addOptimization(new PostProcessesOptimization(priority));
  98661. result.addOptimization(new ParticlesOptimization(priority));
  98662. // Next priority
  98663. priority++;
  98664. result.addOptimization(new TextureOptimization(priority, 256));
  98665. // Next priority
  98666. priority++;
  98667. result.addOptimization(new RenderTargetsOptimization(priority));
  98668. // Next priority
  98669. priority++;
  98670. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  98671. return result;
  98672. };
  98673. return SceneOptimizerOptions;
  98674. }());
  98675. /**
  98676. * Class used to run optimizations in order to reach a target frame rate
  98677. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98678. */
  98679. var SceneOptimizer = /** @class */ (function () {
  98680. /**
  98681. * Creates a new SceneOptimizer
  98682. * @param scene defines the scene to work on
  98683. * @param options defines the options to use with the SceneOptimizer
  98684. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  98685. * @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)
  98686. */
  98687. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  98688. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  98689. if (improvementMode === void 0) { improvementMode = false; }
  98690. var _this = this;
  98691. this._isRunning = false;
  98692. this._currentPriorityLevel = 0;
  98693. this._targetFrameRate = 60;
  98694. this._trackerDuration = 2000;
  98695. this._currentFrameRate = 0;
  98696. this._improvementMode = false;
  98697. /**
  98698. * Defines an observable called when the optimizer reaches the target frame rate
  98699. */
  98700. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98701. /**
  98702. * Defines an observable called when the optimizer enables an optimization
  98703. */
  98704. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98705. /**
  98706. * Defines an observable called when the optimizer is not able to reach the target frame rate
  98707. */
  98708. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98709. if (!options) {
  98710. this._options = new SceneOptimizerOptions();
  98711. }
  98712. else {
  98713. this._options = options;
  98714. }
  98715. if (this._options.targetFrameRate) {
  98716. this._targetFrameRate = this._options.targetFrameRate;
  98717. }
  98718. if (this._options.trackerDuration) {
  98719. this._trackerDuration = this._options.trackerDuration;
  98720. }
  98721. if (autoGeneratePriorities) {
  98722. var priority = 0;
  98723. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  98724. var optim = _a[_i];
  98725. optim.priority = priority++;
  98726. }
  98727. }
  98728. this._improvementMode = improvementMode;
  98729. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  98730. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  98731. _this._sceneDisposeObserver = null;
  98732. _this.dispose();
  98733. });
  98734. }
  98735. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  98736. /**
  98737. * Gets a boolean indicating if the optimizer is in improvement mode
  98738. */
  98739. get: function () {
  98740. return this._improvementMode;
  98741. },
  98742. enumerable: true,
  98743. configurable: true
  98744. });
  98745. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  98746. /**
  98747. * Gets the current priority level (0 at start)
  98748. */
  98749. get: function () {
  98750. return this._currentPriorityLevel;
  98751. },
  98752. enumerable: true,
  98753. configurable: true
  98754. });
  98755. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  98756. /**
  98757. * Gets the current frame rate checked by the SceneOptimizer
  98758. */
  98759. get: function () {
  98760. return this._currentFrameRate;
  98761. },
  98762. enumerable: true,
  98763. configurable: true
  98764. });
  98765. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  98766. /**
  98767. * Gets or sets the current target frame rate (60 by default)
  98768. */
  98769. get: function () {
  98770. return this._targetFrameRate;
  98771. },
  98772. /**
  98773. * Gets or sets the current target frame rate (60 by default)
  98774. */
  98775. set: function (value) {
  98776. this._targetFrameRate = value;
  98777. },
  98778. enumerable: true,
  98779. configurable: true
  98780. });
  98781. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  98782. /**
  98783. * Gets or sets the current interval between two checks (every 2000ms by default)
  98784. */
  98785. get: function () {
  98786. return this._trackerDuration;
  98787. },
  98788. /**
  98789. * Gets or sets the current interval between two checks (every 2000ms by default)
  98790. */
  98791. set: function (value) {
  98792. this._trackerDuration = value;
  98793. },
  98794. enumerable: true,
  98795. configurable: true
  98796. });
  98797. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  98798. /**
  98799. * Gets the list of active optimizations
  98800. */
  98801. get: function () {
  98802. return this._options.optimizations;
  98803. },
  98804. enumerable: true,
  98805. configurable: true
  98806. });
  98807. /**
  98808. * Stops the current optimizer
  98809. */
  98810. SceneOptimizer.prototype.stop = function () {
  98811. this._isRunning = false;
  98812. };
  98813. /**
  98814. * Reset the optimizer to initial step (current priority level = 0)
  98815. */
  98816. SceneOptimizer.prototype.reset = function () {
  98817. this._currentPriorityLevel = 0;
  98818. };
  98819. /**
  98820. * Start the optimizer. By default it will try to reach a specific framerate
  98821. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  98822. */
  98823. SceneOptimizer.prototype.start = function () {
  98824. var _this = this;
  98825. if (this._isRunning) {
  98826. return;
  98827. }
  98828. this._isRunning = true;
  98829. // Let's wait for the scene to be ready before running our check
  98830. this._scene.executeWhenReady(function () {
  98831. setTimeout(function () {
  98832. _this._checkCurrentState();
  98833. }, _this._trackerDuration);
  98834. });
  98835. };
  98836. SceneOptimizer.prototype._checkCurrentState = function () {
  98837. var _this = this;
  98838. if (!this._isRunning) {
  98839. return;
  98840. }
  98841. var scene = this._scene;
  98842. var options = this._options;
  98843. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  98844. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  98845. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  98846. this._isRunning = false;
  98847. this.onSuccessObservable.notifyObservers(this);
  98848. return;
  98849. }
  98850. // Apply current level of optimizations
  98851. var allDone = true;
  98852. var noOptimizationApplied = true;
  98853. for (var index = 0; index < options.optimizations.length; index++) {
  98854. var optimization = options.optimizations[index];
  98855. if (optimization.priority === this._currentPriorityLevel) {
  98856. noOptimizationApplied = false;
  98857. allDone = allDone && optimization.apply(scene, this);
  98858. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  98859. }
  98860. }
  98861. // If no optimization was applied, this is a failure :(
  98862. if (noOptimizationApplied) {
  98863. this._isRunning = false;
  98864. this.onFailureObservable.notifyObservers(this);
  98865. return;
  98866. }
  98867. // If all optimizations were done, move to next level
  98868. if (allDone) {
  98869. this._currentPriorityLevel++;
  98870. }
  98871. // Let's the system running for a specific amount of time before checking FPS
  98872. scene.executeWhenReady(function () {
  98873. setTimeout(function () {
  98874. _this._checkCurrentState();
  98875. }, _this._trackerDuration);
  98876. });
  98877. };
  98878. /**
  98879. * Release all resources
  98880. */
  98881. SceneOptimizer.prototype.dispose = function () {
  98882. this.stop();
  98883. this.onSuccessObservable.clear();
  98884. this.onFailureObservable.clear();
  98885. this.onNewOptimizationAppliedObservable.clear();
  98886. if (this._sceneDisposeObserver) {
  98887. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  98888. }
  98889. };
  98890. /**
  98891. * Helper function to create a SceneOptimizer with one single line of code
  98892. * @param scene defines the scene to work on
  98893. * @param options defines the options to use with the SceneOptimizer
  98894. * @param onSuccess defines a callback to call on success
  98895. * @param onFailure defines a callback to call on failure
  98896. * @returns the new SceneOptimizer object
  98897. */
  98898. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  98899. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  98900. if (onSuccess) {
  98901. optimizer.onSuccessObservable.add(function () {
  98902. onSuccess();
  98903. });
  98904. }
  98905. if (onFailure) {
  98906. optimizer.onFailureObservable.add(function () {
  98907. onFailure();
  98908. });
  98909. }
  98910. optimizer.start();
  98911. return optimizer;
  98912. };
  98913. return SceneOptimizer;
  98914. }());
  98915. /***/ }),
  98916. /***/ "./Misc/sceneSerializer.ts":
  98917. /*!*********************************!*\
  98918. !*** ./Misc/sceneSerializer.ts ***!
  98919. \*********************************/
  98920. /*! exports provided: SceneSerializer */
  98921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98922. "use strict";
  98923. __webpack_require__.r(__webpack_exports__);
  98924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  98925. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  98926. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98927. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  98928. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  98929. var serializedGeometries = [];
  98930. var serializeGeometry = function (geometry, serializationGeometries) {
  98931. if (serializedGeometries[geometry.id]) {
  98932. return;
  98933. }
  98934. if (geometry.doNotSerialize) {
  98935. return;
  98936. }
  98937. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  98938. serializedGeometries[geometry.id] = true;
  98939. };
  98940. var serializeMesh = function (mesh, serializationScene) {
  98941. var serializationObject = {};
  98942. // Geometry
  98943. var geometry = mesh._geometry;
  98944. if (geometry) {
  98945. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  98946. // 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
  98947. serializeGeometry(geometry, serializationScene.geometries);
  98948. }
  98949. }
  98950. // Custom
  98951. if (mesh.serialize) {
  98952. mesh.serialize(serializationObject);
  98953. }
  98954. return serializationObject;
  98955. };
  98956. var finalizeSingleMesh = function (mesh, serializationObject) {
  98957. //only works if the mesh is already loaded
  98958. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  98959. //serialize material
  98960. if (mesh.material) {
  98961. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  98962. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  98963. serializationObject.materials = serializationObject.materials || [];
  98964. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  98965. serializationObject.multiMaterials.push(mesh.material.serialize());
  98966. var _loop_1 = function (submaterial) {
  98967. if (submaterial) {
  98968. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  98969. serializationObject.materials.push(submaterial.serialize());
  98970. }
  98971. }
  98972. };
  98973. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  98974. var submaterial = _a[_i];
  98975. _loop_1(submaterial);
  98976. }
  98977. }
  98978. }
  98979. else {
  98980. serializationObject.materials = serializationObject.materials || [];
  98981. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  98982. serializationObject.materials.push(mesh.material.serialize());
  98983. }
  98984. }
  98985. }
  98986. //serialize geometry
  98987. var geometry = mesh._geometry;
  98988. if (geometry) {
  98989. if (!serializationObject.geometries) {
  98990. serializationObject.geometries = {};
  98991. serializationObject.geometries.boxes = [];
  98992. serializationObject.geometries.spheres = [];
  98993. serializationObject.geometries.cylinders = [];
  98994. serializationObject.geometries.toruses = [];
  98995. serializationObject.geometries.grounds = [];
  98996. serializationObject.geometries.planes = [];
  98997. serializationObject.geometries.torusKnots = [];
  98998. serializationObject.geometries.vertexData = [];
  98999. }
  99000. serializeGeometry(geometry, serializationObject.geometries);
  99001. }
  99002. // Skeletons
  99003. if (mesh.skeleton) {
  99004. serializationObject.skeletons = serializationObject.skeletons || [];
  99005. serializationObject.skeletons.push(mesh.skeleton.serialize());
  99006. }
  99007. //serialize the actual mesh
  99008. serializationObject.meshes = serializationObject.meshes || [];
  99009. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  99010. }
  99011. };
  99012. /**
  99013. * Class used to serialize a scene into a string
  99014. */
  99015. var SceneSerializer = /** @class */ (function () {
  99016. function SceneSerializer() {
  99017. }
  99018. /**
  99019. * Clear cache used by a previous serialization
  99020. */
  99021. SceneSerializer.ClearCache = function () {
  99022. serializedGeometries = [];
  99023. };
  99024. /**
  99025. * Serialize a scene into a JSON compatible object
  99026. * @param scene defines the scene to serialize
  99027. * @returns a JSON compatible object
  99028. */
  99029. SceneSerializer.Serialize = function (scene) {
  99030. var serializationObject = {};
  99031. SceneSerializer.ClearCache();
  99032. // Scene
  99033. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  99034. serializationObject.autoClear = scene.autoClear;
  99035. serializationObject.clearColor = scene.clearColor.asArray();
  99036. serializationObject.ambientColor = scene.ambientColor.asArray();
  99037. serializationObject.gravity = scene.gravity.asArray();
  99038. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  99039. // Fog
  99040. if (scene.fogMode && scene.fogMode !== 0) {
  99041. serializationObject.fogMode = scene.fogMode;
  99042. serializationObject.fogColor = scene.fogColor.asArray();
  99043. serializationObject.fogStart = scene.fogStart;
  99044. serializationObject.fogEnd = scene.fogEnd;
  99045. serializationObject.fogDensity = scene.fogDensity;
  99046. }
  99047. //Physics
  99048. if (scene.isPhysicsEnabled()) {
  99049. var physicEngine = scene.getPhysicsEngine();
  99050. if (physicEngine) {
  99051. serializationObject.physicsEnabled = true;
  99052. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  99053. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  99054. }
  99055. }
  99056. // Metadata
  99057. if (scene.metadata) {
  99058. serializationObject.metadata = scene.metadata;
  99059. }
  99060. // Morph targets
  99061. serializationObject.morphTargetManagers = [];
  99062. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  99063. var abstractMesh = _a[_i];
  99064. var manager = abstractMesh.morphTargetManager;
  99065. if (manager) {
  99066. serializationObject.morphTargetManagers.push(manager.serialize());
  99067. }
  99068. }
  99069. // Lights
  99070. serializationObject.lights = [];
  99071. var index;
  99072. var light;
  99073. for (index = 0; index < scene.lights.length; index++) {
  99074. light = scene.lights[index];
  99075. if (!light.doNotSerialize) {
  99076. serializationObject.lights.push(light.serialize());
  99077. }
  99078. }
  99079. // Cameras
  99080. serializationObject.cameras = [];
  99081. for (index = 0; index < scene.cameras.length; index++) {
  99082. var camera = scene.cameras[index];
  99083. if (!camera.doNotSerialize) {
  99084. serializationObject.cameras.push(camera.serialize());
  99085. }
  99086. }
  99087. if (scene.activeCamera) {
  99088. serializationObject.activeCameraID = scene.activeCamera.id;
  99089. }
  99090. // Animations
  99091. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  99092. // Reflection probes
  99093. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  99094. serializationObject.reflectionProbes = [];
  99095. for (index = 0; index < scene.reflectionProbes.length; index++) {
  99096. var reflectionProbe = scene.reflectionProbes[index];
  99097. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  99098. }
  99099. }
  99100. // Materials
  99101. serializationObject.materials = [];
  99102. serializationObject.multiMaterials = [];
  99103. var material;
  99104. for (index = 0; index < scene.materials.length; index++) {
  99105. material = scene.materials[index];
  99106. if (!material.doNotSerialize) {
  99107. serializationObject.materials.push(material.serialize());
  99108. }
  99109. }
  99110. // MultiMaterials
  99111. serializationObject.multiMaterials = [];
  99112. for (index = 0; index < scene.multiMaterials.length; index++) {
  99113. var multiMaterial = scene.multiMaterials[index];
  99114. serializationObject.multiMaterials.push(multiMaterial.serialize());
  99115. }
  99116. // Environment texture
  99117. if (scene.environmentTexture) {
  99118. serializationObject.environmentTexture = scene.environmentTexture.name;
  99119. }
  99120. // Skeletons
  99121. serializationObject.skeletons = [];
  99122. for (index = 0; index < scene.skeletons.length; index++) {
  99123. var skeleton = scene.skeletons[index];
  99124. if (!skeleton.doNotSerialize) {
  99125. serializationObject.skeletons.push(skeleton.serialize());
  99126. }
  99127. }
  99128. // Transform nodes
  99129. serializationObject.transformNodes = [];
  99130. for (index = 0; index < scene.transformNodes.length; index++) {
  99131. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  99132. }
  99133. // Geometries
  99134. serializationObject.geometries = {};
  99135. serializationObject.geometries.boxes = [];
  99136. serializationObject.geometries.spheres = [];
  99137. serializationObject.geometries.cylinders = [];
  99138. serializationObject.geometries.toruses = [];
  99139. serializationObject.geometries.grounds = [];
  99140. serializationObject.geometries.planes = [];
  99141. serializationObject.geometries.torusKnots = [];
  99142. serializationObject.geometries.vertexData = [];
  99143. serializedGeometries = [];
  99144. var geometries = scene.getGeometries();
  99145. for (index = 0; index < geometries.length; index++) {
  99146. var geometry = geometries[index];
  99147. if (geometry.isReady()) {
  99148. serializeGeometry(geometry, serializationObject.geometries);
  99149. }
  99150. }
  99151. // Meshes
  99152. serializationObject.meshes = [];
  99153. for (index = 0; index < scene.meshes.length; index++) {
  99154. var abstractMesh = scene.meshes[index];
  99155. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  99156. var mesh = abstractMesh;
  99157. if (!mesh.doNotSerialize) {
  99158. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  99159. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  99160. }
  99161. }
  99162. }
  99163. }
  99164. // Particles Systems
  99165. serializationObject.particleSystems = [];
  99166. for (index = 0; index < scene.particleSystems.length; index++) {
  99167. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  99168. }
  99169. // Action Manager
  99170. if (scene.actionManager) {
  99171. serializationObject.actions = scene.actionManager.serialize("scene");
  99172. }
  99173. // Components
  99174. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  99175. var component = _c[_b];
  99176. component.serialize(serializationObject);
  99177. }
  99178. return serializationObject;
  99179. };
  99180. /**
  99181. * Serialize a mesh into a JSON compatible object
  99182. * @param toSerialize defines the mesh to serialize
  99183. * @param withParents defines if parents must be serialized as well
  99184. * @param withChildren defines if children must be serialized as well
  99185. * @returns a JSON compatible object
  99186. */
  99187. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  99188. if (withParents === void 0) { withParents = false; }
  99189. if (withChildren === void 0) { withChildren = false; }
  99190. var serializationObject = {};
  99191. SceneSerializer.ClearCache();
  99192. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  99193. if (withParents || withChildren) {
  99194. //deliberate for loop! not for each, appended should be processed as well.
  99195. for (var i = 0; i < toSerialize.length; ++i) {
  99196. if (withChildren) {
  99197. toSerialize[i].getDescendants().forEach(function (node) {
  99198. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  99199. toSerialize.push(node);
  99200. }
  99201. });
  99202. }
  99203. //make sure the array doesn't contain the object already
  99204. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  99205. toSerialize.push(toSerialize[i].parent);
  99206. }
  99207. }
  99208. }
  99209. toSerialize.forEach(function (mesh) {
  99210. finalizeSingleMesh(mesh, serializationObject);
  99211. });
  99212. return serializationObject;
  99213. };
  99214. return SceneSerializer;
  99215. }());
  99216. /***/ }),
  99217. /***/ "./Misc/screenshotTools.ts":
  99218. /*!*********************************!*\
  99219. !*** ./Misc/screenshotTools.ts ***!
  99220. \*********************************/
  99221. /*! exports provided: ScreenshotTools */
  99222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99223. "use strict";
  99224. __webpack_require__.r(__webpack_exports__);
  99225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  99226. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  99227. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  99228. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  99229. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  99230. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  99231. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99232. /**
  99233. * Class containing a set of static utilities functions for screenshots
  99234. */
  99235. var ScreenshotTools = /** @class */ (function () {
  99236. function ScreenshotTools() {
  99237. }
  99238. /**
  99239. * Captures a screenshot of the current rendering
  99240. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99241. * @param engine defines the rendering engine
  99242. * @param camera defines the source camera
  99243. * @param size This parameter can be set to a single number or to an object with the
  99244. * following (optional) properties: precision, width, height. If a single number is passed,
  99245. * it will be used for both width and height. If an object is passed, the screenshot size
  99246. * will be derived from the parameters. The precision property is a multiplier allowing
  99247. * rendering at a higher or lower resolution
  99248. * @param successCallback defines the callback receives a single parameter which contains the
  99249. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99250. * src parameter of an <img> to display it
  99251. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99252. * Check your browser for supported MIME types
  99253. */
  99254. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  99255. if (mimeType === void 0) { mimeType = "image/png"; }
  99256. var width;
  99257. var height;
  99258. // If a precision value is specified
  99259. if (size.precision) {
  99260. width = Math.round(engine.getRenderWidth() * size.precision);
  99261. height = Math.round(width / engine.getAspectRatio(camera));
  99262. }
  99263. else if (size.width && size.height) {
  99264. width = size.width;
  99265. height = size.height;
  99266. }
  99267. //If passing only width, computing height to keep display canvas ratio.
  99268. else if (size.width && !size.height) {
  99269. width = size.width;
  99270. height = Math.round(width / engine.getAspectRatio(camera));
  99271. }
  99272. //If passing only height, computing width to keep display canvas ratio.
  99273. else if (size.height && !size.width) {
  99274. height = size.height;
  99275. width = Math.round(height * engine.getAspectRatio(camera));
  99276. }
  99277. //Assuming here that "size" parameter is a number
  99278. else if (!isNaN(size)) {
  99279. height = size;
  99280. width = size;
  99281. }
  99282. else {
  99283. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  99284. return;
  99285. }
  99286. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  99287. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  99288. }
  99289. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  99290. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  99291. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  99292. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  99293. var newWidth = width;
  99294. var newHeight = newWidth / ratio;
  99295. if (newHeight > height) {
  99296. newHeight = height;
  99297. newWidth = newHeight * ratio;
  99298. }
  99299. var offsetX = Math.max(0, width - newWidth) / 2;
  99300. var offsetY = Math.max(0, height - newHeight) / 2;
  99301. var renderingCanvas = engine.getRenderingCanvas();
  99302. if (renderContext && renderingCanvas) {
  99303. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  99304. }
  99305. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  99306. };
  99307. /**
  99308. * Generates an image screenshot from the specified camera.
  99309. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99310. * @param engine The engine to use for rendering
  99311. * @param camera The camera to use for rendering
  99312. * @param size This parameter can be set to a single number or to an object with the
  99313. * following (optional) properties: precision, width, height. If a single number is passed,
  99314. * it will be used for both width and height. If an object is passed, the screenshot size
  99315. * will be derived from the parameters. The precision property is a multiplier allowing
  99316. * rendering at a higher or lower resolution
  99317. * @param successCallback The callback receives a single parameter which contains the
  99318. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99319. * src parameter of an <img> to display it
  99320. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99321. * Check your browser for supported MIME types
  99322. * @param samples Texture samples (default: 1)
  99323. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99324. * @param fileName A name for for the downloaded file.
  99325. */
  99326. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  99327. if (mimeType === void 0) { mimeType = "image/png"; }
  99328. if (samples === void 0) { samples = 1; }
  99329. if (antialiasing === void 0) { antialiasing = false; }
  99330. var width;
  99331. var height;
  99332. //If a precision value is specified
  99333. if (size.precision) {
  99334. width = Math.round(engine.getRenderWidth() * size.precision);
  99335. height = Math.round(width / engine.getAspectRatio(camera));
  99336. size = { width: width, height: height };
  99337. }
  99338. else if (size.width && size.height) {
  99339. width = size.width;
  99340. height = size.height;
  99341. }
  99342. //If passing only width, computing height to keep display canvas ratio.
  99343. else if (size.width && !size.height) {
  99344. width = size.width;
  99345. height = Math.round(width / engine.getAspectRatio(camera));
  99346. size = { width: width, height: height };
  99347. }
  99348. //If passing only height, computing width to keep display canvas ratio.
  99349. else if (size.height && !size.width) {
  99350. height = size.height;
  99351. width = Math.round(height * engine.getAspectRatio(camera));
  99352. size = { width: width, height: height };
  99353. }
  99354. //Assuming here that "size" parameter is a number
  99355. else if (!isNaN(size)) {
  99356. height = size;
  99357. width = size;
  99358. }
  99359. else {
  99360. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  99361. return;
  99362. }
  99363. var scene = camera.getScene();
  99364. var previousCamera = null;
  99365. if (scene.activeCamera !== camera) {
  99366. previousCamera = scene.activeCamera;
  99367. scene.activeCamera = camera;
  99368. }
  99369. var renderCanvas = engine.getRenderingCanvas();
  99370. if (!renderCanvas) {
  99371. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  99372. return;
  99373. }
  99374. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  99375. engine.setSize(width, height);
  99376. scene.render();
  99377. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  99378. 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);
  99379. texture.renderList = null;
  99380. texture.samples = samples;
  99381. if (antialiasing) {
  99382. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  99383. }
  99384. texture.onAfterRenderObservable.add(function () {
  99385. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  99386. });
  99387. scene.incrementRenderId();
  99388. scene.resetCachedMaterial();
  99389. texture.render(true);
  99390. texture.dispose();
  99391. if (previousCamera) {
  99392. scene.activeCamera = previousCamera;
  99393. }
  99394. engine.setSize(originalSize.width, originalSize.height);
  99395. camera.getProjectionMatrix(true); // Force cache refresh;
  99396. };
  99397. return ScreenshotTools;
  99398. }());
  99399. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  99400. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  99401. /***/ }),
  99402. /***/ "./Misc/smartArray.ts":
  99403. /*!****************************!*\
  99404. !*** ./Misc/smartArray.ts ***!
  99405. \****************************/
  99406. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  99407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99408. "use strict";
  99409. __webpack_require__.r(__webpack_exports__);
  99410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  99411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  99412. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99413. /**
  99414. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  99415. */
  99416. var SmartArray = /** @class */ (function () {
  99417. /**
  99418. * Instantiates a Smart Array.
  99419. * @param capacity defines the default capacity of the array.
  99420. */
  99421. function SmartArray(capacity) {
  99422. /**
  99423. * The active length of the array.
  99424. */
  99425. this.length = 0;
  99426. this.data = new Array(capacity);
  99427. this._id = SmartArray._GlobalId++;
  99428. }
  99429. /**
  99430. * Pushes a value at the end of the active data.
  99431. * @param value defines the object to push in the array.
  99432. */
  99433. SmartArray.prototype.push = function (value) {
  99434. this.data[this.length++] = value;
  99435. if (this.length > this.data.length) {
  99436. this.data.length *= 2;
  99437. }
  99438. };
  99439. /**
  99440. * Iterates over the active data and apply the lambda to them.
  99441. * @param func defines the action to apply on each value.
  99442. */
  99443. SmartArray.prototype.forEach = function (func) {
  99444. for (var index = 0; index < this.length; index++) {
  99445. func(this.data[index]);
  99446. }
  99447. };
  99448. /**
  99449. * Sorts the full sets of data.
  99450. * @param compareFn defines the comparison function to apply.
  99451. */
  99452. SmartArray.prototype.sort = function (compareFn) {
  99453. this.data.sort(compareFn);
  99454. };
  99455. /**
  99456. * Resets the active data to an empty array.
  99457. */
  99458. SmartArray.prototype.reset = function () {
  99459. this.length = 0;
  99460. };
  99461. /**
  99462. * Releases all the data from the array as well as the array.
  99463. */
  99464. SmartArray.prototype.dispose = function () {
  99465. this.reset();
  99466. if (this.data) {
  99467. this.data.length = 0;
  99468. this.data = [];
  99469. }
  99470. };
  99471. /**
  99472. * Concats the active data with a given array.
  99473. * @param array defines the data to concatenate with.
  99474. */
  99475. SmartArray.prototype.concat = function (array) {
  99476. if (array.length === 0) {
  99477. return;
  99478. }
  99479. if (this.length + array.length > this.data.length) {
  99480. this.data.length = (this.length + array.length) * 2;
  99481. }
  99482. for (var index = 0; index < array.length; index++) {
  99483. this.data[this.length++] = (array.data || array)[index];
  99484. }
  99485. };
  99486. /**
  99487. * Returns the position of a value in the active data.
  99488. * @param value defines the value to find the index for
  99489. * @returns the index if found in the active data otherwise -1
  99490. */
  99491. SmartArray.prototype.indexOf = function (value) {
  99492. var position = this.data.indexOf(value);
  99493. if (position >= this.length) {
  99494. return -1;
  99495. }
  99496. return position;
  99497. };
  99498. /**
  99499. * Returns whether an element is part of the active data.
  99500. * @param value defines the value to look for
  99501. * @returns true if found in the active data otherwise false
  99502. */
  99503. SmartArray.prototype.contains = function (value) {
  99504. return this.indexOf(value) !== -1;
  99505. };
  99506. // Statics
  99507. SmartArray._GlobalId = 0;
  99508. return SmartArray;
  99509. }());
  99510. /**
  99511. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  99512. * The data in this array can only be present once
  99513. */
  99514. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  99515. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  99516. function SmartArrayNoDuplicate() {
  99517. var _this = _super !== null && _super.apply(this, arguments) || this;
  99518. _this._duplicateId = 0;
  99519. return _this;
  99520. }
  99521. /**
  99522. * Pushes a value at the end of the active data.
  99523. * THIS DOES NOT PREVENT DUPPLICATE DATA
  99524. * @param value defines the object to push in the array.
  99525. */
  99526. SmartArrayNoDuplicate.prototype.push = function (value) {
  99527. _super.prototype.push.call(this, value);
  99528. if (!value.__smartArrayFlags) {
  99529. value.__smartArrayFlags = {};
  99530. }
  99531. value.__smartArrayFlags[this._id] = this._duplicateId;
  99532. };
  99533. /**
  99534. * Pushes a value at the end of the active data.
  99535. * If the data is already present, it won t be added again
  99536. * @param value defines the object to push in the array.
  99537. * @returns true if added false if it was already present
  99538. */
  99539. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  99540. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  99541. return false;
  99542. }
  99543. this.push(value);
  99544. return true;
  99545. };
  99546. /**
  99547. * Resets the active data to an empty array.
  99548. */
  99549. SmartArrayNoDuplicate.prototype.reset = function () {
  99550. _super.prototype.reset.call(this);
  99551. this._duplicateId++;
  99552. };
  99553. /**
  99554. * Concats the active data with a given array.
  99555. * This ensures no dupplicate will be present in the result.
  99556. * @param array defines the data to concatenate with.
  99557. */
  99558. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  99559. if (array.length === 0) {
  99560. return;
  99561. }
  99562. if (this.length + array.length > this.data.length) {
  99563. this.data.length = (this.length + array.length) * 2;
  99564. }
  99565. for (var index = 0; index < array.length; index++) {
  99566. var item = (array.data || array)[index];
  99567. this.pushNoDuplicate(item);
  99568. }
  99569. };
  99570. return SmartArrayNoDuplicate;
  99571. }(SmartArray));
  99572. /***/ }),
  99573. /***/ "./Misc/stringDictionary.ts":
  99574. /*!**********************************!*\
  99575. !*** ./Misc/stringDictionary.ts ***!
  99576. \**********************************/
  99577. /*! exports provided: StringDictionary */
  99578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99579. "use strict";
  99580. __webpack_require__.r(__webpack_exports__);
  99581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  99582. /**
  99583. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99584. * The underlying implementation relies on an associative array to ensure the best performances.
  99585. * The value can be anything including 'null' but except 'undefined'
  99586. */
  99587. var StringDictionary = /** @class */ (function () {
  99588. function StringDictionary() {
  99589. this._count = 0;
  99590. this._data = {};
  99591. }
  99592. /**
  99593. * This will clear this dictionary and copy the content from the 'source' one.
  99594. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99595. * @param source the dictionary to take the content from and copy to this dictionary
  99596. */
  99597. StringDictionary.prototype.copyFrom = function (source) {
  99598. var _this = this;
  99599. this.clear();
  99600. source.forEach(function (t, v) { return _this.add(t, v); });
  99601. };
  99602. /**
  99603. * Get a value based from its key
  99604. * @param key the given key to get the matching value from
  99605. * @return the value if found, otherwise undefined is returned
  99606. */
  99607. StringDictionary.prototype.get = function (key) {
  99608. var val = this._data[key];
  99609. if (val !== undefined) {
  99610. return val;
  99611. }
  99612. return undefined;
  99613. };
  99614. /**
  99615. * Get a value from its key or add it if it doesn't exist.
  99616. * This method will ensure you that a given key/data will be present in the dictionary.
  99617. * @param key the given key to get the matching value from
  99618. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99619. * The factory will only be invoked if there's no data for the given key.
  99620. * @return the value corresponding to the key.
  99621. */
  99622. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  99623. var val = this.get(key);
  99624. if (val !== undefined) {
  99625. return val;
  99626. }
  99627. val = factory(key);
  99628. if (val) {
  99629. this.add(key, val);
  99630. }
  99631. return val;
  99632. };
  99633. /**
  99634. * Get a value from its key if present in the dictionary otherwise add it
  99635. * @param key the key to get the value from
  99636. * @param val if there's no such key/value pair in the dictionary add it with this value
  99637. * @return the value corresponding to the key
  99638. */
  99639. StringDictionary.prototype.getOrAdd = function (key, val) {
  99640. var curVal = this.get(key);
  99641. if (curVal !== undefined) {
  99642. return curVal;
  99643. }
  99644. this.add(key, val);
  99645. return val;
  99646. };
  99647. /**
  99648. * Check if there's a given key in the dictionary
  99649. * @param key the key to check for
  99650. * @return true if the key is present, false otherwise
  99651. */
  99652. StringDictionary.prototype.contains = function (key) {
  99653. return this._data[key] !== undefined;
  99654. };
  99655. /**
  99656. * Add a new key and its corresponding value
  99657. * @param key the key to add
  99658. * @param value the value corresponding to the key
  99659. * @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
  99660. */
  99661. StringDictionary.prototype.add = function (key, value) {
  99662. if (this._data[key] !== undefined) {
  99663. return false;
  99664. }
  99665. this._data[key] = value;
  99666. ++this._count;
  99667. return true;
  99668. };
  99669. /**
  99670. * Update a specific value associated to a key
  99671. * @param key defines the key to use
  99672. * @param value defines the value to store
  99673. * @returns true if the value was updated (or false if the key was not found)
  99674. */
  99675. StringDictionary.prototype.set = function (key, value) {
  99676. if (this._data[key] === undefined) {
  99677. return false;
  99678. }
  99679. this._data[key] = value;
  99680. return true;
  99681. };
  99682. /**
  99683. * Get the element of the given key and remove it from the dictionary
  99684. * @param key defines the key to search
  99685. * @returns the value associated with the key or null if not found
  99686. */
  99687. StringDictionary.prototype.getAndRemove = function (key) {
  99688. var val = this.get(key);
  99689. if (val !== undefined) {
  99690. delete this._data[key];
  99691. --this._count;
  99692. return val;
  99693. }
  99694. return null;
  99695. };
  99696. /**
  99697. * Remove a key/value from the dictionary.
  99698. * @param key the key to remove
  99699. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99700. */
  99701. StringDictionary.prototype.remove = function (key) {
  99702. if (this.contains(key)) {
  99703. delete this._data[key];
  99704. --this._count;
  99705. return true;
  99706. }
  99707. return false;
  99708. };
  99709. /**
  99710. * Clear the whole content of the dictionary
  99711. */
  99712. StringDictionary.prototype.clear = function () {
  99713. this._data = {};
  99714. this._count = 0;
  99715. };
  99716. Object.defineProperty(StringDictionary.prototype, "count", {
  99717. /**
  99718. * Gets the current count
  99719. */
  99720. get: function () {
  99721. return this._count;
  99722. },
  99723. enumerable: true,
  99724. configurable: true
  99725. });
  99726. /**
  99727. * Execute a callback on each key/val of the dictionary.
  99728. * Note that you can remove any element in this dictionary in the callback implementation
  99729. * @param callback the callback to execute on a given key/value pair
  99730. */
  99731. StringDictionary.prototype.forEach = function (callback) {
  99732. for (var cur in this._data) {
  99733. var val = this._data[cur];
  99734. callback(cur, val);
  99735. }
  99736. };
  99737. /**
  99738. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99739. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99740. * Note that you can remove any element in this dictionary in the callback implementation
  99741. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99742. * @returns the first item
  99743. */
  99744. StringDictionary.prototype.first = function (callback) {
  99745. for (var cur in this._data) {
  99746. var val = this._data[cur];
  99747. var res = callback(cur, val);
  99748. if (res) {
  99749. return res;
  99750. }
  99751. }
  99752. return null;
  99753. };
  99754. return StringDictionary;
  99755. }());
  99756. /***/ }),
  99757. /***/ "./Misc/tags.ts":
  99758. /*!**********************!*\
  99759. !*** ./Misc/tags.ts ***!
  99760. \**********************/
  99761. /*! exports provided: Tags */
  99762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99763. "use strict";
  99764. __webpack_require__.r(__webpack_exports__);
  99765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  99766. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99767. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  99768. /**
  99769. * Class used to store custom tags
  99770. */
  99771. var Tags = /** @class */ (function () {
  99772. function Tags() {
  99773. }
  99774. /**
  99775. * Adds support for tags on the given object
  99776. * @param obj defines the object to use
  99777. */
  99778. Tags.EnableFor = function (obj) {
  99779. obj._tags = obj._tags || {};
  99780. obj.hasTags = function () {
  99781. return Tags.HasTags(obj);
  99782. };
  99783. obj.addTags = function (tagsString) {
  99784. return Tags.AddTagsTo(obj, tagsString);
  99785. };
  99786. obj.removeTags = function (tagsString) {
  99787. return Tags.RemoveTagsFrom(obj, tagsString);
  99788. };
  99789. obj.matchesTagsQuery = function (tagsQuery) {
  99790. return Tags.MatchesQuery(obj, tagsQuery);
  99791. };
  99792. };
  99793. /**
  99794. * Removes tags support
  99795. * @param obj defines the object to use
  99796. */
  99797. Tags.DisableFor = function (obj) {
  99798. delete obj._tags;
  99799. delete obj.hasTags;
  99800. delete obj.addTags;
  99801. delete obj.removeTags;
  99802. delete obj.matchesTagsQuery;
  99803. };
  99804. /**
  99805. * Gets a boolean indicating if the given object has tags
  99806. * @param obj defines the object to use
  99807. * @returns a boolean
  99808. */
  99809. Tags.HasTags = function (obj) {
  99810. if (!obj._tags) {
  99811. return false;
  99812. }
  99813. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  99814. };
  99815. /**
  99816. * Gets the tags available on a given object
  99817. * @param obj defines the object to use
  99818. * @param asString defines if the tags must be returned as a string instead of an array of strings
  99819. * @returns the tags
  99820. */
  99821. Tags.GetTags = function (obj, asString) {
  99822. if (asString === void 0) { asString = true; }
  99823. if (!obj._tags) {
  99824. return null;
  99825. }
  99826. if (asString) {
  99827. var tagsArray = [];
  99828. for (var tag in obj._tags) {
  99829. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  99830. tagsArray.push(tag);
  99831. }
  99832. }
  99833. return tagsArray.join(" ");
  99834. }
  99835. else {
  99836. return obj._tags;
  99837. }
  99838. };
  99839. /**
  99840. * Adds tags to an object
  99841. * @param obj defines the object to use
  99842. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  99843. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  99844. */
  99845. Tags.AddTagsTo = function (obj, tagsString) {
  99846. if (!tagsString) {
  99847. return;
  99848. }
  99849. if (typeof tagsString !== "string") {
  99850. return;
  99851. }
  99852. var tags = tagsString.split(" ");
  99853. tags.forEach(function (tag, index, array) {
  99854. Tags._AddTagTo(obj, tag);
  99855. });
  99856. };
  99857. /**
  99858. * @hidden
  99859. */
  99860. Tags._AddTagTo = function (obj, tag) {
  99861. tag = tag.trim();
  99862. if (tag === "" || tag === "true" || tag === "false") {
  99863. return;
  99864. }
  99865. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  99866. return;
  99867. }
  99868. Tags.EnableFor(obj);
  99869. obj._tags[tag] = true;
  99870. };
  99871. /**
  99872. * Removes specific tags from a specific object
  99873. * @param obj defines the object to use
  99874. * @param tagsString defines the tags to remove
  99875. */
  99876. Tags.RemoveTagsFrom = function (obj, tagsString) {
  99877. if (!Tags.HasTags(obj)) {
  99878. return;
  99879. }
  99880. var tags = tagsString.split(" ");
  99881. for (var t in tags) {
  99882. Tags._RemoveTagFrom(obj, tags[t]);
  99883. }
  99884. };
  99885. /**
  99886. * @hidden
  99887. */
  99888. Tags._RemoveTagFrom = function (obj, tag) {
  99889. delete obj._tags[tag];
  99890. };
  99891. /**
  99892. * Defines if tags hosted on an object match a given query
  99893. * @param obj defines the object to use
  99894. * @param tagsQuery defines the tag query
  99895. * @returns a boolean
  99896. */
  99897. Tags.MatchesQuery = function (obj, tagsQuery) {
  99898. if (tagsQuery === undefined) {
  99899. return true;
  99900. }
  99901. if (tagsQuery === "") {
  99902. return Tags.HasTags(obj);
  99903. }
  99904. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  99905. };
  99906. return Tags;
  99907. }());
  99908. /***/ }),
  99909. /***/ "./Misc/textureTools.ts":
  99910. /*!******************************!*\
  99911. !*** ./Misc/textureTools.ts ***!
  99912. \******************************/
  99913. /*! exports provided: TextureTools */
  99914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99915. "use strict";
  99916. __webpack_require__.r(__webpack_exports__);
  99917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  99918. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  99919. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  99920. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  99921. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  99922. /**
  99923. * Class used to host texture specific utilities
  99924. */
  99925. var TextureTools = /** @class */ (function () {
  99926. function TextureTools() {
  99927. }
  99928. /**
  99929. * Uses the GPU to create a copy texture rescaled at a given size
  99930. * @param texture Texture to copy from
  99931. * @param width defines the desired width
  99932. * @param height defines the desired height
  99933. * @param useBilinearMode defines if bilinear mode has to be used
  99934. * @return the generated texture
  99935. */
  99936. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  99937. if (useBilinearMode === void 0) { useBilinearMode = true; }
  99938. var scene = texture.getScene();
  99939. var engine = scene.getEngine();
  99940. 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);
  99941. rtt.wrapU = texture.wrapU;
  99942. rtt.wrapV = texture.wrapV;
  99943. rtt.uOffset = texture.uOffset;
  99944. rtt.vOffset = texture.vOffset;
  99945. rtt.uScale = texture.uScale;
  99946. rtt.vScale = texture.vScale;
  99947. rtt.uAng = texture.uAng;
  99948. rtt.vAng = texture.vAng;
  99949. rtt.wAng = texture.wAng;
  99950. rtt.coordinatesIndex = texture.coordinatesIndex;
  99951. rtt.level = texture.level;
  99952. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  99953. rtt._texture.isReady = false;
  99954. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99955. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99956. 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);
  99957. passPostProcess.getEffect().executeWhenCompiled(function () {
  99958. passPostProcess.onApply = function (effect) {
  99959. effect.setTexture("textureSampler", texture);
  99960. };
  99961. var internalTexture = rtt.getInternalTexture();
  99962. if (internalTexture) {
  99963. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  99964. engine.unBindFramebuffer(internalTexture);
  99965. rtt.disposeFramebufferObjects();
  99966. passPostProcess.dispose();
  99967. internalTexture.isReady = true;
  99968. }
  99969. });
  99970. return rtt;
  99971. };
  99972. /**
  99973. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  99974. * @param scene defines the hosting scene
  99975. * @returns the environment BRDF texture
  99976. */
  99977. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  99978. if (!scene._environmentBRDFTexture) {
  99979. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, true, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  99980. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99981. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99982. scene._environmentBRDFTexture = texture;
  99983. }
  99984. return scene._environmentBRDFTexture;
  99985. };
  99986. TextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAEZ3SURBVHhe7b1rm2TLrpW3q/fmfLG52MY3jME2GJuLb2CwDXzx//9H5zyczZCGpFAoLjPmzKzuXqvrfVSaQ0OKyKzKmJVZvfaBj//kL//wh//whz//B8lZdPqvJf6sWeLPXqrI+c/IxXTHWl427dENrAKMk2rudBK2NjlzwVzKO1keyPUkg7sm2PvgcACMAhx2wX7gchVYafBgDJxPAne+2dX5sOsan/i4HM0DZfj6YQawZFxVzKnuhaRFS6CYlqu84nBVMcvkpgtWAvmBAFOx0uTEvKXBqkU9bYGxtSqBl3YD5FZQTV/TQcez9WMszcsNk0rREW4YuRVBVNtWvWnlqAchsneqYI5gucqLQNKvlKdRWrfKMWLgljiPB0t+7rCPQPkDT/0UhI8rHvVTkGbqnNtHFDouuo8u0UrRDUSA4iCQBqeKqalC1qoYW5ZL+TS3ByoZXJpgWoK9D54JcLcLPluDwxa4WdaPQB28S0bcrE3WeVUW/M0dcCzCPbvkyCRTUpTqNAFGMwl7JqW1KZ/m9mZVggMlirkqQ7w9Pm/nnzWGdwD8Yl6/CbQ/fF3Ib7gwkV00P5nm906JNsAAxUG4acNeLvVCyHIVlkfxpixXajAOgE1ZTLAS55Pk8Rj4nhpsyvNJMJQf/+lftqMf535+A2Ax7wHX5iQtOUzXJrysRzwHhnEtJkOf7ui0YS2rvhJynfldnpqHGeQbYGi1DB6U4EUB7nbBrQFwuRYcLgfPJkEp8R5wcQPQxLn02L0JZIFXfWYy7NQOfoQNgGRaFBMp6eyfCFmbytJ9Y+Z10gIPSvB2Ad5lgpUGL46Bx5Ogd/wGwFmc/uKnhojgyVYReXoPdCYjt66imwG57J3uEGd9KTS35cz78jCDwbQHAkNLmJbgmQ9CgNfHwH4S3NXg9RZ4oexuADv3ceizZmBxfhPw3DkM+kmXkNbMj0DKpUUxvfzce+DFDLyU62C2DKZdsB8DtwS42wV7E9zV4PUWeKGUGwAHsZ17iuTIMeU9gJXIGu34MuOldRFOZzJyK8x12AxIZnVc1+FLwexCrqns8tQsGRwMiBzMlsG0BHsfPBPgXSa4q8FhCzybJOuB2Q2AYzpqrIFm4IXUTN05jKTrPZBi05IAmBmcean64T3AjOV9aeLFDHrT7M0MeNEHIcBbuuB8AKw0eDAGPqesN0DWckDdFF+zLGZJgexidBh2LpMT0Z3vWSDlUutFiTQz54K5L2W5ii5PzZLBnQF7ILCeEVbicgCMAtztgmcDYKXBgzHwSgkWA3YDyHH3sx7CTBXi8wQjq2glsgt5acNxf3nKNy3g2maSU8ukpSrmSuTsQq6DeS+DgwGRqTSGMWPvg1sCvMsEdzV4vQX2JTgb6G+AENMbAAugERR4FZOmaAc6TA2bnMXyHmDoE20zWraIMkScrWwWwVxK5liecylLBvdbkliC3AXTErxdgL0JzgfASoMHY+CNJZgNTG4A0UUga7QTr6Id6yS6A+3+5JTHktLlM+sDKZfdzEyL7B0TzCvfsz0fL29kcNwye9oFl+JkEtztgmcDYKXB6y1wqwSXDv9LsJzF1bmPG0NDTgY1BV5Fai/FSdqCk9npY9Pis0TIjGuLXIZW0Q0XwVxK5lS2HZhLGRncaoFUSpp2QRGXA2AjwAMTnA+ArMGDMfB5JRicj7/5l+24x4ef7lOQd+0ca24lNXISdqDD91j5wFqrkAmfUZ39qlXIsIrWYl75OWN5Lg8zuG+aMfjGuwQ47ILzAbDS4PUWeKUEV878BmjnPnyeWmgXkeWoscxORLSKP8SkC/qyzeRW6F7IsIrWYt6Xntty5lyC0i0ZbMretAcC30GAByZYafDiEnA+Cc63IlunuwHyua9mBA6WZmpkO5QsXbeTmmPqA9fzVXkg6ew33Qs7W7nFXMoxq2jLLzO4NMFsxh4F9P5DAe52wd4EKw1eHAOvlODuAHBHbgA5l+UGoEMzujziKF1IpuPCHA0xe4dhw7PoWmBW2nEZ/KmwDekw78shy3XdnWdwsxRZuuBFAd5lgpUGr7fAG0tw7CxvgIlGYI3m5T2QzHrQVz6fikftIvKAaplRkc1OhEbqy9K9bLXH2mRwaYJtaQ8EFgPCagaMAhx2wX4VyBpcriWHLXCrBHcHwMypN0DW7QagifU8xCgpwolbIkLLyWnWWPmMduZyhKPCdlDdidFE6suWp+aQ5bru1gwelCA/EDgR4PEYuNSrAXC5lnxeCe4OgMH5+Jt/tT735R7QLFtontwDSUdMTYQdSgQIrdFaiNxNWqrBbLoIpJnZ8tRMWa6rLrg0wd7XLKn44ESAu13wGRoctsCtEtwdAKMDknlwA3hpJ95zd7JV2MENU6M7zSlWvgTS4Ixa5GAuBdLMPM9t+SaDkxIsfHsUsBgQRvNBF3yGBp9XgktnHADrVe0GyEffboYww8cyaM+tZHAgR4zNwnyQzAjpllaULrqZlWDGcC5znpqzbA8HFgOWwbQEB76k1QAYBZjq80nwigaHLXCrBJ/nAPwN8Lf+avK7P4TouBnoY6OU5UywZIz3gMbUREx8fVqM1k1m0ypkRsXYasKzbejlgyzXVReclOBqwL4pcCLAAxO8S4PPK8G7HDCYww2gQs5xnPvwNeS1gUBWYUcqHJ7IVDZzEUi5bIE0OKOwmeR0gjmVMk+dzPMsadGyDKYl2PvAhT1JcEuAvQnepcFhC9wqwd0B8misuwHkQA9CdNwMOK+aqSnaMXWzHlwNWwiKn8tpN5uhk7AdktMJ5lS2PVeZAsy6cs0O6AeMaQlWoi8llQEQAjwwwbs02JT7SfD6ALhcRbam3ADtd3x5ExiELIsTX8qI0fFY+ngivSPhpq3ysmlmFXWmCOZUyrzrGxmoWC4H0xLcHcD1YEbYm2A6AC7nweES8EoJPs8BUxPwb4Drc0/NwF484tQa0nVtDvLUROgDl1i21LGulxOBNPVD5IwNc7nJYNGStGgJRax8sBUmNzNgb4LLAXC5lhyuAqUEdwfAMwccm3YDyJnGeQ2hOoTk8LELXhgKL5uTop3aFFMTVF+sFmJEGboIpIU/KZEG5yKD3pTromVMu+BYSAoHLMaM/SQ40WBTnk+CfQne5YCnZn8DIMZ3g+xjsWc7bSzzyR6dPuox9WgnMoc7tUvN7KLNMO9LpMGZZLAwRQ5my2BagjvCniQIAR6Y4ESD83I/Ce4OgBMHHI6B7fJ2A8iZRp7eDB75HjDtpTgsU4wOYmICFa3lTi6tq7oJZhcyo8JyKZlTafMgmcsMetPszQyYliAE2HTLo5BxDOxNsNLgsAVeKcG7HHBugoX/8bfjX4Gm576/B/INgGj3gJvj4R4dRD3KEUh9WXRdSMHsQq6ptFzKlOW67hprU54SmXVrCW4JoFrSuitMTXCiwWEL7EtwdwCcOOBFEwz+/AZomsIHpMQWCGgV3T0QB3RqgtFkpNZkuNd1gILZhVxTabmUKcuVGswGWgZDKXLdbRmMAmy6LuQ6dsHeBCsNHoyBUoK7A+DEAYdj4KkvN0D+NR/3QDjNDI3FCBVyHMPR6E72wmGID7KpZZvXctRSZTNnF3JN5SSn0p4JSKZlcGniuu3eE2DWbf39EnCiwWELvFKS0TxxwLkJ7vp2A+BYlzcBxOoewCuhWYJl0ox2gqcOWJvUmxaydFWE02UXck3lPss1O6AfMNalpGkX7H1yYFq1nwQnGhy2wL4EdwfIZ5hg5YOhZTfA5E0g3RXZlC1QIjOy9jCHwyCbfSDlMoYRUrnOPvXJPdBmmEs5ZLlSg9wCuSwmUGEPB7ZjwkaArdkeBbyiwWELlBLcHQCjA85NcGsYHLR2N0DT+a8CrMRZcSGxuQdWDnBtfnJC24s9+BRdlyJnFW3mLE/mwUkJ8JQ0G0WMPlgNk5m2Z0he0WBTlhbYrwXPHHBuklXrrq/4DaCnfLwHQnQaO+LFdjEtxelLUB0GUtInfgg7Ddkfcps5yzYPcgtMS9D7F8vBRoC9CXibkfVMY6XBKyV45oDDMXDXB5sWGLoff+ev/GTv3wSyxi48WK6bsy4ZzQSh+aJGmbRUrpufhB247A9ZrviatWoGMR8ZFLH1JW0HjNUM2WpJqwGwam3GwK0SjA54PAamJrjrg02L+EC6ATTGv4brDYCVzDzNrq3sY3IPIBUHgZR0EdIazBAiR3/Icl13x8xrZ4JpOXPacyYnYqVnplynwyBrcNgau+DuAHk8Ru764FlLkRvATnYc8V5MNDZljiNeyhTmgEszyuyrbucpmZZjYc6l1CzXmV8zUNEelBSx8oEKSVczwijAgbanR1YaHLbIfmCcB5ebkKkJbg2DTQvc79YbIOvlPYCNGFl7XDtIg0MhvusmVNuSMHsh1zDH7EKupUVGk8MqWgbTEgzCvhdwIsBUZxP0M62ariWHLXJ3AIwOODfBygfPWmDfBT5gN4Ac5Tjfg6gaiyNKyUM8dcDeVF39JDYtZLmGuc6yieuLjGtfVhElmM2YnLWMUYATDbQ072rMKC2wGSbPHDA1wV0fbFpg3wXbgckNkHU1sRc1REQp4xAzQHFGU8vQ5oeZxKaFLNcwF1muqy4YTEnZBHeEPGEyCnBugtmMXWct45USnDhgaoJbw2DTAq90yTDz8Z+lP4L3576ZKHGSXIh2IV2QHY96dmn2Jbt2aJKzazG7kGtpDVmu2QH9QMuA8ypaBicClOVgMWZMTZA1SKX9TIJXSvDMAVMT3PXBpgX2XXIyo8xvANPYZTTp8yy6trKP6iD1JYWZXlKIqeKoxexCrqVFUtk2mWbQlzYPpmNgFMB1Ww7OlggnGvBbDoZux74EowMej5GVDzYtsO+CywGyHpMboJ3sLLBmMLFRvQc4lksPe9WvTDGiDI00OF0rlaWLLFdqEN0+t00ig7UpqXcEitEHSdtjgf3k1ARZg6HsjKvhjlKS0TwcA1OTPGuRywFwMhP4cL0BRKNHEQ6F+vkGQNgxZXAtAqjougikvqQQ03XzkXLZi24JBbMK64LS7bOkRUsYSpNlAGwEUC1pMIWpCU408NKupQsW840TB5ybYOWDTQvsu+ByIDibtBugnWwe4t7BXk3HALKGHdNBdw7ITiqp65gLkdlhVtEtGbJcV13gpVwXrZaBCkm9I2wESGazFwONlQbrUmTpgv1ycOKQqX9rONh3weUAOJnJzOY//vPyNwCG8s3gTjM5gMzIWqMrwcZRHSEGdS9WvqS+LFmuow960+zeNIbSZBkAowCDlrQdMFYarEuRpQv2y8HogKkJbg2DTYu8PhCcTyb6GwBb5LOOwEvuursZIFLYwlwCL+dOLl13YxSam8+cSmmlsmS5UoPZAOn2B9vShkEIMJrTLuR0AFz6YNNS2uZkGJg44EWTPGsF75opXC2RG8AOt57g8bhHq2rkFLsSqS8p7NXq/c6kQOrL627KvE5aIM8MpjErJYUD+q4w7QLVZmxnjKzBQdl5ZYCM5uEYWflg0wL7bnA4Rm4NF3Tt+gZAe695WD2ybg4fJsreETmYUmWTOXwvTWi2Vm/mzGtngr5szzYyKCJKyNUM2ZpynQ6DrMFhi6jT2eMMeNEkz1rkcoAcjhVurrIbIJ/s/e/+ZmrYMLULCaRcFkcKCTtGK5PZhVwHk3nTIt2eYFbaDJh1hV5IGltgbyrtscCJBvsSuNM64wx40Qxe6YLLgcLd+ZHZDpMbIOvuZgiTArkc+lUJshOlijqjYhxjlutgMltrnW1PkFsgz7gQki8Mom5IpjqbQEvzpvNgtqRj65gcZ8C5CVY+2XfB5QA5HBt5vND5+C/ij2CcoSLyXZFM02hp2Amelkh9iWyOaoo2M5p0UpbrvrXOkrIJhtLkdAz0QlI4YKqzCVIp32NmupzsS9A7Vo1jYGqCu37w+kDh7vzI8Q5yA8hB54FeicFENq3RnXKWYFGKE6WL0ZFrdlKW6741zbj2ZRVlDPT+VIRM6lTnqi/Wq0ApwejQm/lzE6x8sGkF75qZ8njhFX4D4AH0oI83QNel4AByil2JlDSFOK4pRkdMiiG34SHLddXF1UXxi5C0HRBcyDVMcEfbNbfArRIsnNEW5q7yrBWczAS3hqe8vkPcANgrftNvBHK7MeBDpMhl0yAc11KGTsJWJQdZrmGm3DYcslxHH6ioXTATJrczRgyDps40q965V4KFM9ozK/FKN3M+Se7Ov0L/WB9/l38DwE2HeyI0S+DFdlM0hEfWUmL7KFWX891OcAikXLqQa5TAddthyHKlBsPApAsGYfuDk2H7ck404bMNysC+BKMD3KzN6XCw75KTGXI+ueL1Ha64uAGQRYegGfcDMnzNTYNcJqd0RWbHhcjsaG6TfV75yLxOWqB0wUyczDRiHvR+I2uQSpNlAKyXGKMDkln70/lg3wWXA1Oerbrk5W3lBmgHOp3s/blvJkAJ7ZG1lDpggeRi4yCLqcKyimp6nvjgqiXXwXk2I6g2Y/Ab65ZUZRg8c0Aya386H+y7weHYyOOFn4PdAHhacaab0NxEmmlaQwZSWAmmpYulg9SX0RWfZZ/NB6vWdCC6pMwAFZIWLSPp+YZk0wL8OWRmM5XRIb3fVaslweVAcD654S2bPOXgBtiYyB5Zg2UphZYqJg4zT0MqTSAlHZnXYjLL1dp9C6iYDJBkmlx0G6onw2AY63CndcYZsF5Y6f2uWi3JnMwEt4bv8nmbf8jmH/9l/htAM7Q4IfrWRHsghZaSwk0pXcvVReekElmuqWQ2s2RcR9OzjWQTJNENgBDAte1PtpNgPkxKCXpHqnEGnJtg8JuxWjJyPhk8WPJDkRsgn+l64metpjmJbajhu7AytUS6oCMyO0h9iSyOipzlOvq4jua0BQZhAyAE6E2r9pNgOkxKCQanPZPC1L8z3LzVqpHzyRWv7/CZ2A2AZ8kzvf+VP78HoF00DbIfpYqJwwynL+UaZcpyzQ5QMRkGuQVmXbsOppDMZk8HQNLtEUkpwcIZ7Zm1MMHCb/Zq4Yq788945VHweeYR9QaYHvdwum6Y1BFIqRQtlgaSi7mjWa692TZJWa7ZASq6YZBKSdMuiIF2UYZJuU4HwKCbkVuglCSZy4WZVWu9xDqbPTc8W/Vz8/Ffrf4GCKdvdWNhloPO0p2spXRRnZTbbp5HR8aSNlTYMMhdtlwIMxEyqapPZrprboFSksEUYzpJHrVaZ7P8hBeX/0D69wq5AexMI1b3wOgUE0DT9xB71DGpojl9KSnplYMs1+wAFTYMhq7JMgBU1C4YtKRsgvV8GRzqmQPGhZld76Jrzf0OD3j7hoc8/fBD9AbAU/eDzgwnjnvTyYwxMTV3GmQ/ShV08iRzG/BcHcxECdyfmpZSKbjodgYhADckvd9YzYDZkuUwGB0wLszM3cR2oDUv93mdw4d47RC/wsd/jY9AeJar3/R0XJjZd22AgRSavlgaSC6s68IcpKSb05typQYbEyyGiT0WGEXukly6luvBGKkbkgOzjkyXZC4HYuRg8vfA9u5qNwB+HJujP74J5K5pEJqB5MJaLui0VZ7zPhRyDVNzc8DGBPRVtAxUSOodI7rtomQNYnMwtDq07LwyEAy+Gav5kYPJNnK+7U/O438Fwg2An8Kto29nuh8D5muIMdM2Fs5QIss1TM07B2RTRcug+OCkBaJL+lYgsptbls0uA8HCtx/RCceTNni+8w/k7R+Q0oZ2A9ix7s/05uiHkC61hmmw1pK2JbJczx2QTRWGC3kI4pNGLAFlRhGZSmEoO2M7LFUZIFOTaGvTbxwNGW32zqrP5TMP+oqP/2b8COSi3gA6Zod1cw9g171WMS9TvucAF3bWVz7YtMCgm5FbIJUiSxfM5uvUuCrj3f3UVXtOt+jRDke8/VhPefoocgPgmy+/48ejHwOi1ZncA0Ad87WsWgXzvpSUHYAZzdTM1swmri7CoZB00gJZo+rL0hXimZDZQNDkOBYMrfnsZocr3rzh9zno4JUHGtbaDVCP/uw3/SiQm8aVmqbUXoZGctFK6lJ6njguIvPambi6CIdCUjggdZs9G7BrbpEyANYzQXt6I+vW7iEecb1NTHy385158UEPln/8t/mfQe8LZNMappHClEJLFaIppiVS0lOH1zxQTaBCUu8Ii2Fij0WyBrEwqHW/nIwOGLcic7dh/auxc96305t4fOKfLfzQGwA/Bv7il9fvRKgO0UwKMGi5uuhamuUaTi6BijJvqTd59YsJSb0jxDBoyrSkbAIv7Vq6pMyA6RgYJ8FqeMB+FO/j3fud8fr7yYMdZku6G2AukOOU5+Me90DWSGH2GllKFZJCl1KzXLMzDFjKJq592cbapQkbJkmvfIFPLFNrQbyZP5pmTIdHfOxw/JD37nbBK+f+TSe+8PH3Vh+B8GLvbwbVMSwa+6kWc6bl6kJamqklJT12zVERWVIq5eoiHAiT4QDVkgbTrtkHqTRZBoibtTkdBvHcNgwT10tu8vYNO77nob81r8NyA8jLMD3WlzcDIt8DYSKFGVqUhEgvs64lU3Q185pNSamUq4twIEJm01MyQfZBboHSJbUWzJu1jOlWmXVvt+o+793NeHzuP//QZ7obQARy3AzprhgHolXvAexKIaqadFoLKWlpJS2JGuQBFZElpVKuLoStCdHsPFDmQena14K8bWFoTCY3OzsHIzd4z24/4aG/mvz47/gRCC9YHOv+rLM7+k33XWBmEjLgorVY9lomk5ZEDfKAisiSzF06dg0TnPjtklBntItVByYLjNZZzxSOB494abef7dzfuT3kBsB3L4ds/cmnlM0pXReisXuYoSlmZddCoga5TKbJ5EtKA5bCAWG2ixK7gdU86QrBjMEPpLPuNvJzOObBkhVPtvo+5/7OaT4lTdoNIC9APs1+D0h+dg8gDcIGVDDLdaYlJS3XvoQwmXxJacBTMkEsBMm3/UnWrHpHcGfsGJcD5HBsxoMlG27s9tlH/8H+J0tmMx9/f/wIhJyOdSlFlHsAkd80kAG1C7m6mPgsQ4OhJde+hDB54oCm0gMB13bdtEDuKp0xdMHMuzO5RZbkZY+P5uGjP9v/7qrD+XeMyQ2Ab10OxOrj/lBOnc7ExjSRNO/8tZbrtoQwuXEgkw5frtkHsRaUFozBiZmxU5CByyFlPrVdu2vePHkXz/HuOQ7OF55MHu52OaYDdgMgeHzlZU5lOKf3QBaA2oVcR19z07i6yWz2tAQnDmTSgpbjGKiTwJ3WGWY2LbKwK5f7jBwNnh2a660OD19wPn92Xq+5uc/Hf+8fgeIdoJThTO4B5P62aRrJhZkqRFNoXmlLuaWCuSvB6ECmbrumASEWkjzZLokyH6g7byUmA7M1l/uM3F6yOCUX+xweQXI+fPPIznk6IzcAvm85Luko29k9vAcQadJMkIQkdrWUq5fdjIuuBWIJYanCCAe4asuB6nEGdGMk70a87vxh4bhTQ3u7gcThWHB3XlicmOVWJycsOBx+emo7Xhv4+AfxRzByuQf63+7mr+6BJJpGciGm5uaznGowlCJLqSIoa+2aBqBz1Y21iyFV75D2KCNl/4F9Nzgcy9xesjgWy31ODit449jlzDsG5AbANy0vKnJ/uCW/eA8ACM16aWbzNTeNq5skl5LchwgZyoaJajOS382QvBXJa0newa7OpjVwOUAOx4K786vDMd/n5LyCk7G3zLxvwG4AhByL4888HB79TiNlIRcJkV7ONa5uknmpNB1d+1JUWBXmzAFS9Q6YmiA/h8K8k1yT2xdpvf2S20sWT2Cyz+V5At9tZj9ws/vxD+OPYBzBO7/vy6rsmAYQmvVyYVrykle/dGNydSGMw/blxADR4sQhRz5xa9JK7LvB9Vj/ch5u21iclck++1MFLgfA65vsBx4tlxsA37GcJ0T5hyAX1/fAIJpG0mwmRTanGnBYBXNX5kkQXaCqDINuHuQlTp1xlr59TVjYxr4bHI4J+uremCezM1E3eXSwKi9u8mnLP/6H/Ecw4uk9kHUTeIQsNO9MRZYTFbk0GZP2pUQXqCqlXZsrWJXMJqeTgdbVTGxa5HIAnMxk/nx5UAqL+e5xXzx8YD/wqcuvNpcbAN8uj6zk9CmIedU9EkiazVEhKUzNc63Cri4mLfsy2iSIYaJFc1ztZhJizhoTz63pPpk2sH6dLjcpyPzlkQoWk92DvnbCfuTyg+7H/9i/A5Tf9My1HP5W7gR2nTpIdLQMM+tqqrCri0nLvow2qZSyLQ9GJ/YrW9m1Uh8ise4Iy27/yu03Kdjw/rUPFmPdIx4cox2Pl3/ezsC7cgPg2+XRtHxyD9wSSJrF0XytVViy2jcB/Uy75tI1KCWYO8RV3zfMHHrTYbJpgX1X+DiY6bH5ywME1jPtQd9xzuZsuvuF4E1rP/6n8g6APP5jaF9e+p3Ag2ShObSMFQ3yMK+hywxRZWVMdpdagibLTGJcBcYxsvJBe9oZfxk2CwObuXxplbbhyfxi5nSTTfeTFoL3PajcAPheeV4tz94BmEex8k2ALDQXHd2qXcjVBWiamxBVpyXIax1z+sY4Bqrp9XQYrHxi3e0r1+1weT7y/OXwYuB0h033t7DQbgCEHKzIdz4FlVIENp46SJqLjq5pFZas9mFlpdtyUsoyLP18Eco8GcfAbnLGpgW67uJVrDtsX+w2vD8TYD1gm+x32HQ/Y+HjPcGs+/GPxncA5kd/CSDlsgkkzUXLlY4LM1VYstpXKSvdljtdV/r5UodBmScz74ZJNi0w6fYv2OVAphveHwuwGLBN9ss33e/ZAo+6dgMg5IUv+fweAIsxEdqVpLno6JoOYYVPKivd1ipdS5r50k2CMgwGQxhNcWaj0+VA/PWLtFqVl8xnFnu24f3JILMZ22G/fNP9ni3wqPvxj1fvAJrLfxczkwLXXM4EEsumkTRPHJBNF3KNgbUGXau7xFXhoyRK11PH6ICpCe76fHmWXbAfmL263fD+cIDNDvu1m+6q9fYNyaOFH//z+K9AfX5WgrkjF63ohPCWpV7I1QXotH0ZtRXwQROtVFW64MQB5ya5aF29xpvl49pueL8zmA2cPKUlq9bbNySPFsoNgO9Szs063y6x8crRR20OEq3UkmRF8rNZtH0ZJvWSbGE+6bTSVRkAowOqqT/u6SRY+aR1F6+ZDBy/0tMntmTWtR2OH7Hje7bAo4Uf/+TmO8DUbAKp+GK5o9ocpOyokGRFE20gmxyP4e7S5kFeAvrqogtOHHBq6isxHQ667uyVs4HVi5r81RNYMnQvHgu8vQVW3WeryKIrNwC+SzkH67wvm4n9iq9OHUCKll5zS66DaJMgaRExbFdTrQw9TirLcjGPH2V1xhnnwp+9KpMl/Vg3sHrV3b/crWNoteVXDzThWQt8xz0//pe3vAMg5ZJC3ORHSaFXE1Z4N0SMgYU24fV8PvvKcpWyL8loNif9rKdrQfX7l2e+arXt6oVX/3KryuaZbB9ozhuXkHcvlBsA32U7pn0+amGbXGoWj4KOzlC0UjPpzKkAKy1Vu5z44JUSjA6Ym4sf/XSYr9O8RVYD00fZ/NG8eFZCanXLV0vOtqo82A08eywyG/j4X9fvAFOztrDHYIo3K8XReXMUE2wthKdkKrEJaLLM2FXIM54at0rQHP/JjjOk89PLsJoHF//L/unJXiyZb7XZv2+tnnzH8W6NB0vI44VgGJAbAN8iD2g7pgdZBDbIZTLnZcxT6LUKLcaWp2Qqor0+9RObFtgMk7kz/JTHMWH7b5rWWr+iyztk+ujT4fXmuVWf5AtbVVatzRLwSpekmY9/evBH8JhFYPXWjNIcXLMvtQq29sIvoU0okwGl06nIPlgtAaUEnaM/x4sZsBgj4i9es7ZkNmDd6drePJ/s8FZ95qslB1tNeLAb2HfB8cDHP7v6I3jMJnBdm7V0QVOEZktXwq5h6sU7QqdTsZyxq5A12JdgOZB+6PNVs1dlupx0m9xcK4zP52qsw/3uaZCrJRMetDZLyH7gcjn40BsA32I7nVfZBK5jqzdbKcp91RRW7oV9CaHdaGMgyaT56M6JBvPSf6ClCybO7Kffxvput3zTAscLDTdXD91YL6/Pgdzah7y9RfYDV8s//vmdd4BWYmlpIaVSjChVU3TDcmHl5UyAZtqXrSJL07mrwY1Sf8RlAJjTvwDjQjCu3bVA2nO6YYeadZ/1ZOXlf0fq2CwBDzYMnu788S/0BpATNstTE6k41VRtJa6qQ9AUodnSKPRiAtJVnVHGMTAdACcaWOk/u3nXKcOkm9FWWWWsDtl2Cand/gkY033WkwVZOB0GKx88a4HPWEhmA3ID4FtsR/Mk4zo40wEpozUTVorBr17oxQSkq7EF2phdhU6nosn+8GUNli39UW6GpwPC4qyLuXj99v/aM32IKaf/GDob2zw94Xu2wCtd0A98/G/3/whGCm0C10FLGZNJWJfCcyfsqxdKN6OEA5ppV+G5Hg7rvEw/0DIAxmM3riLiz168lS+oPz7ovX0OzNVz7th0V63HG4JXusAHPv737UegScYi11OT2kpci8nJvrTEUuFaEfa1aCkmyphdhanOJn4cl/PC1S0xDgBx+tejzSR/ahJrLV7Uw/8gsNvkymzPjaweEaxaD5aQxwvB5QBGcAPg+7Nj2ufRFIFFpVUcXFWHEJkEZ1qp2VIIZF4GH8wd54EJsgZS+o9v0gJnXdAGzk1wNZw5uQdWmzfWm3RryWoYvL0FXumC9cDH/3H3IxCuG8e1lFL0JsW0VORKR1Lv68WNJEJl065NZD018TOa+0o+YaVVFoKu1IWXS1ZjQWvNXkvpznzDW93+q/np/neGjbe3XuySYebj/0w3QIhdxqKNo9pKXLPZl8X0yhaK8Iv5mqMEVehl2VXihexMuwpNb471qpV+uHVgfG3GewAsTFD9fsPWHR+ITDcB0/nBlIXbnedsWuAzFpLLAeAzcgPg+7Oj2eepCVaOlFL0Y8lZlpo9eddLG1DmA0mA0dx3gWj/iUyGtZV9kJeArjs7x2UejA6YmnTqnutHX3HvF/l0/1s7kE0LPF4IXh/AyP/lN4CcqpOM68YJLSo5Q9nMlC2xVEwMzsono9l1/ecyXQJEr2bSz7S11MyToJy2MkzMHCd7h8yPr5vl0YVhfrWzcGvz7fCcx939QvLCzMe/XPwNMDUlY9HGCY1rcqzcmJ5F2BeTZdANKN0At3W6Gf3mO8dpuv+13en0s1vNAykXk6Sb75+SMI6l3UDZv7C/Pchq58Zik+55kls7BJ/XJSczII19/KurfwatJq4rR1Snaytla/XZuuzTl2QZFB9MBpzR7IT/FCZLVjeDLula/U88lpOyEOS1426bhWTlA2kNppH8zQ7GzF9ufmeTjs3A5VrwrhlM4QbA92fH1HMpu4xrMcVqLa0XrT63gZQ9zUqlE2kAUEQJSgs/lOooovXnVU0w+v1PdjWWH8uY/Sqd/OZe/8YdNwxaa9wQuLnZoaP3DzefsGmBV7qZk8nFzMf/vf0bYGqCzpG694uTs3ebqV8TU2ldhaKU4HIATIbTD6Xrut8tH4fVyTNwurJfRSYOvnoz75+Z3i1Be+hxjKxvrTneqqvW+y/ZtMC+Cy4HgsNJH/v418PfAKWctLAut3AtfnGGLGmRQ3hlonVTBisx+kC0fudjd3ozYLguB/0OZQaUYyrdcfPFwwXjGJncA0DN8jTGtWC+HKx8ML1twKOtrrmcOdmEHEx+/Jur/w4wMbEuOa3EtQzQ8dxaJZcBL6mBNw0RPglWIl7scQCI1oHaPTBBPeWpzEtAKUHbZ9hWGM315o2z3+7L5cGsJatuLhEeLClcjh3uEwzzH//P7I/gUtYWZDal7v3iTLN+5dyZuPJinS6DaQmOBvSnEA4YzXBAmxzfEMrMbAnIq8omwuzsTn5Vz7bKSGtcBZI5PvSccedgtQSc7TbhcgCczJDzScz+v/0NECLniYkUZWhRySm+GEM3sn1NhkUMGRQx99PZWg2YcMb3jbwJWP2yX82D+naBrysHzM3ByTP2uOMMULM8MWM6D9yfrFotIZvufiF510ywHpYbAN+fHDXNIS5KXHvdmaI8hy/V0BXbuiG6lmbQWkrX9QM3745ielekn5GYWnZjPmBmPwD2p3xSgpsO2dwDtoSMY8pkOVn5myVk0328sHA5eb5VoEs+/r/FvwLtS9BMKZrZHJabbF9tXq6DA6yVMjgt9fssPpi3egfEa2/megDMZ/YlOHaI+ckxhnceYRhbLg9WS8idhR37LrgcIIdj4GDy498ON4CI9P8tgHzzpcuM6zhD8zLrV8vZwVUvWYsYMpiUw2/3Uo4DoJ7y0dFy7ILpQC37JcJwWMcBUGYmZr/KWmUr4uZ0zzmrJWSzEOy74PWB4HwS9MMf/278Z1D9/xhGRPi45pJdcb0MjWuUm4yrXjon6+gqucwZ8Ny0MmUgYnri8TVbWIfLTPrZxTyIgbwclDNdS3xtB8DogInpTn70srkx3HiN6bwyPtXKvks+e4fM8eTHvy//DJp/92cBWXyxmu7MPksrspuWszPTnpYZTMrh0Fs59fWH1fm9U1f5D7eZ6cedB8BkflGCE4fkbTPTG6ZMrvZsTB8us1kL9l1yOXOySXBrGKT5b9BjgOJ8/Fly5+tPpZpe5lyCJr4u9Yd8tXKagZW4RLgpqGPd8FnSd6M6WmrDSV1raYgXWgrFHYOtddmCqF7OLEyze9OYmqD4iExpMTKlhSiULiNTWoyRMpBjSpnJkehvAD3lOUArU7fzvWSemjm30BdsEu5zHl88B82JHC2tc8tMXwVYWliSS/jVsdQ5Qu5SaylE6U57ULItyzMU9k6Y4Jm58RlB8SMKpYsolC5ipAww9pRhxB4fm78DjGFLyh3ibwLFN7MPmpL10jn61fm4+Ils2Q9iy8p8QMmmlcgs85g7NkF6p62SwoOkh5Aquu5EaYaXxqrcOCCb4U9NcGlmH5QWIlNaOQqlixgpA4gVZSzHijIW4dgNAFaiBD4Pmih+NvsZ5giWlv1MWNZL18WFOft9lotG1xpNllp3pTqkrXIzHKPX3XLqsaQzK28sJ6OZnTDBiZ/Jfm4VnzFSBiIypRUxUgYiNpTJiD14Cf7/+C/B+uevCM0bAVophZZFRMY1Ccn6Zc5QWh6ds4xvqZr6U8glNTDTf0zN3ztpQ7D6C9gG+uH86EIp+93I6NQ9SXncYNyQl3FbMvPbnqtVhfeOBXfng/XC049AOfDzaKX+bMwPM0UxWeIrtISWDJr44m9HydlfZZ+3EllLLhdSaV48RF967TqcrIGXZnhprEtJqTTcMc/LqdO4NF/xQWkhCqUbMVIGGBvKJGNDmSyx5skNIKH3ACgOgz5zMUvZsl7YYrCUrPVF5iS/GJa6AYFl1KtSHRNpoDlWe7BKZdMcTqWh2sYIdZRg49wysw9O/NICpYsolG6OFWUsYkUZizihLNGwG+BbZ3rgTEeUVh+Lzc1nLiZe+FxK1lqyOhEsrzMufi4ls9SaZR44LA3qqcMql1mDUoLiRHnLAecmyH5urXxyq4tYUcZyrChjEXvKcIkZ63eAcujH2yDK5IMicsncTD1wrYysdeRSLrNc03LVgpYhpRU9bR2W3HbqGOwm7UUq1ZGUSuOWE2Z2wgQrH6x8kFt3u6AMROwpw4w9ZTjiHF/iN8DqcPcRn/5jhxCr6Aa0zia+cmnmkCNYTjLPpZ9O8+kkbWUMa0su29LWEu+a45qPGyWJBxXNr+QIMyevEqIMB4wOCHPjn7eAmvJX+LrbxYoyVmJDmYzYUCZX4dR3APkstDj9Frkbmn8Ka9n9iZxCBqaln57OTKVkrW1ymjnGHD6dXutFUV1bLENrGZrDJuikrhZCW05WpTv14UDvmN2bxqWZfbBpgVe6pMwwLinzEZeUecRN5AaY/wGwif0d4gGK2JValNxKufqkC8vDKvOR6Wy1XKLkcm1MS4usWYIYTs6uBMWJMhxw35SnkXHfovBKF5QBxJ4yHHFCWcJ4QL/D8DfA2eHOv/ubmWPml0ePMkQumUuJL7zAPGqWo4WcfLNA6ORL4qRr+iKpp2VszqQ6HJYt6KVSkpfiE3ca4WxNu/amEWbxQW7d7YLLgUwZRlxS5nMcUlaN0fMt//qfaxzls7sCrEQLvPbJD1FKCmaeIcthUuSWWvSrSc2Oai8spPIlRi5VcCtqi7EEqrtHAaty44BLc+Vnsl9aYN8FlwNBmURsKJMR55SFETdZ/ysQIh996nwnuLYP/TnnUAewHEUpTegZ4jHKvmSa7A6m1LqkM9XeaL0oqtkyn7u5pqS2MUi2ksOyBSklcKd5LOkHLIsJ7vogty67iA2Hk2WMcU5ZGPGMskn+CJT//M26xso/D32Bo7RnpQVbIsKnCF9rmlZmM8p+0pyiY3LQFkhJj6Xpseyd5aqNAy7NE58ctsZupkwiVhyOZcqSHK9QtkIM2A2QP/xIpFM++VwU3YObBMyFFsgmcsuFZA5kX5X4LPWLZilbJlp2AgyaVWwopP2FXFJECbysjzuYtkk4IJxLE6x8kFulu2llyhhiw/kkKMOMFym7RRyg/wrUn+N6M0yjHP3hTgDFuRd6Pnhc6OArO61EFm9SivKQ0k2VC63CXTWpQS5VS6mV+b3TgmQnTHBm2nXwjeyXFti0SB5gOPV/WgfKJGLPreGRsnwaj8FHoHLcpUyn2UqGm11kfzXjoY94JfQw7Rx1WQIrvV6WblJLSFG1yaTpW+maMpdClIPDhzbctAimJrjrg9wau+RygOQxxp4yjDikrIp4I2VnBN8BLP5cf/fXmyHdBqX1StgT0wK5OXrpHHW7lvamJR2RoRmKmUWrcLdpSa4Fai/Lzq0bDrg0/ckIvd+x8sGmRfLAagYcjoEyyTikrEK8hbJniRntbwA7/Ysjbt3eZJRPUOMAKA6imXo6i4kvmuaoO2mpZktrK0XSp+ZXDNMctciJtgKklvmpZcPhhWO16WqCcIoPNi2waYHcnQ4ED8b2k4WyEPGMsskY95GPQO1weyxPP8to5bM+nPtpgFbqabgw1WWLFxGqpUXJNlvqs2Vr2S2lOiaowV5z/yiZqLU07jjx3Az3Jy2QuhaFfTcoY4gVh2NBmY+4S1ke8XbG/xJs98P69FucHfdl8AVOjuhi6oVaxKBFqlavzbMOX3teqraSw6GlsK42TNhCL1X1mtfeaeXGISsf5NZlF7EizUz+78sKafiCPMl4RtkE8UbKziVwvEPL0R+OtX3uTzF/N2DOYhV6pKqJSCa+ogwtJC1ClYzJVxKc4YAoF6qjjK61aNJImr4XpqOyltflgQR3shdm7/Z+aYF9l5QZxoYyidhzPrki78C4RVl7GVfYR6DuWOshnt8P3pWY/tG8CT1zECBM0cW/1DpPRKhugl8cplDfRCpzV5I7Wii9tuVeMkoZcBjRPHeSpax8kFtjl5zMBGUYsUX+DfTOfEdZGHGXF5df4e8A6azL0e+dZjL8DrFyH3p0JIrPyL5edhoZFzdNF+HaBL90uUj6Q8lakm8iOTtEW+oqpQQnDghz45cWKQOIge7/gL3EhjIZcc7jhSPv2ueA7l+BulOewj4IFQciZVmYZqb71IiD6NrK0Hr4QjPJcaTWbhZZm+ByCs64L5FKMwn16ASxGynLAcvsADeLHf6EaK0GgjKJWFHGGLcoaxkPKDtEfAblITyGfwXqzzQOevsgBOG+OR5Hxz2Hnpgo8ZV9e7ZxUGJYvrylvRCd7k1ZwKTaOpxJJaOZ7lgo1vWydIXRAXuz+GDTInkgYkUZQ1xS5sd4QNmB8RbKnqtYkP4VSD/T57CboY/uftAsk32MThd6wpqOMglczFEBosuaXcIxVT4v7c5U1wVnpJ6XrCX52tjBSKVcWarjdmc2piYIf2yB3J0OBGUSsacMM16nbIh4L+/buf0R3E6tn2wrNbqZ1KqrsuPROX7aQjPwZdpF50itDk02Zi1tMzUtxCQk26mVy+haTbI5+hmfaXY4zVLCdL/r00/dOXlsP0mO5yf/KyBSdpjG65QNS7yP/r8D9Cfbgp+CGDHp3ezQLE4XeiwQMuZahGrQmVJLWDlzdM3QWmhBh02yndZaKOzGTCP5sZXAsZmTPcH9OfsuiIFbYxG3KGsZ76VsHvG96N4BWsRZ7w89yzbQj8G3MoWZelzCxJfpLKSRJr2lXzuHRWuphdaopaJQ34RqM1iyID5j2VyFkwxLndOx8kG0pl1wOQDyzGZsz1s2yZQNx/j+9I/bvwMg8olP2m4MRB7ou8VEmKnnpkWUMwGag+xCLltH3eaQom2AX1ylWMvrVrrTyhyZqQlWPti0yH4gupuZKWVhjgeUHUr8QMoziSBezt4B+Ndw/pu4HHqWmiddDS4UreesRZQrwWLmS0uf+uiImR2w0CKSb8GqlPxKjhGmR3sgRaroFsIfW2Q/sO9OSUvs/4WfV0i7Wfw8PHpiwztACRzuOO5+0O2uiCPeR+fzXIb2Eo/azNxKvqBF8aXDQkW0zMHVTS26JdA0m4bUUqKU6tAuZtD5OQorn0T3cuCEGD5fMqXsw/ixlCdT4hH6DqB/5lrwBFNEGaFOedwIzjRHT96o7fTrEexaU589oKL5LqIlVzhmiWMD0S1aLzGfuwbLZMqVSzzPYSvHlMPuaiDIk5fDI2W5xvX/Zu4V+se6EZ/A4j+EbSLeELTMN4kNMPTwZW1j9KMbZfbXpVyAitKSLnFTGzS0q1pKas5I7cGkuu1GOFBMEH6OPfuxfTeIscvJkbz2wfK7lIdD/EzYR6A4xBL+619ayBpiprMeweU19GwhZAZ/Z3DSz2V0dyXyqnQhFxAidYsZGkLKwFvmeRnY2t40Z/TD8G5bnsNHGkN3zuHYlFfW3iI/EOPnZvYfwhB6+pe/3f3XfxMeMV9X8dSOInIpNcsFsEy+iXDc5LCEO2YClq5ZWqWlOGY0x8q4JLMjWquBkfP5w7FCrHqwdqTstonfFuX/KD6f3ey34I2xDpnRk2RBHU6U2U8mn1NkmiJlQhzLIDsu6lZAu7aJl7zy0iYBu9kBbhY7fDZqF6QBeZQSe84nM89WTclbvb7bd6M87cvAoZWPNzy++iFHjjh/r9NX08LHbHmIHHpQOh3OptSMr9GUfCy0kO9KUN0MV3Kl1tLQHVzaxcZ6aMYwaJLzETPEzjOrOMD+pwr9quX/fuGEfqufjvz0VnGf9hGIO8QpZ46dJaYnPpYg/ON+aBwUG6OIXEo8kdxixIAKgcVegFiu2pUg+7gGVibHyuSYHHxw3QLRjXgL93eb3xuxT9rqpbvodfJTyvE5+Eeg+AWfHhERZo1xPg5r0jaTb4bIpVwMaCFPtPhNRCuZukDDYavRlyJ1PjwTajY3CH9sgX33MW/ZNm/yyj63KA+6j++L/CuQHVM+gfRRh1l+8cfv/sWbAI9d1RSeZbfeiUDdTM+qvMxdtojVSYCkbW1p6T4Gu61WfCwwOfiNaE27I3n+MB7zlk1ukR/xuz3oI7qPQN2hh6PZBtKv/F3EpyAe1iGvfMkReF7ZVKGu5qFlYqYbdNvVlGlF5ltbMDn4jU2rEJOH86/wPR+LfP9HfBN6A/Cg+xEXncowl+8D+cwlYTcDzZR394BmXEoJpAxfHS1UgJUGXtqVF3fs4g658MHQmhNjl5Mr8g4RI5cDn8H3f8RPoL0DMHC4850gZz2/D4wRv/KTIwtT5kx2NhmI1lK/WilddczUKrrqtgFBS3pi28Ww3dxpnd7vUF8W7tnssCFW5ZhSZhDvY/cX8Kc96A/E/gjmoZfTr4fYDn28CYRwbT+EdLxMa7a7IjnIsgpaQ1qzACI045KXy0WTOGpqIabgZhvw0l3OKdrN5LG+I8gwY4PPlJ0v8FUSn8nzf9j5Xs/wR9H/DZBFPuiI/mMPJ1v4iUe2k6e53gN9OckuQJT61Qa8YFKHJsgaTEvuGbg5YjvPWsDs7cyEmL+16nv+0+TTZ/gboHxrGjiTfoh54pE1OEBtAz5jwUOPMZ5Fz2yFI2MQjGF4kvsSl/D5PVgrvh9eR1+Uo2W1vWgONf3sFmJgM5O5O38X3/zh/4TTl1v81infSykH7B0AXcl+vlm2464i9pFI58lmNKLF2yPOZdwSYcZdgYYIPBfNzRGriTamWkq9+kVJvgSXxCSJtldG74/I0xgGclWXzuZfIjYskSmtk/iNUr6LiEwpZ9Q/ghFYJWI49DHQRf8rfywpLEdks28BmlOBS9ZS8spLUEoymFLRVD83TevDxcCK1ozh7fwpebe3bPhb5xN+Gn4D6L/2QMRHoKY5oDMmeMoxwPOnuZhy9LMYb4ZVVoGvpRg0lV29bNAZTOxQzWC6ZEUMH85vyFu9vtt9fvD/CGLKJ/9A9F+B4mSn4z43EXryKMRMWVobEaXmEiCyBMsipG1dHe00w6/JLORVCXE4P/am3BreEPvc2epnPKmvk38UEZ9M9xEIDyfH3d8NwpTgP4zOgucJOW6DLKKVy0lOJb4g5BqCX+yqtsmiCSfVbEGnTJIYciYzDnYow0+ITfp98rH+fR7xIP8EIn4E7SOQhT4TmpNDrye7CT1PVvLADUKyO11OPpCspWXOuKBpwn3qIAY66BSTpNa034jJi7ktb9nk+5CfaolnlE0QPw12A+ApUUjwNuCbAHMJPf08iKJZuqaILoXkEmrikssi2JWrTqqhuK9SvxjtmlUP/dSaTgl8FG0vZ/ZwuW/yo9i9meRnGLGhTCKmnMz8HHQfgeQc59MfwdIPOsMcPak4KKElU3uYo2McnmQV+IKQq7i9I6mVKvVLx9xzp9UOh0Z/gA99Mjknlj/e4fPIz43xOmVDxm8HvQHi0POg96ffvik/Z3LQmXmmQ+uA5KJjrZYRsER4tyuldlOk674UR0siq1JtFS/JL1gnxtaTO15c/knkZ8X4YuBbPfT83M+bITRbEXqsEThzonnK1acTGkIyzShzxsVLfFmpjpRhUo8lpJaswzRHx5o5kNfeJtY+W/6A/IgncZPf+Z/dC9JHoP4ffxD4GZrWI15FBCZVWNYudJjycrhjQSf8KFXgkgWQrJOkleq43ZkZehY6wxiZeU7bYr72DaSHmMQXn0D9G8B+9+sPvPMRetYlx0HXwGngQc9ZhLaaw9JNBAqWWYDm6FOMUjS/WMTVd/NqBgfmvTkyG6vuLMzs1uXNGS/wa/7+fp1vf8QXD70GXgU5uH4bSOhRbponO3QKnEJpTcUqu5CLOyIkySWXHDOtOQZUNpqGYpwTS26tOiHv/PbNv3jE8h2ghh7lpj1w/iKjZUKdXeiknAE9ClbqmaAWkwOpZLc4Utq1Ceu2+godvrfkEu6W44ufD78BeO716OOVMrNEOtxZWPYBlPJyc0YFyy5HoMSzcAFHayb1+9JiSnR9YDVoDPMvkXdjfPFbYPYOEDnCT3NXpsDLLdnDzEUIEDwnNNVpJgfoeylOlDmzxdr9oJQctugZjEa06gz3YfysfP1tsEdvAP3dj8/99q9A5fRHxIlPJU4etQjvytnV8zrPKrSQZxCOVuab1i6LcBr9ZFAc24FxzHw2bzWf+BS+wyH+Ze8TewfAq0kxOf1xsvuIJThh5pyEzmdhSO1+KolfrSW+TmZKKTVjbA3sBmKfy11mfP0C/slJ/yFMA6+ynfsx0ukvwaPM42slDsw0F9FrQVUrk4+x5iY6T2dksme2bo1uYvE5vHJjfN1Ub8Q/AvGIU+cyH/RS6jkrDiJMOdYROEvMeMw4VVY7MWm1IFqtMClyFjjT6tRyRoeIr8tbfPHLMPlXoEmk813CzjcDhycJLCymFkzeCs2BBM3ilhlfb9Ul3aAuHB/iO/P16/zH4v8hzM5DOvQIPeJ/RPxBchx6BM5NLhk8sl1gT8+48CGiJdAq6ECmjnBVckPWyQIf2p/AxfAn8HXcfzaGd4DyJjCc8oh2khg+LAcrsguQHdbWzZEHFPoELdZ0cp5iLV1i8cUvznAY0t8As6Mv7w9+4vkmgFMYTo44u5EBzRD2oFkTWaDRE/PTbqHrx5KrVV/cJv9sc/zMTJ+klvavQNP/AnDjYw/mQ+fAzi6ErPUJdN2EtNpFiBmKKDt0HhsG87Ernq36XaE/yXlM+Qk/210+Z4AzbOeeocPi8Pe9ioi4H+zUanQllnvWzZvAF1vEWlHTiQjlJNkhvu5c5n81Xjp+8f+DfI5D8MCMn4T734L/DaBLuncAP/TlfaAEDp+s5fmOcAc0Rx+PLRZhGqw7S8hG04vhL3bEDy3HA36ec//y9yI3gP2Pn/W/gsmHfn74SR+B/vhNBbMHTzaFZOzjB70IYJmul0Q89wvFtjF9xCkL+5fEf1ZdvEIc+h977t/4HSn6NwD/V0Dx6x8HevgDAIFjx8wwjadRsj4tyeqI1i/zWXqOmlevmhByIzEYjdzajP203Dtj/OGUeJ184u89ofdRvinEu/GPQHH6GX7oy22AQxxCNJ6Sa3l6kSn0AaChTGsWaLpfMFNnYmI6+csRP5Mca+6d23zc7618B+WbYnw+/kewPhxPPw49z7188vnm90D6/IODy2yBtS7w1Z65mnpNWduajBAGe72bqzLPspi/E/BdlXgvP+rEl2+K8YOQj0D2P4Tmm4Cfcvvcjxg++jPL0y5ZhZB0yzLkukc67I69X4T49nO8l3LcEZ9N+XYifib8HcA/AvHXv70DxLn3ewDHlDkL+Y70u5LvLpz0zcKJgYyUbM26wcr/rRLfco63U8464vMo30vEbwG5Afhs5fRr5omX04+8+OQjq/Sgs7TvV76EVmqX8Noyu1oG6nXsy0OerXoP/JZyLHjpiOaDzng75bvI8VvG/hUoPv+0d4D+I5Acep51PbVdpgiNXe3CJFCwhUnJ6oAQgfYtVqxamyWfTjzpHJ9BOeuIN1Kef8TvFH0H8M8/dtwZPP1+7plF6Bi1UH46WtILW0SxPp/Pfaj4dnJ8BuWgM16kPO0Svxjf+Bcw74H49S/R3wa8B7qjjx9XOusSXmZkWK3ig3DG1s8Fv4Ucn0E55YzHlCec44uEfwTir3+NOPq4DT6+yQmmb+dbf4Ki/biLYZcOzpi2q4lhduKM7Fed7HANdhnjvZQjHvGA8jxzfHEGjrr/+uc7gB/98uvfjrv+ZE3reiqWFj5/wtnUBc83sWec4r2UI864RXl6Jb54GfsIxHcAnH4GTz9+/bfTz8CPnRlLw+FOoCsa4c2ajX03cz7ZgWUl3kg55YxDyrPK8cUn0z4CydFf/e7nQdeXxF6XEErMjIwmnenwhrvzsqDEWyhHPGJPeSYlvvhx6DsAf/3z84//F4DuNsDL5Cc+bgPCox/YTIog6xUnM3Pi8SJepJzviA3lCeR4gf1jfvEi9hGIpz9//pFzz8Ar6CeeZ71pqnZ9wpO1fOgcr5DPd8SK8rg5vvgNIjfA/A+A/vSzBJKydrIe2XcvkYfL8Zhyyhkj5eFyfPH7wm6AdvT565/3AF5xfcnjuMtVfZaRz7lcKya+StylHPGITHmIHF/8Mnz7+Gu5Af4Uv/7jww9OQr4H+OWnf8qqtVli6M4tblGOOCOje8p3UeKLL+wdgJ9//uhvAv3pZ8ZFk0GRM8n6AoxGnFMOOiLIG+b4CchP84ufim9/+Gv5C/hP+fSnEDTngzQeqk23lVA5LsmnPAKUfSJ+Dfgz+OJdfMNPlB9+5Aboj76cK+j7p6vNc/HVFtLMp5zBBp9Mji++eB/yDiC//v8ov/75v/yxQ784beFRTEZ0YeyTaWU56whdxbCHRnzx+eBn/ysjfwPEDVD+/B1ZnsnLU5vPOiKGI7744kcgH4HsDwAefXh+HFl61QQQHe3cCPJxB3l4Ov/FFz8C/N7/w5/+JDeA/NZnDEe0c1iUCZCPO4ixcfKLL34avuEXP94B4vQvmZ7mfOinA1988XPzTf75H38A+OmPA9xOcjnW01/zX3zx2+TbX/xJ//1HP/l05MM9Hvovvvhd8O0v/kL/DtAzzYMtbwVUce7D+eKL3xdyA7Rf//noQ36d+y9+73z7G38jnf78OeeLL34Bvv0Rn38A3wS+zv0Xvxjf+I8/X3zxa6K//7/ugS9+Tf7wh/8IWJPIB1GI308AAAAASUVORK5CYII=";
  99987. return TextureTools;
  99988. }());
  99989. /***/ }),
  99990. /***/ "./Misc/tga.ts":
  99991. /*!*********************!*\
  99992. !*** ./Misc/tga.ts ***!
  99993. \*********************/
  99994. /*! exports provided: TGATools */
  99995. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99996. "use strict";
  99997. __webpack_require__.r(__webpack_exports__);
  99998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  99999. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100000. /**
  100001. * Based on jsTGALoader - Javascript loader for TGA file
  100002. * By Vincent Thibault
  100003. * @see http://blog.robrowser.com/javascript-tga-loader.html
  100004. */
  100005. var TGATools = /** @class */ (function () {
  100006. function TGATools() {
  100007. }
  100008. /**
  100009. * Gets the header of a TGA file
  100010. * @param data defines the TGA data
  100011. * @returns the header
  100012. */
  100013. TGATools.GetTGAHeader = function (data) {
  100014. var offset = 0;
  100015. var header = {
  100016. id_length: data[offset++],
  100017. colormap_type: data[offset++],
  100018. image_type: data[offset++],
  100019. colormap_index: data[offset++] | data[offset++] << 8,
  100020. colormap_length: data[offset++] | data[offset++] << 8,
  100021. colormap_size: data[offset++],
  100022. origin: [
  100023. data[offset++] | data[offset++] << 8,
  100024. data[offset++] | data[offset++] << 8
  100025. ],
  100026. width: data[offset++] | data[offset++] << 8,
  100027. height: data[offset++] | data[offset++] << 8,
  100028. pixel_size: data[offset++],
  100029. flags: data[offset++]
  100030. };
  100031. return header;
  100032. };
  100033. /**
  100034. * Uploads TGA content to a Babylon Texture
  100035. * @hidden
  100036. */
  100037. TGATools.UploadContent = function (texture, data) {
  100038. // Not enough data to contain header ?
  100039. if (data.length < 19) {
  100040. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  100041. return;
  100042. }
  100043. // Read Header
  100044. var offset = 18;
  100045. var header = TGATools.GetTGAHeader(data);
  100046. // Assume it's a valid Targa file.
  100047. if (header.id_length + offset > data.length) {
  100048. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  100049. return;
  100050. }
  100051. // Skip not needed data
  100052. offset += header.id_length;
  100053. var use_rle = false;
  100054. var use_pal = false;
  100055. var use_grey = false;
  100056. // Get some informations.
  100057. switch (header.image_type) {
  100058. case TGATools._TYPE_RLE_INDEXED:
  100059. use_rle = true;
  100060. case TGATools._TYPE_INDEXED:
  100061. use_pal = true;
  100062. break;
  100063. case TGATools._TYPE_RLE_RGB:
  100064. use_rle = true;
  100065. case TGATools._TYPE_RGB:
  100066. // use_rgb = true;
  100067. break;
  100068. case TGATools._TYPE_RLE_GREY:
  100069. use_rle = true;
  100070. case TGATools._TYPE_GREY:
  100071. use_grey = true;
  100072. break;
  100073. }
  100074. var pixel_data;
  100075. // var numAlphaBits = header.flags & 0xf;
  100076. var pixel_size = header.pixel_size >> 3;
  100077. var pixel_total = header.width * header.height * pixel_size;
  100078. // Read palettes
  100079. var palettes;
  100080. if (use_pal) {
  100081. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  100082. }
  100083. // Read LRE
  100084. if (use_rle) {
  100085. pixel_data = new Uint8Array(pixel_total);
  100086. var c, count, i;
  100087. var localOffset = 0;
  100088. var pixels = new Uint8Array(pixel_size);
  100089. while (offset < pixel_total && localOffset < pixel_total) {
  100090. c = data[offset++];
  100091. count = (c & 0x7f) + 1;
  100092. // RLE pixels
  100093. if (c & 0x80) {
  100094. // Bind pixel tmp array
  100095. for (i = 0; i < pixel_size; ++i) {
  100096. pixels[i] = data[offset++];
  100097. }
  100098. // Copy pixel array
  100099. for (i = 0; i < count; ++i) {
  100100. pixel_data.set(pixels, localOffset + i * pixel_size);
  100101. }
  100102. localOffset += pixel_size * count;
  100103. }
  100104. // Raw pixels
  100105. else {
  100106. count *= pixel_size;
  100107. for (i = 0; i < count; ++i) {
  100108. pixel_data[localOffset + i] = data[offset++];
  100109. }
  100110. localOffset += count;
  100111. }
  100112. }
  100113. }
  100114. // RAW Pixels
  100115. else {
  100116. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  100117. }
  100118. // Load to texture
  100119. var x_start, y_start, x_step, y_step, y_end, x_end;
  100120. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  100121. default:
  100122. case TGATools._ORIGIN_UL:
  100123. x_start = 0;
  100124. x_step = 1;
  100125. x_end = header.width;
  100126. y_start = 0;
  100127. y_step = 1;
  100128. y_end = header.height;
  100129. break;
  100130. case TGATools._ORIGIN_BL:
  100131. x_start = 0;
  100132. x_step = 1;
  100133. x_end = header.width;
  100134. y_start = header.height - 1;
  100135. y_step = -1;
  100136. y_end = -1;
  100137. break;
  100138. case TGATools._ORIGIN_UR:
  100139. x_start = header.width - 1;
  100140. x_step = -1;
  100141. x_end = -1;
  100142. y_start = 0;
  100143. y_step = 1;
  100144. y_end = header.height;
  100145. break;
  100146. case TGATools._ORIGIN_BR:
  100147. x_start = header.width - 1;
  100148. x_step = -1;
  100149. x_end = -1;
  100150. y_start = header.height - 1;
  100151. y_step = -1;
  100152. y_end = -1;
  100153. break;
  100154. }
  100155. // Load the specify method
  100156. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  100157. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  100158. var engine = texture.getEngine();
  100159. engine._uploadDataToTextureDirectly(texture, imageData);
  100160. };
  100161. /** @hidden */
  100162. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100163. var image = pixel_data, colormap = palettes;
  100164. var width = header.width, height = header.height;
  100165. var color, i = 0, x, y;
  100166. var imageData = new Uint8Array(width * height * 4);
  100167. for (y = y_start; y !== y_end; y += y_step) {
  100168. for (x = x_start; x !== x_end; x += x_step, i++) {
  100169. color = image[i];
  100170. imageData[(x + width * y) * 4 + 3] = 255;
  100171. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  100172. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  100173. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  100174. }
  100175. }
  100176. return imageData;
  100177. };
  100178. /** @hidden */
  100179. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100180. var image = pixel_data;
  100181. var width = header.width, height = header.height;
  100182. var color, i = 0, x, y;
  100183. var imageData = new Uint8Array(width * height * 4);
  100184. for (y = y_start; y !== y_end; y += y_step) {
  100185. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  100186. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  100187. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  100188. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  100189. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  100190. imageData[(x + width * y) * 4 + 0] = r;
  100191. imageData[(x + width * y) * 4 + 1] = g;
  100192. imageData[(x + width * y) * 4 + 2] = b;
  100193. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  100194. }
  100195. }
  100196. return imageData;
  100197. };
  100198. /** @hidden */
  100199. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100200. var image = pixel_data;
  100201. var width = header.width, height = header.height;
  100202. var i = 0, x, y;
  100203. var imageData = new Uint8Array(width * height * 4);
  100204. for (y = y_start; y !== y_end; y += y_step) {
  100205. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  100206. imageData[(x + width * y) * 4 + 3] = 255;
  100207. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  100208. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  100209. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  100210. }
  100211. }
  100212. return imageData;
  100213. };
  100214. /** @hidden */
  100215. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100216. var image = pixel_data;
  100217. var width = header.width, height = header.height;
  100218. var i = 0, x, y;
  100219. var imageData = new Uint8Array(width * height * 4);
  100220. for (y = y_start; y !== y_end; y += y_step) {
  100221. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  100222. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  100223. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  100224. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  100225. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  100226. }
  100227. }
  100228. return imageData;
  100229. };
  100230. /** @hidden */
  100231. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100232. var image = pixel_data;
  100233. var width = header.width, height = header.height;
  100234. var color, i = 0, x, y;
  100235. var imageData = new Uint8Array(width * height * 4);
  100236. for (y = y_start; y !== y_end; y += y_step) {
  100237. for (x = x_start; x !== x_end; x += x_step, i++) {
  100238. color = image[i];
  100239. imageData[(x + width * y) * 4 + 0] = color;
  100240. imageData[(x + width * y) * 4 + 1] = color;
  100241. imageData[(x + width * y) * 4 + 2] = color;
  100242. imageData[(x + width * y) * 4 + 3] = 255;
  100243. }
  100244. }
  100245. return imageData;
  100246. };
  100247. /** @hidden */
  100248. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  100249. var image = pixel_data;
  100250. var width = header.width, height = header.height;
  100251. var i = 0, x, y;
  100252. var imageData = new Uint8Array(width * height * 4);
  100253. for (y = y_start; y !== y_end; y += y_step) {
  100254. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  100255. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  100256. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  100257. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  100258. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  100259. }
  100260. }
  100261. return imageData;
  100262. };
  100263. //private static _TYPE_NO_DATA = 0;
  100264. TGATools._TYPE_INDEXED = 1;
  100265. TGATools._TYPE_RGB = 2;
  100266. TGATools._TYPE_GREY = 3;
  100267. TGATools._TYPE_RLE_INDEXED = 9;
  100268. TGATools._TYPE_RLE_RGB = 10;
  100269. TGATools._TYPE_RLE_GREY = 11;
  100270. TGATools._ORIGIN_MASK = 0x30;
  100271. TGATools._ORIGIN_SHIFT = 0x04;
  100272. TGATools._ORIGIN_BL = 0x00;
  100273. TGATools._ORIGIN_BR = 0x01;
  100274. TGATools._ORIGIN_UL = 0x02;
  100275. TGATools._ORIGIN_UR = 0x03;
  100276. return TGATools;
  100277. }());
  100278. /***/ }),
  100279. /***/ "./Misc/tools.ts":
  100280. /*!***********************!*\
  100281. !*** ./Misc/tools.ts ***!
  100282. \***********************/
  100283. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  100284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100285. "use strict";
  100286. __webpack_require__.r(__webpack_exports__);
  100287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  100288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  100289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  100290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  100291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  100292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  100293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  100294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  100295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  100296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100297. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100298. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100299. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  100300. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  100301. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  100302. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  100303. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  100304. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  100305. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  100306. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  100307. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  100308. /** Class used to store color4 gradient */
  100309. var ColorGradient = /** @class */ (function () {
  100310. function ColorGradient() {
  100311. }
  100312. /**
  100313. * Will get a color picked randomly between color1 and color2.
  100314. * If color2 is undefined then color1 will be used
  100315. * @param result defines the target Color4 to store the result in
  100316. */
  100317. ColorGradient.prototype.getColorToRef = function (result) {
  100318. if (!this.color2) {
  100319. result.copyFrom(this.color1);
  100320. return;
  100321. }
  100322. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  100323. };
  100324. return ColorGradient;
  100325. }());
  100326. /** Class used to store color 3 gradient */
  100327. var Color3Gradient = /** @class */ (function () {
  100328. function Color3Gradient() {
  100329. }
  100330. return Color3Gradient;
  100331. }());
  100332. /** Class used to store factor gradient */
  100333. var FactorGradient = /** @class */ (function () {
  100334. function FactorGradient() {
  100335. }
  100336. /**
  100337. * Will get a number picked randomly between factor1 and factor2.
  100338. * If factor2 is undefined then factor1 will be used
  100339. * @returns the picked number
  100340. */
  100341. FactorGradient.prototype.getFactor = function () {
  100342. if (this.factor2 === undefined) {
  100343. return this.factor1;
  100344. }
  100345. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  100346. };
  100347. return FactorGradient;
  100348. }());
  100349. /**
  100350. * @ignore
  100351. * Application error to support additional information when loading a file
  100352. */
  100353. var LoadFileError = /** @class */ (function (_super) {
  100354. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  100355. /**
  100356. * Creates a new LoadFileError
  100357. * @param message defines the message of the error
  100358. * @param request defines the optional XHR request
  100359. */
  100360. function LoadFileError(message,
  100361. /** defines the optional XHR request */
  100362. request) {
  100363. var _this = _super.call(this, message) || this;
  100364. _this.request = request;
  100365. _this.name = "LoadFileError";
  100366. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  100367. return _this;
  100368. }
  100369. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  100370. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  100371. // Polyfill for Object.setPrototypeOf if necessary.
  100372. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  100373. return LoadFileError;
  100374. }(Error));
  100375. /**
  100376. * Class used to define a retry strategy when error happens while loading assets
  100377. */
  100378. var RetryStrategy = /** @class */ (function () {
  100379. function RetryStrategy() {
  100380. }
  100381. /**
  100382. * Function used to defines an exponential back off strategy
  100383. * @param maxRetries defines the maximum number of retries (3 by default)
  100384. * @param baseInterval defines the interval between retries
  100385. * @returns the strategy function to use
  100386. */
  100387. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  100388. if (maxRetries === void 0) { maxRetries = 3; }
  100389. if (baseInterval === void 0) { baseInterval = 500; }
  100390. return function (url, request, retryIndex) {
  100391. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  100392. return -1;
  100393. }
  100394. return Math.pow(2, retryIndex) * baseInterval;
  100395. };
  100396. };
  100397. return RetryStrategy;
  100398. }());
  100399. /**
  100400. * Class containing a set of static utilities functions
  100401. */
  100402. var Tools = /** @class */ (function () {
  100403. function Tools() {
  100404. }
  100405. /**
  100406. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100407. * @param u defines the coordinate on X axis
  100408. * @param v defines the coordinate on Y axis
  100409. * @param width defines the width of the source data
  100410. * @param height defines the height of the source data
  100411. * @param pixels defines the source byte array
  100412. * @param color defines the output color
  100413. */
  100414. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  100415. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  100416. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  100417. var position = (wrappedU + wrappedV * width) * 4;
  100418. color.r = pixels[position] / 255;
  100419. color.g = pixels[position + 1] / 255;
  100420. color.b = pixels[position + 2] / 255;
  100421. color.a = pixels[position + 3] / 255;
  100422. };
  100423. /**
  100424. * Interpolates between a and b via alpha
  100425. * @param a The lower value (returned when alpha = 0)
  100426. * @param b The upper value (returned when alpha = 1)
  100427. * @param alpha The interpolation-factor
  100428. * @return The mixed value
  100429. */
  100430. Tools.Mix = function (a, b, alpha) {
  100431. return a * (1 - alpha) + b * alpha;
  100432. };
  100433. /**
  100434. * Tries to instantiate a new object from a given class name
  100435. * @param className defines the class name to instantiate
  100436. * @returns the new object or null if the system was not able to do the instantiation
  100437. */
  100438. Tools.Instantiate = function (className) {
  100439. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  100440. return Tools.RegisteredExternalClasses[className];
  100441. }
  100442. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  100443. if (internalClass) {
  100444. return internalClass;
  100445. }
  100446. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  100447. var arr = className.split(".");
  100448. var fn = (window || this);
  100449. for (var i = 0, len = arr.length; i < len; i++) {
  100450. fn = fn[arr[i]];
  100451. }
  100452. if (typeof fn !== "function") {
  100453. return null;
  100454. }
  100455. return fn;
  100456. };
  100457. /**
  100458. * Provides a slice function that will work even on IE
  100459. * @param data defines the array to slice
  100460. * @param start defines the start of the data (optional)
  100461. * @param end defines the end of the data (optional)
  100462. * @returns the new sliced array
  100463. */
  100464. Tools.Slice = function (data, start, end) {
  100465. if (data.slice) {
  100466. return data.slice(start, end);
  100467. }
  100468. return Array.prototype.slice.call(data, start, end);
  100469. };
  100470. /**
  100471. * Polyfill for setImmediate
  100472. * @param action defines the action to execute after the current execution block
  100473. */
  100474. Tools.SetImmediate = function (action) {
  100475. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  100476. window.setImmediate(action);
  100477. }
  100478. else {
  100479. setTimeout(action, 1);
  100480. }
  100481. };
  100482. /**
  100483. * Function indicating if a number is an exponent of 2
  100484. * @param value defines the value to test
  100485. * @returns true if the value is an exponent of 2
  100486. */
  100487. Tools.IsExponentOfTwo = function (value) {
  100488. var count = 1;
  100489. do {
  100490. count *= 2;
  100491. } while (count < value);
  100492. return count === value;
  100493. };
  100494. /**
  100495. * Returns the nearest 32-bit single precision float representation of a Number
  100496. * @param value A Number. If the parameter is of a different type, it will get converted
  100497. * to a number or to NaN if it cannot be converted
  100498. * @returns number
  100499. */
  100500. Tools.FloatRound = function (value) {
  100501. if (Math.fround) {
  100502. return Math.fround(value);
  100503. }
  100504. return (Tools._tmpFloatArray[0] = value);
  100505. };
  100506. /**
  100507. * Find the next highest power of two.
  100508. * @param x Number to start search from.
  100509. * @return Next highest power of two.
  100510. */
  100511. Tools.CeilingPOT = function (x) {
  100512. x--;
  100513. x |= x >> 1;
  100514. x |= x >> 2;
  100515. x |= x >> 4;
  100516. x |= x >> 8;
  100517. x |= x >> 16;
  100518. x++;
  100519. return x;
  100520. };
  100521. /**
  100522. * Find the next lowest power of two.
  100523. * @param x Number to start search from.
  100524. * @return Next lowest power of two.
  100525. */
  100526. Tools.FloorPOT = function (x) {
  100527. x = x | (x >> 1);
  100528. x = x | (x >> 2);
  100529. x = x | (x >> 4);
  100530. x = x | (x >> 8);
  100531. x = x | (x >> 16);
  100532. return x - (x >> 1);
  100533. };
  100534. /**
  100535. * Find the nearest power of two.
  100536. * @param x Number to start search from.
  100537. * @return Next nearest power of two.
  100538. */
  100539. Tools.NearestPOT = function (x) {
  100540. var c = Tools.CeilingPOT(x);
  100541. var f = Tools.FloorPOT(x);
  100542. return (c - x) > (x - f) ? f : c;
  100543. };
  100544. /**
  100545. * Get the closest exponent of two
  100546. * @param value defines the value to approximate
  100547. * @param max defines the maximum value to return
  100548. * @param mode defines how to define the closest value
  100549. * @returns closest exponent of two of the given value
  100550. */
  100551. Tools.GetExponentOfTwo = function (value, max, mode) {
  100552. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  100553. var pot;
  100554. switch (mode) {
  100555. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  100556. pot = Tools.FloorPOT(value);
  100557. break;
  100558. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  100559. pot = Tools.NearestPOT(value);
  100560. break;
  100561. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  100562. default:
  100563. pot = Tools.CeilingPOT(value);
  100564. break;
  100565. }
  100566. return Math.min(pot, max);
  100567. };
  100568. /**
  100569. * Extracts the filename from a path
  100570. * @param path defines the path to use
  100571. * @returns the filename
  100572. */
  100573. Tools.GetFilename = function (path) {
  100574. var index = path.lastIndexOf("/");
  100575. if (index < 0) {
  100576. return path;
  100577. }
  100578. return path.substring(index + 1);
  100579. };
  100580. /**
  100581. * Extracts the "folder" part of a path (everything before the filename).
  100582. * @param uri The URI to extract the info from
  100583. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100584. * @returns The "folder" part of the path
  100585. */
  100586. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  100587. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  100588. var index = uri.lastIndexOf("/");
  100589. if (index < 0) {
  100590. if (returnUnchangedIfNoSlash) {
  100591. return uri;
  100592. }
  100593. return "";
  100594. }
  100595. return uri.substring(0, index + 1);
  100596. };
  100597. /**
  100598. * Convert an angle in radians to degrees
  100599. * @param angle defines the angle to convert
  100600. * @returns the angle in degrees
  100601. */
  100602. Tools.ToDegrees = function (angle) {
  100603. return angle * 180 / Math.PI;
  100604. };
  100605. /**
  100606. * Convert an angle in degrees to radians
  100607. * @param angle defines the angle to convert
  100608. * @returns the angle in radians
  100609. */
  100610. Tools.ToRadians = function (angle) {
  100611. return angle * Math.PI / 180;
  100612. };
  100613. /**
  100614. * Encode a buffer to a base64 string
  100615. * @param buffer defines the buffer to encode
  100616. * @returns the encoded string
  100617. */
  100618. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  100619. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  100620. var output = "";
  100621. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  100622. var i = 0;
  100623. var bytes = new Uint8Array(buffer);
  100624. while (i < bytes.length) {
  100625. chr1 = bytes[i++];
  100626. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  100627. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  100628. enc1 = chr1 >> 2;
  100629. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  100630. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  100631. enc4 = chr3 & 63;
  100632. if (isNaN(chr2)) {
  100633. enc3 = enc4 = 64;
  100634. }
  100635. else if (isNaN(chr3)) {
  100636. enc4 = 64;
  100637. }
  100638. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  100639. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  100640. }
  100641. return "data:image/png;base64," + output;
  100642. };
  100643. /**
  100644. * Extracts minimum and maximum values from a list of indexed positions
  100645. * @param positions defines the positions to use
  100646. * @param indices defines the indices to the positions
  100647. * @param indexStart defines the start index
  100648. * @param indexCount defines the end index
  100649. * @param bias defines bias value to add to the result
  100650. * @return minimum and maximum values
  100651. */
  100652. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  100653. if (bias === void 0) { bias = null; }
  100654. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  100655. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  100656. for (var index = indexStart; index < indexStart + indexCount; index++) {
  100657. var offset = indices[index] * 3;
  100658. var x = positions[offset];
  100659. var y = positions[offset + 1];
  100660. var z = positions[offset + 2];
  100661. minimum.minimizeInPlaceFromFloats(x, y, z);
  100662. maximum.maximizeInPlaceFromFloats(x, y, z);
  100663. }
  100664. if (bias) {
  100665. minimum.x -= minimum.x * bias.x + bias.y;
  100666. minimum.y -= minimum.y * bias.x + bias.y;
  100667. minimum.z -= minimum.z * bias.x + bias.y;
  100668. maximum.x += maximum.x * bias.x + bias.y;
  100669. maximum.y += maximum.y * bias.x + bias.y;
  100670. maximum.z += maximum.z * bias.x + bias.y;
  100671. }
  100672. return {
  100673. minimum: minimum,
  100674. maximum: maximum
  100675. };
  100676. };
  100677. /**
  100678. * Extracts minimum and maximum values from a list of positions
  100679. * @param positions defines the positions to use
  100680. * @param start defines the start index in the positions array
  100681. * @param count defines the number of positions to handle
  100682. * @param bias defines bias value to add to the result
  100683. * @param stride defines the stride size to use (distance between two positions in the positions array)
  100684. * @return minimum and maximum values
  100685. */
  100686. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  100687. if (bias === void 0) { bias = null; }
  100688. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  100689. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  100690. if (!stride) {
  100691. stride = 3;
  100692. }
  100693. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  100694. var x = positions[offset];
  100695. var y = positions[offset + 1];
  100696. var z = positions[offset + 2];
  100697. minimum.minimizeInPlaceFromFloats(x, y, z);
  100698. maximum.maximizeInPlaceFromFloats(x, y, z);
  100699. }
  100700. if (bias) {
  100701. minimum.x -= minimum.x * bias.x + bias.y;
  100702. minimum.y -= minimum.y * bias.x + bias.y;
  100703. minimum.z -= minimum.z * bias.x + bias.y;
  100704. maximum.x += maximum.x * bias.x + bias.y;
  100705. maximum.y += maximum.y * bias.x + bias.y;
  100706. maximum.z += maximum.z * bias.x + bias.y;
  100707. }
  100708. return {
  100709. minimum: minimum,
  100710. maximum: maximum
  100711. };
  100712. };
  100713. /**
  100714. * Returns an array if obj is not an array
  100715. * @param obj defines the object to evaluate as an array
  100716. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100717. * @returns either obj directly if obj is an array or a new array containing obj
  100718. */
  100719. Tools.MakeArray = function (obj, allowsNullUndefined) {
  100720. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  100721. return null;
  100722. }
  100723. return Array.isArray(obj) ? obj : [obj];
  100724. };
  100725. /**
  100726. * Gets the pointer prefix to use
  100727. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100728. */
  100729. Tools.GetPointerPrefix = function () {
  100730. var eventPrefix = "pointer";
  100731. // Check if pointer events are supported
  100732. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  100733. eventPrefix = "mouse";
  100734. }
  100735. return eventPrefix;
  100736. };
  100737. /**
  100738. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100739. * @param func - the function to be called
  100740. * @param requester - the object that will request the next frame. Falls back to window.
  100741. * @returns frame number
  100742. */
  100743. Tools.QueueNewFrame = function (func, requester) {
  100744. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  100745. return setTimeout(func, 16);
  100746. }
  100747. if (!requester) {
  100748. requester = window;
  100749. }
  100750. if (requester.requestAnimationFrame) {
  100751. return requester.requestAnimationFrame(func);
  100752. }
  100753. else if (requester.msRequestAnimationFrame) {
  100754. return requester.msRequestAnimationFrame(func);
  100755. }
  100756. else if (requester.webkitRequestAnimationFrame) {
  100757. return requester.webkitRequestAnimationFrame(func);
  100758. }
  100759. else if (requester.mozRequestAnimationFrame) {
  100760. return requester.mozRequestAnimationFrame(func);
  100761. }
  100762. else if (requester.oRequestAnimationFrame) {
  100763. return requester.oRequestAnimationFrame(func);
  100764. }
  100765. else {
  100766. return window.setTimeout(func, 16);
  100767. }
  100768. };
  100769. /**
  100770. * Ask the browser to promote the current element to fullscreen rendering mode
  100771. * @param element defines the DOM element to promote
  100772. */
  100773. Tools.RequestFullscreen = function (element) {
  100774. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  100775. if (!requestFunction) {
  100776. return;
  100777. }
  100778. requestFunction.call(element);
  100779. };
  100780. /**
  100781. * Asks the browser to exit fullscreen mode
  100782. */
  100783. Tools.ExitFullscreen = function () {
  100784. var anyDoc = document;
  100785. if (document.exitFullscreen) {
  100786. document.exitFullscreen();
  100787. }
  100788. else if (anyDoc.mozCancelFullScreen) {
  100789. anyDoc.mozCancelFullScreen();
  100790. }
  100791. else if (anyDoc.webkitCancelFullScreen) {
  100792. anyDoc.webkitCancelFullScreen();
  100793. }
  100794. else if (anyDoc.msCancelFullScreen) {
  100795. anyDoc.msCancelFullScreen();
  100796. }
  100797. };
  100798. /**
  100799. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100800. * @param url define the url we are trying
  100801. * @param element define the dom element where to configure the cors policy
  100802. */
  100803. Tools.SetCorsBehavior = function (url, element) {
  100804. if (url && url.indexOf("data:") === 0) {
  100805. return;
  100806. }
  100807. if (Tools.CorsBehavior) {
  100808. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  100809. element.crossOrigin = Tools.CorsBehavior;
  100810. }
  100811. else {
  100812. var result = Tools.CorsBehavior(url);
  100813. if (result) {
  100814. element.crossOrigin = result;
  100815. }
  100816. }
  100817. }
  100818. };
  100819. // External files
  100820. /**
  100821. * Removes unwanted characters from an url
  100822. * @param url defines the url to clean
  100823. * @returns the cleaned url
  100824. */
  100825. Tools.CleanUrl = function (url) {
  100826. url = url.replace(/#/mg, "%23");
  100827. return url;
  100828. };
  100829. /**
  100830. * Loads an image as an HTMLImageElement.
  100831. * @param input url string, ArrayBuffer, or Blob to load
  100832. * @param onLoad callback called when the image successfully loads
  100833. * @param onError callback called when the image fails to load
  100834. * @param offlineProvider offline provider for caching
  100835. * @returns the HTMLImageElement of the loaded image
  100836. */
  100837. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  100838. var url;
  100839. var usingObjectURL = false;
  100840. if (input instanceof ArrayBuffer) {
  100841. url = URL.createObjectURL(new Blob([input]));
  100842. usingObjectURL = true;
  100843. }
  100844. else if (input instanceof Blob) {
  100845. url = URL.createObjectURL(input);
  100846. usingObjectURL = true;
  100847. }
  100848. else {
  100849. url = Tools.CleanUrl(input);
  100850. url = Tools.PreprocessUrl(input);
  100851. }
  100852. var img = new Image();
  100853. Tools.SetCorsBehavior(url, img);
  100854. var loadHandler = function () {
  100855. img.removeEventListener("load", loadHandler);
  100856. img.removeEventListener("error", errorHandler);
  100857. onLoad(img);
  100858. // Must revoke the URL after calling onLoad to avoid security exceptions in
  100859. // certain scenarios (e.g. when hosted in vscode).
  100860. if (usingObjectURL && img.src) {
  100861. URL.revokeObjectURL(img.src);
  100862. }
  100863. };
  100864. var errorHandler = function (err) {
  100865. img.removeEventListener("load", loadHandler);
  100866. img.removeEventListener("error", errorHandler);
  100867. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  100868. if (onError) {
  100869. onError("Error while trying to load image: " + input, err);
  100870. }
  100871. if (usingObjectURL && img.src) {
  100872. URL.revokeObjectURL(img.src);
  100873. }
  100874. };
  100875. img.addEventListener("load", loadHandler);
  100876. img.addEventListener("error", errorHandler);
  100877. var noOfflineSupport = function () {
  100878. img.src = url;
  100879. };
  100880. var loadFromOfflineSupport = function () {
  100881. if (offlineProvider) {
  100882. offlineProvider.loadImage(url, img);
  100883. }
  100884. };
  100885. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  100886. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  100887. }
  100888. else {
  100889. if (url.indexOf("file:") !== -1) {
  100890. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  100891. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  100892. try {
  100893. var blobURL;
  100894. try {
  100895. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  100896. }
  100897. catch (ex) {
  100898. // Chrome doesn't support oneTimeOnly parameter
  100899. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  100900. }
  100901. img.src = blobURL;
  100902. usingObjectURL = true;
  100903. }
  100904. catch (e) {
  100905. img.src = "";
  100906. }
  100907. return img;
  100908. }
  100909. }
  100910. noOfflineSupport();
  100911. }
  100912. return img;
  100913. };
  100914. /**
  100915. * Loads a file
  100916. * @param url url string, ArrayBuffer, or Blob to load
  100917. * @param onSuccess callback called when the file successfully loads
  100918. * @param onProgress callback called while file is loading (if the server supports this mode)
  100919. * @param offlineProvider defines the offline provider for caching
  100920. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100921. * @param onError callback called when the file fails to load
  100922. * @returns a file request object
  100923. */
  100924. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  100925. url = Tools.CleanUrl(url);
  100926. url = Tools.PreprocessUrl(url);
  100927. // If file and file input are set
  100928. if (url.indexOf("file:") !== -1) {
  100929. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  100930. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  100931. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  100932. }
  100933. }
  100934. var loadUrl = Tools.BaseUrl + url;
  100935. var aborted = false;
  100936. var fileRequest = {
  100937. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  100938. abort: function () { return aborted = true; },
  100939. };
  100940. var requestFile = function () {
  100941. var request = new XMLHttpRequest();
  100942. var retryHandle = null;
  100943. fileRequest.abort = function () {
  100944. aborted = true;
  100945. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  100946. request.abort();
  100947. }
  100948. if (retryHandle !== null) {
  100949. clearTimeout(retryHandle);
  100950. retryHandle = null;
  100951. }
  100952. };
  100953. var retryLoop = function (retryIndex) {
  100954. request.open('GET', loadUrl, true);
  100955. if (useArrayBuffer) {
  100956. request.responseType = "arraybuffer";
  100957. }
  100958. if (onProgress) {
  100959. request.addEventListener("progress", onProgress);
  100960. }
  100961. var onLoadEnd = function () {
  100962. request.removeEventListener("loadend", onLoadEnd);
  100963. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  100964. fileRequest.onCompleteObservable.clear();
  100965. };
  100966. request.addEventListener("loadend", onLoadEnd);
  100967. var onReadyStateChange = function () {
  100968. if (aborted) {
  100969. return;
  100970. }
  100971. // In case of undefined state in some browsers.
  100972. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  100973. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  100974. request.removeEventListener("readystatechange", onReadyStateChange);
  100975. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  100976. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  100977. return;
  100978. }
  100979. var retryStrategy = Tools.DefaultRetryStrategy;
  100980. if (retryStrategy) {
  100981. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  100982. if (waitTime !== -1) {
  100983. // Prevent the request from completing for retry.
  100984. request.removeEventListener("loadend", onLoadEnd);
  100985. request = new XMLHttpRequest();
  100986. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  100987. return;
  100988. }
  100989. }
  100990. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  100991. if (onError) {
  100992. onError(request, e);
  100993. }
  100994. else {
  100995. throw e;
  100996. }
  100997. }
  100998. };
  100999. request.addEventListener("readystatechange", onReadyStateChange);
  101000. if (Tools.UseCustomRequestHeaders) {
  101001. Tools.InjectCustomRequestHeaders(request);
  101002. }
  101003. request.send();
  101004. };
  101005. retryLoop(0);
  101006. };
  101007. // Caching all files
  101008. if (offlineProvider && offlineProvider.enableSceneOffline) {
  101009. var noOfflineSupport_1 = function (request) {
  101010. if (request && request.status > 400) {
  101011. if (onError) {
  101012. onError(request);
  101013. }
  101014. }
  101015. else {
  101016. if (!aborted) {
  101017. requestFile();
  101018. }
  101019. }
  101020. };
  101021. var loadFromOfflineSupport = function () {
  101022. // TODO: database needs to support aborting and should return a IFileRequest
  101023. if (aborted) {
  101024. return;
  101025. }
  101026. if (offlineProvider) {
  101027. offlineProvider.loadFile(url, function (data) {
  101028. if (!aborted) {
  101029. onSuccess(data);
  101030. }
  101031. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  101032. }, onProgress ? function (event) {
  101033. if (!aborted) {
  101034. onProgress(event);
  101035. }
  101036. } : undefined, noOfflineSupport_1, useArrayBuffer);
  101037. }
  101038. };
  101039. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  101040. }
  101041. else {
  101042. requestFile();
  101043. }
  101044. return fileRequest;
  101045. };
  101046. /**
  101047. * Load a script (identified by an url). When the url returns, the
  101048. * content of this file is added into a new script element, attached to the DOM (body element)
  101049. * @param scriptUrl defines the url of the script to laod
  101050. * @param onSuccess defines the callback called when the script is loaded
  101051. * @param onError defines the callback to call if an error occurs
  101052. */
  101053. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  101054. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  101055. return;
  101056. }
  101057. var head = document.getElementsByTagName('head')[0];
  101058. var script = document.createElement('script');
  101059. script.type = 'text/javascript';
  101060. script.src = scriptUrl;
  101061. script.onload = function () {
  101062. if (onSuccess) {
  101063. onSuccess();
  101064. }
  101065. };
  101066. script.onerror = function (e) {
  101067. if (onError) {
  101068. onError("Unable to load script '" + scriptUrl + "'", e);
  101069. }
  101070. };
  101071. head.appendChild(script);
  101072. };
  101073. /**
  101074. * Loads a file from a blob
  101075. * @param fileToLoad defines the blob to use
  101076. * @param callback defines the callback to call when data is loaded
  101077. * @param progressCallback defines the callback to call during loading process
  101078. * @returns a file request object
  101079. */
  101080. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  101081. var reader = new FileReader();
  101082. var request = {
  101083. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  101084. abort: function () { return reader.abort(); },
  101085. };
  101086. reader.onloadend = function (e) {
  101087. request.onCompleteObservable.notifyObservers(request);
  101088. };
  101089. reader.onload = function (e) {
  101090. //target doesn't have result from ts 1.3
  101091. callback(e.target['result']);
  101092. };
  101093. reader.onprogress = progressCallback;
  101094. reader.readAsDataURL(fileToLoad);
  101095. return request;
  101096. };
  101097. /**
  101098. * Loads a file
  101099. * @param fileToLoad defines the file to load
  101100. * @param callback defines the callback to call when data is loaded
  101101. * @param progressCallBack defines the callback to call during loading process
  101102. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  101103. * @returns a file request object
  101104. */
  101105. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  101106. var reader = new FileReader();
  101107. var request = {
  101108. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  101109. abort: function () { return reader.abort(); },
  101110. };
  101111. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  101112. reader.onerror = function (e) {
  101113. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  101114. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  101115. };
  101116. reader.onload = function (e) {
  101117. //target doesn't have result from ts 1.3
  101118. callback(e.target['result']);
  101119. };
  101120. if (progressCallBack) {
  101121. reader.onprogress = progressCallBack;
  101122. }
  101123. if (!useArrayBuffer) {
  101124. // Asynchronous read
  101125. reader.readAsText(fileToLoad);
  101126. }
  101127. else {
  101128. reader.readAsArrayBuffer(fileToLoad);
  101129. }
  101130. return request;
  101131. };
  101132. /**
  101133. * Creates a data url from a given string content
  101134. * @param content defines the content to convert
  101135. * @returns the new data url link
  101136. */
  101137. Tools.FileAsURL = function (content) {
  101138. var fileBlob = new Blob([content]);
  101139. var url = window.URL || window.webkitURL;
  101140. var link = url.createObjectURL(fileBlob);
  101141. return link;
  101142. };
  101143. /**
  101144. * Format the given number to a specific decimal format
  101145. * @param value defines the number to format
  101146. * @param decimals defines the number of decimals to use
  101147. * @returns the formatted string
  101148. */
  101149. Tools.Format = function (value, decimals) {
  101150. if (decimals === void 0) { decimals = 2; }
  101151. return value.toFixed(decimals);
  101152. };
  101153. /**
  101154. * Checks if a given vector is inside a specific range
  101155. * @param v defines the vector to test
  101156. * @param min defines the minimum range
  101157. * @param max defines the maximum range
  101158. */
  101159. Tools.CheckExtends = function (v, min, max) {
  101160. min.minimizeInPlace(v);
  101161. max.maximizeInPlace(v);
  101162. };
  101163. /**
  101164. * Tries to copy an object by duplicating every property
  101165. * @param source defines the source object
  101166. * @param destination defines the target object
  101167. * @param doNotCopyList defines a list of properties to avoid
  101168. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  101169. */
  101170. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  101171. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  101172. };
  101173. /**
  101174. * Gets a boolean indicating if the given object has no own property
  101175. * @param obj defines the object to test
  101176. * @returns true if object has no own property
  101177. */
  101178. Tools.IsEmpty = function (obj) {
  101179. for (var i in obj) {
  101180. if (obj.hasOwnProperty(i)) {
  101181. return false;
  101182. }
  101183. }
  101184. return true;
  101185. };
  101186. /**
  101187. * Function used to register events at window level
  101188. * @param events defines the events to register
  101189. */
  101190. Tools.RegisterTopRootEvents = function (events) {
  101191. for (var index = 0; index < events.length; index++) {
  101192. var event = events[index];
  101193. window.addEventListener(event.name, event.handler, false);
  101194. try {
  101195. if (window.parent) {
  101196. window.parent.addEventListener(event.name, event.handler, false);
  101197. }
  101198. }
  101199. catch (e) {
  101200. // Silently fails...
  101201. }
  101202. }
  101203. };
  101204. /**
  101205. * Function used to unregister events from window level
  101206. * @param events defines the events to unregister
  101207. */
  101208. Tools.UnregisterTopRootEvents = function (events) {
  101209. for (var index = 0; index < events.length; index++) {
  101210. var event = events[index];
  101211. window.removeEventListener(event.name, event.handler);
  101212. try {
  101213. if (window.parent) {
  101214. window.parent.removeEventListener(event.name, event.handler);
  101215. }
  101216. }
  101217. catch (e) {
  101218. // Silently fails...
  101219. }
  101220. }
  101221. };
  101222. /**
  101223. * Dumps the current bound framebuffer
  101224. * @param width defines the rendering width
  101225. * @param height defines the rendering height
  101226. * @param engine defines the hosting engine
  101227. * @param successCallback defines the callback triggered once the data are available
  101228. * @param mimeType defines the mime type of the result
  101229. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  101230. */
  101231. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  101232. if (mimeType === void 0) { mimeType = "image/png"; }
  101233. // Read the contents of the framebuffer
  101234. var numberOfChannelsByLine = width * 4;
  101235. var halfHeight = height / 2;
  101236. //Reading datas from WebGL
  101237. var data = engine.readPixels(0, 0, width, height);
  101238. //To flip image on Y axis.
  101239. for (var i = 0; i < halfHeight; i++) {
  101240. for (var j = 0; j < numberOfChannelsByLine; j++) {
  101241. var currentCell = j + i * numberOfChannelsByLine;
  101242. var targetLine = height - i - 1;
  101243. var targetCell = j + targetLine * numberOfChannelsByLine;
  101244. var temp = data[currentCell];
  101245. data[currentCell] = data[targetCell];
  101246. data[targetCell] = temp;
  101247. }
  101248. }
  101249. // Create a 2D canvas to store the result
  101250. if (!Tools._ScreenshotCanvas) {
  101251. Tools._ScreenshotCanvas = document.createElement('canvas');
  101252. }
  101253. Tools._ScreenshotCanvas.width = width;
  101254. Tools._ScreenshotCanvas.height = height;
  101255. var context = Tools._ScreenshotCanvas.getContext('2d');
  101256. if (context) {
  101257. // Copy the pixels to a 2D canvas
  101258. var imageData = context.createImageData(width, height);
  101259. var castData = (imageData.data);
  101260. castData.set(data);
  101261. context.putImageData(imageData, 0, 0);
  101262. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  101263. }
  101264. };
  101265. /**
  101266. * Converts the canvas data to blob.
  101267. * This acts as a polyfill for browsers not supporting the to blob function.
  101268. * @param canvas Defines the canvas to extract the data from
  101269. * @param successCallback Defines the callback triggered once the data are available
  101270. * @param mimeType Defines the mime type of the result
  101271. */
  101272. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  101273. if (mimeType === void 0) { mimeType = "image/png"; }
  101274. // We need HTMLCanvasElement.toBlob for HD screenshots
  101275. if (!canvas.toBlob) {
  101276. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  101277. canvas.toBlob = function (callback, type, quality) {
  101278. var _this = this;
  101279. setTimeout(function () {
  101280. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  101281. for (var i = 0; i < len; i++) {
  101282. arr[i] = binStr.charCodeAt(i);
  101283. }
  101284. callback(new Blob([arr]));
  101285. });
  101286. };
  101287. }
  101288. canvas.toBlob(function (blob) {
  101289. successCallback(blob);
  101290. }, mimeType);
  101291. };
  101292. /**
  101293. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  101294. * @param successCallback defines the callback triggered once the data are available
  101295. * @param mimeType defines the mime type of the result
  101296. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  101297. */
  101298. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  101299. if (mimeType === void 0) { mimeType = "image/png"; }
  101300. if (successCallback) {
  101301. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  101302. successCallback(base64Image);
  101303. }
  101304. else {
  101305. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  101306. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  101307. if (("download" in document.createElement("a"))) {
  101308. if (!fileName) {
  101309. var date = new Date();
  101310. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  101311. fileName = "screenshot_" + stringDate + ".png";
  101312. }
  101313. Tools.Download(blob, fileName);
  101314. }
  101315. else {
  101316. var url = URL.createObjectURL(blob);
  101317. var newWindow = window.open("");
  101318. if (!newWindow) {
  101319. return;
  101320. }
  101321. var img = newWindow.document.createElement("img");
  101322. img.onload = function () {
  101323. // no longer need to read the blob so it's revoked
  101324. URL.revokeObjectURL(url);
  101325. };
  101326. img.src = url;
  101327. newWindow.document.body.appendChild(img);
  101328. }
  101329. }, mimeType);
  101330. }
  101331. };
  101332. /**
  101333. * Downloads a blob in the browser
  101334. * @param blob defines the blob to download
  101335. * @param fileName defines the name of the downloaded file
  101336. */
  101337. Tools.Download = function (blob, fileName) {
  101338. if (navigator && navigator.msSaveBlob) {
  101339. navigator.msSaveBlob(blob, fileName);
  101340. return;
  101341. }
  101342. var url = window.URL.createObjectURL(blob);
  101343. var a = document.createElement("a");
  101344. document.body.appendChild(a);
  101345. a.style.display = "none";
  101346. a.href = url;
  101347. a.download = fileName;
  101348. a.addEventListener("click", function () {
  101349. if (a.parentElement) {
  101350. a.parentElement.removeChild(a);
  101351. }
  101352. });
  101353. a.click();
  101354. window.URL.revokeObjectURL(url);
  101355. };
  101356. /**
  101357. * Captures a screenshot of the current rendering
  101358. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101359. * @param engine defines the rendering engine
  101360. * @param camera defines the source camera
  101361. * @param size This parameter can be set to a single number or to an object with the
  101362. * following (optional) properties: precision, width, height. If a single number is passed,
  101363. * it will be used for both width and height. If an object is passed, the screenshot size
  101364. * will be derived from the parameters. The precision property is a multiplier allowing
  101365. * rendering at a higher or lower resolution
  101366. * @param successCallback defines the callback receives a single parameter which contains the
  101367. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101368. * src parameter of an <img> to display it
  101369. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  101370. * Check your browser for supported MIME types
  101371. */
  101372. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  101373. if (mimeType === void 0) { mimeType = "image/png"; }
  101374. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  101375. };
  101376. /**
  101377. * Generates an image screenshot from the specified camera.
  101378. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101379. * @param engine The engine to use for rendering
  101380. * @param camera The camera to use for rendering
  101381. * @param size This parameter can be set to a single number or to an object with the
  101382. * following (optional) properties: precision, width, height. If a single number is passed,
  101383. * it will be used for both width and height. If an object is passed, the screenshot size
  101384. * will be derived from the parameters. The precision property is a multiplier allowing
  101385. * rendering at a higher or lower resolution
  101386. * @param successCallback The callback receives a single parameter which contains the
  101387. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101388. * src parameter of an <img> to display it
  101389. * @param mimeType The MIME type of the screenshot image (default: image/png).
  101390. * Check your browser for supported MIME types
  101391. * @param samples Texture samples (default: 1)
  101392. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  101393. * @param fileName A name for for the downloaded file.
  101394. */
  101395. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  101396. if (mimeType === void 0) { mimeType = "image/png"; }
  101397. if (samples === void 0) { samples = 1; }
  101398. if (antialiasing === void 0) { antialiasing = false; }
  101399. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  101400. };
  101401. /**
  101402. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101403. * Be aware Math.random() could cause collisions, but:
  101404. * "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"
  101405. * @returns a pseudo random id
  101406. */
  101407. Tools.RandomId = function () {
  101408. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  101409. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  101410. return v.toString(16);
  101411. });
  101412. };
  101413. /**
  101414. * Test if the given uri is a base64 string
  101415. * @param uri The uri to test
  101416. * @return True if the uri is a base64 string or false otherwise
  101417. */
  101418. Tools.IsBase64 = function (uri) {
  101419. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  101420. };
  101421. /**
  101422. * Decode the given base64 uri.
  101423. * @param uri The uri to decode
  101424. * @return The decoded base64 data.
  101425. */
  101426. Tools.DecodeBase64 = function (uri) {
  101427. var decodedString = atob(uri.split(",")[1]);
  101428. var bufferLength = decodedString.length;
  101429. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  101430. for (var i = 0; i < bufferLength; i++) {
  101431. bufferView[i] = decodedString.charCodeAt(i);
  101432. }
  101433. return bufferView.buffer;
  101434. };
  101435. Object.defineProperty(Tools, "errorsCount", {
  101436. /**
  101437. * Gets a value indicating the number of loading errors
  101438. * @ignorenaming
  101439. */
  101440. get: function () {
  101441. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  101442. },
  101443. enumerable: true,
  101444. configurable: true
  101445. });
  101446. /**
  101447. * Log a message to the console
  101448. * @param message defines the message to log
  101449. */
  101450. Tools.Log = function (message) {
  101451. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  101452. };
  101453. /**
  101454. * Write a warning message to the console
  101455. * @param message defines the message to log
  101456. */
  101457. Tools.Warn = function (message) {
  101458. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  101459. };
  101460. /**
  101461. * Write an error message to the console
  101462. * @param message defines the message to log
  101463. */
  101464. Tools.Error = function (message) {
  101465. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  101466. };
  101467. Object.defineProperty(Tools, "LogCache", {
  101468. /**
  101469. * Gets current log cache (list of logs)
  101470. */
  101471. get: function () {
  101472. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  101473. },
  101474. enumerable: true,
  101475. configurable: true
  101476. });
  101477. /**
  101478. * Clears the log cache
  101479. */
  101480. Tools.ClearLogCache = function () {
  101481. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  101482. };
  101483. Object.defineProperty(Tools, "LogLevels", {
  101484. /**
  101485. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  101486. */
  101487. set: function (level) {
  101488. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  101489. },
  101490. enumerable: true,
  101491. configurable: true
  101492. });
  101493. /**
  101494. * Checks if the loaded document was accessed via `file:`-Protocol.
  101495. * @returns boolean
  101496. */
  101497. Tools.IsFileURL = function () {
  101498. return location.protocol === "file:";
  101499. };
  101500. Object.defineProperty(Tools, "PerformanceLogLevel", {
  101501. /**
  101502. * Sets the current performance log level
  101503. */
  101504. set: function (level) {
  101505. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  101506. Tools.StartPerformanceCounter = Tools._StartUserMark;
  101507. Tools.EndPerformanceCounter = Tools._EndUserMark;
  101508. return;
  101509. }
  101510. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  101511. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  101512. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  101513. return;
  101514. }
  101515. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  101516. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  101517. },
  101518. enumerable: true,
  101519. configurable: true
  101520. });
  101521. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  101522. };
  101523. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  101524. };
  101525. Tools._StartUserMark = function (counterName, condition) {
  101526. if (condition === void 0) { condition = true; }
  101527. if (!Tools._performance) {
  101528. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  101529. return;
  101530. }
  101531. Tools._performance = window.performance;
  101532. }
  101533. if (!condition || !Tools._performance.mark) {
  101534. return;
  101535. }
  101536. Tools._performance.mark(counterName + "-Begin");
  101537. };
  101538. Tools._EndUserMark = function (counterName, condition) {
  101539. if (condition === void 0) { condition = true; }
  101540. if (!condition || !Tools._performance.mark) {
  101541. return;
  101542. }
  101543. Tools._performance.mark(counterName + "-End");
  101544. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  101545. };
  101546. Tools._StartPerformanceConsole = function (counterName, condition) {
  101547. if (condition === void 0) { condition = true; }
  101548. if (!condition) {
  101549. return;
  101550. }
  101551. Tools._StartUserMark(counterName, condition);
  101552. if (console.time) {
  101553. console.time(counterName);
  101554. }
  101555. };
  101556. Tools._EndPerformanceConsole = function (counterName, condition) {
  101557. if (condition === void 0) { condition = true; }
  101558. if (!condition) {
  101559. return;
  101560. }
  101561. Tools._EndUserMark(counterName, condition);
  101562. if (console.time) {
  101563. console.timeEnd(counterName);
  101564. }
  101565. };
  101566. /**
  101567. * Injects the @see CustomRequestHeaders into the given request
  101568. * @param request the request that should be used for injection
  101569. */
  101570. Tools.InjectCustomRequestHeaders = function (request) {
  101571. for (var key in Tools.CustomRequestHeaders) {
  101572. var val = Tools.CustomRequestHeaders[key];
  101573. if (val) {
  101574. request.setRequestHeader(key, val);
  101575. }
  101576. }
  101577. };
  101578. Object.defineProperty(Tools, "Now", {
  101579. /**
  101580. * Gets either window.performance.now() if supported or Date.now() else
  101581. */
  101582. get: function () {
  101583. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  101584. },
  101585. enumerable: true,
  101586. configurable: true
  101587. });
  101588. /**
  101589. * This method will return the name of the class used to create the instance of the given object.
  101590. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  101591. * @param object the object to get the class name from
  101592. * @param isType defines if the object is actually a type
  101593. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  101594. */
  101595. Tools.GetClassName = function (object, isType) {
  101596. if (isType === void 0) { isType = false; }
  101597. var name = null;
  101598. if (!isType && object.getClassName) {
  101599. name = object.getClassName();
  101600. }
  101601. else {
  101602. if (object instanceof Object) {
  101603. var classObj = isType ? object : Object.getPrototypeOf(object);
  101604. name = classObj.constructor["__bjsclassName__"];
  101605. }
  101606. if (!name) {
  101607. name = typeof object;
  101608. }
  101609. }
  101610. return name;
  101611. };
  101612. /**
  101613. * Gets the first element of an array satisfying a given predicate
  101614. * @param array defines the array to browse
  101615. * @param predicate defines the predicate to use
  101616. * @returns null if not found or the element
  101617. */
  101618. Tools.First = function (array, predicate) {
  101619. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  101620. var el = array_1[_i];
  101621. if (predicate(el)) {
  101622. return el;
  101623. }
  101624. }
  101625. return null;
  101626. };
  101627. /**
  101628. * This method will return the name of the full name of the class, including its owning module (if any).
  101629. * 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).
  101630. * @param object the object to get the class name from
  101631. * @param isType defines if the object is actually a type
  101632. * @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.
  101633. * @ignorenaming
  101634. */
  101635. Tools.getFullClassName = function (object, isType) {
  101636. if (isType === void 0) { isType = false; }
  101637. var className = null;
  101638. var moduleName = null;
  101639. if (!isType && object.getClassName) {
  101640. className = object.getClassName();
  101641. }
  101642. else {
  101643. if (object instanceof Object) {
  101644. var classObj = isType ? object : Object.getPrototypeOf(object);
  101645. className = classObj.constructor["__bjsclassName__"];
  101646. moduleName = classObj.constructor["__bjsmoduleName__"];
  101647. }
  101648. if (!className) {
  101649. className = typeof object;
  101650. }
  101651. }
  101652. if (!className) {
  101653. return null;
  101654. }
  101655. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  101656. };
  101657. /**
  101658. * Returns a promise that resolves after the given amount of time.
  101659. * @param delay Number of milliseconds to delay
  101660. * @returns Promise that resolves after the given amount of time
  101661. */
  101662. Tools.DelayAsync = function (delay) {
  101663. return new Promise(function (resolve) {
  101664. setTimeout(function () {
  101665. resolve();
  101666. }, delay);
  101667. });
  101668. };
  101669. /**
  101670. * Gets the current gradient from an array of IValueGradient
  101671. * @param ratio defines the current ratio to get
  101672. * @param gradients defines the array of IValueGradient
  101673. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  101674. */
  101675. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  101676. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  101677. var currentGradient = gradients[gradientIndex];
  101678. var nextGradient = gradients[gradientIndex + 1];
  101679. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  101680. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  101681. updateFunc(currentGradient, nextGradient, scale);
  101682. return;
  101683. }
  101684. }
  101685. // Use last index if over
  101686. var lastIndex = gradients.length - 1;
  101687. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  101688. };
  101689. /**
  101690. * Gets or sets the base URL to use to load assets
  101691. */
  101692. Tools.BaseUrl = "";
  101693. /**
  101694. * Enable/Disable Custom HTTP Request Headers globally.
  101695. * default = false
  101696. * @see CustomRequestHeaders
  101697. */
  101698. Tools.UseCustomRequestHeaders = false;
  101699. /**
  101700. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  101701. * i.e. when loading files, where the server/service expects an Authorization header.
  101702. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  101703. */
  101704. Tools.CustomRequestHeaders = {};
  101705. /**
  101706. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  101707. */
  101708. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  101709. /**
  101710. * Default behaviour for cors in the application.
  101711. * It can be a string if the expected behavior is identical in the entire app.
  101712. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  101713. */
  101714. Tools.CorsBehavior = "anonymous";
  101715. /**
  101716. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  101717. * @ignorenaming
  101718. */
  101719. Tools.UseFallbackTexture = true;
  101720. /**
  101721. * Use this object to register external classes like custom textures or material
  101722. * to allow the laoders to instantiate them
  101723. */
  101724. Tools.RegisteredExternalClasses = {};
  101725. /**
  101726. * Texture content used if a texture cannot loaded
  101727. * @ignorenaming
  101728. */
  101729. 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";
  101730. Tools._tmpFloatArray = new Float32Array(1);
  101731. /**
  101732. * Extracts text content from a DOM element hierarchy
  101733. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  101734. */
  101735. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  101736. /**
  101737. * Gets or sets a function used to pre-process url before using them to load assets
  101738. */
  101739. Tools.PreprocessUrl = function (url) {
  101740. return url;
  101741. };
  101742. // Logs
  101743. /**
  101744. * No log
  101745. */
  101746. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  101747. /**
  101748. * Only message logs
  101749. */
  101750. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  101751. /**
  101752. * Only warning logs
  101753. */
  101754. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  101755. /**
  101756. * Only error logs
  101757. */
  101758. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  101759. /**
  101760. * All logs
  101761. */
  101762. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  101763. /**
  101764. * Checks if the window object exists
  101765. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  101766. */
  101767. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  101768. // Performances
  101769. /**
  101770. * No performance log
  101771. */
  101772. Tools.PerformanceNoneLogLevel = 0;
  101773. /**
  101774. * Use user marks to log performance
  101775. */
  101776. Tools.PerformanceUserMarkLogLevel = 1;
  101777. /**
  101778. * Log performance to the console
  101779. */
  101780. Tools.PerformanceConsoleLogLevel = 2;
  101781. /**
  101782. * Starts a performance counter
  101783. */
  101784. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  101785. /**
  101786. * Ends a specific performance coutner
  101787. */
  101788. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  101789. return Tools;
  101790. }());
  101791. /**
  101792. * This class is used to track a performance counter which is number based.
  101793. * The user has access to many properties which give statistics of different nature.
  101794. *
  101795. * The implementer can track two kinds of Performance Counter: time and count.
  101796. * 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.
  101797. * 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.
  101798. */
  101799. var PerfCounter = /** @class */ (function () {
  101800. /**
  101801. * Creates a new counter
  101802. */
  101803. function PerfCounter() {
  101804. this._startMonitoringTime = 0;
  101805. this._min = 0;
  101806. this._max = 0;
  101807. this._average = 0;
  101808. this._lastSecAverage = 0;
  101809. this._current = 0;
  101810. this._totalValueCount = 0;
  101811. this._totalAccumulated = 0;
  101812. this._lastSecAccumulated = 0;
  101813. this._lastSecTime = 0;
  101814. this._lastSecValueCount = 0;
  101815. }
  101816. Object.defineProperty(PerfCounter.prototype, "min", {
  101817. /**
  101818. * Returns the smallest value ever
  101819. */
  101820. get: function () {
  101821. return this._min;
  101822. },
  101823. enumerable: true,
  101824. configurable: true
  101825. });
  101826. Object.defineProperty(PerfCounter.prototype, "max", {
  101827. /**
  101828. * Returns the biggest value ever
  101829. */
  101830. get: function () {
  101831. return this._max;
  101832. },
  101833. enumerable: true,
  101834. configurable: true
  101835. });
  101836. Object.defineProperty(PerfCounter.prototype, "average", {
  101837. /**
  101838. * Returns the average value since the performance counter is running
  101839. */
  101840. get: function () {
  101841. return this._average;
  101842. },
  101843. enumerable: true,
  101844. configurable: true
  101845. });
  101846. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  101847. /**
  101848. * Returns the average value of the last second the counter was monitored
  101849. */
  101850. get: function () {
  101851. return this._lastSecAverage;
  101852. },
  101853. enumerable: true,
  101854. configurable: true
  101855. });
  101856. Object.defineProperty(PerfCounter.prototype, "current", {
  101857. /**
  101858. * Returns the current value
  101859. */
  101860. get: function () {
  101861. return this._current;
  101862. },
  101863. enumerable: true,
  101864. configurable: true
  101865. });
  101866. Object.defineProperty(PerfCounter.prototype, "total", {
  101867. /**
  101868. * Gets the accumulated total
  101869. */
  101870. get: function () {
  101871. return this._totalAccumulated;
  101872. },
  101873. enumerable: true,
  101874. configurable: true
  101875. });
  101876. Object.defineProperty(PerfCounter.prototype, "count", {
  101877. /**
  101878. * Gets the total value count
  101879. */
  101880. get: function () {
  101881. return this._totalValueCount;
  101882. },
  101883. enumerable: true,
  101884. configurable: true
  101885. });
  101886. /**
  101887. * Call this method to start monitoring a new frame.
  101888. * 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.
  101889. */
  101890. PerfCounter.prototype.fetchNewFrame = function () {
  101891. this._totalValueCount++;
  101892. this._current = 0;
  101893. this._lastSecValueCount++;
  101894. };
  101895. /**
  101896. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101897. * @param newCount the count value to add to the monitored count
  101898. * @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.
  101899. */
  101900. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  101901. if (!PerfCounter.Enabled) {
  101902. return;
  101903. }
  101904. this._current += newCount;
  101905. if (fetchResult) {
  101906. this._fetchResult();
  101907. }
  101908. };
  101909. /**
  101910. * Start monitoring this performance counter
  101911. */
  101912. PerfCounter.prototype.beginMonitoring = function () {
  101913. if (!PerfCounter.Enabled) {
  101914. return;
  101915. }
  101916. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  101917. };
  101918. /**
  101919. * Compute the time lapsed since the previous beginMonitoring() call.
  101920. * @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
  101921. */
  101922. PerfCounter.prototype.endMonitoring = function (newFrame) {
  101923. if (newFrame === void 0) { newFrame = true; }
  101924. if (!PerfCounter.Enabled) {
  101925. return;
  101926. }
  101927. if (newFrame) {
  101928. this.fetchNewFrame();
  101929. }
  101930. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  101931. this._current = currentTime - this._startMonitoringTime;
  101932. if (newFrame) {
  101933. this._fetchResult();
  101934. }
  101935. };
  101936. PerfCounter.prototype._fetchResult = function () {
  101937. this._totalAccumulated += this._current;
  101938. this._lastSecAccumulated += this._current;
  101939. // Min/Max update
  101940. this._min = Math.min(this._min, this._current);
  101941. this._max = Math.max(this._max, this._current);
  101942. this._average = this._totalAccumulated / this._totalValueCount;
  101943. // Reset last sec?
  101944. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  101945. if ((now - this._lastSecTime) > 1000) {
  101946. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  101947. this._lastSecTime = now;
  101948. this._lastSecAccumulated = 0;
  101949. this._lastSecValueCount = 0;
  101950. }
  101951. };
  101952. /**
  101953. * Gets or sets a global boolean to turn on and off all the counters
  101954. */
  101955. PerfCounter.Enabled = true;
  101956. return PerfCounter;
  101957. }());
  101958. /**
  101959. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  101960. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  101961. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  101962. * @param name The name of the class, case should be preserved
  101963. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  101964. */
  101965. function className(name, module) {
  101966. return function (target) {
  101967. target["__bjsclassName__"] = name;
  101968. target["__bjsmoduleName__"] = (module != null) ? module : null;
  101969. };
  101970. }
  101971. /**
  101972. * An implementation of a loop for asynchronous functions.
  101973. */
  101974. var AsyncLoop = /** @class */ (function () {
  101975. /**
  101976. * Constructor.
  101977. * @param iterations the number of iterations.
  101978. * @param func the function to run each iteration
  101979. * @param successCallback the callback that will be called upon succesful execution
  101980. * @param offset starting offset.
  101981. */
  101982. function AsyncLoop(
  101983. /**
  101984. * Defines the number of iterations for the loop
  101985. */
  101986. iterations, func, successCallback, offset) {
  101987. if (offset === void 0) { offset = 0; }
  101988. this.iterations = iterations;
  101989. this.index = offset - 1;
  101990. this._done = false;
  101991. this._fn = func;
  101992. this._successCallback = successCallback;
  101993. }
  101994. /**
  101995. * Execute the next iteration. Must be called after the last iteration was finished.
  101996. */
  101997. AsyncLoop.prototype.executeNext = function () {
  101998. if (!this._done) {
  101999. if (this.index + 1 < this.iterations) {
  102000. ++this.index;
  102001. this._fn(this);
  102002. }
  102003. else {
  102004. this.breakLoop();
  102005. }
  102006. }
  102007. };
  102008. /**
  102009. * Break the loop and run the success callback.
  102010. */
  102011. AsyncLoop.prototype.breakLoop = function () {
  102012. this._done = true;
  102013. this._successCallback();
  102014. };
  102015. /**
  102016. * Create and run an async loop.
  102017. * @param iterations the number of iterations.
  102018. * @param fn the function to run each iteration
  102019. * @param successCallback the callback that will be called upon succesful execution
  102020. * @param offset starting offset.
  102021. * @returns the created async loop object
  102022. */
  102023. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  102024. if (offset === void 0) { offset = 0; }
  102025. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  102026. loop.executeNext();
  102027. return loop;
  102028. };
  102029. /**
  102030. * A for-loop that will run a given number of iterations synchronous and the rest async.
  102031. * @param iterations total number of iterations
  102032. * @param syncedIterations number of synchronous iterations in each async iteration.
  102033. * @param fn the function to call each iteration.
  102034. * @param callback a success call back that will be called when iterating stops.
  102035. * @param breakFunction a break condition (optional)
  102036. * @param timeout timeout settings for the setTimeout function. default - 0.
  102037. * @returns the created async loop object
  102038. */
  102039. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  102040. if (timeout === void 0) { timeout = 0; }
  102041. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  102042. if (breakFunction && breakFunction()) {
  102043. loop.breakLoop();
  102044. }
  102045. else {
  102046. setTimeout(function () {
  102047. for (var i = 0; i < syncedIterations; ++i) {
  102048. var iteration = (loop.index * syncedIterations) + i;
  102049. if (iteration >= iterations) {
  102050. break;
  102051. }
  102052. fn(iteration);
  102053. if (breakFunction && breakFunction()) {
  102054. loop.breakLoop();
  102055. break;
  102056. }
  102057. }
  102058. loop.executeNext();
  102059. }, timeout);
  102060. }
  102061. }, callback);
  102062. };
  102063. return AsyncLoop;
  102064. }());
  102065. /***/ }),
  102066. /***/ "./Misc/typeStore.ts":
  102067. /*!***************************!*\
  102068. !*** ./Misc/typeStore.ts ***!
  102069. \***************************/
  102070. /*! exports provided: _TypeStore */
  102071. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102072. "use strict";
  102073. __webpack_require__.r(__webpack_exports__);
  102074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  102075. /** @hidden */
  102076. var _TypeStore = /** @class */ (function () {
  102077. function _TypeStore() {
  102078. }
  102079. /** @hidden */
  102080. _TypeStore.GetClass = function (fqdn) {
  102081. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  102082. return this.RegisteredTypes[fqdn];
  102083. }
  102084. return null;
  102085. };
  102086. /** @hidden */
  102087. _TypeStore.RegisteredTypes = {};
  102088. return _TypeStore;
  102089. }());
  102090. /***/ }),
  102091. /***/ "./Misc/videoRecorder.ts":
  102092. /*!*******************************!*\
  102093. !*** ./Misc/videoRecorder.ts ***!
  102094. \*******************************/
  102095. /*! exports provided: VideoRecorder */
  102096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102097. "use strict";
  102098. __webpack_require__.r(__webpack_exports__);
  102099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  102100. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102101. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  102102. /**
  102103. * This can helps recording videos from BabylonJS.
  102104. * This is based on the available WebRTC functionalities of the browser.
  102105. *
  102106. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  102107. */
  102108. var VideoRecorder = /** @class */ (function () {
  102109. /**
  102110. * Create a new VideoCapture object which can help converting what you see in Babylon to
  102111. * a video file.
  102112. * @param engine Defines the BabylonJS Engine you wish to record
  102113. * @param options Defines options that can be used to customized the capture
  102114. */
  102115. function VideoRecorder(engine, options) {
  102116. if (options === void 0) { options = null; }
  102117. if (!VideoRecorder.IsSupported(engine)) {
  102118. throw "Your browser does not support recording so far.";
  102119. }
  102120. var canvas = engine.getRenderingCanvas();
  102121. if (!canvas) {
  102122. throw "The babylon engine must have a canvas to be recorded";
  102123. }
  102124. this._canvas = canvas;
  102125. this._canvas.isRecording = false;
  102126. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  102127. var stream = this._canvas.captureStream(this._options.fps);
  102128. if (this._options.audioTracks) {
  102129. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  102130. var track = _a[_i];
  102131. stream.addTrack(track);
  102132. }
  102133. }
  102134. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  102135. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  102136. this._mediaRecorder.onerror = this._handleError.bind(this);
  102137. this._mediaRecorder.onstop = this._handleStop.bind(this);
  102138. }
  102139. /**
  102140. * Returns wehther or not the VideoRecorder is available in your browser.
  102141. * @param engine Defines the Babylon Engine to check the support for
  102142. * @returns true if supported otherwise false
  102143. */
  102144. VideoRecorder.IsSupported = function (engine) {
  102145. var canvas = engine.getRenderingCanvas();
  102146. return (!!canvas && typeof canvas.captureStream === "function");
  102147. };
  102148. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  102149. /**
  102150. * True wether a recording is already in progress.
  102151. */
  102152. get: function () {
  102153. return !!this._canvas && this._canvas.isRecording;
  102154. },
  102155. enumerable: true,
  102156. configurable: true
  102157. });
  102158. /**
  102159. * Stops the current recording before the default capture timeout passed in the startRecording
  102160. * functions.
  102161. */
  102162. VideoRecorder.prototype.stopRecording = function () {
  102163. if (!this._canvas || !this._mediaRecorder) {
  102164. return;
  102165. }
  102166. if (!this.isRecording) {
  102167. return;
  102168. }
  102169. this._canvas.isRecording = false;
  102170. this._mediaRecorder.stop();
  102171. };
  102172. /**
  102173. * Starts recording the canvas for a max duration specified in parameters.
  102174. * @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.
  102175. * @param maxDuration Defines the maximum recording time in seconds.
  102176. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  102177. * @return a promise callback at the end of the recording with the video data in Blob.
  102178. */
  102179. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  102180. var _this = this;
  102181. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  102182. if (maxDuration === void 0) { maxDuration = 7; }
  102183. if (!this._canvas || !this._mediaRecorder) {
  102184. throw "Recorder has already been disposed";
  102185. }
  102186. if (this.isRecording) {
  102187. throw "Recording already in progress";
  102188. }
  102189. if (maxDuration > 0) {
  102190. setTimeout(function () {
  102191. _this.stopRecording();
  102192. }, maxDuration * 1000);
  102193. }
  102194. this._fileName = fileName;
  102195. this._recordedChunks = [];
  102196. this._resolve = null;
  102197. this._reject = null;
  102198. this._canvas.isRecording = true;
  102199. this._mediaRecorder.start(this._options.recordChunckSize);
  102200. return new Promise(function (resolve, reject) {
  102201. _this._resolve = resolve;
  102202. _this._reject = reject;
  102203. });
  102204. };
  102205. /**
  102206. * Releases internal resources used during the recording.
  102207. */
  102208. VideoRecorder.prototype.dispose = function () {
  102209. this._canvas = null;
  102210. this._mediaRecorder = null;
  102211. this._recordedChunks = [];
  102212. this._fileName = null;
  102213. this._resolve = null;
  102214. this._reject = null;
  102215. };
  102216. VideoRecorder.prototype._handleDataAvailable = function (event) {
  102217. if (event.data.size > 0) {
  102218. this._recordedChunks.push(event.data);
  102219. }
  102220. };
  102221. VideoRecorder.prototype._handleError = function (event) {
  102222. this.stopRecording();
  102223. if (this._reject) {
  102224. this._reject(event.error);
  102225. }
  102226. else {
  102227. throw new event.error();
  102228. }
  102229. };
  102230. VideoRecorder.prototype._handleStop = function () {
  102231. this.stopRecording();
  102232. var superBuffer = new Blob(this._recordedChunks);
  102233. if (this._resolve) {
  102234. this._resolve(superBuffer);
  102235. }
  102236. window.URL.createObjectURL(superBuffer);
  102237. if (this._fileName) {
  102238. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  102239. }
  102240. };
  102241. VideoRecorder._defaultOptions = {
  102242. mimeType: "video/webm",
  102243. fps: 25,
  102244. recordChunckSize: 3000
  102245. };
  102246. return VideoRecorder;
  102247. }());
  102248. /***/ }),
  102249. /***/ "./Misc/virtualJoystick.ts":
  102250. /*!*********************************!*\
  102251. !*** ./Misc/virtualJoystick.ts ***!
  102252. \*********************************/
  102253. /*! exports provided: JoystickAxis, VirtualJoystick */
  102254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102255. "use strict";
  102256. __webpack_require__.r(__webpack_exports__);
  102257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  102258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  102259. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102260. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  102261. // Mainly based on these 2 articles :
  102262. // 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
  102263. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  102264. /**
  102265. * Defines the potential axis of a Joystick
  102266. */
  102267. var JoystickAxis;
  102268. (function (JoystickAxis) {
  102269. /** X axis */
  102270. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  102271. /** Y axis */
  102272. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  102273. /** Z axis */
  102274. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  102275. })(JoystickAxis || (JoystickAxis = {}));
  102276. /**
  102277. * Class used to define virtual joystick (used in touch mode)
  102278. */
  102279. var VirtualJoystick = /** @class */ (function () {
  102280. /**
  102281. * Creates a new virtual joystick
  102282. * @param leftJoystick defines that the joystick is for left hand (false by default)
  102283. */
  102284. function VirtualJoystick(leftJoystick) {
  102285. var _this = this;
  102286. if (leftJoystick) {
  102287. this._leftJoystick = true;
  102288. }
  102289. else {
  102290. this._leftJoystick = false;
  102291. }
  102292. VirtualJoystick._globalJoystickIndex++;
  102293. // By default left & right arrow keys are moving the X
  102294. // and up & down keys are moving the Y
  102295. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  102296. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  102297. this.reverseLeftRight = false;
  102298. this.reverseUpDown = false;
  102299. // collections of pointers
  102300. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  102301. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102302. this._joystickSensibility = 25;
  102303. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  102304. this._onResize = function (evt) {
  102305. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  102306. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  102307. if (VirtualJoystick.Canvas) {
  102308. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  102309. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  102310. }
  102311. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  102312. };
  102313. // injecting a canvas element on top of the canvas 3D game
  102314. if (!VirtualJoystick.Canvas) {
  102315. window.addEventListener("resize", this._onResize, false);
  102316. VirtualJoystick.Canvas = document.createElement("canvas");
  102317. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  102318. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  102319. VirtualJoystick.Canvas.width = window.innerWidth;
  102320. VirtualJoystick.Canvas.height = window.innerHeight;
  102321. VirtualJoystick.Canvas.style.width = "100%";
  102322. VirtualJoystick.Canvas.style.height = "100%";
  102323. VirtualJoystick.Canvas.style.position = "absolute";
  102324. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  102325. VirtualJoystick.Canvas.style.top = "0px";
  102326. VirtualJoystick.Canvas.style.left = "0px";
  102327. VirtualJoystick.Canvas.style.zIndex = "5";
  102328. VirtualJoystick.Canvas.style.msTouchAction = "none";
  102329. // Support for jQuery PEP polyfill
  102330. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  102331. var context = VirtualJoystick.Canvas.getContext('2d');
  102332. if (!context) {
  102333. throw new Error("Unable to create canvas for virtual joystick");
  102334. }
  102335. VirtualJoystick.vjCanvasContext = context;
  102336. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  102337. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  102338. document.body.appendChild(VirtualJoystick.Canvas);
  102339. }
  102340. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  102341. this.pressed = false;
  102342. // default joystick color
  102343. this._joystickColor = "cyan";
  102344. this._joystickPointerID = -1;
  102345. // current joystick position
  102346. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  102347. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  102348. // origin joystick position
  102349. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  102350. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  102351. this._onPointerDownHandlerRef = function (evt) {
  102352. _this._onPointerDown(evt);
  102353. };
  102354. this._onPointerMoveHandlerRef = function (evt) {
  102355. _this._onPointerMove(evt);
  102356. };
  102357. this._onPointerUpHandlerRef = function (evt) {
  102358. _this._onPointerUp(evt);
  102359. };
  102360. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  102361. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  102362. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  102363. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  102364. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  102365. evt.preventDefault(); // Disables system menu
  102366. }, false);
  102367. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  102368. }
  102369. /**
  102370. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  102371. * @param newJoystickSensibility defines the new sensibility
  102372. */
  102373. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  102374. this._joystickSensibility = newJoystickSensibility;
  102375. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  102376. };
  102377. VirtualJoystick.prototype._onPointerDown = function (e) {
  102378. var positionOnScreenCondition;
  102379. e.preventDefault();
  102380. if (this._leftJoystick === true) {
  102381. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  102382. }
  102383. else {
  102384. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  102385. }
  102386. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  102387. // First contact will be dedicated to the virtual joystick
  102388. this._joystickPointerID = e.pointerId;
  102389. this._joystickPointerStartPos.x = e.clientX;
  102390. this._joystickPointerStartPos.y = e.clientY;
  102391. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  102392. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  102393. this._deltaJoystickVector.x = 0;
  102394. this._deltaJoystickVector.y = 0;
  102395. this.pressed = true;
  102396. this._touches.add(e.pointerId.toString(), e);
  102397. }
  102398. else {
  102399. // You can only trigger the action buttons with a joystick declared
  102400. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  102401. this._action();
  102402. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  102403. }
  102404. }
  102405. };
  102406. VirtualJoystick.prototype._onPointerMove = function (e) {
  102407. // If the current pointer is the one associated to the joystick (first touch contact)
  102408. if (this._joystickPointerID == e.pointerId) {
  102409. this._joystickPointerPos.x = e.clientX;
  102410. this._joystickPointerPos.y = e.clientY;
  102411. this._deltaJoystickVector = this._joystickPointerPos.clone();
  102412. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  102413. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  102414. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  102415. switch (this._axisTargetedByLeftAndRight) {
  102416. case JoystickAxis.X:
  102417. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  102418. break;
  102419. case JoystickAxis.Y:
  102420. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  102421. break;
  102422. case JoystickAxis.Z:
  102423. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  102424. break;
  102425. }
  102426. var directionUpDown = this.reverseUpDown ? 1 : -1;
  102427. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  102428. switch (this._axisTargetedByUpAndDown) {
  102429. case JoystickAxis.X:
  102430. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  102431. break;
  102432. case JoystickAxis.Y:
  102433. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  102434. break;
  102435. case JoystickAxis.Z:
  102436. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  102437. break;
  102438. }
  102439. }
  102440. else {
  102441. var data = this._touches.get(e.pointerId.toString());
  102442. if (data) {
  102443. data.x = e.clientX;
  102444. data.y = e.clientY;
  102445. }
  102446. }
  102447. };
  102448. VirtualJoystick.prototype._onPointerUp = function (e) {
  102449. if (this._joystickPointerID == e.pointerId) {
  102450. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  102451. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  102452. this._joystickPointerID = -1;
  102453. this.pressed = false;
  102454. }
  102455. else {
  102456. var touch = this._touches.get(e.pointerId.toString());
  102457. if (touch) {
  102458. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  102459. }
  102460. }
  102461. this._deltaJoystickVector.x = 0;
  102462. this._deltaJoystickVector.y = 0;
  102463. this._touches.remove(e.pointerId.toString());
  102464. };
  102465. /**
  102466. * Change the color of the virtual joystick
  102467. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  102468. */
  102469. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  102470. this._joystickColor = newColor;
  102471. };
  102472. /**
  102473. * Defines a callback to call when the joystick is touched
  102474. * @param action defines the callback
  102475. */
  102476. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  102477. this._action = action;
  102478. };
  102479. /**
  102480. * Defines which axis you'd like to control for left & right
  102481. * @param axis defines the axis to use
  102482. */
  102483. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  102484. switch (axis) {
  102485. case JoystickAxis.X:
  102486. case JoystickAxis.Y:
  102487. case JoystickAxis.Z:
  102488. this._axisTargetedByLeftAndRight = axis;
  102489. break;
  102490. default:
  102491. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  102492. break;
  102493. }
  102494. };
  102495. /**
  102496. * Defines which axis you'd like to control for up & down
  102497. * @param axis defines the axis to use
  102498. */
  102499. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  102500. switch (axis) {
  102501. case JoystickAxis.X:
  102502. case JoystickAxis.Y:
  102503. case JoystickAxis.Z:
  102504. this._axisTargetedByUpAndDown = axis;
  102505. break;
  102506. default:
  102507. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  102508. break;
  102509. }
  102510. };
  102511. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  102512. var _this = this;
  102513. if (this.pressed) {
  102514. this._touches.forEach(function (key, touch) {
  102515. if (touch.pointerId === _this._joystickPointerID) {
  102516. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  102517. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  102518. VirtualJoystick.vjCanvasContext.beginPath();
  102519. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  102520. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  102521. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  102522. VirtualJoystick.vjCanvasContext.stroke();
  102523. VirtualJoystick.vjCanvasContext.closePath();
  102524. VirtualJoystick.vjCanvasContext.beginPath();
  102525. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  102526. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  102527. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  102528. VirtualJoystick.vjCanvasContext.stroke();
  102529. VirtualJoystick.vjCanvasContext.closePath();
  102530. VirtualJoystick.vjCanvasContext.beginPath();
  102531. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  102532. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  102533. VirtualJoystick.vjCanvasContext.stroke();
  102534. VirtualJoystick.vjCanvasContext.closePath();
  102535. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  102536. }
  102537. else {
  102538. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  102539. VirtualJoystick.vjCanvasContext.beginPath();
  102540. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  102541. VirtualJoystick.vjCanvasContext.beginPath();
  102542. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  102543. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  102544. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  102545. VirtualJoystick.vjCanvasContext.stroke();
  102546. VirtualJoystick.vjCanvasContext.closePath();
  102547. touch.prevX = touch.x;
  102548. touch.prevY = touch.y;
  102549. }
  102550. });
  102551. }
  102552. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  102553. };
  102554. /**
  102555. * Release internal HTML canvas
  102556. */
  102557. VirtualJoystick.prototype.releaseCanvas = function () {
  102558. if (VirtualJoystick.Canvas) {
  102559. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  102560. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  102561. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  102562. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  102563. window.removeEventListener("resize", this._onResize);
  102564. document.body.removeChild(VirtualJoystick.Canvas);
  102565. VirtualJoystick.Canvas = null;
  102566. }
  102567. };
  102568. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  102569. VirtualJoystick._globalJoystickIndex = 0;
  102570. return VirtualJoystick;
  102571. }());
  102572. /***/ }),
  102573. /***/ "./Misc/workerPool.ts":
  102574. /*!****************************!*\
  102575. !*** ./Misc/workerPool.ts ***!
  102576. \****************************/
  102577. /*! exports provided: WorkerPool */
  102578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102579. "use strict";
  102580. __webpack_require__.r(__webpack_exports__);
  102581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  102582. /**
  102583. * Helper class to push actions to a pool of workers.
  102584. */
  102585. var WorkerPool = /** @class */ (function () {
  102586. /**
  102587. * Constructor
  102588. * @param workers Array of workers to use for actions
  102589. */
  102590. function WorkerPool(workers) {
  102591. this._pendingActions = new Array();
  102592. this._workerInfos = workers.map(function (worker) { return ({
  102593. worker: worker,
  102594. active: false
  102595. }); });
  102596. }
  102597. /**
  102598. * Terminates all workers and clears any pending actions.
  102599. */
  102600. WorkerPool.prototype.dispose = function () {
  102601. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  102602. var workerInfo = _a[_i];
  102603. workerInfo.worker.terminate();
  102604. }
  102605. delete this._workerInfos;
  102606. delete this._pendingActions;
  102607. };
  102608. /**
  102609. * Pushes an action to the worker pool. If all the workers are active, the action will be
  102610. * pended until a worker has completed its action.
  102611. * @param action The action to perform. Call onComplete when the action is complete.
  102612. */
  102613. WorkerPool.prototype.push = function (action) {
  102614. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  102615. var workerInfo = _a[_i];
  102616. if (!workerInfo.active) {
  102617. this._execute(workerInfo, action);
  102618. return;
  102619. }
  102620. }
  102621. this._pendingActions.push(action);
  102622. };
  102623. WorkerPool.prototype._execute = function (workerInfo, action) {
  102624. var _this = this;
  102625. workerInfo.active = true;
  102626. action(workerInfo.worker, function () {
  102627. workerInfo.active = false;
  102628. var nextAction = _this._pendingActions.shift();
  102629. if (nextAction) {
  102630. _this._execute(workerInfo, nextAction);
  102631. }
  102632. });
  102633. };
  102634. return WorkerPool;
  102635. }());
  102636. /***/ }),
  102637. /***/ "./Morph/index.ts":
  102638. /*!************************!*\
  102639. !*** ./Morph/index.ts ***!
  102640. \************************/
  102641. /*! exports provided: MorphTarget, MorphTargetManager */
  102642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102643. "use strict";
  102644. __webpack_require__.r(__webpack_exports__);
  102645. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  102646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  102647. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  102648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  102649. /***/ }),
  102650. /***/ "./Morph/morphTarget.ts":
  102651. /*!******************************!*\
  102652. !*** ./Morph/morphTarget.ts ***!
  102653. \******************************/
  102654. /*! exports provided: MorphTarget */
  102655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102656. "use strict";
  102657. __webpack_require__.r(__webpack_exports__);
  102658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  102659. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102660. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  102661. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  102662. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  102663. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  102664. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  102665. /**
  102666. * Defines a target to use with MorphTargetManager
  102667. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102668. */
  102669. var MorphTarget = /** @class */ (function () {
  102670. /**
  102671. * Creates a new MorphTarget
  102672. * @param name defines the name of the target
  102673. * @param influence defines the influence to use
  102674. * @param scene defines the scene the morphtarget belongs to
  102675. */
  102676. function MorphTarget(
  102677. /** defines the name of the target */
  102678. name, influence, scene) {
  102679. if (influence === void 0) { influence = 0; }
  102680. if (scene === void 0) { scene = null; }
  102681. this.name = name;
  102682. /**
  102683. * Gets or sets the list of animations
  102684. */
  102685. this.animations = new Array();
  102686. this._positions = null;
  102687. this._normals = null;
  102688. this._tangents = null;
  102689. /**
  102690. * Observable raised when the influence changes
  102691. */
  102692. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  102693. /** @hidden */
  102694. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  102695. this._animationPropertiesOverride = null;
  102696. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  102697. this.influence = influence;
  102698. }
  102699. Object.defineProperty(MorphTarget.prototype, "influence", {
  102700. /**
  102701. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  102702. */
  102703. get: function () {
  102704. return this._influence;
  102705. },
  102706. set: function (influence) {
  102707. if (this._influence === influence) {
  102708. return;
  102709. }
  102710. var previous = this._influence;
  102711. this._influence = influence;
  102712. if (this.onInfluenceChanged.hasObservers) {
  102713. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  102714. }
  102715. },
  102716. enumerable: true,
  102717. configurable: true
  102718. });
  102719. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  102720. /**
  102721. * Gets or sets the animation properties override
  102722. */
  102723. get: function () {
  102724. if (!this._animationPropertiesOverride && this._scene) {
  102725. return this._scene.animationPropertiesOverride;
  102726. }
  102727. return this._animationPropertiesOverride;
  102728. },
  102729. set: function (value) {
  102730. this._animationPropertiesOverride = value;
  102731. },
  102732. enumerable: true,
  102733. configurable: true
  102734. });
  102735. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  102736. /**
  102737. * Gets a boolean defining if the target contains position data
  102738. */
  102739. get: function () {
  102740. return !!this._positions;
  102741. },
  102742. enumerable: true,
  102743. configurable: true
  102744. });
  102745. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  102746. /**
  102747. * Gets a boolean defining if the target contains normal data
  102748. */
  102749. get: function () {
  102750. return !!this._normals;
  102751. },
  102752. enumerable: true,
  102753. configurable: true
  102754. });
  102755. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  102756. /**
  102757. * Gets a boolean defining if the target contains tangent data
  102758. */
  102759. get: function () {
  102760. return !!this._tangents;
  102761. },
  102762. enumerable: true,
  102763. configurable: true
  102764. });
  102765. /**
  102766. * Affects position data to this target
  102767. * @param data defines the position data to use
  102768. */
  102769. MorphTarget.prototype.setPositions = function (data) {
  102770. var hadPositions = this.hasPositions;
  102771. this._positions = data;
  102772. if (hadPositions !== this.hasPositions) {
  102773. this._onDataLayoutChanged.notifyObservers(undefined);
  102774. }
  102775. };
  102776. /**
  102777. * Gets the position data stored in this target
  102778. * @returns a FloatArray containing the position data (or null if not present)
  102779. */
  102780. MorphTarget.prototype.getPositions = function () {
  102781. return this._positions;
  102782. };
  102783. /**
  102784. * Affects normal data to this target
  102785. * @param data defines the normal data to use
  102786. */
  102787. MorphTarget.prototype.setNormals = function (data) {
  102788. var hadNormals = this.hasNormals;
  102789. this._normals = data;
  102790. if (hadNormals !== this.hasNormals) {
  102791. this._onDataLayoutChanged.notifyObservers(undefined);
  102792. }
  102793. };
  102794. /**
  102795. * Gets the normal data stored in this target
  102796. * @returns a FloatArray containing the normal data (or null if not present)
  102797. */
  102798. MorphTarget.prototype.getNormals = function () {
  102799. return this._normals;
  102800. };
  102801. /**
  102802. * Affects tangent data to this target
  102803. * @param data defines the tangent data to use
  102804. */
  102805. MorphTarget.prototype.setTangents = function (data) {
  102806. var hadTangents = this.hasTangents;
  102807. this._tangents = data;
  102808. if (hadTangents !== this.hasTangents) {
  102809. this._onDataLayoutChanged.notifyObservers(undefined);
  102810. }
  102811. };
  102812. /**
  102813. * Gets the tangent data stored in this target
  102814. * @returns a FloatArray containing the tangent data (or null if not present)
  102815. */
  102816. MorphTarget.prototype.getTangents = function () {
  102817. return this._tangents;
  102818. };
  102819. /**
  102820. * Serializes the current target into a Serialization object
  102821. * @returns the serialized object
  102822. */
  102823. MorphTarget.prototype.serialize = function () {
  102824. var serializationObject = {};
  102825. serializationObject.name = this.name;
  102826. serializationObject.influence = this.influence;
  102827. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  102828. if (this.id != null) {
  102829. serializationObject.id = this.id;
  102830. }
  102831. if (this.hasNormals) {
  102832. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  102833. }
  102834. if (this.hasTangents) {
  102835. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  102836. }
  102837. // Animations
  102838. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  102839. return serializationObject;
  102840. };
  102841. /**
  102842. * Returns the string "MorphTarget"
  102843. * @returns "MorphTarget"
  102844. */
  102845. MorphTarget.prototype.getClassName = function () {
  102846. return "MorphTarget";
  102847. };
  102848. // Statics
  102849. /**
  102850. * Creates a new target from serialized data
  102851. * @param serializationObject defines the serialized data to use
  102852. * @returns a new MorphTarget
  102853. */
  102854. MorphTarget.Parse = function (serializationObject) {
  102855. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  102856. result.setPositions(serializationObject.positions);
  102857. if (serializationObject.id != null) {
  102858. result.id = serializationObject.id;
  102859. }
  102860. if (serializationObject.normals) {
  102861. result.setNormals(serializationObject.normals);
  102862. }
  102863. if (serializationObject.tangents) {
  102864. result.setTangents(serializationObject.tangents);
  102865. }
  102866. // Animations
  102867. if (serializationObject.animations) {
  102868. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  102869. var parsedAnimation = serializationObject.animations[animationIndex];
  102870. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  102871. if (internalClass) {
  102872. result.animations.push(internalClass.Parse(parsedAnimation));
  102873. }
  102874. }
  102875. }
  102876. return result;
  102877. };
  102878. /**
  102879. * Creates a MorphTarget from mesh data
  102880. * @param mesh defines the source mesh
  102881. * @param name defines the name to use for the new target
  102882. * @param influence defines the influence to attach to the target
  102883. * @returns a new MorphTarget
  102884. */
  102885. MorphTarget.FromMesh = function (mesh, name, influence) {
  102886. if (!name) {
  102887. name = mesh.name;
  102888. }
  102889. var result = new MorphTarget(name, influence, mesh.getScene());
  102890. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  102891. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  102892. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  102893. }
  102894. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  102895. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  102896. }
  102897. return result;
  102898. };
  102899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  102900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  102901. ], MorphTarget.prototype, "id", void 0);
  102902. return MorphTarget;
  102903. }());
  102904. /***/ }),
  102905. /***/ "./Morph/morphTargetManager.ts":
  102906. /*!*************************************!*\
  102907. !*** ./Morph/morphTargetManager.ts ***!
  102908. \*************************************/
  102909. /*! exports provided: MorphTargetManager */
  102910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102911. "use strict";
  102912. __webpack_require__.r(__webpack_exports__);
  102913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  102914. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  102915. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  102916. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  102917. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  102918. /**
  102919. * This class is used to deform meshes using morphing between different targets
  102920. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102921. */
  102922. var MorphTargetManager = /** @class */ (function () {
  102923. /**
  102924. * Creates a new MorphTargetManager
  102925. * @param scene defines the current scene
  102926. */
  102927. function MorphTargetManager(scene) {
  102928. if (scene === void 0) { scene = null; }
  102929. this._targets = new Array();
  102930. this._targetInfluenceChangedObservers = new Array();
  102931. this._targetDataLayoutChangedObservers = new Array();
  102932. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  102933. this._supportsNormals = false;
  102934. this._supportsTangents = false;
  102935. this._vertexCount = 0;
  102936. this._uniqueId = 0;
  102937. this._tempInfluences = new Array();
  102938. if (!scene) {
  102939. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  102940. }
  102941. this._scene = scene;
  102942. if (this._scene) {
  102943. this._scene.morphTargetManagers.push(this);
  102944. this._uniqueId = this._scene.getUniqueId();
  102945. }
  102946. }
  102947. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  102948. /**
  102949. * Gets the unique ID of this manager
  102950. */
  102951. get: function () {
  102952. return this._uniqueId;
  102953. },
  102954. enumerable: true,
  102955. configurable: true
  102956. });
  102957. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  102958. /**
  102959. * Gets the number of vertices handled by this manager
  102960. */
  102961. get: function () {
  102962. return this._vertexCount;
  102963. },
  102964. enumerable: true,
  102965. configurable: true
  102966. });
  102967. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  102968. /**
  102969. * Gets a boolean indicating if this manager supports morphing of normals
  102970. */
  102971. get: function () {
  102972. return this._supportsNormals;
  102973. },
  102974. enumerable: true,
  102975. configurable: true
  102976. });
  102977. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  102978. /**
  102979. * Gets a boolean indicating if this manager supports morphing of tangents
  102980. */
  102981. get: function () {
  102982. return this._supportsTangents;
  102983. },
  102984. enumerable: true,
  102985. configurable: true
  102986. });
  102987. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  102988. /**
  102989. * Gets the number of targets stored in this manager
  102990. */
  102991. get: function () {
  102992. return this._targets.length;
  102993. },
  102994. enumerable: true,
  102995. configurable: true
  102996. });
  102997. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  102998. /**
  102999. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103000. */
  103001. get: function () {
  103002. return this._activeTargets.length;
  103003. },
  103004. enumerable: true,
  103005. configurable: true
  103006. });
  103007. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  103008. /**
  103009. * Gets the list of influences (one per target)
  103010. */
  103011. get: function () {
  103012. return this._influences;
  103013. },
  103014. enumerable: true,
  103015. configurable: true
  103016. });
  103017. /**
  103018. * Gets the active target at specified index. An active target is a target with an influence > 0
  103019. * @param index defines the index to check
  103020. * @returns the requested target
  103021. */
  103022. MorphTargetManager.prototype.getActiveTarget = function (index) {
  103023. return this._activeTargets.data[index];
  103024. };
  103025. /**
  103026. * Gets the target at specified index
  103027. * @param index defines the index to check
  103028. * @returns the requested target
  103029. */
  103030. MorphTargetManager.prototype.getTarget = function (index) {
  103031. return this._targets[index];
  103032. };
  103033. /**
  103034. * Add a new target to this manager
  103035. * @param target defines the target to add
  103036. */
  103037. MorphTargetManager.prototype.addTarget = function (target) {
  103038. var _this = this;
  103039. this._targets.push(target);
  103040. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  103041. _this._syncActiveTargets(needUpdate);
  103042. }));
  103043. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  103044. _this._syncActiveTargets(true);
  103045. }));
  103046. this._syncActiveTargets(true);
  103047. };
  103048. /**
  103049. * Removes a target from the manager
  103050. * @param target defines the target to remove
  103051. */
  103052. MorphTargetManager.prototype.removeTarget = function (target) {
  103053. var index = this._targets.indexOf(target);
  103054. if (index >= 0) {
  103055. this._targets.splice(index, 1);
  103056. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  103057. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  103058. this._syncActiveTargets(true);
  103059. }
  103060. };
  103061. /**
  103062. * Serializes the current manager into a Serialization object
  103063. * @returns the serialized object
  103064. */
  103065. MorphTargetManager.prototype.serialize = function () {
  103066. var serializationObject = {};
  103067. serializationObject.id = this.uniqueId;
  103068. serializationObject.targets = [];
  103069. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  103070. var target = _a[_i];
  103071. serializationObject.targets.push(target.serialize());
  103072. }
  103073. return serializationObject;
  103074. };
  103075. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  103076. var influenceCount = 0;
  103077. this._activeTargets.reset();
  103078. this._supportsNormals = true;
  103079. this._supportsTangents = true;
  103080. this._vertexCount = 0;
  103081. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  103082. var target = _a[_i];
  103083. if (target.influence === 0) {
  103084. continue;
  103085. }
  103086. this._activeTargets.push(target);
  103087. this._tempInfluences[influenceCount++] = target.influence;
  103088. this._supportsNormals = this._supportsNormals && target.hasNormals;
  103089. this._supportsTangents = this._supportsTangents && target.hasTangents;
  103090. var positions = target.getPositions();
  103091. if (positions) {
  103092. var vertexCount = positions.length / 3;
  103093. if (this._vertexCount === 0) {
  103094. this._vertexCount = vertexCount;
  103095. }
  103096. else if (this._vertexCount !== vertexCount) {
  103097. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  103098. return;
  103099. }
  103100. }
  103101. }
  103102. if (!this._influences || this._influences.length !== influenceCount) {
  103103. this._influences = new Float32Array(influenceCount);
  103104. }
  103105. for (var index = 0; index < influenceCount; index++) {
  103106. this._influences[index] = this._tempInfluences[index];
  103107. }
  103108. if (needUpdate) {
  103109. this.synchronize();
  103110. }
  103111. };
  103112. /**
  103113. * Syncrhonize the targets with all the meshes using this morph target manager
  103114. */
  103115. MorphTargetManager.prototype.synchronize = function () {
  103116. if (!this._scene) {
  103117. return;
  103118. }
  103119. // Flag meshes as dirty to resync with the active targets
  103120. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  103121. var mesh = _a[_i];
  103122. if (mesh.morphTargetManager === this) {
  103123. mesh._syncGeometryWithMorphTargetManager();
  103124. }
  103125. }
  103126. };
  103127. // Statics
  103128. /**
  103129. * Creates a new MorphTargetManager from serialized data
  103130. * @param serializationObject defines the serialized data
  103131. * @param scene defines the hosting scene
  103132. * @returns the new MorphTargetManager
  103133. */
  103134. MorphTargetManager.Parse = function (serializationObject, scene) {
  103135. var result = new MorphTargetManager(scene);
  103136. result._uniqueId = serializationObject.id;
  103137. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  103138. var targetData = _a[_i];
  103139. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  103140. }
  103141. return result;
  103142. };
  103143. return MorphTargetManager;
  103144. }());
  103145. /***/ }),
  103146. /***/ "./Offline/database.ts":
  103147. /*!*****************************!*\
  103148. !*** ./Offline/database.ts ***!
  103149. \*****************************/
  103150. /*! exports provided: Database */
  103151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103152. "use strict";
  103153. __webpack_require__.r(__webpack_exports__);
  103154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  103155. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103156. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  103157. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  103158. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  103159. // Sets the default offline provider to Babylon.js
  103160. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  103161. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  103162. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  103163. };
  103164. /**
  103165. * Class used to enable access to IndexedDB
  103166. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  103167. */
  103168. var Database = /** @class */ (function () {
  103169. /**
  103170. * Creates a new Database
  103171. * @param urlToScene defines the url to load the scene
  103172. * @param callbackManifestChecked defines the callback to use when manifest is checked
  103173. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  103174. */
  103175. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  103176. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  103177. var _this = this;
  103178. // Handling various flavors of prefixed version of IndexedDB
  103179. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  103180. this._callbackManifestChecked = callbackManifestChecked;
  103181. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  103182. this._db = null;
  103183. this._enableSceneOffline = false;
  103184. this._enableTexturesOffline = false;
  103185. this._manifestVersionFound = 0;
  103186. this._mustUpdateRessources = false;
  103187. this._hasReachedQuota = false;
  103188. if (!Database.IDBStorageEnabled) {
  103189. this._callbackManifestChecked(true);
  103190. }
  103191. else {
  103192. if (disableManifestCheck) {
  103193. this._enableSceneOffline = true;
  103194. this._enableTexturesOffline = true;
  103195. this._manifestVersionFound = 1;
  103196. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  103197. _this._callbackManifestChecked(true);
  103198. });
  103199. }
  103200. else {
  103201. this._checkManifestFile();
  103202. }
  103203. }
  103204. }
  103205. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  103206. /**
  103207. * Gets a boolean indicating if scene must be saved in the database
  103208. */
  103209. get: function () {
  103210. return this._enableSceneOffline;
  103211. },
  103212. enumerable: true,
  103213. configurable: true
  103214. });
  103215. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  103216. /**
  103217. * Gets a boolean indicating if textures must be saved in the database
  103218. */
  103219. get: function () {
  103220. return this._enableTexturesOffline;
  103221. },
  103222. enumerable: true,
  103223. configurable: true
  103224. });
  103225. Database.prototype._checkManifestFile = function () {
  103226. var _this = this;
  103227. var noManifestFile = function () {
  103228. _this._enableSceneOffline = false;
  103229. _this._enableTexturesOffline = false;
  103230. _this._callbackManifestChecked(false);
  103231. };
  103232. var timeStampUsed = false;
  103233. var manifestURL = this._currentSceneUrl + ".manifest";
  103234. var xhr = new XMLHttpRequest();
  103235. if (navigator.onLine) {
  103236. // Adding a timestamp to by-pass browsers' cache
  103237. timeStampUsed = true;
  103238. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  103239. }
  103240. xhr.open("GET", manifestURL, true);
  103241. xhr.addEventListener("load", function () {
  103242. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  103243. try {
  103244. var manifestFile = JSON.parse(xhr.response);
  103245. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  103246. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  103247. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  103248. _this._manifestVersionFound = manifestFile.version;
  103249. }
  103250. if (_this._callbackManifestChecked) {
  103251. _this._callbackManifestChecked(true);
  103252. }
  103253. }
  103254. catch (ex) {
  103255. noManifestFile();
  103256. }
  103257. }
  103258. else {
  103259. noManifestFile();
  103260. }
  103261. }, false);
  103262. xhr.addEventListener("error", function () {
  103263. if (timeStampUsed) {
  103264. timeStampUsed = false;
  103265. // Let's retry without the timeStamp
  103266. // It could fail when coupled with HTML5 Offline API
  103267. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  103268. xhr.open("GET", retryManifestURL, true);
  103269. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  103270. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  103271. }
  103272. xhr.send();
  103273. }
  103274. else {
  103275. noManifestFile();
  103276. }
  103277. }, false);
  103278. try {
  103279. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  103280. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  103281. }
  103282. xhr.send();
  103283. }
  103284. catch (ex) {
  103285. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  103286. this._callbackManifestChecked(false);
  103287. }
  103288. };
  103289. /**
  103290. * Open the database and make it available
  103291. * @param successCallback defines the callback to call on success
  103292. * @param errorCallback defines the callback to call on error
  103293. */
  103294. Database.prototype.open = function (successCallback, errorCallback) {
  103295. var _this = this;
  103296. var handleError = function () {
  103297. _this._isSupported = false;
  103298. if (errorCallback) {
  103299. errorCallback();
  103300. }
  103301. };
  103302. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  103303. // Your browser doesn't support IndexedDB
  103304. this._isSupported = false;
  103305. if (errorCallback) {
  103306. errorCallback();
  103307. }
  103308. }
  103309. else {
  103310. // If the DB hasn't been opened or created yet
  103311. if (!this._db) {
  103312. this._hasReachedQuota = false;
  103313. this._isSupported = true;
  103314. var request = this._idbFactory.open("babylonjs", 1);
  103315. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  103316. request.onerror = function () {
  103317. handleError();
  103318. };
  103319. // executes when a version change transaction cannot complete due to other active transactions
  103320. request.onblocked = function () {
  103321. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  103322. handleError();
  103323. };
  103324. // DB has been opened successfully
  103325. request.onsuccess = function () {
  103326. _this._db = request.result;
  103327. successCallback();
  103328. };
  103329. // Initialization of the DB. Creating Scenes & Textures stores
  103330. request.onupgradeneeded = function (event) {
  103331. _this._db = (event.target).result;
  103332. if (_this._db) {
  103333. try {
  103334. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  103335. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  103336. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  103337. }
  103338. catch (ex) {
  103339. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  103340. handleError();
  103341. }
  103342. }
  103343. };
  103344. }
  103345. // DB has already been created and opened
  103346. else {
  103347. if (successCallback) {
  103348. successCallback();
  103349. }
  103350. }
  103351. }
  103352. };
  103353. /**
  103354. * Loads an image from the database
  103355. * @param url defines the url to load from
  103356. * @param image defines the target DOM image
  103357. */
  103358. Database.prototype.loadImage = function (url, image) {
  103359. var _this = this;
  103360. var completeURL = Database._ReturnFullUrlLocation(url);
  103361. var saveAndLoadImage = function () {
  103362. if (!_this._hasReachedQuota && _this._db !== null) {
  103363. // the texture is not yet in the DB, let's try to save it
  103364. _this._saveImageIntoDBAsync(completeURL, image);
  103365. }
  103366. // If the texture is not in the DB and we've reached the DB quota limit
  103367. // let's load it directly from the web
  103368. else {
  103369. image.src = url;
  103370. }
  103371. };
  103372. if (!this._mustUpdateRessources) {
  103373. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  103374. }
  103375. // First time we're download the images or update requested in the manifest file by a version change
  103376. else {
  103377. saveAndLoadImage();
  103378. }
  103379. };
  103380. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  103381. if (this._isSupported && this._db !== null) {
  103382. var texture;
  103383. var transaction = this._db.transaction(["textures"]);
  103384. transaction.onabort = function () {
  103385. image.src = url;
  103386. };
  103387. transaction.oncomplete = function () {
  103388. var blobTextureURL;
  103389. if (texture) {
  103390. var URL = window.URL || window.webkitURL;
  103391. blobTextureURL = URL.createObjectURL(texture.data);
  103392. image.onerror = function () {
  103393. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  103394. image.src = url;
  103395. };
  103396. image.src = blobTextureURL;
  103397. }
  103398. else {
  103399. notInDBCallback();
  103400. }
  103401. };
  103402. var getRequest = transaction.objectStore("textures").get(url);
  103403. getRequest.onsuccess = function (event) {
  103404. texture = (event.target).result;
  103405. };
  103406. getRequest.onerror = function () {
  103407. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  103408. image.src = url;
  103409. };
  103410. }
  103411. else {
  103412. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  103413. image.src = url;
  103414. }
  103415. };
  103416. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  103417. var _this = this;
  103418. if (this._isSupported) {
  103419. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  103420. var generateBlobUrl = function () {
  103421. var blobTextureURL;
  103422. if (blob) {
  103423. var URL = window.URL || window.webkitURL;
  103424. try {
  103425. blobTextureURL = URL.createObjectURL(blob);
  103426. }
  103427. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  103428. catch (ex) {
  103429. blobTextureURL = URL.createObjectURL(blob);
  103430. }
  103431. }
  103432. if (blobTextureURL) {
  103433. image.src = blobTextureURL;
  103434. }
  103435. };
  103436. if (Database.IsUASupportingBlobStorage) { // Create XHR
  103437. var xhr = new XMLHttpRequest(), blob;
  103438. xhr.open("GET", url, true);
  103439. xhr.responseType = "blob";
  103440. xhr.addEventListener("load", function () {
  103441. if (xhr.status === 200 && _this._db) {
  103442. // Blob as response (XHR2)
  103443. blob = xhr.response;
  103444. var transaction = _this._db.transaction(["textures"], "readwrite");
  103445. // the transaction could abort because of a QuotaExceededError error
  103446. transaction.onabort = function (event) {
  103447. try {
  103448. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  103449. var srcElement = (event.srcElement || event.target);
  103450. var error = srcElement.error;
  103451. if (error && error.name === "QuotaExceededError") {
  103452. _this._hasReachedQuota = true;
  103453. }
  103454. }
  103455. catch (ex) { }
  103456. generateBlobUrl();
  103457. };
  103458. transaction.oncomplete = function () {
  103459. generateBlobUrl();
  103460. };
  103461. var newTexture = { textureUrl: url, data: blob };
  103462. try {
  103463. // Put the blob into the dabase
  103464. var addRequest = transaction.objectStore("textures").put(newTexture);
  103465. addRequest.onsuccess = function () {
  103466. };
  103467. addRequest.onerror = function () {
  103468. generateBlobUrl();
  103469. };
  103470. }
  103471. catch (ex) {
  103472. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  103473. if (ex.code === 25) {
  103474. Database.IsUASupportingBlobStorage = false;
  103475. _this._enableTexturesOffline = false;
  103476. }
  103477. image.src = url;
  103478. }
  103479. }
  103480. else {
  103481. image.src = url;
  103482. }
  103483. }, false);
  103484. xhr.addEventListener("error", function () {
  103485. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  103486. image.src = url;
  103487. }, false);
  103488. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  103489. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  103490. }
  103491. xhr.send();
  103492. }
  103493. else {
  103494. image.src = url;
  103495. }
  103496. }
  103497. else {
  103498. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  103499. image.src = url;
  103500. }
  103501. };
  103502. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  103503. var _this = this;
  103504. var updateVersion = function () {
  103505. // the version is not yet in the DB or we need to update it
  103506. _this._saveVersionIntoDBAsync(url, versionLoaded);
  103507. };
  103508. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  103509. };
  103510. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  103511. var _this = this;
  103512. if (this._isSupported && this._db) {
  103513. var version;
  103514. try {
  103515. var transaction = this._db.transaction(["versions"]);
  103516. transaction.oncomplete = function () {
  103517. if (version) {
  103518. // If the version in the JSON file is different from the version in DB
  103519. if (_this._manifestVersionFound !== version.data) {
  103520. _this._mustUpdateRessources = true;
  103521. updateInDBCallback();
  103522. }
  103523. else {
  103524. callback(version.data);
  103525. }
  103526. }
  103527. // version was not found in DB
  103528. else {
  103529. _this._mustUpdateRessources = true;
  103530. updateInDBCallback();
  103531. }
  103532. };
  103533. transaction.onabort = function () {
  103534. callback(-1);
  103535. };
  103536. var getRequest = transaction.objectStore("versions").get(url);
  103537. getRequest.onsuccess = function (event) {
  103538. version = (event.target).result;
  103539. };
  103540. getRequest.onerror = function () {
  103541. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  103542. callback(-1);
  103543. };
  103544. }
  103545. catch (ex) {
  103546. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  103547. callback(-1);
  103548. }
  103549. }
  103550. else {
  103551. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  103552. callback(-1);
  103553. }
  103554. };
  103555. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  103556. var _this = this;
  103557. if (this._isSupported && !this._hasReachedQuota && this._db) {
  103558. try {
  103559. // Open a transaction to the database
  103560. var transaction = this._db.transaction(["versions"], "readwrite");
  103561. // the transaction could abort because of a QuotaExceededError error
  103562. transaction.onabort = function (event) {
  103563. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  103564. var error = event.srcElement['error'];
  103565. if (error && error.name === "QuotaExceededError") {
  103566. _this._hasReachedQuota = true;
  103567. }
  103568. }
  103569. catch (ex) { }
  103570. callback(-1);
  103571. };
  103572. transaction.oncomplete = function () {
  103573. callback(_this._manifestVersionFound);
  103574. };
  103575. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  103576. // Put the scene into the database
  103577. var addRequest = transaction.objectStore("versions").put(newVersion);
  103578. addRequest.onsuccess = function () {
  103579. };
  103580. addRequest.onerror = function () {
  103581. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  103582. };
  103583. }
  103584. catch (ex) {
  103585. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  103586. callback(-1);
  103587. }
  103588. }
  103589. else {
  103590. callback(-1);
  103591. }
  103592. };
  103593. /**
  103594. * Loads a file from database
  103595. * @param url defines the URL to load from
  103596. * @param sceneLoaded defines a callback to call on success
  103597. * @param progressCallBack defines a callback to call when progress changed
  103598. * @param errorCallback defines a callback to call on error
  103599. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  103600. */
  103601. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  103602. var _this = this;
  103603. var completeUrl = Database._ReturnFullUrlLocation(url);
  103604. var saveAndLoadFile = function () {
  103605. // the scene is not yet in the DB, let's try to save it
  103606. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  103607. };
  103608. this._checkVersionFromDB(completeUrl, function (version) {
  103609. if (version !== -1) {
  103610. if (!_this._mustUpdateRessources) {
  103611. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  103612. }
  103613. else {
  103614. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  103615. }
  103616. }
  103617. else {
  103618. if (errorCallback) {
  103619. errorCallback();
  103620. }
  103621. }
  103622. });
  103623. };
  103624. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  103625. if (this._isSupported && this._db) {
  103626. var targetStore;
  103627. if (url.indexOf(".babylon") !== -1) {
  103628. targetStore = "scenes";
  103629. }
  103630. else {
  103631. targetStore = "textures";
  103632. }
  103633. var file;
  103634. var transaction = this._db.transaction([targetStore]);
  103635. transaction.oncomplete = function () {
  103636. if (file) {
  103637. callback(file.data);
  103638. }
  103639. // file was not found in DB
  103640. else {
  103641. notInDBCallback();
  103642. }
  103643. };
  103644. transaction.onabort = function () {
  103645. notInDBCallback();
  103646. };
  103647. var getRequest = transaction.objectStore(targetStore).get(url);
  103648. getRequest.onsuccess = function (event) {
  103649. file = (event.target).result;
  103650. };
  103651. getRequest.onerror = function () {
  103652. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  103653. notInDBCallback();
  103654. };
  103655. }
  103656. else {
  103657. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  103658. callback();
  103659. }
  103660. };
  103661. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  103662. var _this = this;
  103663. if (this._isSupported) {
  103664. var targetStore;
  103665. if (url.indexOf(".babylon") !== -1) {
  103666. targetStore = "scenes";
  103667. }
  103668. else {
  103669. targetStore = "textures";
  103670. }
  103671. // Create XHR
  103672. var xhr = new XMLHttpRequest();
  103673. var fileData;
  103674. xhr.open("GET", url + "?" + Date.now(), true);
  103675. if (useArrayBuffer) {
  103676. xhr.responseType = "arraybuffer";
  103677. }
  103678. if (progressCallback) {
  103679. xhr.onprogress = progressCallback;
  103680. }
  103681. xhr.addEventListener("load", function () {
  103682. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  103683. // Blob as response (XHR2)
  103684. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  103685. if (!_this._hasReachedQuota && _this._db) {
  103686. // Open a transaction to the database
  103687. var transaction = _this._db.transaction([targetStore], "readwrite");
  103688. // the transaction could abort because of a QuotaExceededError error
  103689. transaction.onabort = function (event) {
  103690. try {
  103691. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  103692. var error = event.srcElement['error'];
  103693. if (error && error.name === "QuotaExceededError") {
  103694. _this._hasReachedQuota = true;
  103695. }
  103696. }
  103697. catch (ex) { }
  103698. callback(fileData);
  103699. };
  103700. transaction.oncomplete = function () {
  103701. callback(fileData);
  103702. };
  103703. var newFile;
  103704. if (targetStore === "scenes") {
  103705. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  103706. }
  103707. else {
  103708. newFile = { textureUrl: url, data: fileData };
  103709. }
  103710. try {
  103711. // Put the scene into the database
  103712. var addRequest = transaction.objectStore(targetStore).put(newFile);
  103713. addRequest.onsuccess = function () {
  103714. };
  103715. addRequest.onerror = function () {
  103716. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  103717. };
  103718. }
  103719. catch (ex) {
  103720. callback(fileData);
  103721. }
  103722. }
  103723. else {
  103724. callback(fileData);
  103725. }
  103726. }
  103727. else {
  103728. if (xhr.status >= 400 && errorCallback) {
  103729. errorCallback(xhr);
  103730. }
  103731. else {
  103732. callback();
  103733. }
  103734. }
  103735. }, false);
  103736. xhr.addEventListener("error", function () {
  103737. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  103738. callback();
  103739. }, false);
  103740. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  103741. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  103742. }
  103743. xhr.send();
  103744. }
  103745. else {
  103746. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  103747. callback();
  103748. }
  103749. };
  103750. /**
  103751. * Validates if xhr data is correct
  103752. * @param xhr defines the request to validate
  103753. * @param dataType defines the expected data type
  103754. * @returns true if data is correct
  103755. */
  103756. Database._ValidateXHRData = function (xhr, dataType) {
  103757. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  103758. if (dataType === void 0) { dataType = 7; }
  103759. try {
  103760. if (dataType & 1) {
  103761. if (xhr.responseText && xhr.responseText.length > 0) {
  103762. return true;
  103763. }
  103764. else if (dataType === 1) {
  103765. return false;
  103766. }
  103767. }
  103768. if (dataType & 2) {
  103769. // Check header width and height since there is no "TGA" magic number
  103770. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  103771. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  103772. return true;
  103773. }
  103774. else if (dataType === 2) {
  103775. return false;
  103776. }
  103777. }
  103778. if (dataType & 4) {
  103779. // Check for the "DDS" magic number
  103780. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  103781. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  103782. return true;
  103783. }
  103784. else {
  103785. return false;
  103786. }
  103787. }
  103788. }
  103789. catch (e) {
  103790. // Global protection
  103791. }
  103792. return false;
  103793. };
  103794. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  103795. Database.IsUASupportingBlobStorage = true;
  103796. /**
  103797. * Gets a boolean indicating if Database storate is enabled (off by default)
  103798. */
  103799. Database.IDBStorageEnabled = false;
  103800. Database._ParseURL = function (url) {
  103801. var a = document.createElement('a');
  103802. a.href = url;
  103803. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  103804. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  103805. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  103806. return absLocation;
  103807. };
  103808. Database._ReturnFullUrlLocation = function (url) {
  103809. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  103810. return (Database._ParseURL(window.location.href) + url);
  103811. }
  103812. else {
  103813. return url;
  103814. }
  103815. };
  103816. return Database;
  103817. }());
  103818. /***/ }),
  103819. /***/ "./Offline/index.ts":
  103820. /*!**************************!*\
  103821. !*** ./Offline/index.ts ***!
  103822. \**************************/
  103823. /*! exports provided: Database */
  103824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103825. "use strict";
  103826. __webpack_require__.r(__webpack_exports__);
  103827. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  103828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  103829. /***/ }),
  103830. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  103831. /*!******************************************************!*\
  103832. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  103833. \******************************************************/
  103834. /*! exports provided: BoxParticleEmitter */
  103835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103836. "use strict";
  103837. __webpack_require__.r(__webpack_exports__);
  103838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  103839. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103840. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  103841. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103842. /**
  103843. * Particle emitter emitting particles from the inside of a box.
  103844. * It emits the particles randomly between 2 given directions.
  103845. */
  103846. var BoxParticleEmitter = /** @class */ (function () {
  103847. /**
  103848. * Creates a new instance BoxParticleEmitter
  103849. */
  103850. function BoxParticleEmitter() {
  103851. /**
  103852. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103853. */
  103854. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  103855. /**
  103856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103857. */
  103858. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  103859. /**
  103860. * 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.
  103861. */
  103862. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  103863. /**
  103864. * 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.
  103865. */
  103866. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  103867. }
  103868. /**
  103869. * Called by the particle System when the direction is computed for the created particle.
  103870. * @param worldMatrix is the world matrix of the particle system
  103871. * @param directionToUpdate is the direction vector to update with the result
  103872. * @param particle is the particle we are computed the direction for
  103873. */
  103874. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103875. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  103876. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  103877. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  103878. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  103879. };
  103880. /**
  103881. * Called by the particle System when the position is computed for the created particle.
  103882. * @param worldMatrix is the world matrix of the particle system
  103883. * @param positionToUpdate is the position vector to update with the result
  103884. * @param particle is the particle we are computed the position for
  103885. */
  103886. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  103887. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  103888. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  103889. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  103890. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  103891. };
  103892. /**
  103893. * Clones the current emitter and returns a copy of it
  103894. * @returns the new emitter
  103895. */
  103896. BoxParticleEmitter.prototype.clone = function () {
  103897. var newOne = new BoxParticleEmitter();
  103898. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  103899. return newOne;
  103900. };
  103901. /**
  103902. * Called by the GPUParticleSystem to setup the update shader
  103903. * @param effect defines the update shader
  103904. */
  103905. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  103906. effect.setVector3("direction1", this.direction1);
  103907. effect.setVector3("direction2", this.direction2);
  103908. effect.setVector3("minEmitBox", this.minEmitBox);
  103909. effect.setVector3("maxEmitBox", this.maxEmitBox);
  103910. };
  103911. /**
  103912. * Returns a string to use to update the GPU particles update shader
  103913. * @returns a string containng the defines string
  103914. */
  103915. BoxParticleEmitter.prototype.getEffectDefines = function () {
  103916. return "#define BOXEMITTER";
  103917. };
  103918. /**
  103919. * Returns the string "BoxParticleEmitter"
  103920. * @returns a string containing the class name
  103921. */
  103922. BoxParticleEmitter.prototype.getClassName = function () {
  103923. return "BoxParticleEmitter";
  103924. };
  103925. /**
  103926. * Serializes the particle system to a JSON object.
  103927. * @returns the JSON object
  103928. */
  103929. BoxParticleEmitter.prototype.serialize = function () {
  103930. var serializationObject = {};
  103931. serializationObject.type = this.getClassName();
  103932. serializationObject.direction1 = this.direction1.asArray();
  103933. serializationObject.direction2 = this.direction2.asArray();
  103934. serializationObject.minEmitBox = this.minEmitBox.asArray();
  103935. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  103936. return serializationObject;
  103937. };
  103938. /**
  103939. * Parse properties from a JSON object
  103940. * @param serializationObject defines the JSON object
  103941. */
  103942. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  103943. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  103944. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  103945. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  103946. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  103947. };
  103948. return BoxParticleEmitter;
  103949. }());
  103950. /***/ }),
  103951. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  103952. /*!*******************************************************!*\
  103953. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  103954. \*******************************************************/
  103955. /*! exports provided: ConeParticleEmitter */
  103956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103957. "use strict";
  103958. __webpack_require__.r(__webpack_exports__);
  103959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  103960. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103961. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  103962. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103963. /**
  103964. * Particle emitter emitting particles from the inside of a cone.
  103965. * It emits the particles alongside the cone volume from the base to the particle.
  103966. * The emission direction might be randomized.
  103967. */
  103968. var ConeParticleEmitter = /** @class */ (function () {
  103969. /**
  103970. * Creates a new instance ConeParticleEmitter
  103971. * @param radius the radius of the emission cone (1 by default)
  103972. * @param angle the cone base angle (PI by default)
  103973. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  103974. */
  103975. function ConeParticleEmitter(radius, angle,
  103976. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  103977. directionRandomizer) {
  103978. if (radius === void 0) { radius = 1; }
  103979. if (angle === void 0) { angle = Math.PI; }
  103980. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103981. this.directionRandomizer = directionRandomizer;
  103982. /**
  103983. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  103984. */
  103985. this.radiusRange = 1;
  103986. /**
  103987. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  103988. */
  103989. this.heightRange = 1;
  103990. /**
  103991. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  103992. */
  103993. this.emitFromSpawnPointOnly = false;
  103994. this.angle = angle;
  103995. this.radius = radius;
  103996. }
  103997. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  103998. /**
  103999. * Gets or sets the radius of the emission cone
  104000. */
  104001. get: function () {
  104002. return this._radius;
  104003. },
  104004. set: function (value) {
  104005. this._radius = value;
  104006. this._buildHeight();
  104007. },
  104008. enumerable: true,
  104009. configurable: true
  104010. });
  104011. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  104012. /**
  104013. * Gets or sets the angle of the emission cone
  104014. */
  104015. get: function () {
  104016. return this._angle;
  104017. },
  104018. set: function (value) {
  104019. this._angle = value;
  104020. this._buildHeight();
  104021. },
  104022. enumerable: true,
  104023. configurable: true
  104024. });
  104025. ConeParticleEmitter.prototype._buildHeight = function () {
  104026. if (this._angle !== 0) {
  104027. this._height = this._radius / Math.tan(this._angle / 2);
  104028. }
  104029. else {
  104030. this._height = 1;
  104031. }
  104032. };
  104033. /**
  104034. * Called by the particle System when the direction is computed for the created particle.
  104035. * @param worldMatrix is the world matrix of the particle system
  104036. * @param directionToUpdate is the direction vector to update with the result
  104037. * @param particle is the particle we are computed the direction for
  104038. */
  104039. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104040. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  104041. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  104042. }
  104043. else {
  104044. // measure the direction Vector from the emitter to the particle.
  104045. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  104046. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104047. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104048. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104049. direction.x += randX;
  104050. direction.y += randY;
  104051. direction.z += randZ;
  104052. direction.normalize();
  104053. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  104054. }
  104055. };
  104056. /**
  104057. * Called by the particle System when the position is computed for the created particle.
  104058. * @param worldMatrix is the world matrix of the particle system
  104059. * @param positionToUpdate is the position vector to update with the result
  104060. * @param particle is the particle we are computed the position for
  104061. */
  104062. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  104063. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  104064. var h;
  104065. if (!this.emitFromSpawnPointOnly) {
  104066. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  104067. // Better distribution in a cone at normal angles.
  104068. h = 1 - h * h;
  104069. }
  104070. else {
  104071. h = 0.0001;
  104072. }
  104073. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  104074. radius = radius * h;
  104075. var randX = radius * Math.sin(s);
  104076. var randZ = radius * Math.cos(s);
  104077. var randY = h * this._height;
  104078. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  104079. };
  104080. /**
  104081. * Clones the current emitter and returns a copy of it
  104082. * @returns the new emitter
  104083. */
  104084. ConeParticleEmitter.prototype.clone = function () {
  104085. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  104086. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  104087. return newOne;
  104088. };
  104089. /**
  104090. * Called by the GPUParticleSystem to setup the update shader
  104091. * @param effect defines the update shader
  104092. */
  104093. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  104094. effect.setFloat2("radius", this._radius, this.radiusRange);
  104095. effect.setFloat("coneAngle", this._angle);
  104096. effect.setFloat2("height", this._height, this.heightRange);
  104097. effect.setFloat("directionRandomizer", this.directionRandomizer);
  104098. };
  104099. /**
  104100. * Returns a string to use to update the GPU particles update shader
  104101. * @returns a string containng the defines string
  104102. */
  104103. ConeParticleEmitter.prototype.getEffectDefines = function () {
  104104. var defines = "#define CONEEMITTER";
  104105. if (this.emitFromSpawnPointOnly) {
  104106. defines += "\n#define CONEEMITTERSPAWNPOINT";
  104107. }
  104108. return defines;
  104109. };
  104110. /**
  104111. * Returns the string "ConeParticleEmitter"
  104112. * @returns a string containing the class name
  104113. */
  104114. ConeParticleEmitter.prototype.getClassName = function () {
  104115. return "ConeParticleEmitter";
  104116. };
  104117. /**
  104118. * Serializes the particle system to a JSON object.
  104119. * @returns the JSON object
  104120. */
  104121. ConeParticleEmitter.prototype.serialize = function () {
  104122. var serializationObject = {};
  104123. serializationObject.type = this.getClassName();
  104124. serializationObject.radius = this._radius;
  104125. serializationObject.angle = this._angle;
  104126. serializationObject.directionRandomizer = this.directionRandomizer;
  104127. return serializationObject;
  104128. };
  104129. /**
  104130. * Parse properties from a JSON object
  104131. * @param serializationObject defines the JSON object
  104132. */
  104133. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  104134. this.radius = serializationObject.radius;
  104135. this.angle = serializationObject.angle;
  104136. this.directionRandomizer = serializationObject.directionRandomizer;
  104137. };
  104138. return ConeParticleEmitter;
  104139. }());
  104140. /***/ }),
  104141. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  104142. /*!***********************************************************!*\
  104143. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  104144. \***********************************************************/
  104145. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  104146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104147. "use strict";
  104148. __webpack_require__.r(__webpack_exports__);
  104149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  104150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  104151. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104152. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  104153. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104154. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104155. /**
  104156. * Particle emitter emitting particles from the inside of a cylinder.
  104157. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  104158. */
  104159. var CylinderParticleEmitter = /** @class */ (function () {
  104160. /**
  104161. * Creates a new instance CylinderParticleEmitter
  104162. * @param radius the radius of the emission cylinder (1 by default)
  104163. * @param height the height of the emission cylinder (1 by default)
  104164. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  104165. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  104166. */
  104167. function CylinderParticleEmitter(
  104168. /**
  104169. * The radius of the emission cylinder.
  104170. */
  104171. radius,
  104172. /**
  104173. * The height of the emission cylinder.
  104174. */
  104175. height,
  104176. /**
  104177. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  104178. */
  104179. radiusRange,
  104180. /**
  104181. * How much to randomize the particle direction [0-1].
  104182. */
  104183. directionRandomizer) {
  104184. if (radius === void 0) { radius = 1; }
  104185. if (height === void 0) { height = 1; }
  104186. if (radiusRange === void 0) { radiusRange = 1; }
  104187. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  104188. this.radius = radius;
  104189. this.height = height;
  104190. this.radiusRange = radiusRange;
  104191. this.directionRandomizer = directionRandomizer;
  104192. }
  104193. /**
  104194. * Called by the particle System when the direction is computed for the created particle.
  104195. * @param worldMatrix is the world matrix of the particle system
  104196. * @param directionToUpdate is the direction vector to update with the result
  104197. * @param particle is the particle we are computed the direction for
  104198. */
  104199. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104200. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  104201. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  104202. var angle = Math.atan2(direction.x, direction.z);
  104203. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  104204. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  104205. direction.x = Math.sin(angle);
  104206. direction.z = Math.cos(angle);
  104207. direction.normalize();
  104208. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  104209. };
  104210. /**
  104211. * Called by the particle System when the position is computed for the created particle.
  104212. * @param worldMatrix is the world matrix of the particle system
  104213. * @param positionToUpdate is the position vector to update with the result
  104214. * @param particle is the particle we are computed the position for
  104215. */
  104216. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  104217. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  104218. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  104219. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  104220. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  104221. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  104222. var xPos = positionRadius * Math.cos(angle);
  104223. var zPos = positionRadius * Math.sin(angle);
  104224. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  104225. };
  104226. /**
  104227. * Clones the current emitter and returns a copy of it
  104228. * @returns the new emitter
  104229. */
  104230. CylinderParticleEmitter.prototype.clone = function () {
  104231. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  104232. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  104233. return newOne;
  104234. };
  104235. /**
  104236. * Called by the GPUParticleSystem to setup the update shader
  104237. * @param effect defines the update shader
  104238. */
  104239. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  104240. effect.setFloat("radius", this.radius);
  104241. effect.setFloat("height", this.height);
  104242. effect.setFloat("radiusRange", this.radiusRange);
  104243. effect.setFloat("directionRandomizer", this.directionRandomizer);
  104244. };
  104245. /**
  104246. * Returns a string to use to update the GPU particles update shader
  104247. * @returns a string containng the defines string
  104248. */
  104249. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  104250. return "#define CYLINDEREMITTER";
  104251. };
  104252. /**
  104253. * Returns the string "CylinderParticleEmitter"
  104254. * @returns a string containing the class name
  104255. */
  104256. CylinderParticleEmitter.prototype.getClassName = function () {
  104257. return "CylinderParticleEmitter";
  104258. };
  104259. /**
  104260. * Serializes the particle system to a JSON object.
  104261. * @returns the JSON object
  104262. */
  104263. CylinderParticleEmitter.prototype.serialize = function () {
  104264. var serializationObject = {};
  104265. serializationObject.type = this.getClassName();
  104266. serializationObject.radius = this.radius;
  104267. serializationObject.height = this.height;
  104268. serializationObject.radiusRange = this.radiusRange;
  104269. serializationObject.directionRandomizer = this.directionRandomizer;
  104270. return serializationObject;
  104271. };
  104272. /**
  104273. * Parse properties from a JSON object
  104274. * @param serializationObject defines the JSON object
  104275. */
  104276. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  104277. this.radius = serializationObject.radius;
  104278. this.height = serializationObject.height;
  104279. this.radiusRange = serializationObject.radiusRange;
  104280. this.directionRandomizer = serializationObject.directionRandomizer;
  104281. };
  104282. return CylinderParticleEmitter;
  104283. }());
  104284. /**
  104285. * Particle emitter emitting particles from the inside of a cylinder.
  104286. * It emits the particles randomly between two vectors.
  104287. */
  104288. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  104289. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  104290. /**
  104291. * Creates a new instance CylinderDirectedParticleEmitter
  104292. * @param radius the radius of the emission cylinder (1 by default)
  104293. * @param height the height of the emission cylinder (1 by default)
  104294. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  104295. * @param direction1 the min limit of the emission direction (up vector by default)
  104296. * @param direction2 the max limit of the emission direction (up vector by default)
  104297. */
  104298. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  104299. /**
  104300. * The min limit of the emission direction.
  104301. */
  104302. direction1,
  104303. /**
  104304. * The max limit of the emission direction.
  104305. */
  104306. direction2) {
  104307. if (radius === void 0) { radius = 1; }
  104308. if (height === void 0) { height = 1; }
  104309. if (radiusRange === void 0) { radiusRange = 1; }
  104310. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  104311. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  104312. var _this = _super.call(this, radius, height, radiusRange) || this;
  104313. _this.direction1 = direction1;
  104314. _this.direction2 = direction2;
  104315. return _this;
  104316. }
  104317. /**
  104318. * Called by the particle System when the direction is computed for the created particle.
  104319. * @param worldMatrix is the world matrix of the particle system
  104320. * @param directionToUpdate is the direction vector to update with the result
  104321. * @param particle is the particle we are computed the direction for
  104322. */
  104323. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104324. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  104325. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  104326. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  104327. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  104328. };
  104329. /**
  104330. * Clones the current emitter and returns a copy of it
  104331. * @returns the new emitter
  104332. */
  104333. CylinderDirectedParticleEmitter.prototype.clone = function () {
  104334. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  104335. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  104336. return newOne;
  104337. };
  104338. /**
  104339. * Called by the GPUParticleSystem to setup the update shader
  104340. * @param effect defines the update shader
  104341. */
  104342. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  104343. effect.setFloat("radius", this.radius);
  104344. effect.setFloat("height", this.height);
  104345. effect.setFloat("radiusRange", this.radiusRange);
  104346. effect.setVector3("direction1", this.direction1);
  104347. effect.setVector3("direction2", this.direction2);
  104348. };
  104349. /**
  104350. * Returns a string to use to update the GPU particles update shader
  104351. * @returns a string containng the defines string
  104352. */
  104353. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  104354. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  104355. };
  104356. /**
  104357. * Returns the string "CylinderDirectedParticleEmitter"
  104358. * @returns a string containing the class name
  104359. */
  104360. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  104361. return "CylinderDirectedParticleEmitter";
  104362. };
  104363. /**
  104364. * Serializes the particle system to a JSON object.
  104365. * @returns the JSON object
  104366. */
  104367. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  104368. var serializationObject = _super.prototype.serialize.call(this);
  104369. serializationObject.direction1 = this.direction1.asArray();
  104370. serializationObject.direction2 = this.direction2.asArray();
  104371. return serializationObject;
  104372. };
  104373. /**
  104374. * Parse properties from a JSON object
  104375. * @param serializationObject defines the JSON object
  104376. */
  104377. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  104378. _super.prototype.parse.call(this, serializationObject);
  104379. this.direction1.copyFrom(serializationObject.direction1);
  104380. this.direction2.copyFrom(serializationObject.direction2);
  104381. };
  104382. return CylinderDirectedParticleEmitter;
  104383. }(CylinderParticleEmitter));
  104384. /***/ }),
  104385. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  104386. /*!**************************************************************!*\
  104387. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  104388. \**************************************************************/
  104389. /*! exports provided: HemisphericParticleEmitter */
  104390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104391. "use strict";
  104392. __webpack_require__.r(__webpack_exports__);
  104393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  104394. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104395. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  104396. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104397. /**
  104398. * Particle emitter emitting particles from the inside of a hemisphere.
  104399. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  104400. */
  104401. var HemisphericParticleEmitter = /** @class */ (function () {
  104402. /**
  104403. * Creates a new instance HemisphericParticleEmitter
  104404. * @param radius the radius of the emission hemisphere (1 by default)
  104405. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  104406. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  104407. */
  104408. function HemisphericParticleEmitter(
  104409. /**
  104410. * The radius of the emission hemisphere.
  104411. */
  104412. radius,
  104413. /**
  104414. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  104415. */
  104416. radiusRange,
  104417. /**
  104418. * How much to randomize the particle direction [0-1].
  104419. */
  104420. directionRandomizer) {
  104421. if (radius === void 0) { radius = 1; }
  104422. if (radiusRange === void 0) { radiusRange = 1; }
  104423. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  104424. this.radius = radius;
  104425. this.radiusRange = radiusRange;
  104426. this.directionRandomizer = directionRandomizer;
  104427. }
  104428. /**
  104429. * Called by the particle System when the direction is computed for the created particle.
  104430. * @param worldMatrix is the world matrix of the particle system
  104431. * @param directionToUpdate is the direction vector to update with the result
  104432. * @param particle is the particle we are computed the direction for
  104433. */
  104434. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104435. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  104436. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104437. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104438. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104439. direction.x += randX;
  104440. direction.y += randY;
  104441. direction.z += randZ;
  104442. direction.normalize();
  104443. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  104444. };
  104445. /**
  104446. * Called by the particle System when the position is computed for the created particle.
  104447. * @param worldMatrix is the world matrix of the particle system
  104448. * @param positionToUpdate is the position vector to update with the result
  104449. * @param particle is the particle we are computed the position for
  104450. */
  104451. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  104452. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  104453. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  104454. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  104455. var theta = Math.acos(2 * v - 1);
  104456. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  104457. var randY = randRadius * Math.cos(theta);
  104458. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  104459. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  104460. };
  104461. /**
  104462. * Clones the current emitter and returns a copy of it
  104463. * @returns the new emitter
  104464. */
  104465. HemisphericParticleEmitter.prototype.clone = function () {
  104466. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  104467. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  104468. return newOne;
  104469. };
  104470. /**
  104471. * Called by the GPUParticleSystem to setup the update shader
  104472. * @param effect defines the update shader
  104473. */
  104474. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  104475. effect.setFloat("radius", this.radius);
  104476. effect.setFloat("radiusRange", this.radiusRange);
  104477. effect.setFloat("directionRandomizer", this.directionRandomizer);
  104478. };
  104479. /**
  104480. * Returns a string to use to update the GPU particles update shader
  104481. * @returns a string containng the defines string
  104482. */
  104483. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  104484. return "#define HEMISPHERICEMITTER";
  104485. };
  104486. /**
  104487. * Returns the string "HemisphericParticleEmitter"
  104488. * @returns a string containing the class name
  104489. */
  104490. HemisphericParticleEmitter.prototype.getClassName = function () {
  104491. return "HemisphericParticleEmitter";
  104492. };
  104493. /**
  104494. * Serializes the particle system to a JSON object.
  104495. * @returns the JSON object
  104496. */
  104497. HemisphericParticleEmitter.prototype.serialize = function () {
  104498. var serializationObject = {};
  104499. serializationObject.type = this.getClassName();
  104500. serializationObject.radius = this.radius;
  104501. serializationObject.radiusRange = this.radiusRange;
  104502. serializationObject.directionRandomizer = this.directionRandomizer;
  104503. return serializationObject;
  104504. };
  104505. /**
  104506. * Parse properties from a JSON object
  104507. * @param serializationObject defines the JSON object
  104508. */
  104509. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  104510. this.radius = serializationObject.radius;
  104511. this.radiusRange = serializationObject.radiusRange;
  104512. this.directionRandomizer = serializationObject.directionRandomizer;
  104513. };
  104514. return HemisphericParticleEmitter;
  104515. }());
  104516. /***/ }),
  104517. /***/ "./Particles/EmitterTypes/index.ts":
  104518. /*!*****************************************!*\
  104519. !*** ./Particles/EmitterTypes/index.ts ***!
  104520. \*****************************************/
  104521. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  104522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104523. "use strict";
  104524. __webpack_require__.r(__webpack_exports__);
  104525. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  104526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  104527. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  104528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  104529. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  104530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  104531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  104532. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  104533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  104534. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  104535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  104536. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  104537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  104538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  104539. /***/ }),
  104540. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  104541. /*!********************************************************!*\
  104542. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  104543. \********************************************************/
  104544. /*! exports provided: PointParticleEmitter */
  104545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104546. "use strict";
  104547. __webpack_require__.r(__webpack_exports__);
  104548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  104549. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104550. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  104551. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104552. /**
  104553. * Particle emitter emitting particles from a point.
  104554. * It emits the particles randomly between 2 given directions.
  104555. */
  104556. var PointParticleEmitter = /** @class */ (function () {
  104557. /**
  104558. * Creates a new instance PointParticleEmitter
  104559. */
  104560. function PointParticleEmitter() {
  104561. /**
  104562. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  104563. */
  104564. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  104565. /**
  104566. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  104567. */
  104568. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  104569. }
  104570. /**
  104571. * Called by the particle System when the direction is computed for the created particle.
  104572. * @param worldMatrix is the world matrix of the particle system
  104573. * @param directionToUpdate is the direction vector to update with the result
  104574. * @param particle is the particle we are computed the direction for
  104575. */
  104576. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104577. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  104578. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  104579. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  104580. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  104581. };
  104582. /**
  104583. * Called by the particle System when the position is computed for the created particle.
  104584. * @param worldMatrix is the world matrix of the particle system
  104585. * @param positionToUpdate is the position vector to update with the result
  104586. * @param particle is the particle we are computed the position for
  104587. */
  104588. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  104589. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  104590. };
  104591. /**
  104592. * Clones the current emitter and returns a copy of it
  104593. * @returns the new emitter
  104594. */
  104595. PointParticleEmitter.prototype.clone = function () {
  104596. var newOne = new PointParticleEmitter();
  104597. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  104598. return newOne;
  104599. };
  104600. /**
  104601. * Called by the GPUParticleSystem to setup the update shader
  104602. * @param effect defines the update shader
  104603. */
  104604. PointParticleEmitter.prototype.applyToShader = function (effect) {
  104605. effect.setVector3("direction1", this.direction1);
  104606. effect.setVector3("direction2", this.direction2);
  104607. };
  104608. /**
  104609. * Returns a string to use to update the GPU particles update shader
  104610. * @returns a string containng the defines string
  104611. */
  104612. PointParticleEmitter.prototype.getEffectDefines = function () {
  104613. return "#define POINTEMITTER";
  104614. };
  104615. /**
  104616. * Returns the string "PointParticleEmitter"
  104617. * @returns a string containing the class name
  104618. */
  104619. PointParticleEmitter.prototype.getClassName = function () {
  104620. return "PointParticleEmitter";
  104621. };
  104622. /**
  104623. * Serializes the particle system to a JSON object.
  104624. * @returns the JSON object
  104625. */
  104626. PointParticleEmitter.prototype.serialize = function () {
  104627. var serializationObject = {};
  104628. serializationObject.type = this.getClassName();
  104629. serializationObject.direction1 = this.direction1.asArray();
  104630. serializationObject.direction2 = this.direction2.asArray();
  104631. return serializationObject;
  104632. };
  104633. /**
  104634. * Parse properties from a JSON object
  104635. * @param serializationObject defines the JSON object
  104636. */
  104637. PointParticleEmitter.prototype.parse = function (serializationObject) {
  104638. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  104639. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  104640. };
  104641. return PointParticleEmitter;
  104642. }());
  104643. /***/ }),
  104644. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  104645. /*!*********************************************************!*\
  104646. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  104647. \*********************************************************/
  104648. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  104649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104650. "use strict";
  104651. __webpack_require__.r(__webpack_exports__);
  104652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  104653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  104654. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104655. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  104656. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104657. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104658. /**
  104659. * Particle emitter emitting particles from the inside of a sphere.
  104660. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  104661. */
  104662. var SphereParticleEmitter = /** @class */ (function () {
  104663. /**
  104664. * Creates a new instance SphereParticleEmitter
  104665. * @param radius the radius of the emission sphere (1 by default)
  104666. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  104667. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  104668. */
  104669. function SphereParticleEmitter(
  104670. /**
  104671. * The radius of the emission sphere.
  104672. */
  104673. radius,
  104674. /**
  104675. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  104676. */
  104677. radiusRange,
  104678. /**
  104679. * How much to randomize the particle direction [0-1].
  104680. */
  104681. directionRandomizer) {
  104682. if (radius === void 0) { radius = 1; }
  104683. if (radiusRange === void 0) { radiusRange = 1; }
  104684. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  104685. this.radius = radius;
  104686. this.radiusRange = radiusRange;
  104687. this.directionRandomizer = directionRandomizer;
  104688. }
  104689. /**
  104690. * Called by the particle System when the direction is computed for the created particle.
  104691. * @param worldMatrix is the world matrix of the particle system
  104692. * @param directionToUpdate is the direction vector to update with the result
  104693. * @param particle is the particle we are computed the direction for
  104694. */
  104695. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104696. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  104697. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104698. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104699. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104700. direction.x += randX;
  104701. direction.y += randY;
  104702. direction.z += randZ;
  104703. direction.normalize();
  104704. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  104705. };
  104706. /**
  104707. * Called by the particle System when the position is computed for the created particle.
  104708. * @param worldMatrix is the world matrix of the particle system
  104709. * @param positionToUpdate is the position vector to update with the result
  104710. * @param particle is the particle we are computed the position for
  104711. */
  104712. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  104713. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  104714. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  104715. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  104716. var theta = Math.acos(2 * v - 1);
  104717. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  104718. var randY = randRadius * Math.cos(theta);
  104719. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  104720. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  104721. };
  104722. /**
  104723. * Clones the current emitter and returns a copy of it
  104724. * @returns the new emitter
  104725. */
  104726. SphereParticleEmitter.prototype.clone = function () {
  104727. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  104728. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  104729. return newOne;
  104730. };
  104731. /**
  104732. * Called by the GPUParticleSystem to setup the update shader
  104733. * @param effect defines the update shader
  104734. */
  104735. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  104736. effect.setFloat("radius", this.radius);
  104737. effect.setFloat("radiusRange", this.radiusRange);
  104738. effect.setFloat("directionRandomizer", this.directionRandomizer);
  104739. };
  104740. /**
  104741. * Returns a string to use to update the GPU particles update shader
  104742. * @returns a string containng the defines string
  104743. */
  104744. SphereParticleEmitter.prototype.getEffectDefines = function () {
  104745. return "#define SPHEREEMITTER";
  104746. };
  104747. /**
  104748. * Returns the string "SphereParticleEmitter"
  104749. * @returns a string containing the class name
  104750. */
  104751. SphereParticleEmitter.prototype.getClassName = function () {
  104752. return "SphereParticleEmitter";
  104753. };
  104754. /**
  104755. * Serializes the particle system to a JSON object.
  104756. * @returns the JSON object
  104757. */
  104758. SphereParticleEmitter.prototype.serialize = function () {
  104759. var serializationObject = {};
  104760. serializationObject.type = this.getClassName();
  104761. serializationObject.radius = this.radius;
  104762. serializationObject.radiusRange = this.radiusRange;
  104763. serializationObject.directionRandomizer = this.directionRandomizer;
  104764. return serializationObject;
  104765. };
  104766. /**
  104767. * Parse properties from a JSON object
  104768. * @param serializationObject defines the JSON object
  104769. */
  104770. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  104771. this.radius = serializationObject.radius;
  104772. this.radiusRange = serializationObject.radiusRange;
  104773. this.directionRandomizer = serializationObject.directionRandomizer;
  104774. };
  104775. return SphereParticleEmitter;
  104776. }());
  104777. /**
  104778. * Particle emitter emitting particles from the inside of a sphere.
  104779. * It emits the particles randomly between two vectors.
  104780. */
  104781. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  104782. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  104783. /**
  104784. * Creates a new instance SphereDirectedParticleEmitter
  104785. * @param radius the radius of the emission sphere (1 by default)
  104786. * @param direction1 the min limit of the emission direction (up vector by default)
  104787. * @param direction2 the max limit of the emission direction (up vector by default)
  104788. */
  104789. function SphereDirectedParticleEmitter(radius,
  104790. /**
  104791. * The min limit of the emission direction.
  104792. */
  104793. direction1,
  104794. /**
  104795. * The max limit of the emission direction.
  104796. */
  104797. direction2) {
  104798. if (radius === void 0) { radius = 1; }
  104799. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  104800. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  104801. var _this = _super.call(this, radius) || this;
  104802. _this.direction1 = direction1;
  104803. _this.direction2 = direction2;
  104804. return _this;
  104805. }
  104806. /**
  104807. * Called by the particle System when the direction is computed for the created particle.
  104808. * @param worldMatrix is the world matrix of the particle system
  104809. * @param directionToUpdate is the direction vector to update with the result
  104810. * @param particle is the particle we are computed the direction for
  104811. */
  104812. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104813. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  104814. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  104815. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  104816. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  104817. };
  104818. /**
  104819. * Clones the current emitter and returns a copy of it
  104820. * @returns the new emitter
  104821. */
  104822. SphereDirectedParticleEmitter.prototype.clone = function () {
  104823. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  104824. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  104825. return newOne;
  104826. };
  104827. /**
  104828. * Called by the GPUParticleSystem to setup the update shader
  104829. * @param effect defines the update shader
  104830. */
  104831. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  104832. effect.setFloat("radius", this.radius);
  104833. effect.setFloat("radiusRange", this.radiusRange);
  104834. effect.setVector3("direction1", this.direction1);
  104835. effect.setVector3("direction2", this.direction2);
  104836. };
  104837. /**
  104838. * Returns a string to use to update the GPU particles update shader
  104839. * @returns a string containng the defines string
  104840. */
  104841. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  104842. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  104843. };
  104844. /**
  104845. * Returns the string "SphereDirectedParticleEmitter"
  104846. * @returns a string containing the class name
  104847. */
  104848. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  104849. return "SphereDirectedParticleEmitter";
  104850. };
  104851. /**
  104852. * Serializes the particle system to a JSON object.
  104853. * @returns the JSON object
  104854. */
  104855. SphereDirectedParticleEmitter.prototype.serialize = function () {
  104856. var serializationObject = _super.prototype.serialize.call(this);
  104857. serializationObject.direction1 = this.direction1.asArray();
  104858. serializationObject.direction2 = this.direction2.asArray();
  104859. return serializationObject;
  104860. };
  104861. /**
  104862. * Parse properties from a JSON object
  104863. * @param serializationObject defines the JSON object
  104864. */
  104865. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  104866. _super.prototype.parse.call(this, serializationObject);
  104867. this.direction1.copyFrom(serializationObject.direction1);
  104868. this.direction2.copyFrom(serializationObject.direction2);
  104869. };
  104870. return SphereDirectedParticleEmitter;
  104871. }(SphereParticleEmitter));
  104872. /***/ }),
  104873. /***/ "./Particles/baseParticleSystem.ts":
  104874. /*!*****************************************!*\
  104875. !*** ./Particles/baseParticleSystem.ts ***!
  104876. \*****************************************/
  104877. /*! exports provided: BaseParticleSystem */
  104878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104879. "use strict";
  104880. __webpack_require__.r(__webpack_exports__);
  104881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  104882. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104883. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  104884. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104885. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104886. /**
  104887. * This represents the base class for particle system in Babylon.
  104888. * 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.
  104889. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  104890. * @example https://doc.babylonjs.com/babylon101/particles
  104891. */
  104892. var BaseParticleSystem = /** @class */ (function () {
  104893. /**
  104894. * Instantiates a particle system.
  104895. * 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.
  104896. * @param name The name of the particle system
  104897. */
  104898. function BaseParticleSystem(name) {
  104899. /**
  104900. * List of animations used by the particle system.
  104901. */
  104902. this.animations = [];
  104903. /**
  104904. * The rendering group used by the Particle system to chose when to render.
  104905. */
  104906. this.renderingGroupId = 0;
  104907. /**
  104908. * The emitter represents the Mesh or position we are attaching the particle system to.
  104909. */
  104910. this.emitter = null;
  104911. /**
  104912. * The maximum number of particles to emit per frame
  104913. */
  104914. this.emitRate = 10;
  104915. /**
  104916. * If you want to launch only a few particles at once, that can be done, as well.
  104917. */
  104918. this.manualEmitCount = -1;
  104919. /**
  104920. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  104921. */
  104922. this.updateSpeed = 0.01;
  104923. /**
  104924. * The amount of time the particle system is running (depends of the overall update speed).
  104925. */
  104926. this.targetStopDuration = 0;
  104927. /**
  104928. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  104929. */
  104930. this.disposeOnStop = false;
  104931. /**
  104932. * Minimum power of emitting particles.
  104933. */
  104934. this.minEmitPower = 1;
  104935. /**
  104936. * Maximum power of emitting particles.
  104937. */
  104938. this.maxEmitPower = 1;
  104939. /**
  104940. * Minimum life time of emitting particles.
  104941. */
  104942. this.minLifeTime = 1;
  104943. /**
  104944. * Maximum life time of emitting particles.
  104945. */
  104946. this.maxLifeTime = 1;
  104947. /**
  104948. * Minimum Size of emitting particles.
  104949. */
  104950. this.minSize = 1;
  104951. /**
  104952. * Maximum Size of emitting particles.
  104953. */
  104954. this.maxSize = 1;
  104955. /**
  104956. * Minimum scale of emitting particles on X axis.
  104957. */
  104958. this.minScaleX = 1;
  104959. /**
  104960. * Maximum scale of emitting particles on X axis.
  104961. */
  104962. this.maxScaleX = 1;
  104963. /**
  104964. * Minimum scale of emitting particles on Y axis.
  104965. */
  104966. this.minScaleY = 1;
  104967. /**
  104968. * Maximum scale of emitting particles on Y axis.
  104969. */
  104970. this.maxScaleY = 1;
  104971. /**
  104972. * Gets or sets the minimal initial rotation in radians.
  104973. */
  104974. this.minInitialRotation = 0;
  104975. /**
  104976. * Gets or sets the maximal initial rotation in radians.
  104977. */
  104978. this.maxInitialRotation = 0;
  104979. /**
  104980. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  104981. */
  104982. this.minAngularSpeed = 0;
  104983. /**
  104984. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  104985. */
  104986. this.maxAngularSpeed = 0;
  104987. /**
  104988. * The layer mask we are rendering the particles through.
  104989. */
  104990. this.layerMask = 0x0FFFFFFF;
  104991. /**
  104992. * This can help using your own shader to render the particle system.
  104993. * The according effect will be created
  104994. */
  104995. this.customShader = null;
  104996. /**
  104997. * By default particle system starts as soon as they are created. This prevents the
  104998. * automatic start to happen and let you decide when to start emitting particles.
  104999. */
  105000. this.preventAutoStart = false;
  105001. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  105002. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  105003. /**
  105004. * Callback triggered when the particle animation is ending.
  105005. */
  105006. this.onAnimationEnd = null;
  105007. /**
  105008. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  105009. */
  105010. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  105011. /**
  105012. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  105013. * to override the particles.
  105014. */
  105015. this.forceDepthWrite = false;
  105016. /** 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 */
  105017. this.preWarmCycles = 0;
  105018. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  105019. this.preWarmStepOffset = 1;
  105020. /**
  105021. * 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)
  105022. */
  105023. this.spriteCellChangeSpeed = 1;
  105024. /**
  105025. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  105026. */
  105027. this.startSpriteCellID = 0;
  105028. /**
  105029. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  105030. */
  105031. this.endSpriteCellID = 0;
  105032. /**
  105033. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  105034. */
  105035. this.spriteCellWidth = 0;
  105036. /**
  105037. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  105038. */
  105039. this.spriteCellHeight = 0;
  105040. /**
  105041. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  105042. */
  105043. this.spriteRandomStartCell = false;
  105044. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  105045. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  105046. /**
  105047. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  105048. */
  105049. this.beginAnimationOnStart = false;
  105050. /**
  105051. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  105052. */
  105053. this.beginAnimationFrom = 0;
  105054. /**
  105055. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  105056. */
  105057. this.beginAnimationTo = 60;
  105058. /**
  105059. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  105060. */
  105061. this.beginAnimationLoop = false;
  105062. /**
  105063. * Gets or sets a world offset applied to all particles
  105064. */
  105065. this.worldOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  105066. /**
  105067. * You can use gravity if you want to give an orientation to your particles.
  105068. */
  105069. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  105070. this._colorGradients = null;
  105071. this._sizeGradients = null;
  105072. this._lifeTimeGradients = null;
  105073. this._angularSpeedGradients = null;
  105074. this._velocityGradients = null;
  105075. this._limitVelocityGradients = null;
  105076. this._dragGradients = null;
  105077. this._emitRateGradients = null;
  105078. this._startSizeGradients = null;
  105079. this._rampGradients = null;
  105080. this._colorRemapGradients = null;
  105081. this._alphaRemapGradients = null;
  105082. /**
  105083. * Defines the delay in milliseconds before starting the system (0 by default)
  105084. */
  105085. this.startDelay = 0;
  105086. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  105087. this.limitVelocityDamping = 0.4;
  105088. /**
  105089. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  105090. */
  105091. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  105092. /**
  105093. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  105094. */
  105095. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  105096. /**
  105097. * Color the particle will have at the end of its lifetime
  105098. */
  105099. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  105100. /**
  105101. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  105102. */
  105103. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  105104. /** @hidden */
  105105. this._isSubEmitter = false;
  105106. /**
  105107. * Gets or sets the billboard mode to use when isBillboardBased = true.
  105108. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  105109. */
  105110. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  105111. this._isBillboardBased = true;
  105112. /**
  105113. * Local cache of defines for image processing.
  105114. */
  105115. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  105116. this.id = name;
  105117. this.name = name;
  105118. }
  105119. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  105120. /**
  105121. * Gets or sets a texture used to add random noise to particle positions
  105122. */
  105123. get: function () {
  105124. return this._noiseTexture;
  105125. },
  105126. set: function (value) {
  105127. if (this._noiseTexture === value) {
  105128. return;
  105129. }
  105130. this._noiseTexture = value;
  105131. this._reset();
  105132. },
  105133. enumerable: true,
  105134. configurable: true
  105135. });
  105136. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  105137. /**
  105138. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  105139. */
  105140. get: function () {
  105141. return this._isAnimationSheetEnabled;
  105142. },
  105143. set: function (value) {
  105144. if (this._isAnimationSheetEnabled == value) {
  105145. return;
  105146. }
  105147. this._isAnimationSheetEnabled = value;
  105148. this._reset();
  105149. },
  105150. enumerable: true,
  105151. configurable: true
  105152. });
  105153. /**
  105154. * Get hosting scene
  105155. * @returns the scene
  105156. */
  105157. BaseParticleSystem.prototype.getScene = function () {
  105158. return this._scene;
  105159. };
  105160. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  105161. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  105162. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  105163. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  105164. };
  105165. /**
  105166. * Gets the current list of drag gradients.
  105167. * You must use addDragGradient and removeDragGradient to udpate this list
  105168. * @returns the list of drag gradients
  105169. */
  105170. BaseParticleSystem.prototype.getDragGradients = function () {
  105171. return this._dragGradients;
  105172. };
  105173. /**
  105174. * Gets the current list of limit velocity gradients.
  105175. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  105176. * @returns the list of limit velocity gradients
  105177. */
  105178. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  105179. return this._limitVelocityGradients;
  105180. };
  105181. /**
  105182. * Gets the current list of color gradients.
  105183. * You must use addColorGradient and removeColorGradient to udpate this list
  105184. * @returns the list of color gradients
  105185. */
  105186. BaseParticleSystem.prototype.getColorGradients = function () {
  105187. return this._colorGradients;
  105188. };
  105189. /**
  105190. * Gets the current list of size gradients.
  105191. * You must use addSizeGradient and removeSizeGradient to udpate this list
  105192. * @returns the list of size gradients
  105193. */
  105194. BaseParticleSystem.prototype.getSizeGradients = function () {
  105195. return this._sizeGradients;
  105196. };
  105197. /**
  105198. * Gets the current list of color remap gradients.
  105199. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  105200. * @returns the list of color remap gradients
  105201. */
  105202. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  105203. return this._colorRemapGradients;
  105204. };
  105205. /**
  105206. * Gets the current list of alpha remap gradients.
  105207. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  105208. * @returns the list of alpha remap gradients
  105209. */
  105210. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  105211. return this._alphaRemapGradients;
  105212. };
  105213. /**
  105214. * Gets the current list of life time gradients.
  105215. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  105216. * @returns the list of life time gradients
  105217. */
  105218. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  105219. return this._lifeTimeGradients;
  105220. };
  105221. /**
  105222. * Gets the current list of angular speed gradients.
  105223. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  105224. * @returns the list of angular speed gradients
  105225. */
  105226. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  105227. return this._angularSpeedGradients;
  105228. };
  105229. /**
  105230. * Gets the current list of velocity gradients.
  105231. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  105232. * @returns the list of velocity gradients
  105233. */
  105234. BaseParticleSystem.prototype.getVelocityGradients = function () {
  105235. return this._velocityGradients;
  105236. };
  105237. /**
  105238. * Gets the current list of start size gradients.
  105239. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  105240. * @returns the list of start size gradients
  105241. */
  105242. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  105243. return this._startSizeGradients;
  105244. };
  105245. /**
  105246. * Gets the current list of emit rate gradients.
  105247. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  105248. * @returns the list of emit rate gradients
  105249. */
  105250. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  105251. return this._emitRateGradients;
  105252. };
  105253. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  105254. /**
  105255. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105256. * This only works when particleEmitterTyps is a BoxParticleEmitter
  105257. */
  105258. get: function () {
  105259. if (this.particleEmitterType.direction1) {
  105260. return this.particleEmitterType.direction1;
  105261. }
  105262. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  105263. },
  105264. set: function (value) {
  105265. if (this.particleEmitterType.direction1) {
  105266. this.particleEmitterType.direction1 = value;
  105267. }
  105268. },
  105269. enumerable: true,
  105270. configurable: true
  105271. });
  105272. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  105273. /**
  105274. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105275. * This only works when particleEmitterTyps is a BoxParticleEmitter
  105276. */
  105277. get: function () {
  105278. if (this.particleEmitterType.direction2) {
  105279. return this.particleEmitterType.direction2;
  105280. }
  105281. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  105282. },
  105283. set: function (value) {
  105284. if (this.particleEmitterType.direction2) {
  105285. this.particleEmitterType.direction2 = value;
  105286. }
  105287. },
  105288. enumerable: true,
  105289. configurable: true
  105290. });
  105291. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  105292. /**
  105293. * 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.
  105294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  105295. */
  105296. get: function () {
  105297. if (this.particleEmitterType.minEmitBox) {
  105298. return this.particleEmitterType.minEmitBox;
  105299. }
  105300. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  105301. },
  105302. set: function (value) {
  105303. if (this.particleEmitterType.minEmitBox) {
  105304. this.particleEmitterType.minEmitBox = value;
  105305. }
  105306. },
  105307. enumerable: true,
  105308. configurable: true
  105309. });
  105310. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  105311. /**
  105312. * 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.
  105313. * This only works when particleEmitterTyps is a BoxParticleEmitter
  105314. */
  105315. get: function () {
  105316. if (this.particleEmitterType.maxEmitBox) {
  105317. return this.particleEmitterType.maxEmitBox;
  105318. }
  105319. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  105320. },
  105321. set: function (value) {
  105322. if (this.particleEmitterType.maxEmitBox) {
  105323. this.particleEmitterType.maxEmitBox = value;
  105324. }
  105325. },
  105326. enumerable: true,
  105327. configurable: true
  105328. });
  105329. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  105330. /**
  105331. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  105332. */
  105333. get: function () {
  105334. return this._isBillboardBased;
  105335. },
  105336. set: function (value) {
  105337. if (this._isBillboardBased === value) {
  105338. return;
  105339. }
  105340. this._isBillboardBased = value;
  105341. this._reset();
  105342. },
  105343. enumerable: true,
  105344. configurable: true
  105345. });
  105346. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  105347. /**
  105348. * Gets the image processing configuration used either in this material.
  105349. */
  105350. get: function () {
  105351. return this._imageProcessingConfiguration;
  105352. },
  105353. /**
  105354. * Sets the Default image processing configuration used either in the this material.
  105355. *
  105356. * If sets to null, the scene one is in use.
  105357. */
  105358. set: function (value) {
  105359. this._attachImageProcessingConfiguration(value);
  105360. },
  105361. enumerable: true,
  105362. configurable: true
  105363. });
  105364. /**
  105365. * Attaches a new image processing configuration to the Standard Material.
  105366. * @param configuration
  105367. */
  105368. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  105369. if (configuration === this._imageProcessingConfiguration) {
  105370. return;
  105371. }
  105372. // Pick the scene configuration if needed.
  105373. if (!configuration) {
  105374. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  105375. }
  105376. else {
  105377. this._imageProcessingConfiguration = configuration;
  105378. }
  105379. };
  105380. /** @hidden */
  105381. BaseParticleSystem.prototype._reset = function () {
  105382. };
  105383. /** @hidden */
  105384. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  105385. if (!gradients) {
  105386. return this;
  105387. }
  105388. var index = 0;
  105389. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  105390. var valueGradient = gradients_1[_i];
  105391. if (valueGradient.gradient === gradient) {
  105392. gradients.splice(index, 1);
  105393. break;
  105394. }
  105395. index++;
  105396. }
  105397. if (texture) {
  105398. texture.dispose();
  105399. }
  105400. return this;
  105401. };
  105402. /**
  105403. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  105404. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  105405. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  105406. * @returns the emitter
  105407. */
  105408. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  105409. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  105410. particleEmitter.direction1 = direction1;
  105411. particleEmitter.direction2 = direction2;
  105412. this.particleEmitterType = particleEmitter;
  105413. return particleEmitter;
  105414. };
  105415. /**
  105416. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  105417. * @param radius The radius of the hemisphere to emit from
  105418. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  105419. * @returns the emitter
  105420. */
  105421. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  105422. if (radius === void 0) { radius = 1; }
  105423. if (radiusRange === void 0) { radiusRange = 1; }
  105424. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  105425. this.particleEmitterType = particleEmitter;
  105426. return particleEmitter;
  105427. };
  105428. /**
  105429. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  105430. * @param radius The radius of the sphere to emit from
  105431. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  105432. * @returns the emitter
  105433. */
  105434. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  105435. if (radius === void 0) { radius = 1; }
  105436. if (radiusRange === void 0) { radiusRange = 1; }
  105437. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  105438. this.particleEmitterType = particleEmitter;
  105439. return particleEmitter;
  105440. };
  105441. /**
  105442. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  105443. * @param radius The radius of the sphere to emit from
  105444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  105445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  105446. * @returns the emitter
  105447. */
  105448. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  105449. if (radius === void 0) { radius = 1; }
  105450. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  105451. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  105452. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  105453. this.particleEmitterType = particleEmitter;
  105454. return particleEmitter;
  105455. };
  105456. /**
  105457. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  105458. * @param radius The radius of the emission cylinder
  105459. * @param height The height of the emission cylinder
  105460. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  105461. * @param directionRandomizer How much to randomize the particle direction [0-1]
  105462. * @returns the emitter
  105463. */
  105464. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  105465. if (radius === void 0) { radius = 1; }
  105466. if (height === void 0) { height = 1; }
  105467. if (radiusRange === void 0) { radiusRange = 1; }
  105468. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105469. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  105470. this.particleEmitterType = particleEmitter;
  105471. return particleEmitter;
  105472. };
  105473. /**
  105474. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  105475. * @param radius The radius of the cylinder to emit from
  105476. * @param height The height of the emission cylinder
  105477. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105478. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  105479. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  105480. * @returns the emitter
  105481. */
  105482. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  105483. if (radius === void 0) { radius = 1; }
  105484. if (height === void 0) { height = 1; }
  105485. if (radiusRange === void 0) { radiusRange = 1; }
  105486. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  105487. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  105488. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  105489. this.particleEmitterType = particleEmitter;
  105490. return particleEmitter;
  105491. };
  105492. /**
  105493. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  105494. * @param radius The radius of the cone to emit from
  105495. * @param angle The base angle of the cone
  105496. * @returns the emitter
  105497. */
  105498. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  105499. if (radius === void 0) { radius = 1; }
  105500. if (angle === void 0) { angle = Math.PI / 4; }
  105501. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  105502. this.particleEmitterType = particleEmitter;
  105503. return particleEmitter;
  105504. };
  105505. /**
  105506. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  105507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  105508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  105509. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  105510. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  105511. * @returns the emitter
  105512. */
  105513. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  105514. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  105515. this.particleEmitterType = particleEmitter;
  105516. this.direction1 = direction1;
  105517. this.direction2 = direction2;
  105518. this.minEmitBox = minEmitBox;
  105519. this.maxEmitBox = maxEmitBox;
  105520. return particleEmitter;
  105521. };
  105522. /**
  105523. * Source color is added to the destination color without alpha affecting the result
  105524. */
  105525. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  105526. /**
  105527. * Blend current color and particle color using particle’s alpha
  105528. */
  105529. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  105530. /**
  105531. * Add current color and particle color multiplied by particle’s alpha
  105532. */
  105533. BaseParticleSystem.BLENDMODE_ADD = 2;
  105534. /**
  105535. * Multiply current color with particle color
  105536. */
  105537. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  105538. /**
  105539. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  105540. */
  105541. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  105542. return BaseParticleSystem;
  105543. }());
  105544. /***/ }),
  105545. /***/ "./Particles/gpuParticleSystem.ts":
  105546. /*!****************************************!*\
  105547. !*** ./Particles/gpuParticleSystem.ts ***!
  105548. \****************************************/
  105549. /*! exports provided: GPUParticleSystem */
  105550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105551. "use strict";
  105552. __webpack_require__.r(__webpack_exports__);
  105553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  105554. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105555. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105556. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105557. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105558. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105559. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105560. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  105561. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  105562. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  105563. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  105564. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  105565. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  105566. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  105567. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105568. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  105569. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105570. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105571. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105572. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  105573. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  105574. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  105575. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  105576. /**
  105577. * This represents a GPU particle system in Babylon
  105578. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  105579. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  105580. */
  105581. var GPUParticleSystem = /** @class */ (function (_super) {
  105582. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  105583. /**
  105584. * Instantiates a GPU particle system.
  105585. * 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.
  105586. * @param name The name of the particle system
  105587. * @param options The options used to create the system
  105588. * @param scene The scene the particle system belongs to
  105589. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105590. */
  105591. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  105592. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105593. var _this = _super.call(this, name) || this;
  105594. /**
  105595. * The layer mask we are rendering the particles through.
  105596. */
  105597. _this.layerMask = 0x0FFFFFFF;
  105598. _this._accumulatedCount = 0;
  105599. _this._targetIndex = 0;
  105600. _this._currentRenderId = -1;
  105601. _this._started = false;
  105602. _this._stopped = false;
  105603. _this._timeDelta = 0;
  105604. _this._actualFrame = 0;
  105605. _this._rawTextureWidth = 256;
  105606. /**
  105607. * An event triggered when the system is disposed.
  105608. */
  105609. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  105610. /**
  105611. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  105612. * to override the particles.
  105613. */
  105614. _this.forceDepthWrite = false;
  105615. _this._preWarmDone = false;
  105616. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  105617. // Setup the default processing configuration to the scene.
  105618. _this._attachImageProcessingConfiguration(null);
  105619. _this._engine = _this._scene.getEngine();
  105620. if (!options.randomTextureSize) {
  105621. delete options.randomTextureSize;
  105622. }
  105623. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  105624. var optionsAsNumber = options;
  105625. if (isFinite(optionsAsNumber)) {
  105626. fullOptions.capacity = optionsAsNumber;
  105627. }
  105628. _this._capacity = fullOptions.capacity;
  105629. _this._activeCount = fullOptions.capacity;
  105630. _this._currentActiveCount = 0;
  105631. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  105632. _this._scene.particleSystems.push(_this);
  105633. _this._updateEffectOptions = {
  105634. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  105635. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  105636. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  105637. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  105638. uniformBuffersNames: [],
  105639. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  105640. defines: "",
  105641. fallbacks: null,
  105642. onCompiled: null,
  105643. onError: null,
  105644. indexParameters: null,
  105645. maxSimultaneousLights: 0,
  105646. transformFeedbackVaryings: []
  105647. };
  105648. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  105649. // Random data
  105650. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  105651. var d = [];
  105652. for (var i = 0; i < maxTextureSize; ++i) {
  105653. d.push(Math.random());
  105654. d.push(Math.random());
  105655. d.push(Math.random());
  105656. d.push(Math.random());
  105657. }
  105658. _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);
  105659. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  105660. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  105661. d = [];
  105662. for (var i = 0; i < maxTextureSize; ++i) {
  105663. d.push(Math.random());
  105664. d.push(Math.random());
  105665. d.push(Math.random());
  105666. d.push(Math.random());
  105667. }
  105668. _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);
  105669. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  105670. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  105671. _this._randomTextureSize = maxTextureSize;
  105672. return _this;
  105673. }
  105674. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  105675. /**
  105676. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  105677. */
  105678. get: function () {
  105679. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  105680. return false;
  105681. }
  105682. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  105683. },
  105684. enumerable: true,
  105685. configurable: true
  105686. });
  105687. /**
  105688. * Gets the maximum number of particles active at the same time.
  105689. * @returns The max number of active particles.
  105690. */
  105691. GPUParticleSystem.prototype.getCapacity = function () {
  105692. return this._capacity;
  105693. };
  105694. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  105695. /**
  105696. * Gets or set the number of active particles
  105697. */
  105698. get: function () {
  105699. return this._activeCount;
  105700. },
  105701. set: function (value) {
  105702. this._activeCount = Math.min(value, this._capacity);
  105703. },
  105704. enumerable: true,
  105705. configurable: true
  105706. });
  105707. /**
  105708. * Is this system ready to be used/rendered
  105709. * @return true if the system is ready
  105710. */
  105711. GPUParticleSystem.prototype.isReady = function () {
  105712. if (!this._updateEffect) {
  105713. this._recreateUpdateEffect();
  105714. this._recreateRenderEffect();
  105715. return false;
  105716. }
  105717. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  105718. return false;
  105719. }
  105720. return true;
  105721. };
  105722. /**
  105723. * Gets if the system has been started. (Note: this will still be true after stop is called)
  105724. * @returns True if it has been started, otherwise false.
  105725. */
  105726. GPUParticleSystem.prototype.isStarted = function () {
  105727. return this._started;
  105728. };
  105729. /**
  105730. * Starts the particle system and begins to emit
  105731. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  105732. */
  105733. GPUParticleSystem.prototype.start = function (delay) {
  105734. var _this = this;
  105735. if (delay === void 0) { delay = this.startDelay; }
  105736. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  105737. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  105738. }
  105739. if (delay) {
  105740. setTimeout(function () {
  105741. _this.start(0);
  105742. }, delay);
  105743. return;
  105744. }
  105745. this._started = true;
  105746. this._stopped = false;
  105747. this._preWarmDone = false;
  105748. // Animations
  105749. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  105750. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  105751. }
  105752. };
  105753. /**
  105754. * Stops the particle system.
  105755. */
  105756. GPUParticleSystem.prototype.stop = function () {
  105757. this._stopped = true;
  105758. };
  105759. /**
  105760. * Remove all active particles
  105761. */
  105762. GPUParticleSystem.prototype.reset = function () {
  105763. this._releaseBuffers();
  105764. this._releaseVAOs();
  105765. this._currentActiveCount = 0;
  105766. this._targetIndex = 0;
  105767. };
  105768. /**
  105769. * Returns the string "GPUParticleSystem"
  105770. * @returns a string containing the class name
  105771. */
  105772. GPUParticleSystem.prototype.getClassName = function () {
  105773. return "GPUParticleSystem";
  105774. };
  105775. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  105776. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  105777. this._releaseBuffers();
  105778. return this;
  105779. };
  105780. /**
  105781. * Adds a new color gradient
  105782. * @param gradient defines the gradient to use (between 0 and 1)
  105783. * @param color1 defines the color to affect to the specified gradient
  105784. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105785. * @returns the current particle system
  105786. */
  105787. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  105788. if (!this._colorGradients) {
  105789. this._colorGradients = [];
  105790. }
  105791. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  105792. colorGradient.gradient = gradient;
  105793. colorGradient.color1 = color1;
  105794. this._colorGradients.push(colorGradient);
  105795. this._colorGradients.sort(function (a, b) {
  105796. if (a.gradient < b.gradient) {
  105797. return -1;
  105798. }
  105799. else if (a.gradient > b.gradient) {
  105800. return 1;
  105801. }
  105802. return 0;
  105803. });
  105804. if (this._colorGradientsTexture) {
  105805. this._colorGradientsTexture.dispose();
  105806. this._colorGradientsTexture = null;
  105807. }
  105808. this._releaseBuffers();
  105809. return this;
  105810. };
  105811. /**
  105812. * Remove a specific color gradient
  105813. * @param gradient defines the gradient to remove
  105814. * @returns the current particle system
  105815. */
  105816. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  105817. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  105818. this._colorGradientsTexture = null;
  105819. return this;
  105820. };
  105821. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  105822. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  105823. valueGradient.gradient = gradient;
  105824. valueGradient.factor1 = factor;
  105825. factorGradients.push(valueGradient);
  105826. factorGradients.sort(function (a, b) {
  105827. if (a.gradient < b.gradient) {
  105828. return -1;
  105829. }
  105830. else if (a.gradient > b.gradient) {
  105831. return 1;
  105832. }
  105833. return 0;
  105834. });
  105835. this._releaseBuffers();
  105836. };
  105837. /**
  105838. * Adds a new size gradient
  105839. * @param gradient defines the gradient to use (between 0 and 1)
  105840. * @param factor defines the size factor to affect to the specified gradient
  105841. * @returns the current particle system
  105842. */
  105843. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  105844. if (!this._sizeGradients) {
  105845. this._sizeGradients = [];
  105846. }
  105847. this._addFactorGradient(this._sizeGradients, gradient, factor);
  105848. if (this._sizeGradientsTexture) {
  105849. this._sizeGradientsTexture.dispose();
  105850. this._sizeGradientsTexture = null;
  105851. }
  105852. this._releaseBuffers();
  105853. return this;
  105854. };
  105855. /**
  105856. * Remove a specific size gradient
  105857. * @param gradient defines the gradient to remove
  105858. * @returns the current particle system
  105859. */
  105860. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  105861. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  105862. this._sizeGradientsTexture = null;
  105863. return this;
  105864. };
  105865. /**
  105866. * Adds a new angular speed gradient
  105867. * @param gradient defines the gradient to use (between 0 and 1)
  105868. * @param factor defines the angular speed to affect to the specified gradient
  105869. * @returns the current particle system
  105870. */
  105871. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  105872. if (!this._angularSpeedGradients) {
  105873. this._angularSpeedGradients = [];
  105874. }
  105875. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  105876. if (this._angularSpeedGradientsTexture) {
  105877. this._angularSpeedGradientsTexture.dispose();
  105878. this._angularSpeedGradientsTexture = null;
  105879. }
  105880. this._releaseBuffers();
  105881. return this;
  105882. };
  105883. /**
  105884. * Remove a specific angular speed gradient
  105885. * @param gradient defines the gradient to remove
  105886. * @returns the current particle system
  105887. */
  105888. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  105889. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  105890. this._angularSpeedGradientsTexture = null;
  105891. return this;
  105892. };
  105893. /**
  105894. * Adds a new velocity gradient
  105895. * @param gradient defines the gradient to use (between 0 and 1)
  105896. * @param factor defines the velocity to affect to the specified gradient
  105897. * @returns the current particle system
  105898. */
  105899. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  105900. if (!this._velocityGradients) {
  105901. this._velocityGradients = [];
  105902. }
  105903. this._addFactorGradient(this._velocityGradients, gradient, factor);
  105904. if (this._velocityGradientsTexture) {
  105905. this._velocityGradientsTexture.dispose();
  105906. this._velocityGradientsTexture = null;
  105907. }
  105908. this._releaseBuffers();
  105909. return this;
  105910. };
  105911. /**
  105912. * Remove a specific velocity gradient
  105913. * @param gradient defines the gradient to remove
  105914. * @returns the current particle system
  105915. */
  105916. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  105917. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  105918. this._velocityGradientsTexture = null;
  105919. return this;
  105920. };
  105921. /**
  105922. * Adds a new limit velocity gradient
  105923. * @param gradient defines the gradient to use (between 0 and 1)
  105924. * @param factor defines the limit velocity value to affect to the specified gradient
  105925. * @returns the current particle system
  105926. */
  105927. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  105928. if (!this._limitVelocityGradients) {
  105929. this._limitVelocityGradients = [];
  105930. }
  105931. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  105932. if (this._limitVelocityGradientsTexture) {
  105933. this._limitVelocityGradientsTexture.dispose();
  105934. this._limitVelocityGradientsTexture = null;
  105935. }
  105936. this._releaseBuffers();
  105937. return this;
  105938. };
  105939. /**
  105940. * Remove a specific limit velocity gradient
  105941. * @param gradient defines the gradient to remove
  105942. * @returns the current particle system
  105943. */
  105944. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  105945. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  105946. this._limitVelocityGradientsTexture = null;
  105947. return this;
  105948. };
  105949. /**
  105950. * Adds a new drag gradient
  105951. * @param gradient defines the gradient to use (between 0 and 1)
  105952. * @param factor defines the drag value to affect to the specified gradient
  105953. * @returns the current particle system
  105954. */
  105955. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  105956. if (!this._dragGradients) {
  105957. this._dragGradients = [];
  105958. }
  105959. this._addFactorGradient(this._dragGradients, gradient, factor);
  105960. if (this._dragGradientsTexture) {
  105961. this._dragGradientsTexture.dispose();
  105962. this._dragGradientsTexture = null;
  105963. }
  105964. this._releaseBuffers();
  105965. return this;
  105966. };
  105967. /**
  105968. * Remove a specific drag gradient
  105969. * @param gradient defines the gradient to remove
  105970. * @returns the current particle system
  105971. */
  105972. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  105973. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  105974. this._dragGradientsTexture = null;
  105975. return this;
  105976. };
  105977. /**
  105978. * Not supported by GPUParticleSystem
  105979. * @param gradient defines the gradient to use (between 0 and 1)
  105980. * @param factor defines the emit rate value to affect to the specified gradient
  105981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105982. * @returns the current particle system
  105983. */
  105984. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  105985. // Do nothing as emit rate is not supported by GPUParticleSystem
  105986. return this;
  105987. };
  105988. /**
  105989. * Not supported by GPUParticleSystem
  105990. * @param gradient defines the gradient to remove
  105991. * @returns the current particle system
  105992. */
  105993. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  105994. // Do nothing as emit rate is not supported by GPUParticleSystem
  105995. return this;
  105996. };
  105997. /**
  105998. * Not supported by GPUParticleSystem
  105999. * @param gradient defines the gradient to use (between 0 and 1)
  106000. * @param factor defines the start size value to affect to the specified gradient
  106001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106002. * @returns the current particle system
  106003. */
  106004. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  106005. // Do nothing as start size is not supported by GPUParticleSystem
  106006. return this;
  106007. };
  106008. /**
  106009. * Not supported by GPUParticleSystem
  106010. * @param gradient defines the gradient to remove
  106011. * @returns the current particle system
  106012. */
  106013. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  106014. // Do nothing as start size is not supported by GPUParticleSystem
  106015. return this;
  106016. };
  106017. /**
  106018. * Not supported by GPUParticleSystem
  106019. * @param gradient defines the gradient to use (between 0 and 1)
  106020. * @param min defines the color remap minimal range
  106021. * @param max defines the color remap maximal range
  106022. * @returns the current particle system
  106023. */
  106024. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  106025. // Do nothing as start size is not supported by GPUParticleSystem
  106026. return this;
  106027. };
  106028. /**
  106029. * Not supported by GPUParticleSystem
  106030. * @param gradient defines the gradient to remove
  106031. * @returns the current particle system
  106032. */
  106033. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  106034. // Do nothing as start size is not supported by GPUParticleSystem
  106035. return this;
  106036. };
  106037. /**
  106038. * Not supported by GPUParticleSystem
  106039. * @param gradient defines the gradient to use (between 0 and 1)
  106040. * @param min defines the alpha remap minimal range
  106041. * @param max defines the alpha remap maximal range
  106042. * @returns the current particle system
  106043. */
  106044. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  106045. // Do nothing as start size is not supported by GPUParticleSystem
  106046. return this;
  106047. };
  106048. /**
  106049. * Not supported by GPUParticleSystem
  106050. * @param gradient defines the gradient to remove
  106051. * @returns the current particle system
  106052. */
  106053. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  106054. // Do nothing as start size is not supported by GPUParticleSystem
  106055. return this;
  106056. };
  106057. /**
  106058. * Not supported by GPUParticleSystem
  106059. * @param gradient defines the gradient to use (between 0 and 1)
  106060. * @param color defines the color to affect to the specified gradient
  106061. * @returns the current particle system
  106062. */
  106063. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  106064. //Not supported by GPUParticleSystem
  106065. return this;
  106066. };
  106067. /**
  106068. * Not supported by GPUParticleSystem
  106069. * @param gradient defines the gradient to remove
  106070. * @returns the current particle system
  106071. */
  106072. GPUParticleSystem.prototype.removeRampGradient = function () {
  106073. //Not supported by GPUParticleSystem
  106074. return this;
  106075. };
  106076. /**
  106077. * Not supported by GPUParticleSystem
  106078. * @returns the list of ramp gradients
  106079. */
  106080. GPUParticleSystem.prototype.getRampGradients = function () {
  106081. return null;
  106082. };
  106083. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  106084. /**
  106085. * Not supported by GPUParticleSystem
  106086. * Gets or sets a boolean indicating that ramp gradients must be used
  106087. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  106088. */
  106089. get: function () {
  106090. //Not supported by GPUParticleSystem
  106091. return false;
  106092. },
  106093. set: function (value) {
  106094. //Not supported by GPUParticleSystem
  106095. },
  106096. enumerable: true,
  106097. configurable: true
  106098. });
  106099. /**
  106100. * Not supported by GPUParticleSystem
  106101. * @param gradient defines the gradient to use (between 0 and 1)
  106102. * @param factor defines the life time factor to affect to the specified gradient
  106103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106104. * @returns the current particle system
  106105. */
  106106. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  106107. //Not supported by GPUParticleSystem
  106108. return this;
  106109. };
  106110. /**
  106111. * Not supported by GPUParticleSystem
  106112. * @param gradient defines the gradient to remove
  106113. * @returns the current particle system
  106114. */
  106115. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  106116. //Not supported by GPUParticleSystem
  106117. return this;
  106118. };
  106119. GPUParticleSystem.prototype._reset = function () {
  106120. this._releaseBuffers();
  106121. };
  106122. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  106123. var updateVertexBuffers = {};
  106124. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  106125. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  106126. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  106127. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  106128. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  106129. var offset = 12;
  106130. if (!this._colorGradientsTexture) {
  106131. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  106132. offset += 4;
  106133. }
  106134. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  106135. offset += 3;
  106136. if (!this._isBillboardBased) {
  106137. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  106138. offset += 3;
  106139. }
  106140. if (this._angularSpeedGradientsTexture) {
  106141. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  106142. offset += 1;
  106143. }
  106144. else {
  106145. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  106146. offset += 2;
  106147. }
  106148. if (this._isAnimationSheetEnabled) {
  106149. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  106150. offset += 1;
  106151. if (this.spriteRandomStartCell) {
  106152. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  106153. offset += 1;
  106154. }
  106155. }
  106156. if (this.noiseTexture) {
  106157. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  106158. offset += 3;
  106159. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  106160. offset += 3;
  106161. }
  106162. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  106163. this._engine.bindArrayBuffer(null);
  106164. return vao;
  106165. };
  106166. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  106167. var renderVertexBuffers = {};
  106168. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  106169. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  106170. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  106171. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  106172. var offset = 12;
  106173. if (!this._colorGradientsTexture) {
  106174. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  106175. offset += 4;
  106176. }
  106177. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  106178. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  106179. }
  106180. offset += 3; // Direction
  106181. if (!this._isBillboardBased) {
  106182. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  106183. offset += 3;
  106184. }
  106185. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  106186. if (this._angularSpeedGradientsTexture) {
  106187. offset++;
  106188. }
  106189. else {
  106190. offset += 2;
  106191. }
  106192. if (this._isAnimationSheetEnabled) {
  106193. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  106194. offset += 1;
  106195. if (this.spriteRandomStartCell) {
  106196. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  106197. offset += 1;
  106198. }
  106199. }
  106200. if (this.noiseTexture) {
  106201. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  106202. offset += 3;
  106203. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  106204. offset += 3;
  106205. }
  106206. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  106207. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  106208. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  106209. this._engine.bindArrayBuffer(null);
  106210. return vao;
  106211. };
  106212. GPUParticleSystem.prototype._initialize = function (force) {
  106213. if (force === void 0) { force = false; }
  106214. if (this._buffer0 && !force) {
  106215. return;
  106216. }
  106217. var engine = this._scene.getEngine();
  106218. var data = new Array();
  106219. this._attributesStrideSize = 21;
  106220. this._targetIndex = 0;
  106221. if (!this.isBillboardBased) {
  106222. this._attributesStrideSize += 3;
  106223. }
  106224. if (this._colorGradientsTexture) {
  106225. this._attributesStrideSize -= 4;
  106226. }
  106227. if (this._angularSpeedGradientsTexture) {
  106228. this._attributesStrideSize -= 1;
  106229. }
  106230. if (this._isAnimationSheetEnabled) {
  106231. this._attributesStrideSize += 1;
  106232. if (this.spriteRandomStartCell) {
  106233. this._attributesStrideSize += 1;
  106234. }
  106235. }
  106236. if (this.noiseTexture) {
  106237. this._attributesStrideSize += 6;
  106238. }
  106239. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  106240. // position
  106241. data.push(0.0);
  106242. data.push(0.0);
  106243. data.push(0.0);
  106244. // Age and life
  106245. data.push(0.0); // create the particle as a dead one to create a new one at start
  106246. data.push(0.0);
  106247. // Seed
  106248. data.push(Math.random());
  106249. data.push(Math.random());
  106250. data.push(Math.random());
  106251. data.push(Math.random());
  106252. // Size
  106253. data.push(0.0);
  106254. data.push(0.0);
  106255. data.push(0.0);
  106256. if (!this._colorGradientsTexture) {
  106257. // color
  106258. data.push(0.0);
  106259. data.push(0.0);
  106260. data.push(0.0);
  106261. data.push(0.0);
  106262. }
  106263. // direction
  106264. data.push(0.0);
  106265. data.push(0.0);
  106266. data.push(0.0);
  106267. if (!this.isBillboardBased) {
  106268. // initialDirection
  106269. data.push(0.0);
  106270. data.push(0.0);
  106271. data.push(0.0);
  106272. }
  106273. // angle
  106274. data.push(0.0);
  106275. if (!this._angularSpeedGradientsTexture) {
  106276. data.push(0.0);
  106277. }
  106278. if (this._isAnimationSheetEnabled) {
  106279. data.push(0.0);
  106280. if (this.spriteRandomStartCell) {
  106281. data.push(0.0);
  106282. }
  106283. }
  106284. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  106285. data.push(Math.random());
  106286. data.push(Math.random());
  106287. data.push(Math.random());
  106288. data.push(Math.random());
  106289. data.push(Math.random());
  106290. data.push(Math.random());
  106291. }
  106292. }
  106293. // Sprite data
  106294. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  106295. -0.5, 0.5, 0, 1,
  106296. -0.5, -0.5, 0, 0,
  106297. 0.5, -0.5, 1, 0]);
  106298. // Buffers
  106299. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  106300. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  106301. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  106302. // Update VAO
  106303. this._updateVAO = [];
  106304. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  106305. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  106306. // Render VAO
  106307. this._renderVAO = [];
  106308. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  106309. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  106310. // Links
  106311. this._sourceBuffer = this._buffer0;
  106312. this._targetBuffer = this._buffer1;
  106313. };
  106314. /** @hidden */
  106315. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  106316. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  106317. if (this._isBillboardBased) {
  106318. defines += "\n#define BILLBOARD";
  106319. }
  106320. if (this._colorGradientsTexture) {
  106321. defines += "\n#define COLORGRADIENTS";
  106322. }
  106323. if (this._sizeGradientsTexture) {
  106324. defines += "\n#define SIZEGRADIENTS";
  106325. }
  106326. if (this._angularSpeedGradientsTexture) {
  106327. defines += "\n#define ANGULARSPEEDGRADIENTS";
  106328. }
  106329. if (this._velocityGradientsTexture) {
  106330. defines += "\n#define VELOCITYGRADIENTS";
  106331. }
  106332. if (this._limitVelocityGradientsTexture) {
  106333. defines += "\n#define LIMITVELOCITYGRADIENTS";
  106334. }
  106335. if (this._dragGradientsTexture) {
  106336. defines += "\n#define DRAGGRADIENTS";
  106337. }
  106338. if (this.isAnimationSheetEnabled) {
  106339. defines += "\n#define ANIMATESHEET";
  106340. if (this.spriteRandomStartCell) {
  106341. defines += "\n#define ANIMATESHEETRANDOMSTART";
  106342. }
  106343. }
  106344. if (this.noiseTexture) {
  106345. defines += "\n#define NOISE";
  106346. }
  106347. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  106348. return;
  106349. }
  106350. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  106351. if (!this._colorGradientsTexture) {
  106352. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  106353. }
  106354. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  106355. if (!this._isBillboardBased) {
  106356. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  106357. }
  106358. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  106359. if (this.isAnimationSheetEnabled) {
  106360. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  106361. if (this.spriteRandomStartCell) {
  106362. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  106363. }
  106364. }
  106365. if (this.noiseTexture) {
  106366. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  106367. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  106368. }
  106369. this._updateEffectOptions.defines = defines;
  106370. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  106371. };
  106372. /** @hidden */
  106373. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  106374. var defines = "";
  106375. if (this._scene.clipPlane) {
  106376. defines = "\n#define CLIPPLANE";
  106377. }
  106378. if (this._scene.clipPlane2) {
  106379. defines = "\n#define CLIPPLANE2";
  106380. }
  106381. if (this._scene.clipPlane3) {
  106382. defines = "\n#define CLIPPLANE3";
  106383. }
  106384. if (this._scene.clipPlane4) {
  106385. defines = "\n#define CLIPPLANE4";
  106386. }
  106387. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  106388. defines = "\n#define BLENDMULTIPLYMODE";
  106389. }
  106390. if (this._isBillboardBased) {
  106391. defines += "\n#define BILLBOARD";
  106392. switch (this.billboardMode) {
  106393. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  106394. defines += "\n#define BILLBOARDY";
  106395. break;
  106396. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  106397. defines += "\n#define BILLBOARDSTRETCHED";
  106398. break;
  106399. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  106400. default:
  106401. break;
  106402. }
  106403. }
  106404. if (this._colorGradientsTexture) {
  106405. defines += "\n#define COLORGRADIENTS";
  106406. }
  106407. if (this.isAnimationSheetEnabled) {
  106408. defines += "\n#define ANIMATESHEET";
  106409. }
  106410. if (this._imageProcessingConfiguration) {
  106411. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  106412. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  106413. }
  106414. if (this._renderEffect && this._renderEffect.defines === defines) {
  106415. return;
  106416. }
  106417. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  106418. var samplers = ["textureSampler", "colorGradientSampler"];
  106419. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  106420. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  106421. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  106422. }
  106423. 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);
  106424. };
  106425. /**
  106426. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106427. * @param preWarm defines if we are in the pre-warmimg phase
  106428. */
  106429. GPUParticleSystem.prototype.animate = function (preWarm) {
  106430. if (preWarm === void 0) { preWarm = false; }
  106431. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  106432. this._actualFrame += this._timeDelta;
  106433. if (!this._stopped) {
  106434. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  106435. this.stop();
  106436. }
  106437. }
  106438. };
  106439. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  106440. var texture = this[textureName];
  106441. if (!factorGradients || !factorGradients.length || texture) {
  106442. return;
  106443. }
  106444. var data = new Float32Array(this._rawTextureWidth);
  106445. for (var x = 0; x < this._rawTextureWidth; x++) {
  106446. var ratio = x / this._rawTextureWidth;
  106447. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  106448. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  106449. });
  106450. }
  106451. 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);
  106452. };
  106453. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  106454. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  106455. };
  106456. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  106457. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  106458. };
  106459. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  106460. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  106461. };
  106462. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  106463. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  106464. };
  106465. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  106466. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  106467. };
  106468. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  106469. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  106470. return;
  106471. }
  106472. var data = new Uint8Array(this._rawTextureWidth * 4);
  106473. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  106474. for (var x = 0; x < this._rawTextureWidth; x++) {
  106475. var ratio = x / this._rawTextureWidth;
  106476. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  106477. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  106478. data[x * 4] = tmpColor.r * 255;
  106479. data[x * 4 + 1] = tmpColor.g * 255;
  106480. data[x * 4 + 2] = tmpColor.b * 255;
  106481. data[x * 4 + 3] = tmpColor.a * 255;
  106482. });
  106483. }
  106484. 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);
  106485. };
  106486. /**
  106487. * Renders the particle system in its current state
  106488. * @param preWarm defines if the system should only update the particles but not render them
  106489. * @returns the current number of particles
  106490. */
  106491. GPUParticleSystem.prototype.render = function (preWarm) {
  106492. if (preWarm === void 0) { preWarm = false; }
  106493. if (!this._started) {
  106494. return 0;
  106495. }
  106496. this._createColorGradientTexture();
  106497. this._createSizeGradientTexture();
  106498. this._createAngularSpeedGradientTexture();
  106499. this._createVelocityGradientTexture();
  106500. this._createLimitVelocityGradientTexture();
  106501. this._createDragGradientTexture();
  106502. this._recreateUpdateEffect();
  106503. this._recreateRenderEffect();
  106504. if (!this.isReady()) {
  106505. return 0;
  106506. }
  106507. if (!preWarm) {
  106508. if (!this._preWarmDone && this.preWarmCycles) {
  106509. for (var index = 0; index < this.preWarmCycles; index++) {
  106510. this.animate(true);
  106511. this.render(true);
  106512. }
  106513. this._preWarmDone = true;
  106514. }
  106515. if (this._currentRenderId === this._scene.getFrameId()) {
  106516. return 0;
  106517. }
  106518. this._currentRenderId = this._scene.getFrameId();
  106519. }
  106520. // Get everything ready to render
  106521. this._initialize();
  106522. this._accumulatedCount += this.emitRate * this._timeDelta;
  106523. if (this._accumulatedCount > 1) {
  106524. var intPart = this._accumulatedCount | 0;
  106525. this._accumulatedCount -= intPart;
  106526. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  106527. }
  106528. if (!this._currentActiveCount) {
  106529. return 0;
  106530. }
  106531. // Enable update effect
  106532. this._engine.enableEffect(this._updateEffect);
  106533. this._engine.setState(false);
  106534. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  106535. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  106536. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  106537. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  106538. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  106539. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  106540. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  106541. if (!this._colorGradientsTexture) {
  106542. this._updateEffect.setDirectColor4("color1", this.color1);
  106543. this._updateEffect.setDirectColor4("color2", this.color2);
  106544. }
  106545. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  106546. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  106547. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  106548. this._updateEffect.setVector3("gravity", this.gravity);
  106549. if (this._sizeGradientsTexture) {
  106550. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  106551. }
  106552. if (this._angularSpeedGradientsTexture) {
  106553. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  106554. }
  106555. if (this._velocityGradientsTexture) {
  106556. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  106557. }
  106558. if (this._limitVelocityGradientsTexture) {
  106559. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  106560. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  106561. }
  106562. if (this._dragGradientsTexture) {
  106563. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  106564. }
  106565. if (this.particleEmitterType) {
  106566. this.particleEmitterType.applyToShader(this._updateEffect);
  106567. }
  106568. if (this._isAnimationSheetEnabled) {
  106569. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  106570. }
  106571. if (this.noiseTexture) {
  106572. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  106573. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  106574. }
  106575. var emitterWM;
  106576. if (this.emitter.position) {
  106577. var emitterMesh = this.emitter;
  106578. emitterWM = emitterMesh.getWorldMatrix();
  106579. }
  106580. else {
  106581. var emitterPosition = this.emitter;
  106582. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  106583. }
  106584. this._updateEffect.setMatrix("emitterWM", emitterWM);
  106585. // Bind source VAO
  106586. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  106587. // Update
  106588. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  106589. this._engine.setRasterizerState(false);
  106590. this._engine.beginTransformFeedback(true);
  106591. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  106592. this._engine.endTransformFeedback();
  106593. this._engine.setRasterizerState(true);
  106594. this._engine.bindTransformFeedbackBuffer(null);
  106595. if (!preWarm) {
  106596. // Enable render effect
  106597. this._engine.enableEffect(this._renderEffect);
  106598. var viewMatrix = this._scene.getViewMatrix();
  106599. this._renderEffect.setMatrix("view", viewMatrix);
  106600. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  106601. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  106602. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  106603. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  106604. if (this._colorGradientsTexture) {
  106605. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  106606. }
  106607. else {
  106608. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  106609. }
  106610. if (this._isAnimationSheetEnabled && this.particleTexture) {
  106611. var baseSize = this.particleTexture.getBaseSize();
  106612. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  106613. }
  106614. if (this._isBillboardBased) {
  106615. var camera = this._scene.activeCamera;
  106616. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  106617. }
  106618. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  106619. var invView = viewMatrix.clone();
  106620. invView.invert();
  106621. this._renderEffect.setMatrix("invView", invView);
  106622. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  106623. }
  106624. // image processing
  106625. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  106626. this._imageProcessingConfiguration.bind(this._renderEffect);
  106627. }
  106628. // Draw order
  106629. switch (this.blendMode) {
  106630. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  106631. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  106632. break;
  106633. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  106634. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  106635. break;
  106636. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  106637. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  106638. break;
  106639. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  106640. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  106641. break;
  106642. }
  106643. if (this.forceDepthWrite) {
  106644. this._engine.setDepthWrite(true);
  106645. }
  106646. // Bind source VAO
  106647. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  106648. // Render
  106649. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  106650. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  106651. }
  106652. // Switch VAOs
  106653. this._targetIndex++;
  106654. if (this._targetIndex === 2) {
  106655. this._targetIndex = 0;
  106656. }
  106657. // Switch buffers
  106658. var tmpBuffer = this._sourceBuffer;
  106659. this._sourceBuffer = this._targetBuffer;
  106660. this._targetBuffer = tmpBuffer;
  106661. return this._currentActiveCount;
  106662. };
  106663. /**
  106664. * Rebuilds the particle system
  106665. */
  106666. GPUParticleSystem.prototype.rebuild = function () {
  106667. this._initialize(true);
  106668. };
  106669. GPUParticleSystem.prototype._releaseBuffers = function () {
  106670. if (this._buffer0) {
  106671. this._buffer0.dispose();
  106672. this._buffer0 = null;
  106673. }
  106674. if (this._buffer1) {
  106675. this._buffer1.dispose();
  106676. this._buffer1 = null;
  106677. }
  106678. if (this._spriteBuffer) {
  106679. this._spriteBuffer.dispose();
  106680. this._spriteBuffer = null;
  106681. }
  106682. };
  106683. GPUParticleSystem.prototype._releaseVAOs = function () {
  106684. if (!this._updateVAO) {
  106685. return;
  106686. }
  106687. for (var index = 0; index < this._updateVAO.length; index++) {
  106688. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  106689. }
  106690. this._updateVAO = [];
  106691. for (var index = 0; index < this._renderVAO.length; index++) {
  106692. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  106693. }
  106694. this._renderVAO = [];
  106695. };
  106696. /**
  106697. * Disposes the particle system and free the associated resources
  106698. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106699. */
  106700. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  106701. if (disposeTexture === void 0) { disposeTexture = true; }
  106702. var index = this._scene.particleSystems.indexOf(this);
  106703. if (index > -1) {
  106704. this._scene.particleSystems.splice(index, 1);
  106705. }
  106706. this._releaseBuffers();
  106707. this._releaseVAOs();
  106708. if (this._colorGradientsTexture) {
  106709. this._colorGradientsTexture.dispose();
  106710. this._colorGradientsTexture = null;
  106711. }
  106712. if (this._sizeGradientsTexture) {
  106713. this._sizeGradientsTexture.dispose();
  106714. this._sizeGradientsTexture = null;
  106715. }
  106716. if (this._angularSpeedGradientsTexture) {
  106717. this._angularSpeedGradientsTexture.dispose();
  106718. this._angularSpeedGradientsTexture = null;
  106719. }
  106720. if (this._velocityGradientsTexture) {
  106721. this._velocityGradientsTexture.dispose();
  106722. this._velocityGradientsTexture = null;
  106723. }
  106724. if (this._limitVelocityGradientsTexture) {
  106725. this._limitVelocityGradientsTexture.dispose();
  106726. this._limitVelocityGradientsTexture = null;
  106727. }
  106728. if (this._dragGradientsTexture) {
  106729. this._dragGradientsTexture.dispose();
  106730. this._dragGradientsTexture = null;
  106731. }
  106732. if (this._randomTexture) {
  106733. this._randomTexture.dispose();
  106734. this._randomTexture = null;
  106735. }
  106736. if (this._randomTexture2) {
  106737. this._randomTexture2.dispose();
  106738. this._randomTexture2 = null;
  106739. }
  106740. if (disposeTexture && this.particleTexture) {
  106741. this.particleTexture.dispose();
  106742. this.particleTexture = null;
  106743. }
  106744. if (disposeTexture && this.noiseTexture) {
  106745. this.noiseTexture.dispose();
  106746. this.noiseTexture = null;
  106747. }
  106748. // Callback
  106749. this.onDisposeObservable.notifyObservers(this);
  106750. this.onDisposeObservable.clear();
  106751. };
  106752. /**
  106753. * Clones the particle system.
  106754. * @param name The name of the cloned object
  106755. * @param newEmitter The new emitter to use
  106756. * @returns the cloned particle system
  106757. */
  106758. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  106759. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  106760. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  106761. if (newEmitter === undefined) {
  106762. newEmitter = this.emitter;
  106763. }
  106764. result.emitter = newEmitter;
  106765. if (this.particleTexture) {
  106766. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  106767. }
  106768. return result;
  106769. };
  106770. /**
  106771. * Serializes the particle system to a JSON object.
  106772. * @returns the JSON object
  106773. */
  106774. GPUParticleSystem.prototype.serialize = function () {
  106775. var serializationObject = {};
  106776. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  106777. serializationObject.activeParticleCount = this.activeParticleCount;
  106778. return serializationObject;
  106779. };
  106780. /**
  106781. * Parses a JSON object to create a GPU particle system.
  106782. * @param parsedParticleSystem The JSON object to parse
  106783. * @param scene The scene to create the particle system in
  106784. * @param rootUrl The root url to use to load external dependencies like texture
  106785. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106786. * @returns the parsed GPU particle system
  106787. */
  106788. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  106789. if (doNotStart === void 0) { doNotStart = false; }
  106790. var name = parsedParticleSystem.name;
  106791. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  106792. if (parsedParticleSystem.activeParticleCount) {
  106793. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  106794. }
  106795. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  106796. // Auto start
  106797. if (parsedParticleSystem.preventAutoStart) {
  106798. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  106799. }
  106800. if (!doNotStart && !particleSystem.preventAutoStart) {
  106801. particleSystem.start();
  106802. }
  106803. return particleSystem;
  106804. };
  106805. return GPUParticleSystem;
  106806. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  106807. /***/ }),
  106808. /***/ "./Particles/index.ts":
  106809. /*!****************************!*\
  106810. !*** ./Particles/index.ts ***!
  106811. \****************************/
  106812. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  106813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106814. "use strict";
  106815. __webpack_require__.r(__webpack_exports__);
  106816. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  106817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  106818. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  106819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  106820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  106821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  106822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  106823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  106824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  106825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  106826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  106827. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  106828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  106829. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  106830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  106831. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  106832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  106833. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  106834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  106835. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  106836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  106837. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  106838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  106839. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  106840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  106841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  106842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  106843. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  106844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  106845. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  106846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  106847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  106848. /***/ }),
  106849. /***/ "./Particles/particle.ts":
  106850. /*!*******************************!*\
  106851. !*** ./Particles/particle.ts ***!
  106852. \*******************************/
  106853. /*! exports provided: Particle */
  106854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106855. "use strict";
  106856. __webpack_require__.r(__webpack_exports__);
  106857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  106858. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106859. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106860. /**
  106861. * A particle represents one of the element emitted by a particle system.
  106862. * This is mainly define by its coordinates, direction, velocity and age.
  106863. */
  106864. var Particle = /** @class */ (function () {
  106865. /**
  106866. * Creates a new instance Particle
  106867. * @param particleSystem the particle system the particle belongs to
  106868. */
  106869. function Particle(
  106870. /**
  106871. * The particle system the particle belongs to.
  106872. */
  106873. particleSystem) {
  106874. this.particleSystem = particleSystem;
  106875. /**
  106876. * The world position of the particle in the scene.
  106877. */
  106878. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106879. /**
  106880. * The world direction of the particle in the scene.
  106881. */
  106882. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106883. /**
  106884. * The color of the particle.
  106885. */
  106886. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106887. /**
  106888. * The color change of the particle per step.
  106889. */
  106890. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106891. /**
  106892. * Defines how long will the life of the particle be.
  106893. */
  106894. this.lifeTime = 1.0;
  106895. /**
  106896. * The current age of the particle.
  106897. */
  106898. this.age = 0;
  106899. /**
  106900. * The current size of the particle.
  106901. */
  106902. this.size = 0;
  106903. /**
  106904. * The current scale of the particle.
  106905. */
  106906. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  106907. /**
  106908. * The current angle of the particle.
  106909. */
  106910. this.angle = 0;
  106911. /**
  106912. * Defines how fast is the angle changing.
  106913. */
  106914. this.angularSpeed = 0;
  106915. /**
  106916. * Defines the cell index used by the particle to be rendered from a sprite.
  106917. */
  106918. this.cellIndex = 0;
  106919. /** @hidden */
  106920. this._attachedSubEmitters = null;
  106921. /** @hidden */
  106922. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106923. /** @hidden */
  106924. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106925. /** @hidden */
  106926. this._currentSize1 = 0;
  106927. /** @hidden */
  106928. this._currentSize2 = 0;
  106929. /** @hidden */
  106930. this._currentAngularSpeed1 = 0;
  106931. /** @hidden */
  106932. this._currentAngularSpeed2 = 0;
  106933. /** @hidden */
  106934. this._currentVelocity1 = 0;
  106935. /** @hidden */
  106936. this._currentVelocity2 = 0;
  106937. /** @hidden */
  106938. this._currentLimitVelocity1 = 0;
  106939. /** @hidden */
  106940. this._currentLimitVelocity2 = 0;
  106941. /** @hidden */
  106942. this._currentDrag1 = 0;
  106943. /** @hidden */
  106944. this._currentDrag2 = 0;
  106945. this.id = Particle._Count++;
  106946. if (!this.particleSystem.isAnimationSheetEnabled) {
  106947. return;
  106948. }
  106949. this.updateCellInfoFromSystem();
  106950. }
  106951. Particle.prototype.updateCellInfoFromSystem = function () {
  106952. this.cellIndex = this.particleSystem.startSpriteCellID;
  106953. };
  106954. /**
  106955. * Defines how the sprite cell index is updated for the particle
  106956. */
  106957. Particle.prototype.updateCellIndex = function () {
  106958. var offsetAge = this.age;
  106959. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  106960. if (this.particleSystem.spriteRandomStartCell) {
  106961. if (this._randomCellOffset === undefined) {
  106962. this._randomCellOffset = Math.random() * this.lifeTime;
  106963. }
  106964. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  106965. changeSpeed = 1;
  106966. offsetAge = this._randomCellOffset;
  106967. }
  106968. else {
  106969. offsetAge += this._randomCellOffset;
  106970. }
  106971. }
  106972. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  106973. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  106974. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  106975. };
  106976. /** @hidden */
  106977. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  106978. if (subEmitter.particleSystem.emitter.position) {
  106979. var emitterMesh = subEmitter.particleSystem.emitter;
  106980. emitterMesh.position.copyFrom(this.position);
  106981. if (subEmitter.inheritDirection) {
  106982. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  106983. // Look at using Y as forward
  106984. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  106985. }
  106986. }
  106987. else {
  106988. var emitterPosition = subEmitter.particleSystem.emitter;
  106989. emitterPosition.copyFrom(this.position);
  106990. }
  106991. // Set inheritedVelocityOffset to be used when new particles are created
  106992. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  106993. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  106994. };
  106995. /** @hidden */
  106996. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  106997. var _this = this;
  106998. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  106999. this._attachedSubEmitters.forEach(function (subEmitter) {
  107000. _this._inheritParticleInfoToSubEmitter(subEmitter);
  107001. });
  107002. }
  107003. };
  107004. /** @hidden */
  107005. Particle.prototype._reset = function () {
  107006. this.age = 0;
  107007. this._currentColorGradient = null;
  107008. this._currentSizeGradient = null;
  107009. this._currentAngularSpeedGradient = null;
  107010. this._currentVelocityGradient = null;
  107011. this._currentLimitVelocityGradient = null;
  107012. this._currentDragGradient = null;
  107013. this.cellIndex = this.particleSystem.startSpriteCellID;
  107014. this._randomCellOffset = undefined;
  107015. };
  107016. /**
  107017. * Copy the properties of particle to another one.
  107018. * @param other the particle to copy the information to.
  107019. */
  107020. Particle.prototype.copyTo = function (other) {
  107021. other.position.copyFrom(this.position);
  107022. if (this._initialDirection) {
  107023. if (other._initialDirection) {
  107024. other._initialDirection.copyFrom(this._initialDirection);
  107025. }
  107026. else {
  107027. other._initialDirection = this._initialDirection.clone();
  107028. }
  107029. }
  107030. else {
  107031. other._initialDirection = null;
  107032. }
  107033. other.direction.copyFrom(this.direction);
  107034. other.color.copyFrom(this.color);
  107035. other.colorStep.copyFrom(this.colorStep);
  107036. other.lifeTime = this.lifeTime;
  107037. other.age = this.age;
  107038. other._randomCellOffset = this._randomCellOffset;
  107039. other.size = this.size;
  107040. other.scale.copyFrom(this.scale);
  107041. other.angle = this.angle;
  107042. other.angularSpeed = this.angularSpeed;
  107043. other.particleSystem = this.particleSystem;
  107044. other.cellIndex = this.cellIndex;
  107045. other.id = this.id;
  107046. other._attachedSubEmitters = this._attachedSubEmitters;
  107047. if (this._currentColorGradient) {
  107048. other._currentColorGradient = this._currentColorGradient;
  107049. other._currentColor1.copyFrom(this._currentColor1);
  107050. other._currentColor2.copyFrom(this._currentColor2);
  107051. }
  107052. if (this._currentSizeGradient) {
  107053. other._currentSizeGradient = this._currentSizeGradient;
  107054. other._currentSize1 = this._currentSize1;
  107055. other._currentSize2 = this._currentSize2;
  107056. }
  107057. if (this._currentAngularSpeedGradient) {
  107058. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  107059. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  107060. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  107061. }
  107062. if (this._currentVelocityGradient) {
  107063. other._currentVelocityGradient = this._currentVelocityGradient;
  107064. other._currentVelocity1 = this._currentVelocity1;
  107065. other._currentVelocity2 = this._currentVelocity2;
  107066. }
  107067. if (this._currentLimitVelocityGradient) {
  107068. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  107069. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  107070. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  107071. }
  107072. if (this._currentDragGradient) {
  107073. other._currentDragGradient = this._currentDragGradient;
  107074. other._currentDrag1 = this._currentDrag1;
  107075. other._currentDrag2 = this._currentDrag2;
  107076. }
  107077. if (this.particleSystem.isAnimationSheetEnabled) {
  107078. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  107079. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  107080. }
  107081. if (this.particleSystem.useRampGradients) {
  107082. other.remapData.copyFrom(this.remapData);
  107083. }
  107084. if (this._randomNoiseCoordinates1) {
  107085. if (other._randomNoiseCoordinates1) {
  107086. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  107087. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  107088. }
  107089. else {
  107090. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  107091. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  107092. }
  107093. }
  107094. };
  107095. Particle._Count = 0;
  107096. return Particle;
  107097. }());
  107098. /***/ }),
  107099. /***/ "./Particles/particleHelper.ts":
  107100. /*!*************************************!*\
  107101. !*** ./Particles/particleHelper.ts ***!
  107102. \*************************************/
  107103. /*! exports provided: ParticleHelper */
  107104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107105. "use strict";
  107106. __webpack_require__.r(__webpack_exports__);
  107107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  107108. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  107109. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107110. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  107111. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107112. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107113. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  107114. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  107115. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107116. /**
  107117. * This class is made for on one-liner static method to help creating particle system set.
  107118. */
  107119. var ParticleHelper = /** @class */ (function () {
  107120. function ParticleHelper() {
  107121. }
  107122. /**
  107123. * Create a default particle system that you can tweak
  107124. * @param emitter defines the emitter to use
  107125. * @param capacity defines the system capacity (default is 500 particles)
  107126. * @param scene defines the hosting scene
  107127. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107128. * @returns the new Particle system
  107129. */
  107130. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  107131. if (capacity === void 0) { capacity = 500; }
  107132. if (useGPU === void 0) { useGPU = false; }
  107133. var system;
  107134. if (useGPU) {
  107135. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  107136. }
  107137. else {
  107138. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  107139. }
  107140. system.emitter = emitter;
  107141. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  107142. system.createConeEmitter(0.1, Math.PI / 4);
  107143. // Particle color
  107144. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  107145. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  107146. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  107147. // Particle Size
  107148. system.minSize = 0.1;
  107149. system.maxSize = 0.1;
  107150. // Emission speed
  107151. system.minEmitPower = 2;
  107152. system.maxEmitPower = 2;
  107153. // Update speed
  107154. system.updateSpeed = 1 / 60;
  107155. system.emitRate = 30;
  107156. return system;
  107157. };
  107158. /**
  107159. * This is the main static method (one-liner) of this helper to create different particle systems
  107160. * @param type This string represents the type to the particle system to create
  107161. * @param scene The scene where the particle system should live
  107162. * @param gpu If the system will use gpu
  107163. * @returns the ParticleSystemSet created
  107164. */
  107165. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  107166. if (gpu === void 0) { gpu = false; }
  107167. if (!scene) {
  107168. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  107169. }
  107170. var token = {};
  107171. scene._addPendingData(token);
  107172. return new Promise(function (resolve, reject) {
  107173. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  107174. scene._removePendingData(token);
  107175. return reject("Particle system with GPU is not supported.");
  107176. }
  107177. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  107178. scene._removePendingData(token);
  107179. var newData = JSON.parse(data.toString());
  107180. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  107181. }, undefined, undefined, undefined, function () {
  107182. scene._removePendingData(token);
  107183. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  107184. });
  107185. });
  107186. };
  107187. /**
  107188. * Static function used to export a particle system to a ParticleSystemSet variable.
  107189. * Please note that the emitter shape is not exported
  107190. * @param systems defines the particle systems to export
  107191. * @returns the created particle system set
  107192. */
  107193. ParticleHelper.ExportSet = function (systems) {
  107194. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  107195. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  107196. var system = systems_1[_i];
  107197. set.systems.push(system);
  107198. }
  107199. return set;
  107200. };
  107201. /**
  107202. * Gets or sets base Assets URL
  107203. */
  107204. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  107205. return ParticleHelper;
  107206. }());
  107207. /***/ }),
  107208. /***/ "./Particles/particleSystem.ts":
  107209. /*!*************************************!*\
  107210. !*** ./Particles/particleSystem.ts ***!
  107211. \*************************************/
  107212. /*! exports provided: ParticleSystem */
  107213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107214. "use strict";
  107215. __webpack_require__.r(__webpack_exports__);
  107216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  107217. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  107218. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  107219. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  107220. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107221. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107222. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  107223. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  107224. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  107225. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  107226. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  107227. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  107228. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  107229. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  107230. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107231. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  107232. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  107233. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  107234. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  107235. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107236. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  107237. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107238. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  107239. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  107240. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  107241. /**
  107242. * This represents a particle system in Babylon.
  107243. * 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.
  107244. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  107245. * @example https://doc.babylonjs.com/babylon101/particles
  107246. */
  107247. var ParticleSystem = /** @class */ (function (_super) {
  107248. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  107249. /**
  107250. * Instantiates a particle system.
  107251. * 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.
  107252. * @param name The name of the particle system
  107253. * @param capacity The max number of particles alive at the same time
  107254. * @param scene The scene the particle system belongs to
  107255. * @param customEffect a custom effect used to change the way particles are rendered by default
  107256. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107257. * @param epsilon Offset used to render the particles
  107258. */
  107259. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  107260. if (customEffect === void 0) { customEffect = null; }
  107261. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  107262. if (epsilon === void 0) { epsilon = 0.01; }
  107263. var _this = _super.call(this, name) || this;
  107264. /**
  107265. * @hidden
  107266. */
  107267. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  107268. /**
  107269. * An event triggered when the system is disposed
  107270. */
  107271. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  107272. _this._particles = new Array();
  107273. _this._stockParticles = new Array();
  107274. _this._newPartsExcess = 0;
  107275. _this._vertexBuffers = {};
  107276. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  107277. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  107278. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  107279. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  107280. _this._currentRenderId = -1;
  107281. _this._useInstancing = false;
  107282. _this._started = false;
  107283. _this._stopped = false;
  107284. _this._actualFrame = 0;
  107285. /** @hidden */
  107286. _this._currentEmitRate1 = 0;
  107287. /** @hidden */
  107288. _this._currentEmitRate2 = 0;
  107289. /** @hidden */
  107290. _this._currentStartSize1 = 0;
  107291. /** @hidden */
  107292. _this._currentStartSize2 = 0;
  107293. _this._rawTextureWidth = 256;
  107294. _this._useRampGradients = false;
  107295. /**
  107296. * @hidden
  107297. * If the particle systems emitter should be disposed when the particle system is disposed
  107298. */
  107299. _this._disposeEmitterOnDispose = false;
  107300. // start of sub system methods
  107301. /**
  107302. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  107303. * Its lifetime will start back at 0.
  107304. */
  107305. _this.recycleParticle = function (particle) {
  107306. // move particle from activeParticle list to stock particles
  107307. var lastParticle = _this._particles.pop();
  107308. if (lastParticle !== particle) {
  107309. lastParticle.copyTo(particle);
  107310. }
  107311. _this._stockParticles.push(lastParticle);
  107312. };
  107313. _this._createParticle = function () {
  107314. var particle;
  107315. if (_this._stockParticles.length !== 0) {
  107316. particle = _this._stockParticles.pop();
  107317. particle._reset();
  107318. }
  107319. else {
  107320. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  107321. }
  107322. // Attach emitters
  107323. if (_this._subEmitters && _this._subEmitters.length > 0) {
  107324. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  107325. particle._attachedSubEmitters = [];
  107326. subEmitters.forEach(function (subEmitter) {
  107327. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  107328. var newEmitter = subEmitter.clone();
  107329. particle._attachedSubEmitters.push(newEmitter);
  107330. newEmitter.particleSystem.start();
  107331. }
  107332. });
  107333. }
  107334. return particle;
  107335. };
  107336. _this._emitFromParticle = function (particle) {
  107337. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  107338. return;
  107339. }
  107340. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  107341. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  107342. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  107343. var subSystem = subEmitter.clone();
  107344. particle._inheritParticleInfoToSubEmitter(subSystem);
  107345. subSystem.particleSystem._rootParticleSystem = _this;
  107346. _this.activeSubSystems.push(subSystem.particleSystem);
  107347. subSystem.particleSystem.start();
  107348. }
  107349. });
  107350. };
  107351. _this._capacity = capacity;
  107352. _this._epsilon = epsilon;
  107353. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  107354. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  107355. // Setup the default processing configuration to the scene.
  107356. _this._attachImageProcessingConfiguration(null);
  107357. _this._customEffect = customEffect;
  107358. _this._scene.particleSystems.push(_this);
  107359. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  107360. _this._createIndexBuffer();
  107361. _this._createVertexBuffers();
  107362. // Default emitter type
  107363. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107364. // Update
  107365. _this.updateFunction = function (particles) {
  107366. var noiseTextureSize = null;
  107367. var noiseTextureData = null;
  107368. if (_this.noiseTexture) { // We need to get texture data back to CPU
  107369. noiseTextureSize = _this.noiseTexture.getSize();
  107370. noiseTextureData = (_this.noiseTexture.getContent());
  107371. }
  107372. var _loop_1 = function () {
  107373. particle = particles[index];
  107374. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  107375. var previousAge = particle.age;
  107376. particle.age += scaledUpdateSpeed;
  107377. // Evaluate step to death
  107378. if (particle.age > particle.lifeTime) {
  107379. var diff = particle.age - previousAge;
  107380. var oldDiff = particle.lifeTime - previousAge;
  107381. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  107382. particle.age = particle.lifeTime;
  107383. }
  107384. var ratio = particle.age / particle.lifeTime;
  107385. // Color
  107386. if (_this._colorGradients && _this._colorGradients.length > 0) {
  107387. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  107388. if (currentGradient !== particle._currentColorGradient) {
  107389. particle._currentColor1.copyFrom(particle._currentColor2);
  107390. nextGradient.getColorToRef(particle._currentColor2);
  107391. particle._currentColorGradient = currentGradient;
  107392. }
  107393. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  107394. });
  107395. }
  107396. else {
  107397. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  107398. particle.color.addInPlace(_this._scaledColorStep);
  107399. if (particle.color.a < 0) {
  107400. particle.color.a = 0;
  107401. }
  107402. }
  107403. // Angular speed
  107404. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  107405. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  107406. if (currentGradient !== particle._currentAngularSpeedGradient) {
  107407. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  107408. particle._currentAngularSpeed2 = nextGradient.getFactor();
  107409. particle._currentAngularSpeedGradient = currentGradient;
  107410. }
  107411. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  107412. });
  107413. }
  107414. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  107415. // Direction
  107416. var directionScale = scaledUpdateSpeed;
  107417. /// Velocity
  107418. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  107419. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  107420. if (currentGradient !== particle._currentVelocityGradient) {
  107421. particle._currentVelocity1 = particle._currentVelocity2;
  107422. particle._currentVelocity2 = nextGradient.getFactor();
  107423. particle._currentVelocityGradient = currentGradient;
  107424. }
  107425. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  107426. });
  107427. }
  107428. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  107429. /// Limit velocity
  107430. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  107431. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  107432. if (currentGradient !== particle._currentLimitVelocityGradient) {
  107433. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  107434. particle._currentLimitVelocity2 = nextGradient.getFactor();
  107435. particle._currentLimitVelocityGradient = currentGradient;
  107436. }
  107437. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  107438. var currentVelocity = particle.direction.length();
  107439. if (currentVelocity > limitVelocity) {
  107440. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  107441. }
  107442. });
  107443. }
  107444. /// Drag
  107445. if (_this._dragGradients && _this._dragGradients.length > 0) {
  107446. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  107447. if (currentGradient !== particle._currentDragGradient) {
  107448. particle._currentDrag1 = particle._currentDrag2;
  107449. particle._currentDrag2 = nextGradient.getFactor();
  107450. particle._currentDragGradient = currentGradient;
  107451. }
  107452. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  107453. _this._scaledDirection.scaleInPlace(1.0 - drag);
  107454. });
  107455. }
  107456. particle.position.addInPlace(_this._scaledDirection);
  107457. // Noise
  107458. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  107459. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  107460. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  107461. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  107462. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  107463. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  107464. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  107465. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  107466. particle.direction.addInPlace(scaledForce);
  107467. }
  107468. // Gravity
  107469. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  107470. particle.direction.addInPlace(_this._scaledGravity);
  107471. // Size
  107472. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  107473. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  107474. if (currentGradient !== particle._currentSizeGradient) {
  107475. particle._currentSize1 = particle._currentSize2;
  107476. particle._currentSize2 = nextGradient.getFactor();
  107477. particle._currentSizeGradient = currentGradient;
  107478. }
  107479. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  107480. });
  107481. }
  107482. // Remap data
  107483. if (_this._useRampGradients) {
  107484. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  107485. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  107486. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  107487. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  107488. particle.remapData.x = min;
  107489. particle.remapData.y = max - min;
  107490. });
  107491. }
  107492. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  107493. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  107494. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  107495. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  107496. particle.remapData.z = min;
  107497. particle.remapData.w = max - min;
  107498. });
  107499. }
  107500. }
  107501. if (_this._isAnimationSheetEnabled) {
  107502. particle.updateCellIndex();
  107503. }
  107504. // Update the position of the attached sub-emitters to match their attached particle
  107505. particle._inheritParticleInfoToSubEmitters();
  107506. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  107507. _this._emitFromParticle(particle);
  107508. if (particle._attachedSubEmitters) {
  107509. particle._attachedSubEmitters.forEach(function (subEmitter) {
  107510. subEmitter.particleSystem.disposeOnStop = true;
  107511. subEmitter.particleSystem.stop();
  107512. });
  107513. particle._attachedSubEmitters = null;
  107514. }
  107515. _this.recycleParticle(particle);
  107516. index--;
  107517. return "continue";
  107518. }
  107519. };
  107520. var particle;
  107521. for (var index = 0; index < particles.length; index++) {
  107522. _loop_1();
  107523. }
  107524. };
  107525. return _this;
  107526. }
  107527. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  107528. /**
  107529. * Sets a callback that will be triggered when the system is disposed
  107530. */
  107531. set: function (callback) {
  107532. if (this._onDisposeObserver) {
  107533. this.onDisposeObservable.remove(this._onDisposeObserver);
  107534. }
  107535. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  107536. },
  107537. enumerable: true,
  107538. configurable: true
  107539. });
  107540. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  107541. /** Gets or sets a boolean indicating that ramp gradients must be used
  107542. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107543. */
  107544. get: function () {
  107545. return this._useRampGradients;
  107546. },
  107547. set: function (value) {
  107548. if (this._useRampGradients === value) {
  107549. return;
  107550. }
  107551. this._useRampGradients = value;
  107552. this._resetEffect();
  107553. },
  107554. enumerable: true,
  107555. configurable: true
  107556. });
  107557. Object.defineProperty(ParticleSystem.prototype, "particles", {
  107558. //end of Sub-emitter
  107559. /**
  107560. * Gets the current list of active particles
  107561. */
  107562. get: function () {
  107563. return this._particles;
  107564. },
  107565. enumerable: true,
  107566. configurable: true
  107567. });
  107568. /**
  107569. * Returns the string "ParticleSystem"
  107570. * @returns a string containing the class name
  107571. */
  107572. ParticleSystem.prototype.getClassName = function () {
  107573. return "ParticleSystem";
  107574. };
  107575. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  107576. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  107577. newGradient.gradient = gradient;
  107578. newGradient.factor1 = factor;
  107579. newGradient.factor2 = factor2;
  107580. factorGradients.push(newGradient);
  107581. factorGradients.sort(function (a, b) {
  107582. if (a.gradient < b.gradient) {
  107583. return -1;
  107584. }
  107585. else if (a.gradient > b.gradient) {
  107586. return 1;
  107587. }
  107588. return 0;
  107589. });
  107590. };
  107591. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  107592. if (!factorGradients) {
  107593. return;
  107594. }
  107595. var index = 0;
  107596. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  107597. var factorGradient = factorGradients_1[_i];
  107598. if (factorGradient.gradient === gradient) {
  107599. factorGradients.splice(index, 1);
  107600. break;
  107601. }
  107602. index++;
  107603. }
  107604. };
  107605. /**
  107606. * Adds a new life time gradient
  107607. * @param gradient defines the gradient to use (between 0 and 1)
  107608. * @param factor defines the life time factor to affect to the specified gradient
  107609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107610. * @returns the current particle system
  107611. */
  107612. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  107613. if (!this._lifeTimeGradients) {
  107614. this._lifeTimeGradients = [];
  107615. }
  107616. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  107617. return this;
  107618. };
  107619. /**
  107620. * Remove a specific life time gradient
  107621. * @param gradient defines the gradient to remove
  107622. * @returns the current particle system
  107623. */
  107624. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  107625. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  107626. return this;
  107627. };
  107628. /**
  107629. * Adds a new size gradient
  107630. * @param gradient defines the gradient to use (between 0 and 1)
  107631. * @param factor defines the size factor to affect to the specified gradient
  107632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107633. * @returns the current particle system
  107634. */
  107635. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  107636. if (!this._sizeGradients) {
  107637. this._sizeGradients = [];
  107638. }
  107639. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  107640. return this;
  107641. };
  107642. /**
  107643. * Remove a specific size gradient
  107644. * @param gradient defines the gradient to remove
  107645. * @returns the current particle system
  107646. */
  107647. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  107648. this._removeFactorGradient(this._sizeGradients, gradient);
  107649. return this;
  107650. };
  107651. /**
  107652. * Adds a new color remap gradient
  107653. * @param gradient defines the gradient to use (between 0 and 1)
  107654. * @param min defines the color remap minimal range
  107655. * @param max defines the color remap maximal range
  107656. * @returns the current particle system
  107657. */
  107658. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  107659. if (!this._colorRemapGradients) {
  107660. this._colorRemapGradients = [];
  107661. }
  107662. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  107663. return this;
  107664. };
  107665. /**
  107666. * Remove a specific color remap gradient
  107667. * @param gradient defines the gradient to remove
  107668. * @returns the current particle system
  107669. */
  107670. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  107671. this._removeFactorGradient(this._colorRemapGradients, gradient);
  107672. return this;
  107673. };
  107674. /**
  107675. * Adds a new alpha remap gradient
  107676. * @param gradient defines the gradient to use (between 0 and 1)
  107677. * @param min defines the alpha remap minimal range
  107678. * @param max defines the alpha remap maximal range
  107679. * @returns the current particle system
  107680. */
  107681. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  107682. if (!this._alphaRemapGradients) {
  107683. this._alphaRemapGradients = [];
  107684. }
  107685. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  107686. return this;
  107687. };
  107688. /**
  107689. * Remove a specific alpha remap gradient
  107690. * @param gradient defines the gradient to remove
  107691. * @returns the current particle system
  107692. */
  107693. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  107694. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  107695. return this;
  107696. };
  107697. /**
  107698. * Adds a new angular speed gradient
  107699. * @param gradient defines the gradient to use (between 0 and 1)
  107700. * @param factor defines the angular speed to affect to the specified gradient
  107701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107702. * @returns the current particle system
  107703. */
  107704. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  107705. if (!this._angularSpeedGradients) {
  107706. this._angularSpeedGradients = [];
  107707. }
  107708. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  107709. return this;
  107710. };
  107711. /**
  107712. * Remove a specific angular speed gradient
  107713. * @param gradient defines the gradient to remove
  107714. * @returns the current particle system
  107715. */
  107716. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  107717. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  107718. return this;
  107719. };
  107720. /**
  107721. * Adds a new velocity gradient
  107722. * @param gradient defines the gradient to use (between 0 and 1)
  107723. * @param factor defines the velocity to affect to the specified gradient
  107724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107725. * @returns the current particle system
  107726. */
  107727. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  107728. if (!this._velocityGradients) {
  107729. this._velocityGradients = [];
  107730. }
  107731. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  107732. return this;
  107733. };
  107734. /**
  107735. * Remove a specific velocity gradient
  107736. * @param gradient defines the gradient to remove
  107737. * @returns the current particle system
  107738. */
  107739. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  107740. this._removeFactorGradient(this._velocityGradients, gradient);
  107741. return this;
  107742. };
  107743. /**
  107744. * Adds a new limit velocity gradient
  107745. * @param gradient defines the gradient to use (between 0 and 1)
  107746. * @param factor defines the limit velocity value to affect to the specified gradient
  107747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107748. * @returns the current particle system
  107749. */
  107750. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  107751. if (!this._limitVelocityGradients) {
  107752. this._limitVelocityGradients = [];
  107753. }
  107754. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  107755. return this;
  107756. };
  107757. /**
  107758. * Remove a specific limit velocity gradient
  107759. * @param gradient defines the gradient to remove
  107760. * @returns the current particle system
  107761. */
  107762. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  107763. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  107764. return this;
  107765. };
  107766. /**
  107767. * Adds a new drag gradient
  107768. * @param gradient defines the gradient to use (between 0 and 1)
  107769. * @param factor defines the drag value to affect to the specified gradient
  107770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107771. * @returns the current particle system
  107772. */
  107773. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  107774. if (!this._dragGradients) {
  107775. this._dragGradients = [];
  107776. }
  107777. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  107778. return this;
  107779. };
  107780. /**
  107781. * Remove a specific drag gradient
  107782. * @param gradient defines the gradient to remove
  107783. * @returns the current particle system
  107784. */
  107785. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  107786. this._removeFactorGradient(this._dragGradients, gradient);
  107787. return this;
  107788. };
  107789. /**
  107790. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  107791. * @param gradient defines the gradient to use (between 0 and 1)
  107792. * @param factor defines the emit rate value to affect to the specified gradient
  107793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107794. * @returns the current particle system
  107795. */
  107796. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  107797. if (!this._emitRateGradients) {
  107798. this._emitRateGradients = [];
  107799. }
  107800. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  107801. return this;
  107802. };
  107803. /**
  107804. * Remove a specific emit rate gradient
  107805. * @param gradient defines the gradient to remove
  107806. * @returns the current particle system
  107807. */
  107808. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  107809. this._removeFactorGradient(this._emitRateGradients, gradient);
  107810. return this;
  107811. };
  107812. /**
  107813. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  107814. * @param gradient defines the gradient to use (between 0 and 1)
  107815. * @param factor defines the start size value to affect to the specified gradient
  107816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107817. * @returns the current particle system
  107818. */
  107819. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  107820. if (!this._startSizeGradients) {
  107821. this._startSizeGradients = [];
  107822. }
  107823. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  107824. return this;
  107825. };
  107826. /**
  107827. * Remove a specific start size gradient
  107828. * @param gradient defines the gradient to remove
  107829. * @returns the current particle system
  107830. */
  107831. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  107832. this._removeFactorGradient(this._emitRateGradients, gradient);
  107833. return this;
  107834. };
  107835. ParticleSystem.prototype._createRampGradientTexture = function () {
  107836. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  107837. return;
  107838. }
  107839. var data = new Uint8Array(this._rawTextureWidth * 4);
  107840. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  107841. for (var x = 0; x < this._rawTextureWidth; x++) {
  107842. var ratio = x / this._rawTextureWidth;
  107843. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  107844. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  107845. data[x * 4] = tmpColor.r * 255;
  107846. data[x * 4 + 1] = tmpColor.g * 255;
  107847. data[x * 4 + 2] = tmpColor.b * 255;
  107848. data[x * 4 + 3] = 255;
  107849. });
  107850. }
  107851. 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);
  107852. };
  107853. /**
  107854. * Gets the current list of ramp gradients.
  107855. * You must use addRampGradient and removeRampGradient to udpate this list
  107856. * @returns the list of ramp gradients
  107857. */
  107858. ParticleSystem.prototype.getRampGradients = function () {
  107859. return this._rampGradients;
  107860. };
  107861. /**
  107862. * Adds a new ramp gradient used to remap particle colors
  107863. * @param gradient defines the gradient to use (between 0 and 1)
  107864. * @param color defines the color to affect to the specified gradient
  107865. * @returns the current particle system
  107866. */
  107867. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  107868. if (!this._rampGradients) {
  107869. this._rampGradients = [];
  107870. }
  107871. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  107872. rampGradient.gradient = gradient;
  107873. rampGradient.color = color;
  107874. this._rampGradients.push(rampGradient);
  107875. this._rampGradients.sort(function (a, b) {
  107876. if (a.gradient < b.gradient) {
  107877. return -1;
  107878. }
  107879. else if (a.gradient > b.gradient) {
  107880. return 1;
  107881. }
  107882. return 0;
  107883. });
  107884. if (this._rampGradientsTexture) {
  107885. this._rampGradientsTexture.dispose();
  107886. this._rampGradientsTexture = null;
  107887. }
  107888. this._createRampGradientTexture();
  107889. return this;
  107890. };
  107891. /**
  107892. * Remove a specific ramp gradient
  107893. * @param gradient defines the gradient to remove
  107894. * @returns the current particle system
  107895. */
  107896. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  107897. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  107898. this._rampGradientsTexture = null;
  107899. if (this._rampGradients && this._rampGradients.length > 0) {
  107900. this._createRampGradientTexture();
  107901. }
  107902. return this;
  107903. };
  107904. /**
  107905. * Adds a new color gradient
  107906. * @param gradient defines the gradient to use (between 0 and 1)
  107907. * @param color1 defines the color to affect to the specified gradient
  107908. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  107909. * @returns this particle system
  107910. */
  107911. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  107912. if (!this._colorGradients) {
  107913. this._colorGradients = [];
  107914. }
  107915. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  107916. colorGradient.gradient = gradient;
  107917. colorGradient.color1 = color1;
  107918. colorGradient.color2 = color2;
  107919. this._colorGradients.push(colorGradient);
  107920. this._colorGradients.sort(function (a, b) {
  107921. if (a.gradient < b.gradient) {
  107922. return -1;
  107923. }
  107924. else if (a.gradient > b.gradient) {
  107925. return 1;
  107926. }
  107927. return 0;
  107928. });
  107929. return this;
  107930. };
  107931. /**
  107932. * Remove a specific color gradient
  107933. * @param gradient defines the gradient to remove
  107934. * @returns this particle system
  107935. */
  107936. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  107937. if (!this._colorGradients) {
  107938. return this;
  107939. }
  107940. var index = 0;
  107941. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  107942. var colorGradient = _a[_i];
  107943. if (colorGradient.gradient === gradient) {
  107944. this._colorGradients.splice(index, 1);
  107945. break;
  107946. }
  107947. index++;
  107948. }
  107949. return this;
  107950. };
  107951. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  107952. u = Math.abs(u) * 0.5 + 0.5;
  107953. v = Math.abs(v) * 0.5 + 0.5;
  107954. var wrappedU = ((u * width) % width) | 0;
  107955. var wrappedV = ((v * height) % height) | 0;
  107956. var position = (wrappedU + wrappedV * width) * 4;
  107957. return pixels[position] / 255;
  107958. };
  107959. ParticleSystem.prototype._reset = function () {
  107960. this._resetEffect();
  107961. };
  107962. ParticleSystem.prototype._resetEffect = function () {
  107963. if (this._vertexBuffer) {
  107964. this._vertexBuffer.dispose();
  107965. this._vertexBuffer = null;
  107966. }
  107967. if (this._spriteBuffer) {
  107968. this._spriteBuffer.dispose();
  107969. this._spriteBuffer = null;
  107970. }
  107971. this._createVertexBuffers();
  107972. };
  107973. ParticleSystem.prototype._createVertexBuffers = function () {
  107974. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  107975. if (this._isAnimationSheetEnabled) {
  107976. this._vertexBufferSize += 1;
  107977. }
  107978. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  107979. this._vertexBufferSize += 3;
  107980. }
  107981. if (this._useRampGradients) {
  107982. this._vertexBufferSize += 4;
  107983. }
  107984. var engine = this._scene.getEngine();
  107985. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  107986. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  107987. var dataOffset = 0;
  107988. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  107989. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  107990. dataOffset += 3;
  107991. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  107992. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  107993. dataOffset += 4;
  107994. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  107995. this._vertexBuffers["angle"] = options;
  107996. dataOffset += 1;
  107997. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  107998. this._vertexBuffers["size"] = size;
  107999. dataOffset += 2;
  108000. if (this._isAnimationSheetEnabled) {
  108001. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  108002. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  108003. dataOffset += 1;
  108004. }
  108005. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  108006. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  108007. this._vertexBuffers["direction"] = directionBuffer;
  108008. dataOffset += 3;
  108009. }
  108010. if (this._useRampGradients) {
  108011. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  108012. this._vertexBuffers["remapData"] = rampDataBuffer;
  108013. dataOffset += 4;
  108014. }
  108015. var offsets;
  108016. if (this._useInstancing) {
  108017. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  108018. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  108019. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  108020. }
  108021. else {
  108022. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  108023. dataOffset += 2;
  108024. }
  108025. this._vertexBuffers["offset"] = offsets;
  108026. };
  108027. ParticleSystem.prototype._createIndexBuffer = function () {
  108028. if (this._useInstancing) {
  108029. return;
  108030. }
  108031. var indices = [];
  108032. var index = 0;
  108033. for (var count = 0; count < this._capacity; count++) {
  108034. indices.push(index);
  108035. indices.push(index + 1);
  108036. indices.push(index + 2);
  108037. indices.push(index);
  108038. indices.push(index + 2);
  108039. indices.push(index + 3);
  108040. index += 4;
  108041. }
  108042. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  108043. };
  108044. /**
  108045. * Gets the maximum number of particles active at the same time.
  108046. * @returns The max number of active particles.
  108047. */
  108048. ParticleSystem.prototype.getCapacity = function () {
  108049. return this._capacity;
  108050. };
  108051. /**
  108052. * Gets whether there are still active particles in the system.
  108053. * @returns True if it is alive, otherwise false.
  108054. */
  108055. ParticleSystem.prototype.isAlive = function () {
  108056. return this._alive;
  108057. };
  108058. /**
  108059. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108060. * @returns True if it has been started, otherwise false.
  108061. */
  108062. ParticleSystem.prototype.isStarted = function () {
  108063. return this._started;
  108064. };
  108065. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  108066. var _this = this;
  108067. this._subEmitters = new Array();
  108068. if (this.subEmitters) {
  108069. this.subEmitters.forEach(function (subEmitter) {
  108070. if (subEmitter instanceof ParticleSystem) {
  108071. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  108072. }
  108073. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  108074. _this._subEmitters.push([subEmitter]);
  108075. }
  108076. else if (subEmitter instanceof Array) {
  108077. _this._subEmitters.push(subEmitter);
  108078. }
  108079. });
  108080. }
  108081. };
  108082. /**
  108083. * Starts the particle system and begins to emit
  108084. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108085. */
  108086. ParticleSystem.prototype.start = function (delay) {
  108087. var _this = this;
  108088. if (delay === void 0) { delay = this.startDelay; }
  108089. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  108090. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  108091. }
  108092. if (delay) {
  108093. setTimeout(function () {
  108094. _this.start(0);
  108095. }, delay);
  108096. return;
  108097. }
  108098. // Convert the subEmitters field to the constant type field _subEmitters
  108099. this._prepareSubEmitterInternalArray();
  108100. this._started = true;
  108101. this._stopped = false;
  108102. this._actualFrame = 0;
  108103. if (this._subEmitters && this._subEmitters.length != 0) {
  108104. this.activeSubSystems = new Array();
  108105. }
  108106. // Reset emit gradient so it acts the same on every start
  108107. if (this._emitRateGradients) {
  108108. if (this._emitRateGradients.length > 0) {
  108109. this._currentEmitRateGradient = this._emitRateGradients[0];
  108110. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  108111. this._currentEmitRate2 = this._currentEmitRate1;
  108112. }
  108113. if (this._emitRateGradients.length > 1) {
  108114. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  108115. }
  108116. }
  108117. // Reset start size gradient so it acts the same on every start
  108118. if (this._startSizeGradients) {
  108119. if (this._startSizeGradients.length > 0) {
  108120. this._currentStartSizeGradient = this._startSizeGradients[0];
  108121. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  108122. this._currentStartSize2 = this._currentStartSize1;
  108123. }
  108124. if (this._startSizeGradients.length > 1) {
  108125. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  108126. }
  108127. }
  108128. if (this.preWarmCycles) {
  108129. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  108130. this.emitter.computeWorldMatrix(true);
  108131. }
  108132. var noiseTextureAsProcedural_1 = this.noiseTexture;
  108133. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  108134. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  108135. setTimeout(function () {
  108136. for (var index = 0; index < _this.preWarmCycles; index++) {
  108137. _this.animate(true);
  108138. noiseTextureAsProcedural_1.render();
  108139. }
  108140. });
  108141. });
  108142. }
  108143. else {
  108144. for (var index = 0; index < this.preWarmCycles; index++) {
  108145. this.animate(true);
  108146. }
  108147. }
  108148. }
  108149. // Animations
  108150. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  108151. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  108152. }
  108153. };
  108154. /**
  108155. * Stops the particle system.
  108156. * @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.
  108157. */
  108158. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  108159. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  108160. this._stopped = true;
  108161. if (stopSubEmitters) {
  108162. this._stopSubEmitters();
  108163. }
  108164. };
  108165. // animation sheet
  108166. /**
  108167. * Remove all active particles
  108168. */
  108169. ParticleSystem.prototype.reset = function () {
  108170. this._stockParticles = [];
  108171. this._particles = [];
  108172. };
  108173. /**
  108174. * @hidden (for internal use only)
  108175. */
  108176. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  108177. var offset = index * this._vertexBufferSize;
  108178. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  108179. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  108180. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  108181. this._vertexData[offset++] = particle.color.r;
  108182. this._vertexData[offset++] = particle.color.g;
  108183. this._vertexData[offset++] = particle.color.b;
  108184. this._vertexData[offset++] = particle.color.a;
  108185. this._vertexData[offset++] = particle.angle;
  108186. this._vertexData[offset++] = particle.scale.x * particle.size;
  108187. this._vertexData[offset++] = particle.scale.y * particle.size;
  108188. if (this._isAnimationSheetEnabled) {
  108189. this._vertexData[offset++] = particle.cellIndex;
  108190. }
  108191. if (!this._isBillboardBased) {
  108192. if (particle._initialDirection) {
  108193. this._vertexData[offset++] = particle._initialDirection.x;
  108194. this._vertexData[offset++] = particle._initialDirection.y;
  108195. this._vertexData[offset++] = particle._initialDirection.z;
  108196. }
  108197. else {
  108198. this._vertexData[offset++] = particle.direction.x;
  108199. this._vertexData[offset++] = particle.direction.y;
  108200. this._vertexData[offset++] = particle.direction.z;
  108201. }
  108202. }
  108203. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  108204. this._vertexData[offset++] = particle.direction.x;
  108205. this._vertexData[offset++] = particle.direction.y;
  108206. this._vertexData[offset++] = particle.direction.z;
  108207. }
  108208. if (this._useRampGradients) {
  108209. this._vertexData[offset++] = particle.remapData.x;
  108210. this._vertexData[offset++] = particle.remapData.y;
  108211. this._vertexData[offset++] = particle.remapData.z;
  108212. this._vertexData[offset++] = particle.remapData.w;
  108213. }
  108214. if (!this._useInstancing) {
  108215. if (this._isAnimationSheetEnabled) {
  108216. if (offsetX === 0) {
  108217. offsetX = this._epsilon;
  108218. }
  108219. else if (offsetX === 1) {
  108220. offsetX = 1 - this._epsilon;
  108221. }
  108222. if (offsetY === 0) {
  108223. offsetY = this._epsilon;
  108224. }
  108225. else if (offsetY === 1) {
  108226. offsetY = 1 - this._epsilon;
  108227. }
  108228. }
  108229. this._vertexData[offset++] = offsetX;
  108230. this._vertexData[offset++] = offsetY;
  108231. }
  108232. };
  108233. ParticleSystem.prototype._stopSubEmitters = function () {
  108234. if (!this.activeSubSystems) {
  108235. return;
  108236. }
  108237. this.activeSubSystems.forEach(function (subSystem) {
  108238. subSystem.stop(true);
  108239. });
  108240. this.activeSubSystems = new Array();
  108241. };
  108242. ParticleSystem.prototype._removeFromRoot = function () {
  108243. if (!this._rootParticleSystem) {
  108244. return;
  108245. }
  108246. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  108247. if (index !== -1) {
  108248. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  108249. }
  108250. this._rootParticleSystem = null;
  108251. };
  108252. // End of sub system methods
  108253. ParticleSystem.prototype._update = function (newParticles) {
  108254. var _this = this;
  108255. // Update current
  108256. this._alive = this._particles.length > 0;
  108257. if (this.emitter.position) {
  108258. var emitterMesh = this.emitter;
  108259. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  108260. }
  108261. else {
  108262. var emitterPosition = this.emitter;
  108263. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  108264. }
  108265. this.updateFunction(this._particles);
  108266. // Add new ones
  108267. var particle;
  108268. var _loop_2 = function () {
  108269. if (this_1._particles.length === this_1._capacity) {
  108270. return "break";
  108271. }
  108272. particle = this_1._createParticle();
  108273. this_1._particles.push(particle);
  108274. // Emitter
  108275. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  108276. if (this_1.startPositionFunction) {
  108277. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  108278. }
  108279. else {
  108280. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  108281. }
  108282. if (this_1.startDirectionFunction) {
  108283. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  108284. }
  108285. else {
  108286. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  108287. }
  108288. if (emitPower === 0) {
  108289. if (!particle._initialDirection) {
  108290. particle._initialDirection = particle.direction.clone();
  108291. }
  108292. else {
  108293. particle._initialDirection.copyFrom(particle.direction);
  108294. }
  108295. }
  108296. else {
  108297. particle._initialDirection = null;
  108298. }
  108299. particle.direction.scaleInPlace(emitPower);
  108300. // Life time
  108301. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  108302. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  108303. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  108304. var factorGradient1 = currentGradient;
  108305. var factorGradient2 = nextGradient;
  108306. var lifeTime1 = factorGradient1.getFactor();
  108307. var lifeTime2 = factorGradient2.getFactor();
  108308. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  108309. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  108310. });
  108311. }
  108312. else {
  108313. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  108314. }
  108315. // Size
  108316. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  108317. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  108318. }
  108319. else {
  108320. particle._currentSizeGradient = this_1._sizeGradients[0];
  108321. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  108322. particle.size = particle._currentSize1;
  108323. if (this_1._sizeGradients.length > 1) {
  108324. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  108325. }
  108326. else {
  108327. particle._currentSize2 = particle._currentSize1;
  108328. }
  108329. }
  108330. // Size and scale
  108331. 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));
  108332. // Adjust scale by start size
  108333. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  108334. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  108335. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  108336. if (currentGradient !== _this._currentStartSizeGradient) {
  108337. _this._currentStartSize1 = _this._currentStartSize2;
  108338. _this._currentStartSize2 = nextGradient.getFactor();
  108339. _this._currentStartSizeGradient = currentGradient;
  108340. }
  108341. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  108342. particle.scale.scaleInPlace(value);
  108343. });
  108344. }
  108345. // Angle
  108346. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  108347. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  108348. }
  108349. else {
  108350. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  108351. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  108352. particle._currentAngularSpeed1 = particle.angularSpeed;
  108353. if (this_1._angularSpeedGradients.length > 1) {
  108354. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  108355. }
  108356. else {
  108357. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  108358. }
  108359. }
  108360. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  108361. // Velocity
  108362. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  108363. particle._currentVelocityGradient = this_1._velocityGradients[0];
  108364. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  108365. if (this_1._velocityGradients.length > 1) {
  108366. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  108367. }
  108368. else {
  108369. particle._currentVelocity2 = particle._currentVelocity1;
  108370. }
  108371. }
  108372. // Limit velocity
  108373. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  108374. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  108375. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  108376. if (this_1._limitVelocityGradients.length > 1) {
  108377. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  108378. }
  108379. else {
  108380. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  108381. }
  108382. }
  108383. // Drag
  108384. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  108385. particle._currentDragGradient = this_1._dragGradients[0];
  108386. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  108387. if (this_1._dragGradients.length > 1) {
  108388. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  108389. }
  108390. else {
  108391. particle._currentDrag2 = particle._currentDrag1;
  108392. }
  108393. }
  108394. // Color
  108395. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  108396. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  108397. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  108398. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  108399. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  108400. }
  108401. else {
  108402. particle._currentColorGradient = this_1._colorGradients[0];
  108403. particle._currentColorGradient.getColorToRef(particle.color);
  108404. particle._currentColor1.copyFrom(particle.color);
  108405. if (this_1._colorGradients.length > 1) {
  108406. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  108407. }
  108408. else {
  108409. particle._currentColor2.copyFrom(particle.color);
  108410. }
  108411. }
  108412. // Sheet
  108413. if (this_1._isAnimationSheetEnabled) {
  108414. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  108415. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  108416. }
  108417. // Inherited Velocity
  108418. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  108419. // Ramp
  108420. if (this_1._useRampGradients) {
  108421. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  108422. }
  108423. // Noise texture coordinates
  108424. if (this_1.noiseTexture) {
  108425. if (particle._randomNoiseCoordinates1) {
  108426. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  108427. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  108428. }
  108429. else {
  108430. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  108431. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  108432. }
  108433. }
  108434. // Update the position of the attached sub-emitters to match their attached particle
  108435. particle._inheritParticleInfoToSubEmitters();
  108436. };
  108437. var this_1 = this, step;
  108438. for (var index = 0; index < newParticles; index++) {
  108439. var state_1 = _loop_2();
  108440. if (state_1 === "break")
  108441. break;
  108442. }
  108443. };
  108444. /** @hidden */
  108445. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  108446. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  108447. if (isBillboardBased === void 0) { isBillboardBased = false; }
  108448. if (useRampGradients === void 0) { useRampGradients = false; }
  108449. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  108450. if (isAnimationSheetEnabled) {
  108451. attributeNamesOrOptions.push("cellIndex");
  108452. }
  108453. if (!isBillboardBased) {
  108454. attributeNamesOrOptions.push("direction");
  108455. }
  108456. if (useRampGradients) {
  108457. attributeNamesOrOptions.push("remapData");
  108458. }
  108459. return attributeNamesOrOptions;
  108460. };
  108461. /** @hidden */
  108462. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  108463. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  108464. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  108465. if (isAnimationSheetEnabled) {
  108466. effectCreationOption.push("particlesInfos");
  108467. }
  108468. return effectCreationOption;
  108469. };
  108470. /** @hidden */
  108471. ParticleSystem.prototype._getEffect = function (blendMode) {
  108472. if (this._customEffect) {
  108473. return this._customEffect;
  108474. }
  108475. var defines = [];
  108476. if (this._scene.clipPlane) {
  108477. defines.push("#define CLIPPLANE");
  108478. }
  108479. if (this._scene.clipPlane2) {
  108480. defines.push("#define CLIPPLANE2");
  108481. }
  108482. if (this._scene.clipPlane3) {
  108483. defines.push("#define CLIPPLANE3");
  108484. }
  108485. if (this._scene.clipPlane4) {
  108486. defines.push("#define CLIPPLANE4");
  108487. }
  108488. if (this._isAnimationSheetEnabled) {
  108489. defines.push("#define ANIMATESHEET");
  108490. }
  108491. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  108492. defines.push("#define BLENDMULTIPLYMODE");
  108493. }
  108494. if (this._useRampGradients) {
  108495. defines.push("#define RAMPGRADIENT");
  108496. }
  108497. if (this._isBillboardBased) {
  108498. defines.push("#define BILLBOARD");
  108499. switch (this.billboardMode) {
  108500. case ParticleSystem.BILLBOARDMODE_Y:
  108501. defines.push("#define BILLBOARDY");
  108502. break;
  108503. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  108504. defines.push("#define BILLBOARDSTRETCHED");
  108505. break;
  108506. case ParticleSystem.BILLBOARDMODE_ALL:
  108507. default:
  108508. break;
  108509. }
  108510. }
  108511. if (this._imageProcessingConfiguration) {
  108512. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  108513. defines.push(this._imageProcessingConfigurationDefines.toString());
  108514. }
  108515. // Effect
  108516. var join = defines.join("\n");
  108517. if (this._cachedDefines !== join) {
  108518. this._cachedDefines = join;
  108519. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  108520. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  108521. var samplers = ["diffuseSampler", "rampSampler"];
  108522. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  108523. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  108524. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  108525. }
  108526. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  108527. }
  108528. return this._effect;
  108529. };
  108530. /**
  108531. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108532. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  108533. */
  108534. ParticleSystem.prototype.animate = function (preWarmOnly) {
  108535. var _this = this;
  108536. if (preWarmOnly === void 0) { preWarmOnly = false; }
  108537. if (!this._started) {
  108538. return;
  108539. }
  108540. if (!preWarmOnly) {
  108541. // Check
  108542. if (!this.isReady()) {
  108543. return;
  108544. }
  108545. if (this._currentRenderId === this._scene.getFrameId()) {
  108546. return;
  108547. }
  108548. this._currentRenderId = this._scene.getFrameId();
  108549. }
  108550. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  108551. // Determine the number of particles we need to create
  108552. var newParticles;
  108553. if (this.manualEmitCount > -1) {
  108554. newParticles = this.manualEmitCount;
  108555. this._newPartsExcess = 0;
  108556. this.manualEmitCount = 0;
  108557. }
  108558. else {
  108559. var rate_1 = this.emitRate;
  108560. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  108561. var ratio = this._actualFrame / this.targetStopDuration;
  108562. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  108563. if (currentGradient !== _this._currentEmitRateGradient) {
  108564. _this._currentEmitRate1 = _this._currentEmitRate2;
  108565. _this._currentEmitRate2 = nextGradient.getFactor();
  108566. _this._currentEmitRateGradient = currentGradient;
  108567. }
  108568. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  108569. });
  108570. }
  108571. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  108572. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  108573. }
  108574. if (this._newPartsExcess > 1.0) {
  108575. newParticles += this._newPartsExcess >> 0;
  108576. this._newPartsExcess -= this._newPartsExcess >> 0;
  108577. }
  108578. this._alive = false;
  108579. if (!this._stopped) {
  108580. this._actualFrame += this._scaledUpdateSpeed;
  108581. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  108582. this.stop();
  108583. }
  108584. }
  108585. else {
  108586. newParticles = 0;
  108587. }
  108588. this._update(newParticles);
  108589. // Stopped?
  108590. if (this._stopped) {
  108591. if (!this._alive) {
  108592. this._started = false;
  108593. if (this.onAnimationEnd) {
  108594. this.onAnimationEnd();
  108595. }
  108596. if (this.disposeOnStop) {
  108597. this._scene._toBeDisposed.push(this);
  108598. }
  108599. }
  108600. }
  108601. if (!preWarmOnly) {
  108602. // Update VBO
  108603. var offset = 0;
  108604. for (var index = 0; index < this._particles.length; index++) {
  108605. var particle = this._particles[index];
  108606. this._appendParticleVertices(offset, particle);
  108607. offset += this._useInstancing ? 1 : 4;
  108608. }
  108609. if (this._vertexBuffer) {
  108610. this._vertexBuffer.update(this._vertexData);
  108611. }
  108612. }
  108613. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  108614. this.stop();
  108615. }
  108616. };
  108617. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  108618. this._appendParticleVertex(offset++, particle, 0, 0);
  108619. if (!this._useInstancing) {
  108620. this._appendParticleVertex(offset++, particle, 1, 0);
  108621. this._appendParticleVertex(offset++, particle, 1, 1);
  108622. this._appendParticleVertex(offset++, particle, 0, 1);
  108623. }
  108624. };
  108625. /**
  108626. * Rebuilds the particle system.
  108627. */
  108628. ParticleSystem.prototype.rebuild = function () {
  108629. this._createIndexBuffer();
  108630. if (this._vertexBuffer) {
  108631. this._vertexBuffer._rebuild();
  108632. }
  108633. };
  108634. /**
  108635. * Is this system ready to be used/rendered
  108636. * @return true if the system is ready
  108637. */
  108638. ParticleSystem.prototype.isReady = function () {
  108639. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  108640. return false;
  108641. }
  108642. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  108643. if (!this._getEffect(this.blendMode).isReady()) {
  108644. return false;
  108645. }
  108646. }
  108647. else {
  108648. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  108649. return false;
  108650. }
  108651. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  108652. return false;
  108653. }
  108654. }
  108655. return true;
  108656. };
  108657. ParticleSystem.prototype._render = function (blendMode) {
  108658. var effect = this._getEffect(blendMode);
  108659. var engine = this._scene.getEngine();
  108660. // Render
  108661. engine.enableEffect(effect);
  108662. var viewMatrix = this._scene.getViewMatrix();
  108663. effect.setTexture("diffuseSampler", this.particleTexture);
  108664. effect.setMatrix("view", viewMatrix);
  108665. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  108666. if (this._isAnimationSheetEnabled && this.particleTexture) {
  108667. var baseSize = this.particleTexture.getBaseSize();
  108668. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  108669. }
  108670. effect.setVector2("translationPivot", this.translationPivot);
  108671. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  108672. if (this._isBillboardBased) {
  108673. var camera = this._scene.activeCamera;
  108674. effect.setVector3("eyePosition", camera.globalPosition);
  108675. }
  108676. if (this._rampGradientsTexture) {
  108677. effect.setTexture("rampSampler", this._rampGradientsTexture);
  108678. }
  108679. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  108680. var invView = viewMatrix.clone();
  108681. invView.invert();
  108682. effect.setMatrix("invView", invView);
  108683. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  108684. }
  108685. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  108686. // image processing
  108687. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  108688. this._imageProcessingConfiguration.bind(effect);
  108689. }
  108690. // Draw order
  108691. switch (blendMode) {
  108692. case ParticleSystem.BLENDMODE_ADD:
  108693. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  108694. break;
  108695. case ParticleSystem.BLENDMODE_ONEONE:
  108696. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  108697. break;
  108698. case ParticleSystem.BLENDMODE_STANDARD:
  108699. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  108700. break;
  108701. case ParticleSystem.BLENDMODE_MULTIPLY:
  108702. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  108703. break;
  108704. }
  108705. if (this._useInstancing) {
  108706. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  108707. }
  108708. else {
  108709. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  108710. }
  108711. return this._particles.length;
  108712. };
  108713. /**
  108714. * Renders the particle system in its current state.
  108715. * @returns the current number of particles
  108716. */
  108717. ParticleSystem.prototype.render = function () {
  108718. // Check
  108719. if (!this.isReady() || !this._particles.length) {
  108720. return 0;
  108721. }
  108722. var engine = this._scene.getEngine();
  108723. engine.setState(false);
  108724. if (this.forceDepthWrite) {
  108725. engine.setDepthWrite(true);
  108726. }
  108727. var outparticles = 0;
  108728. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  108729. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  108730. }
  108731. outparticles = this._render(this.blendMode);
  108732. engine.unbindInstanceAttributes();
  108733. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  108734. return outparticles;
  108735. };
  108736. /**
  108737. * Disposes the particle system and free the associated resources
  108738. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108739. */
  108740. ParticleSystem.prototype.dispose = function (disposeTexture) {
  108741. if (disposeTexture === void 0) { disposeTexture = true; }
  108742. if (this._vertexBuffer) {
  108743. this._vertexBuffer.dispose();
  108744. this._vertexBuffer = null;
  108745. }
  108746. if (this._spriteBuffer) {
  108747. this._spriteBuffer.dispose();
  108748. this._spriteBuffer = null;
  108749. }
  108750. if (this._indexBuffer) {
  108751. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  108752. this._indexBuffer = null;
  108753. }
  108754. if (disposeTexture && this.particleTexture) {
  108755. this.particleTexture.dispose();
  108756. this.particleTexture = null;
  108757. }
  108758. if (disposeTexture && this.noiseTexture) {
  108759. this.noiseTexture.dispose();
  108760. this.noiseTexture = null;
  108761. }
  108762. if (this._rampGradientsTexture) {
  108763. this._rampGradientsTexture.dispose();
  108764. this._rampGradientsTexture = null;
  108765. }
  108766. this._removeFromRoot();
  108767. if (this._subEmitters && this._subEmitters.length) {
  108768. for (var index = 0; index < this._subEmitters.length; index++) {
  108769. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  108770. var subEmitter = _a[_i];
  108771. subEmitter.dispose();
  108772. }
  108773. }
  108774. this._subEmitters = [];
  108775. this.subEmitters = [];
  108776. }
  108777. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  108778. this.emitter.dispose(true);
  108779. }
  108780. // Remove from scene
  108781. var index = this._scene.particleSystems.indexOf(this);
  108782. if (index > -1) {
  108783. this._scene.particleSystems.splice(index, 1);
  108784. }
  108785. this._scene._activeParticleSystems.dispose();
  108786. // Callback
  108787. this.onDisposeObservable.notifyObservers(this);
  108788. this.onDisposeObservable.clear();
  108789. this.reset();
  108790. };
  108791. // Clone
  108792. /**
  108793. * Clones the particle system.
  108794. * @param name The name of the cloned object
  108795. * @param newEmitter The new emitter to use
  108796. * @returns the cloned particle system
  108797. */
  108798. ParticleSystem.prototype.clone = function (name, newEmitter) {
  108799. var custom = null;
  108800. var program = null;
  108801. if (this.customShader != null) {
  108802. program = this.customShader;
  108803. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  108804. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  108805. }
  108806. else if (this._customEffect) {
  108807. custom = this._customEffect;
  108808. }
  108809. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  108810. result.customShader = program;
  108811. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  108812. if (newEmitter === undefined) {
  108813. newEmitter = this.emitter;
  108814. }
  108815. result.noiseTexture = this.noiseTexture;
  108816. result.emitter = newEmitter;
  108817. if (this.particleTexture) {
  108818. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  108819. }
  108820. // Clone gradients
  108821. if (this._colorGradients) {
  108822. this._colorGradients.forEach(function (v) {
  108823. result.addColorGradient(v.gradient, v.color1, v.color2);
  108824. });
  108825. }
  108826. if (this._dragGradients) {
  108827. this._dragGradients.forEach(function (v) {
  108828. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  108829. });
  108830. }
  108831. if (this._angularSpeedGradients) {
  108832. this._angularSpeedGradients.forEach(function (v) {
  108833. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  108834. });
  108835. }
  108836. if (this._emitRateGradients) {
  108837. this._emitRateGradients.forEach(function (v) {
  108838. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  108839. });
  108840. }
  108841. if (this._lifeTimeGradients) {
  108842. this._lifeTimeGradients.forEach(function (v) {
  108843. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  108844. });
  108845. }
  108846. if (this._limitVelocityGradients) {
  108847. this._limitVelocityGradients.forEach(function (v) {
  108848. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  108849. });
  108850. }
  108851. if (this._sizeGradients) {
  108852. this._sizeGradients.forEach(function (v) {
  108853. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  108854. });
  108855. }
  108856. if (this._startSizeGradients) {
  108857. this._startSizeGradients.forEach(function (v) {
  108858. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  108859. });
  108860. }
  108861. if (this._velocityGradients) {
  108862. this._velocityGradients.forEach(function (v) {
  108863. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  108864. });
  108865. }
  108866. if (this._rampGradients) {
  108867. this._rampGradients.forEach(function (v) {
  108868. result.addRampGradient(v.gradient, v.color);
  108869. });
  108870. }
  108871. if (this._colorRemapGradients) {
  108872. this._colorRemapGradients.forEach(function (v) {
  108873. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  108874. });
  108875. }
  108876. if (this._alphaRemapGradients) {
  108877. this._alphaRemapGradients.forEach(function (v) {
  108878. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  108879. });
  108880. }
  108881. if (!this.preventAutoStart) {
  108882. result.start();
  108883. }
  108884. return result;
  108885. };
  108886. /**
  108887. * Serializes the particle system to a JSON object.
  108888. * @returns the JSON object
  108889. */
  108890. ParticleSystem.prototype.serialize = function () {
  108891. var serializationObject = {};
  108892. ParticleSystem._Serialize(serializationObject, this);
  108893. serializationObject.textureMask = this.textureMask.asArray();
  108894. serializationObject.customShader = this.customShader;
  108895. serializationObject.preventAutoStart = this.preventAutoStart;
  108896. // SubEmitters
  108897. if (this.subEmitters) {
  108898. serializationObject.subEmitters = [];
  108899. if (!this._subEmitters) {
  108900. this._prepareSubEmitterInternalArray();
  108901. }
  108902. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  108903. var subs = _a[_i];
  108904. var cell = [];
  108905. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  108906. var sub = subs_1[_b];
  108907. cell.push(sub.serialize());
  108908. }
  108909. serializationObject.subEmitters.push(cell);
  108910. }
  108911. }
  108912. return serializationObject;
  108913. };
  108914. /** @hidden */
  108915. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  108916. serializationObject.name = particleSystem.name;
  108917. serializationObject.id = particleSystem.id;
  108918. serializationObject.capacity = particleSystem.getCapacity();
  108919. // Emitter
  108920. if (particleSystem.emitter.position) {
  108921. var emitterMesh = particleSystem.emitter;
  108922. serializationObject.emitterId = emitterMesh.id;
  108923. }
  108924. else {
  108925. var emitterPosition = particleSystem.emitter;
  108926. serializationObject.emitter = emitterPosition.asArray();
  108927. }
  108928. // Emitter
  108929. if (particleSystem.particleEmitterType) {
  108930. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  108931. }
  108932. if (particleSystem.particleTexture) {
  108933. serializationObject.textureName = particleSystem.particleTexture.name;
  108934. serializationObject.invertY = particleSystem.particleTexture._invertY;
  108935. }
  108936. // Animations
  108937. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  108938. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  108939. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  108940. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  108941. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  108942. // Particle system
  108943. serializationObject.startDelay = particleSystem.startDelay;
  108944. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  108945. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  108946. serializationObject.billboardMode = particleSystem.billboardMode;
  108947. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  108948. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  108949. serializationObject.minSize = particleSystem.minSize;
  108950. serializationObject.maxSize = particleSystem.maxSize;
  108951. serializationObject.minScaleX = particleSystem.minScaleX;
  108952. serializationObject.maxScaleX = particleSystem.maxScaleX;
  108953. serializationObject.minScaleY = particleSystem.minScaleY;
  108954. serializationObject.maxScaleY = particleSystem.maxScaleY;
  108955. serializationObject.minEmitPower = particleSystem.minEmitPower;
  108956. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  108957. serializationObject.minLifeTime = particleSystem.minLifeTime;
  108958. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  108959. serializationObject.emitRate = particleSystem.emitRate;
  108960. serializationObject.gravity = particleSystem.gravity.asArray();
  108961. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  108962. serializationObject.color1 = particleSystem.color1.asArray();
  108963. serializationObject.color2 = particleSystem.color2.asArray();
  108964. serializationObject.colorDead = particleSystem.colorDead.asArray();
  108965. serializationObject.updateSpeed = particleSystem.updateSpeed;
  108966. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  108967. serializationObject.blendMode = particleSystem.blendMode;
  108968. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  108969. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  108970. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  108971. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  108972. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  108973. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  108974. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  108975. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  108976. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  108977. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  108978. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  108979. var colorGradients = particleSystem.getColorGradients();
  108980. if (colorGradients) {
  108981. serializationObject.colorGradients = [];
  108982. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  108983. var colorGradient = colorGradients_1[_i];
  108984. var serializedGradient = {
  108985. gradient: colorGradient.gradient,
  108986. color1: colorGradient.color1.asArray()
  108987. };
  108988. if (colorGradient.color2) {
  108989. serializedGradient.color2 = colorGradient.color2.asArray();
  108990. }
  108991. serializationObject.colorGradients.push(serializedGradient);
  108992. }
  108993. }
  108994. var rampGradients = particleSystem.getRampGradients();
  108995. if (rampGradients) {
  108996. serializationObject.rampGradients = [];
  108997. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  108998. var rampGradient = rampGradients_1[_a];
  108999. var serializedGradient = {
  109000. gradient: rampGradient.gradient,
  109001. color: rampGradient.color.asArray()
  109002. };
  109003. serializationObject.rampGradients.push(serializedGradient);
  109004. }
  109005. serializationObject.useRampGradients = particleSystem.useRampGradients;
  109006. }
  109007. var colorRemapGradients = particleSystem.getColorRemapGradients();
  109008. if (colorRemapGradients) {
  109009. serializationObject.colorRemapGradients = [];
  109010. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  109011. var colorRemapGradient = colorRemapGradients_1[_b];
  109012. var serializedGradient = {
  109013. gradient: colorRemapGradient.gradient,
  109014. factor1: colorRemapGradient.factor1
  109015. };
  109016. if (colorRemapGradient.factor2 !== undefined) {
  109017. serializedGradient.factor2 = colorRemapGradient.factor2;
  109018. }
  109019. serializationObject.colorRemapGradients.push(serializedGradient);
  109020. }
  109021. }
  109022. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  109023. if (alphaRemapGradients) {
  109024. serializationObject.alphaRemapGradients = [];
  109025. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  109026. var alphaRemapGradient = alphaRemapGradients_1[_c];
  109027. var serializedGradient = {
  109028. gradient: alphaRemapGradient.gradient,
  109029. factor1: alphaRemapGradient.factor1
  109030. };
  109031. if (alphaRemapGradient.factor2 !== undefined) {
  109032. serializedGradient.factor2 = alphaRemapGradient.factor2;
  109033. }
  109034. serializationObject.alphaRemapGradients.push(serializedGradient);
  109035. }
  109036. }
  109037. var sizeGradients = particleSystem.getSizeGradients();
  109038. if (sizeGradients) {
  109039. serializationObject.sizeGradients = [];
  109040. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  109041. var sizeGradient = sizeGradients_1[_d];
  109042. var serializedGradient = {
  109043. gradient: sizeGradient.gradient,
  109044. factor1: sizeGradient.factor1
  109045. };
  109046. if (sizeGradient.factor2 !== undefined) {
  109047. serializedGradient.factor2 = sizeGradient.factor2;
  109048. }
  109049. serializationObject.sizeGradients.push(serializedGradient);
  109050. }
  109051. }
  109052. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  109053. if (angularSpeedGradients) {
  109054. serializationObject.angularSpeedGradients = [];
  109055. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  109056. var angularSpeedGradient = angularSpeedGradients_1[_e];
  109057. var serializedGradient = {
  109058. gradient: angularSpeedGradient.gradient,
  109059. factor1: angularSpeedGradient.factor1
  109060. };
  109061. if (angularSpeedGradient.factor2 !== undefined) {
  109062. serializedGradient.factor2 = angularSpeedGradient.factor2;
  109063. }
  109064. serializationObject.angularSpeedGradients.push(serializedGradient);
  109065. }
  109066. }
  109067. var velocityGradients = particleSystem.getVelocityGradients();
  109068. if (velocityGradients) {
  109069. serializationObject.velocityGradients = [];
  109070. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  109071. var velocityGradient = velocityGradients_1[_f];
  109072. var serializedGradient = {
  109073. gradient: velocityGradient.gradient,
  109074. factor1: velocityGradient.factor1
  109075. };
  109076. if (velocityGradient.factor2 !== undefined) {
  109077. serializedGradient.factor2 = velocityGradient.factor2;
  109078. }
  109079. serializationObject.velocityGradients.push(serializedGradient);
  109080. }
  109081. }
  109082. var dragGradients = particleSystem.getDragGradients();
  109083. if (dragGradients) {
  109084. serializationObject.dragyGradients = [];
  109085. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  109086. var dragGradient = dragGradients_1[_g];
  109087. var serializedGradient = {
  109088. gradient: dragGradient.gradient,
  109089. factor1: dragGradient.factor1
  109090. };
  109091. if (dragGradient.factor2 !== undefined) {
  109092. serializedGradient.factor2 = dragGradient.factor2;
  109093. }
  109094. serializationObject.dragGradients.push(serializedGradient);
  109095. }
  109096. }
  109097. var emitRateGradients = particleSystem.getEmitRateGradients();
  109098. if (emitRateGradients) {
  109099. serializationObject.emitRateGradients = [];
  109100. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  109101. var emitRateGradient = emitRateGradients_1[_h];
  109102. var serializedGradient = {
  109103. gradient: emitRateGradient.gradient,
  109104. factor1: emitRateGradient.factor1
  109105. };
  109106. if (emitRateGradient.factor2 !== undefined) {
  109107. serializedGradient.factor2 = emitRateGradient.factor2;
  109108. }
  109109. serializationObject.emitRateGradients.push(serializedGradient);
  109110. }
  109111. }
  109112. var startSizeGradients = particleSystem.getStartSizeGradients();
  109113. if (startSizeGradients) {
  109114. serializationObject.startSizeGradients = [];
  109115. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  109116. var startSizeGradient = startSizeGradients_1[_j];
  109117. var serializedGradient = {
  109118. gradient: startSizeGradient.gradient,
  109119. factor1: startSizeGradient.factor1
  109120. };
  109121. if (startSizeGradient.factor2 !== undefined) {
  109122. serializedGradient.factor2 = startSizeGradient.factor2;
  109123. }
  109124. serializationObject.startSizeGradients.push(serializedGradient);
  109125. }
  109126. }
  109127. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  109128. if (lifeTimeGradients) {
  109129. serializationObject.lifeTimeGradients = [];
  109130. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  109131. var lifeTimeGradient = lifeTimeGradients_1[_k];
  109132. var serializedGradient = {
  109133. gradient: lifeTimeGradient.gradient,
  109134. factor1: lifeTimeGradient.factor1
  109135. };
  109136. if (lifeTimeGradient.factor2 !== undefined) {
  109137. serializedGradient.factor2 = lifeTimeGradient.factor2;
  109138. }
  109139. serializationObject.lifeTimeGradients.push(serializedGradient);
  109140. }
  109141. }
  109142. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  109143. if (limitVelocityGradients) {
  109144. serializationObject.limitVelocityGradients = [];
  109145. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  109146. var limitVelocityGradient = limitVelocityGradients_1[_l];
  109147. var serializedGradient = {
  109148. gradient: limitVelocityGradient.gradient,
  109149. factor1: limitVelocityGradient.factor1
  109150. };
  109151. if (limitVelocityGradient.factor2 !== undefined) {
  109152. serializedGradient.factor2 = limitVelocityGradient.factor2;
  109153. }
  109154. serializationObject.limitVelocityGradients.push(serializedGradient);
  109155. }
  109156. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  109157. }
  109158. if (particleSystem.noiseTexture) {
  109159. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  109160. }
  109161. };
  109162. /** @hidden */
  109163. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  109164. // Texture
  109165. if (parsedParticleSystem.textureName) {
  109166. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  109167. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  109168. }
  109169. // Emitter
  109170. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  109171. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109172. }
  109173. else if (parsedParticleSystem.emitterId) {
  109174. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  109175. }
  109176. else {
  109177. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  109178. }
  109179. // Misc.
  109180. if (parsedParticleSystem.renderingGroupId !== undefined) {
  109181. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  109182. }
  109183. if (parsedParticleSystem.isBillboardBased !== undefined) {
  109184. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  109185. }
  109186. if (parsedParticleSystem.billboardMode !== undefined) {
  109187. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  109188. }
  109189. // Animations
  109190. if (parsedParticleSystem.animations) {
  109191. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  109192. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  109193. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  109194. if (internalClass) {
  109195. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  109196. }
  109197. }
  109198. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  109199. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  109200. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  109201. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  109202. }
  109203. if (parsedParticleSystem.autoAnimate) {
  109204. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  109205. }
  109206. // Particle system
  109207. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  109208. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  109209. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  109210. particleSystem.minSize = parsedParticleSystem.minSize;
  109211. particleSystem.maxSize = parsedParticleSystem.maxSize;
  109212. if (parsedParticleSystem.minScaleX) {
  109213. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  109214. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  109215. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  109216. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  109217. }
  109218. if (parsedParticleSystem.preWarmCycles !== undefined) {
  109219. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  109220. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  109221. }
  109222. if (parsedParticleSystem.minInitialRotation !== undefined) {
  109223. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  109224. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  109225. }
  109226. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  109227. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  109228. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  109229. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  109230. particleSystem.emitRate = parsedParticleSystem.emitRate;
  109231. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  109232. if (parsedParticleSystem.noiseStrength) {
  109233. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  109234. }
  109235. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  109236. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  109237. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  109238. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  109239. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  109240. particleSystem.blendMode = parsedParticleSystem.blendMode;
  109241. if (parsedParticleSystem.colorGradients) {
  109242. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  109243. var colorGradient = _a[_i];
  109244. 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);
  109245. }
  109246. }
  109247. if (parsedParticleSystem.rampGradients) {
  109248. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  109249. var rampGradient = _c[_b];
  109250. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  109251. }
  109252. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  109253. }
  109254. if (parsedParticleSystem.colorRemapGradients) {
  109255. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  109256. var colorRemapGradient = _e[_d];
  109257. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  109258. }
  109259. }
  109260. if (parsedParticleSystem.alphaRemapGradients) {
  109261. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  109262. var alphaRemapGradient = _g[_f];
  109263. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  109264. }
  109265. }
  109266. if (parsedParticleSystem.sizeGradients) {
  109267. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  109268. var sizeGradient = _j[_h];
  109269. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  109270. }
  109271. }
  109272. if (parsedParticleSystem.sizeGradients) {
  109273. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  109274. var sizeGradient = _l[_k];
  109275. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  109276. }
  109277. }
  109278. if (parsedParticleSystem.angularSpeedGradients) {
  109279. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  109280. var angularSpeedGradient = _o[_m];
  109281. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  109282. }
  109283. }
  109284. if (parsedParticleSystem.velocityGradients) {
  109285. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  109286. var velocityGradient = _q[_p];
  109287. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  109288. }
  109289. }
  109290. if (parsedParticleSystem.dragGradients) {
  109291. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  109292. var dragGradient = _s[_r];
  109293. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  109294. }
  109295. }
  109296. if (parsedParticleSystem.emitRateGradients) {
  109297. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  109298. var emitRateGradient = _u[_t];
  109299. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  109300. }
  109301. }
  109302. if (parsedParticleSystem.startSizeGradients) {
  109303. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  109304. var startSizeGradient = _w[_v];
  109305. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  109306. }
  109307. }
  109308. if (parsedParticleSystem.lifeTimeGradients) {
  109309. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  109310. var lifeTimeGradient = _y[_x];
  109311. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  109312. }
  109313. }
  109314. if (parsedParticleSystem.limitVelocityGradients) {
  109315. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  109316. var limitVelocityGradient = _0[_z];
  109317. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  109318. }
  109319. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  109320. }
  109321. if (parsedParticleSystem.noiseTexture) {
  109322. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  109323. }
  109324. // Emitter
  109325. var emitterType;
  109326. if (parsedParticleSystem.particleEmitterType) {
  109327. switch (parsedParticleSystem.particleEmitterType.type) {
  109328. case "SphereParticleEmitter":
  109329. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  109330. break;
  109331. case "SphereDirectedParticleEmitter":
  109332. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  109333. break;
  109334. case "ConeEmitter":
  109335. case "ConeParticleEmitter":
  109336. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  109337. break;
  109338. case "CylinderParticleEmitter":
  109339. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  109340. break;
  109341. case "HemisphericParticleEmitter":
  109342. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  109343. break;
  109344. case "BoxEmitter":
  109345. case "BoxParticleEmitter":
  109346. default:
  109347. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  109348. break;
  109349. }
  109350. emitterType.parse(parsedParticleSystem.particleEmitterType);
  109351. }
  109352. else {
  109353. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  109354. emitterType.parse(parsedParticleSystem);
  109355. }
  109356. particleSystem.particleEmitterType = emitterType;
  109357. // Animation sheet
  109358. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  109359. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  109360. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  109361. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  109362. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  109363. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  109364. };
  109365. /**
  109366. * Parses a JSON object to create a particle system.
  109367. * @param parsedParticleSystem The JSON object to parse
  109368. * @param scene The scene to create the particle system in
  109369. * @param rootUrl The root url to use to load external dependencies like texture
  109370. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  109371. * @returns the Parsed particle system
  109372. */
  109373. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  109374. if (doNotStart === void 0) { doNotStart = false; }
  109375. var name = parsedParticleSystem.name;
  109376. var custom = null;
  109377. var program = null;
  109378. if (parsedParticleSystem.customShader) {
  109379. program = parsedParticleSystem.customShader;
  109380. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  109381. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  109382. }
  109383. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  109384. particleSystem.customShader = program;
  109385. if (parsedParticleSystem.id) {
  109386. particleSystem.id = parsedParticleSystem.id;
  109387. }
  109388. // SubEmitters
  109389. if (parsedParticleSystem.subEmitters) {
  109390. particleSystem.subEmitters = [];
  109391. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  109392. var cell = _a[_i];
  109393. var cellArray = [];
  109394. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  109395. var sub = cell_1[_b];
  109396. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  109397. }
  109398. particleSystem.subEmitters.push(cellArray);
  109399. }
  109400. }
  109401. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  109402. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  109403. // Auto start
  109404. if (parsedParticleSystem.preventAutoStart) {
  109405. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  109406. }
  109407. if (!doNotStart && !particleSystem.preventAutoStart) {
  109408. particleSystem.start();
  109409. }
  109410. return particleSystem;
  109411. };
  109412. /**
  109413. * Billboard mode will only apply to Y axis
  109414. */
  109415. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  109416. /**
  109417. * Billboard mode will apply to all axes
  109418. */
  109419. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  109420. /**
  109421. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  109422. */
  109423. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  109424. return ParticleSystem;
  109425. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  109426. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  109427. /***/ }),
  109428. /***/ "./Particles/particleSystemComponent.ts":
  109429. /*!**********************************************!*\
  109430. !*** ./Particles/particleSystemComponent.ts ***!
  109431. \**********************************************/
  109432. /*! exports provided: _IDoNeedToBeInTheBuild */
  109433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109434. "use strict";
  109435. __webpack_require__.r(__webpack_exports__);
  109436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  109437. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  109438. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  109439. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  109440. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  109441. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  109442. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  109443. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  109444. // Adds the parsers to the scene parsers.
  109445. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  109446. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  109447. if (!individualParser) {
  109448. return;
  109449. }
  109450. // Particles Systems
  109451. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  109452. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  109453. var parsedParticleSystem = parsedData.particleSystems[index];
  109454. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  109455. }
  109456. }
  109457. });
  109458. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  109459. if (parsedParticleSystem.activeParticleCount) {
  109460. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  109461. return ps;
  109462. }
  109463. else {
  109464. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  109465. return ps;
  109466. }
  109467. });
  109468. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  109469. if (uniformsNames === void 0) { uniformsNames = []; }
  109470. if (samplers === void 0) { samplers = []; }
  109471. if (defines === void 0) { defines = ""; }
  109472. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  109473. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  109474. if (defines.indexOf(" BILLBOARD") === -1) {
  109475. defines += "\n#define BILLBOARD\n";
  109476. }
  109477. if (samplers.indexOf("diffuseSampler") === -1) {
  109478. samplers.push("diffuseSampler");
  109479. }
  109480. return this.createEffect({
  109481. vertex: "particles",
  109482. fragmentElement: fragmentName
  109483. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  109484. };
  109485. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  109486. var results = new Array();
  109487. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  109488. var particleSystem = this.getScene().particleSystems[index];
  109489. if (particleSystem.emitter === this) {
  109490. results.push(particleSystem);
  109491. }
  109492. }
  109493. return results;
  109494. };
  109495. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  109496. var results = new Array();
  109497. var descendants = this.getDescendants();
  109498. descendants.push(this);
  109499. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  109500. var particleSystem = this.getScene().particleSystems[index];
  109501. var emitter = particleSystem.emitter;
  109502. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  109503. results.push(particleSystem);
  109504. }
  109505. }
  109506. return results;
  109507. };
  109508. /**
  109509. * @hidden
  109510. */
  109511. var _IDoNeedToBeInTheBuild = 42;
  109512. /***/ }),
  109513. /***/ "./Particles/particleSystemSet.ts":
  109514. /*!****************************************!*\
  109515. !*** ./Particles/particleSystemSet.ts ***!
  109516. \****************************************/
  109517. /*! exports provided: ParticleSystemSet */
  109518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109519. "use strict";
  109520. __webpack_require__.r(__webpack_exports__);
  109521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  109522. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109523. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  109524. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  109525. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  109526. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  109527. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  109528. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  109529. /** Internal class used to store shapes for emitters */
  109530. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  109531. function ParticleSystemSetEmitterCreationOptions() {
  109532. }
  109533. return ParticleSystemSetEmitterCreationOptions;
  109534. }());
  109535. /**
  109536. * Represents a set of particle systems working together to create a specific effect
  109537. */
  109538. var ParticleSystemSet = /** @class */ (function () {
  109539. function ParticleSystemSet() {
  109540. /**
  109541. * Gets the particle system list
  109542. */
  109543. this.systems = new Array();
  109544. }
  109545. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  109546. /**
  109547. * Gets the emitter node used with this set
  109548. */
  109549. get: function () {
  109550. return this._emitterNode;
  109551. },
  109552. enumerable: true,
  109553. configurable: true
  109554. });
  109555. /**
  109556. * Creates a new emitter mesh as a sphere
  109557. * @param options defines the options used to create the sphere
  109558. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  109559. * @param scene defines the hosting scene
  109560. */
  109561. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  109562. if (this._emitterNode) {
  109563. this._emitterNode.dispose();
  109564. }
  109565. this._emitterCreationOptions = {
  109566. kind: "Sphere",
  109567. options: options,
  109568. renderingGroupId: renderingGroupId
  109569. };
  109570. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  109571. emitterMesh.renderingGroupId = renderingGroupId;
  109572. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  109573. material.emissiveColor = options.color;
  109574. emitterMesh.material = material;
  109575. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  109576. var system = _a[_i];
  109577. system.emitter = emitterMesh;
  109578. }
  109579. this._emitterNode = emitterMesh;
  109580. };
  109581. /**
  109582. * Starts all particle systems of the set
  109583. * @param emitter defines an optional mesh to use as emitter for the particle systems
  109584. */
  109585. ParticleSystemSet.prototype.start = function (emitter) {
  109586. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  109587. var system = _a[_i];
  109588. if (emitter) {
  109589. system.emitter = emitter;
  109590. }
  109591. system.start();
  109592. }
  109593. };
  109594. /**
  109595. * Release all associated resources
  109596. */
  109597. ParticleSystemSet.prototype.dispose = function () {
  109598. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  109599. var system = _a[_i];
  109600. system.dispose();
  109601. }
  109602. this.systems = [];
  109603. if (this._emitterNode) {
  109604. this._emitterNode.dispose();
  109605. this._emitterNode = null;
  109606. }
  109607. };
  109608. /**
  109609. * Serialize the set into a JSON compatible object
  109610. * @returns a JSON compatible representation of the set
  109611. */
  109612. ParticleSystemSet.prototype.serialize = function () {
  109613. var result = {};
  109614. result.systems = [];
  109615. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  109616. var system = _a[_i];
  109617. result.systems.push(system.serialize());
  109618. }
  109619. if (this._emitterNode) {
  109620. result.emitter = this._emitterCreationOptions;
  109621. }
  109622. return result;
  109623. };
  109624. /**
  109625. * Parse a new ParticleSystemSet from a serialized source
  109626. * @param data defines a JSON compatible representation of the set
  109627. * @param scene defines the hosting scene
  109628. * @param gpu defines if we want GPU particles or CPU particles
  109629. * @returns a new ParticleSystemSet
  109630. */
  109631. ParticleSystemSet.Parse = function (data, scene, gpu) {
  109632. if (gpu === void 0) { gpu = false; }
  109633. var result = new ParticleSystemSet();
  109634. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  109635. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  109636. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  109637. var system = _a[_i];
  109638. 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));
  109639. }
  109640. if (data.emitter) {
  109641. var options = data.emitter.options;
  109642. switch (data.emitter.kind) {
  109643. case "Sphere":
  109644. result.setEmitterAsSphere({
  109645. diameter: options.diameter,
  109646. segments: options.segments,
  109647. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  109648. }, data.emitter.renderingGroupId, scene);
  109649. break;
  109650. }
  109651. }
  109652. return result;
  109653. };
  109654. return ParticleSystemSet;
  109655. }());
  109656. /***/ }),
  109657. /***/ "./Particles/solidParticle.ts":
  109658. /*!************************************!*\
  109659. !*** ./Particles/solidParticle.ts ***!
  109660. \************************************/
  109661. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  109662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109663. "use strict";
  109664. __webpack_require__.r(__webpack_exports__);
  109665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  109666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  109667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  109668. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109669. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  109670. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  109671. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  109672. /**
  109673. * Represents one particle of a solid particle system.
  109674. */
  109675. var SolidParticle = /** @class */ (function () {
  109676. /**
  109677. * Creates a Solid Particle object.
  109678. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  109679. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  109680. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  109681. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  109682. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  109683. * @param shapeId (integer) is the model shape identifier in the SPS.
  109684. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  109685. * @param sps defines the sps it is associated to
  109686. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  109687. */
  109688. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  109689. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  109690. /**
  109691. * particle global index
  109692. */
  109693. this.idx = 0;
  109694. /**
  109695. * The color of the particle
  109696. */
  109697. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  109698. /**
  109699. * The world space position of the particle.
  109700. */
  109701. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109702. /**
  109703. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  109704. */
  109705. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109706. /**
  109707. * The scaling of the particle.
  109708. */
  109709. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  109710. /**
  109711. * The uvs of the particle.
  109712. */
  109713. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  109714. /**
  109715. * The current speed of the particle.
  109716. */
  109717. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109718. /**
  109719. * The pivot point in the particle local space.
  109720. */
  109721. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109722. /**
  109723. * Must the particle be translated from its pivot point in its local space ?
  109724. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  109725. * Default : false
  109726. */
  109727. this.translateFromPivot = false;
  109728. /**
  109729. * Is the particle active or not ?
  109730. */
  109731. this.alive = true;
  109732. /**
  109733. * Is the particle visible or not ?
  109734. */
  109735. this.isVisible = true;
  109736. /**
  109737. * Index of this particle in the global "positions" array (Internal use)
  109738. * @hidden
  109739. */
  109740. this._pos = 0;
  109741. /**
  109742. * @hidden Index of this particle in the global "indices" array (Internal use)
  109743. */
  109744. this._ind = 0;
  109745. /**
  109746. * ModelShape id of this particle
  109747. */
  109748. this.shapeId = 0;
  109749. /**
  109750. * Index of the particle in its shape id (Internal use)
  109751. */
  109752. this.idxInShape = 0;
  109753. /**
  109754. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  109755. */
  109756. this._stillInvisible = false;
  109757. /**
  109758. * @hidden Last computed particle rotation matrix
  109759. */
  109760. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  109761. /**
  109762. * Parent particle Id, if any.
  109763. * Default null.
  109764. */
  109765. this.parentId = null;
  109766. /**
  109767. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  109768. * The possible values are :
  109769. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109770. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109771. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109772. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109773. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109774. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  109775. * */
  109776. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  109777. /**
  109778. * @hidden Internal global position in the SPS.
  109779. */
  109780. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109781. this.idx = particleIndex;
  109782. this._pos = positionIndex;
  109783. this._ind = indiceIndex;
  109784. this._model = model;
  109785. this.shapeId = shapeId;
  109786. this.idxInShape = idxInShape;
  109787. this._sps = sps;
  109788. if (modelBoundingInfo) {
  109789. this._modelBoundingInfo = modelBoundingInfo;
  109790. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  109791. }
  109792. }
  109793. Object.defineProperty(SolidParticle.prototype, "scale", {
  109794. /**
  109795. * Legacy support, changed scale to scaling
  109796. */
  109797. get: function () {
  109798. return this.scaling;
  109799. },
  109800. /**
  109801. * Legacy support, changed scale to scaling
  109802. */
  109803. set: function (scale) {
  109804. this.scaling = scale;
  109805. },
  109806. enumerable: true,
  109807. configurable: true
  109808. });
  109809. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  109810. /**
  109811. * Legacy support, changed quaternion to rotationQuaternion
  109812. */
  109813. get: function () {
  109814. return this.rotationQuaternion;
  109815. },
  109816. /**
  109817. * Legacy support, changed quaternion to rotationQuaternion
  109818. */
  109819. set: function (q) {
  109820. this.rotationQuaternion = q;
  109821. },
  109822. enumerable: true,
  109823. configurable: true
  109824. });
  109825. /**
  109826. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  109827. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  109828. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  109829. * @returns true if it intersects
  109830. */
  109831. SolidParticle.prototype.intersectsMesh = function (target) {
  109832. if (!this._boundingInfo || !target._boundingInfo) {
  109833. return false;
  109834. }
  109835. if (this._sps._bSphereOnly) {
  109836. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  109837. }
  109838. return this._boundingInfo.intersects(target._boundingInfo, false);
  109839. };
  109840. /**
  109841. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  109842. * A particle is in the frustum if its bounding box intersects the frustum
  109843. * @param frustumPlanes defines the frustum to test
  109844. * @returns true if the particle is in the frustum planes
  109845. */
  109846. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  109847. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  109848. };
  109849. /**
  109850. * get the rotation matrix of the particle
  109851. * @hidden
  109852. */
  109853. SolidParticle.prototype.getRotationMatrix = function (m) {
  109854. var quaternion;
  109855. if (this.rotationQuaternion) {
  109856. quaternion = this.rotationQuaternion;
  109857. }
  109858. else {
  109859. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  109860. var rotation = this.rotation;
  109861. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  109862. }
  109863. quaternion.toRotationMatrix(m);
  109864. };
  109865. return SolidParticle;
  109866. }());
  109867. /**
  109868. * Represents the shape of the model used by one particle of a solid particle system.
  109869. * SPS internal tool, don't use it manually.
  109870. */
  109871. var ModelShape = /** @class */ (function () {
  109872. /**
  109873. * 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.
  109874. * SPS internal tool, don't use it manually.
  109875. * @hidden
  109876. */
  109877. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  109878. /**
  109879. * length of the shape in the model indices array (internal use)
  109880. * @hidden
  109881. */
  109882. this._indicesLength = 0;
  109883. this.shapeID = id;
  109884. this._shape = shape;
  109885. this._indicesLength = indicesLength;
  109886. this._shapeUV = shapeUV;
  109887. this._positionFunction = posFunction;
  109888. this._vertexFunction = vtxFunction;
  109889. }
  109890. return ModelShape;
  109891. }());
  109892. /**
  109893. * Represents a Depth Sorted Particle in the solid particle system.
  109894. */
  109895. var DepthSortedParticle = /** @class */ (function () {
  109896. function DepthSortedParticle() {
  109897. /**
  109898. * Index of the particle in the "indices" array
  109899. */
  109900. this.ind = 0;
  109901. /**
  109902. * Length of the particle shape in the "indices" array
  109903. */
  109904. this.indicesLength = 0;
  109905. /**
  109906. * Squared distance from the particle to the camera
  109907. */
  109908. this.sqDistance = 0.0;
  109909. }
  109910. return DepthSortedParticle;
  109911. }());
  109912. /***/ }),
  109913. /***/ "./Particles/solidParticleSystem.ts":
  109914. /*!******************************************!*\
  109915. !*** ./Particles/solidParticleSystem.ts ***!
  109916. \******************************************/
  109917. /*! exports provided: SolidParticleSystem */
  109918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109919. "use strict";
  109920. __webpack_require__.r(__webpack_exports__);
  109921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  109922. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109923. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  109924. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  109925. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  109926. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  109927. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  109928. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  109929. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  109930. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  109931. /**
  109932. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109933. *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.
  109934. * The SPS is also a particle system. It provides some methods to manage the particles.
  109935. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109936. *
  109937. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  109938. */
  109939. var SolidParticleSystem = /** @class */ (function () {
  109940. /**
  109941. * Creates a SPS (Solid Particle System) object.
  109942. * @param name (String) is the SPS name, this will be the underlying mesh name.
  109943. * @param scene (Scene) is the scene in which the SPS is added.
  109944. * @param options defines the options of the sps e.g.
  109945. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  109946. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  109947. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  109948. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  109949. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  109950. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  109951. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  109952. */
  109953. function SolidParticleSystem(name, scene, options) {
  109954. /**
  109955. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109956. * Example : var p = SPS.particles[i];
  109957. */
  109958. this.particles = new Array();
  109959. /**
  109960. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109961. */
  109962. this.nbParticles = 0;
  109963. /**
  109964. * If the particles must ever face the camera (default false). Useful for planar particles.
  109965. */
  109966. this.billboard = false;
  109967. /**
  109968. * Recompute normals when adding a shape
  109969. */
  109970. this.recomputeNormals = true;
  109971. /**
  109972. * This a counter ofr your own usage. It's not set by any SPS functions.
  109973. */
  109974. this.counter = 0;
  109975. /**
  109976. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  109977. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  109978. */
  109979. this.vars = {};
  109980. /**
  109981. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  109982. * @hidden
  109983. */
  109984. this._bSphereOnly = false;
  109985. /**
  109986. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  109987. * @hidden
  109988. */
  109989. this._bSphereRadiusFactor = 1.0;
  109990. this._positions = new Array();
  109991. this._indices = new Array();
  109992. this._normals = new Array();
  109993. this._colors = new Array();
  109994. this._uvs = new Array();
  109995. this._index = 0; // indices index
  109996. this._updatable = true;
  109997. this._pickable = false;
  109998. this._isVisibilityBoxLocked = false;
  109999. this._alwaysVisible = false;
  110000. this._depthSort = false;
  110001. this._shapeCounter = 0;
  110002. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  110003. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  110004. this._computeParticleColor = true;
  110005. this._computeParticleTexture = true;
  110006. this._computeParticleRotation = true;
  110007. this._computeParticleVertex = false;
  110008. this._computeBoundingBox = false;
  110009. this._depthSortParticles = true;
  110010. this._mustUnrotateFixedNormals = false;
  110011. this._particlesIntersect = false;
  110012. this._needs32Bits = false;
  110013. this.name = name;
  110014. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  110015. this._camera = scene.activeCamera;
  110016. this._pickable = options ? options.isPickable : false;
  110017. this._depthSort = options ? options.enableDepthSort : false;
  110018. this._particlesIntersect = options ? options.particleIntersection : false;
  110019. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  110020. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  110021. if (options && options.updatable !== undefined) {
  110022. this._updatable = options.updatable;
  110023. }
  110024. else {
  110025. this._updatable = true;
  110026. }
  110027. if (this._pickable) {
  110028. this.pickedParticles = [];
  110029. }
  110030. if (this._depthSort) {
  110031. this.depthSortedParticles = [];
  110032. }
  110033. }
  110034. /**
  110035. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110036. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110037. * @returns the created mesh
  110038. */
  110039. SolidParticleSystem.prototype.buildMesh = function () {
  110040. if (this.nbParticles === 0) {
  110041. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  110042. this.addShape(triangle, 1);
  110043. triangle.dispose();
  110044. }
  110045. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  110046. this._positions32 = new Float32Array(this._positions);
  110047. this._uvs32 = new Float32Array(this._uvs);
  110048. this._colors32 = new Float32Array(this._colors);
  110049. if (this.recomputeNormals) {
  110050. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  110051. }
  110052. this._normals32 = new Float32Array(this._normals);
  110053. this._fixedNormal32 = new Float32Array(this._normals);
  110054. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  110055. this._unrotateFixedNormals();
  110056. }
  110057. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  110058. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  110059. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  110060. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  110061. if (this._uvs32.length > 0) {
  110062. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  110063. }
  110064. if (this._colors32.length > 0) {
  110065. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  110066. }
  110067. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  110068. vertexData.applyToMesh(mesh, this._updatable);
  110069. this.mesh = mesh;
  110070. this.mesh.isPickable = this._pickable;
  110071. // free memory
  110072. if (!this._depthSort) {
  110073. this._indices = null;
  110074. }
  110075. this._positions = null;
  110076. this._normals = null;
  110077. this._uvs = null;
  110078. this._colors = null;
  110079. if (!this._updatable) {
  110080. this.particles.length = 0;
  110081. }
  110082. return mesh;
  110083. };
  110084. /**
  110085. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110086. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110087. * Thus the particles generated from `digest()` have their property `position` set yet.
  110088. * @param mesh ( Mesh ) is the mesh to be digested
  110089. * @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
  110090. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110091. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110092. * @returns the current SPS
  110093. */
  110094. SolidParticleSystem.prototype.digest = function (mesh, options) {
  110095. var size = (options && options.facetNb) || 1;
  110096. var number = (options && options.number) || 0;
  110097. var delta = (options && options.delta) || 0;
  110098. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  110099. var meshInd = mesh.getIndices();
  110100. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  110101. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  110102. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  110103. var f = 0; // facet counter
  110104. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  110105. // compute size from number
  110106. if (number) {
  110107. number = (number > totalFacets) ? totalFacets : number;
  110108. size = Math.round(totalFacets / number);
  110109. delta = 0;
  110110. }
  110111. else {
  110112. size = (size > totalFacets) ? totalFacets : size;
  110113. }
  110114. var facetPos = []; // submesh positions
  110115. var facetInd = []; // submesh indices
  110116. var facetUV = []; // submesh UV
  110117. var facetCol = []; // submesh colors
  110118. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110119. var sizeO = size;
  110120. while (f < totalFacets) {
  110121. size = sizeO + Math.floor((1 + delta) * Math.random());
  110122. if (f > totalFacets - size) {
  110123. size = totalFacets - f;
  110124. }
  110125. // reset temp arrays
  110126. facetPos.length = 0;
  110127. facetInd.length = 0;
  110128. facetUV.length = 0;
  110129. facetCol.length = 0;
  110130. // iterate over "size" facets
  110131. var fi = 0;
  110132. for (var j = f * 3; j < (f + size) * 3; j++) {
  110133. facetInd.push(fi);
  110134. var i = meshInd[j];
  110135. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  110136. if (meshUV) {
  110137. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  110138. }
  110139. if (meshCol) {
  110140. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  110141. }
  110142. fi++;
  110143. }
  110144. // create a model shape for each single particle
  110145. var idx = this.nbParticles;
  110146. var shape = this._posToShape(facetPos);
  110147. var shapeUV = this._uvsToShapeUV(facetUV);
  110148. // compute the barycenter of the shape
  110149. var v;
  110150. for (v = 0; v < shape.length; v++) {
  110151. barycenter.addInPlace(shape[v]);
  110152. }
  110153. barycenter.scaleInPlace(1 / shape.length);
  110154. // shift the shape from its barycenter to the origin
  110155. for (v = 0; v < shape.length; v++) {
  110156. shape[v].subtractInPlace(barycenter);
  110157. }
  110158. var bInfo;
  110159. if (this._particlesIntersect) {
  110160. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  110161. }
  110162. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  110163. // add the particle in the SPS
  110164. var currentPos = this._positions.length;
  110165. var currentInd = this._indices.length;
  110166. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  110167. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  110168. // initialize the particle position
  110169. this.particles[this.nbParticles].position.addInPlace(barycenter);
  110170. this._index += shape.length;
  110171. idx++;
  110172. this.nbParticles++;
  110173. this._shapeCounter++;
  110174. f += size;
  110175. }
  110176. return this;
  110177. };
  110178. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  110179. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  110180. var index = 0;
  110181. var idx = 0;
  110182. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  110183. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  110184. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  110185. for (var p = 0; p < this.particles.length; p++) {
  110186. var particle = this.particles[p];
  110187. var shape = particle._model._shape;
  110188. // computing the inverse of the rotation matrix from the quaternion
  110189. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  110190. if (particle.rotationQuaternion) {
  110191. particle.rotationQuaternion.conjugateToRef(quaternion);
  110192. }
  110193. else {
  110194. var rotation = particle.rotation;
  110195. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  110196. quaternion.conjugateInPlace();
  110197. }
  110198. quaternion.toRotationMatrix(invertedRotMatrix);
  110199. for (var pt = 0; pt < shape.length; pt++) {
  110200. idx = index + pt * 3;
  110201. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  110202. tmpNormal.toArray(this._fixedNormal32, idx);
  110203. }
  110204. index = idx + 3;
  110205. }
  110206. };
  110207. //reset copy
  110208. SolidParticleSystem.prototype._resetCopy = function () {
  110209. var copy = this._copy;
  110210. copy.position.setAll(0);
  110211. copy.rotation.setAll(0);
  110212. copy.rotationQuaternion = null;
  110213. copy.scaling.setAll(1);
  110214. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  110215. copy.color = null;
  110216. copy.translateFromPivot = false;
  110217. };
  110218. // _meshBuilder : inserts the shape model in the global SPS mesh
  110219. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  110220. var i;
  110221. var u = 0;
  110222. var c = 0;
  110223. var n = 0;
  110224. this._resetCopy();
  110225. var copy = this._copy;
  110226. if (options && options.positionFunction) { // call to custom positionFunction
  110227. options.positionFunction(copy, idx, idxInShape);
  110228. this._mustUnrotateFixedNormals = true;
  110229. }
  110230. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  110231. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  110232. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  110233. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  110234. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  110235. copy.getRotationMatrix(rotMatrix);
  110236. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  110237. if (copy.translateFromPivot) {
  110238. pivotBackTranslation.setAll(0.0);
  110239. }
  110240. else {
  110241. pivotBackTranslation.copyFrom(scaledPivot);
  110242. }
  110243. for (i = 0; i < shape.length; i++) {
  110244. tmpVertex.copyFrom(shape[i]);
  110245. if (options && options.vertexFunction) {
  110246. options.vertexFunction(copy, tmpVertex, i);
  110247. }
  110248. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  110249. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  110250. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  110251. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  110252. if (meshUV) {
  110253. var copyUvs = copy.uvs;
  110254. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  110255. u += 2;
  110256. }
  110257. if (copy.color) {
  110258. this._color = copy.color;
  110259. }
  110260. else {
  110261. var color = this._color;
  110262. if (meshCol && meshCol[c] !== undefined) {
  110263. color.r = meshCol[c];
  110264. color.g = meshCol[c + 1];
  110265. color.b = meshCol[c + 2];
  110266. color.a = meshCol[c + 3];
  110267. }
  110268. else {
  110269. color.r = 1.0;
  110270. color.g = 1.0;
  110271. color.b = 1.0;
  110272. color.a = 1.0;
  110273. }
  110274. }
  110275. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  110276. c += 4;
  110277. if (!this.recomputeNormals && meshNor) {
  110278. tmpVertex.x = meshNor[n];
  110279. tmpVertex.y = meshNor[n + 1];
  110280. tmpVertex.z = meshNor[n + 2];
  110281. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  110282. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  110283. n += 3;
  110284. }
  110285. }
  110286. for (i = 0; i < meshInd.length; i++) {
  110287. var current_ind = p + meshInd[i];
  110288. indices.push(current_ind);
  110289. if (current_ind > 65535) {
  110290. this._needs32Bits = true;
  110291. }
  110292. }
  110293. if (this._pickable) {
  110294. var nbfaces = meshInd.length / 3;
  110295. for (i = 0; i < nbfaces; i++) {
  110296. this.pickedParticles.push({ idx: idx, faceId: i });
  110297. }
  110298. }
  110299. if (this._depthSort) {
  110300. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  110301. }
  110302. return copy;
  110303. };
  110304. // returns a shape array from positions array
  110305. SolidParticleSystem.prototype._posToShape = function (positions) {
  110306. var shape = [];
  110307. for (var i = 0; i < positions.length; i += 3) {
  110308. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  110309. }
  110310. return shape;
  110311. };
  110312. // returns a shapeUV array from a Vector4 uvs
  110313. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  110314. var shapeUV = [];
  110315. if (uvs) {
  110316. for (var i = 0; i < uvs.length; i++) {
  110317. shapeUV.push(uvs[i]);
  110318. }
  110319. }
  110320. return shapeUV;
  110321. };
  110322. // adds a new particle object in the particles array
  110323. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  110324. if (bInfo === void 0) { bInfo = null; }
  110325. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  110326. this.particles.push(sp);
  110327. return sp;
  110328. };
  110329. /**
  110330. * Adds some particles to the SPS from the model shape. Returns the shape id.
  110331. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  110332. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  110333. * @param nb (positive integer) the number of particles to be created from this model
  110334. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  110335. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  110336. * @returns the number of shapes in the system
  110337. */
  110338. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  110339. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  110340. var meshInd = mesh.getIndices();
  110341. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  110342. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  110343. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  110344. var bbInfo;
  110345. if (this._particlesIntersect) {
  110346. bbInfo = mesh.getBoundingInfo();
  110347. }
  110348. var shape = this._posToShape(meshPos);
  110349. var shapeUV = this._uvsToShapeUV(meshUV);
  110350. var posfunc = options ? options.positionFunction : null;
  110351. var vtxfunc = options ? options.vertexFunction : null;
  110352. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  110353. // particles
  110354. var sp;
  110355. var currentCopy;
  110356. var idx = this.nbParticles;
  110357. for (var i = 0; i < nb; i++) {
  110358. var currentPos = this._positions.length;
  110359. var currentInd = this._indices.length;
  110360. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  110361. if (this._updatable) {
  110362. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  110363. sp.position.copyFrom(currentCopy.position);
  110364. sp.rotation.copyFrom(currentCopy.rotation);
  110365. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  110366. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  110367. }
  110368. if (currentCopy.color && sp.color) {
  110369. sp.color.copyFrom(currentCopy.color);
  110370. }
  110371. sp.scaling.copyFrom(currentCopy.scaling);
  110372. sp.uvs.copyFrom(currentCopy.uvs);
  110373. }
  110374. this._index += shape.length;
  110375. idx++;
  110376. }
  110377. this.nbParticles += nb;
  110378. this._shapeCounter++;
  110379. return this._shapeCounter - 1;
  110380. };
  110381. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  110382. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  110383. this._resetCopy();
  110384. var copy = this._copy;
  110385. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  110386. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  110387. }
  110388. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  110389. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  110390. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  110391. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  110392. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  110393. copy.getRotationMatrix(rotMatrix);
  110394. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  110395. if (copy.translateFromPivot) {
  110396. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  110397. }
  110398. else {
  110399. pivotBackTranslation.copyFrom(scaledPivot);
  110400. }
  110401. var shape = particle._model._shape;
  110402. for (var pt = 0; pt < shape.length; pt++) {
  110403. tmpVertex.copyFrom(shape[pt]);
  110404. if (particle._model._vertexFunction) {
  110405. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  110406. }
  110407. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  110408. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  110409. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  110410. }
  110411. particle.position.setAll(0.0);
  110412. particle.rotation.setAll(0.0);
  110413. particle.rotationQuaternion = null;
  110414. particle.scaling.setAll(1.0);
  110415. particle.uvs.setAll(0.0);
  110416. particle.pivot.setAll(0.0);
  110417. particle.translateFromPivot = false;
  110418. particle.parentId = null;
  110419. };
  110420. /**
  110421. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  110422. * @returns the SPS.
  110423. */
  110424. SolidParticleSystem.prototype.rebuildMesh = function () {
  110425. for (var p = 0; p < this.particles.length; p++) {
  110426. this._rebuildParticle(this.particles[p]);
  110427. }
  110428. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  110429. return this;
  110430. };
  110431. /**
  110432. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  110433. * This method calls `updateParticle()` for each particle of the SPS.
  110434. * For an animated SPS, it is usually called within the render loop.
  110435. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  110436. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  110437. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  110438. * @returns the SPS.
  110439. */
  110440. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  110441. if (start === void 0) { start = 0; }
  110442. if (end === void 0) { end = this.nbParticles - 1; }
  110443. if (update === void 0) { update = true; }
  110444. if (!this._updatable) {
  110445. return this;
  110446. }
  110447. // custom beforeUpdate
  110448. this.beforeUpdateParticles(start, end, update);
  110449. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  110450. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  110451. var mesh = this.mesh;
  110452. var colors32 = this._colors32;
  110453. var positions32 = this._positions32;
  110454. var normals32 = this._normals32;
  110455. var uvs32 = this._uvs32;
  110456. var indices32 = this._indices32;
  110457. var indices = this._indices;
  110458. var fixedNormal32 = this._fixedNormal32;
  110459. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  110460. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  110461. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  110462. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  110463. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  110464. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  110465. var camInvertedPosition = tempVectors[10].setAll(0);
  110466. // cases when the World Matrix is to be computed first
  110467. if (this.billboard || this._depthSort) {
  110468. this.mesh.computeWorldMatrix(true);
  110469. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  110470. }
  110471. // if the particles will always face the camera
  110472. if (this.billboard) {
  110473. // compute the camera position and un-rotate it by the current mesh rotation
  110474. var tmpVertex = tempVectors[0];
  110475. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  110476. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  110477. camAxisZ.normalize();
  110478. // same for camera up vector extracted from the cam view matrix
  110479. var view = this._camera.getViewMatrix(true);
  110480. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  110481. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  110482. camAxisY.normalize();
  110483. camAxisX.normalize();
  110484. }
  110485. // if depthSort, compute the camera global position in the mesh local system
  110486. if (this._depthSort) {
  110487. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  110488. }
  110489. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  110490. var idx = 0; // current position index in the global array positions32
  110491. var index = 0; // position start index in the global array positions32 of the current particle
  110492. var colidx = 0; // current color index in the global array colors32
  110493. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  110494. var uvidx = 0; // current uv index in the global array uvs32
  110495. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  110496. var pt = 0; // current index in the particle model shape
  110497. if (this.mesh.isFacetDataEnabled) {
  110498. this._computeBoundingBox = true;
  110499. }
  110500. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  110501. if (this._computeBoundingBox) {
  110502. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  110503. var boundingInfo = this.mesh._boundingInfo;
  110504. if (boundingInfo) {
  110505. minimum.copyFrom(boundingInfo.minimum);
  110506. maximum.copyFrom(boundingInfo.maximum);
  110507. }
  110508. }
  110509. }
  110510. // particle loop
  110511. index = this.particles[start]._pos;
  110512. var vpos = (index / 3) | 0;
  110513. colorIndex = vpos * 4;
  110514. uvIndex = vpos * 2;
  110515. for (var p = start; p <= end; p++) {
  110516. var particle = this.particles[p];
  110517. // call to custom user function to update the particle properties
  110518. this.updateParticle(particle);
  110519. var shape = particle._model._shape;
  110520. var shapeUV = particle._model._shapeUV;
  110521. var particleRotationMatrix = particle._rotationMatrix;
  110522. var particlePosition = particle.position;
  110523. var particleRotation = particle.rotation;
  110524. var particleScaling = particle.scaling;
  110525. var particleGlobalPosition = particle._globalPosition;
  110526. // camera-particle distance for depth sorting
  110527. if (this._depthSort && this._depthSortParticles) {
  110528. var dsp = this.depthSortedParticles[p];
  110529. dsp.ind = particle._ind;
  110530. dsp.indicesLength = particle._model._indicesLength;
  110531. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  110532. }
  110533. // skip the computations for inactive or already invisible particles
  110534. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  110535. // increment indexes for the next particle
  110536. pt = shape.length;
  110537. index += pt * 3;
  110538. colorIndex += pt * 4;
  110539. uvIndex += pt * 2;
  110540. continue;
  110541. }
  110542. if (particle.isVisible) {
  110543. particle._stillInvisible = false; // un-mark permanent invisibility
  110544. var scaledPivot = tempVectors[12];
  110545. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  110546. // particle rotation matrix
  110547. if (this.billboard) {
  110548. particleRotation.x = 0.0;
  110549. particleRotation.y = 0.0;
  110550. }
  110551. if (this._computeParticleRotation || this.billboard) {
  110552. particle.getRotationMatrix(rotMatrix);
  110553. }
  110554. var particleHasParent = (particle.parentId !== null);
  110555. if (particleHasParent) {
  110556. var parent_1 = this.particles[particle.parentId];
  110557. var parentRotationMatrix = parent_1._rotationMatrix;
  110558. var parentGlobalPosition = parent_1._globalPosition;
  110559. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  110560. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  110561. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  110562. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  110563. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  110564. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  110565. if (this._computeParticleRotation || this.billboard) {
  110566. var rotMatrixValues = rotMatrix.m;
  110567. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  110568. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  110569. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  110570. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  110571. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  110572. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  110573. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  110574. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  110575. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  110576. }
  110577. }
  110578. else {
  110579. particleGlobalPosition.x = particlePosition.x;
  110580. particleGlobalPosition.y = particlePosition.y;
  110581. particleGlobalPosition.z = particlePosition.z;
  110582. if (this._computeParticleRotation || this.billboard) {
  110583. var rotMatrixValues = rotMatrix.m;
  110584. particleRotationMatrix[0] = rotMatrixValues[0];
  110585. particleRotationMatrix[1] = rotMatrixValues[1];
  110586. particleRotationMatrix[2] = rotMatrixValues[2];
  110587. particleRotationMatrix[3] = rotMatrixValues[4];
  110588. particleRotationMatrix[4] = rotMatrixValues[5];
  110589. particleRotationMatrix[5] = rotMatrixValues[6];
  110590. particleRotationMatrix[6] = rotMatrixValues[8];
  110591. particleRotationMatrix[7] = rotMatrixValues[9];
  110592. particleRotationMatrix[8] = rotMatrixValues[10];
  110593. }
  110594. }
  110595. var pivotBackTranslation = tempVectors[11];
  110596. if (particle.translateFromPivot) {
  110597. pivotBackTranslation.setAll(0.0);
  110598. }
  110599. else {
  110600. pivotBackTranslation.copyFrom(scaledPivot);
  110601. }
  110602. // particle vertex loop
  110603. for (pt = 0; pt < shape.length; pt++) {
  110604. idx = index + pt * 3;
  110605. colidx = colorIndex + pt * 4;
  110606. uvidx = uvIndex + pt * 2;
  110607. var tmpVertex = tempVectors[0];
  110608. tmpVertex.copyFrom(shape[pt]);
  110609. if (this._computeParticleVertex) {
  110610. this.updateParticleVertex(particle, tmpVertex, pt);
  110611. }
  110612. // positions
  110613. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  110614. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  110615. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  110616. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  110617. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  110618. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  110619. rotatedX += pivotBackTranslation.x;
  110620. rotatedY += pivotBackTranslation.y;
  110621. rotatedZ += pivotBackTranslation.z;
  110622. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  110623. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  110624. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  110625. if (this._computeBoundingBox) {
  110626. minimum.minimizeInPlaceFromFloats(px, py, pz);
  110627. maximum.maximizeInPlaceFromFloats(px, py, pz);
  110628. }
  110629. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  110630. if (!this._computeParticleVertex) {
  110631. var normalx = fixedNormal32[idx];
  110632. var normaly = fixedNormal32[idx + 1];
  110633. var normalz = fixedNormal32[idx + 2];
  110634. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  110635. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  110636. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  110637. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  110638. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  110639. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  110640. }
  110641. if (this._computeParticleColor && particle.color) {
  110642. var color = particle.color;
  110643. var colors32_1 = this._colors32;
  110644. colors32_1[colidx] = color.r;
  110645. colors32_1[colidx + 1] = color.g;
  110646. colors32_1[colidx + 2] = color.b;
  110647. colors32_1[colidx + 3] = color.a;
  110648. }
  110649. if (this._computeParticleTexture) {
  110650. var uvs = particle.uvs;
  110651. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  110652. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  110653. }
  110654. }
  110655. }
  110656. // particle just set invisible : scaled to zero and positioned at the origin
  110657. else {
  110658. particle._stillInvisible = true; // mark the particle as invisible
  110659. for (pt = 0; pt < shape.length; pt++) {
  110660. idx = index + pt * 3;
  110661. colidx = colorIndex + pt * 4;
  110662. uvidx = uvIndex + pt * 2;
  110663. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  110664. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  110665. if (this._computeParticleColor && particle.color) {
  110666. var color = particle.color;
  110667. colors32[colidx] = color.r;
  110668. colors32[colidx + 1] = color.g;
  110669. colors32[colidx + 2] = color.b;
  110670. colors32[colidx + 3] = color.a;
  110671. }
  110672. if (this._computeParticleTexture) {
  110673. var uvs = particle.uvs;
  110674. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  110675. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  110676. }
  110677. }
  110678. }
  110679. // if the particle intersections must be computed : update the bbInfo
  110680. if (this._particlesIntersect) {
  110681. var bInfo = particle._boundingInfo;
  110682. var bBox = bInfo.boundingBox;
  110683. var bSphere = bInfo.boundingSphere;
  110684. var modelBoundingInfo = particle._modelBoundingInfo;
  110685. if (!this._bSphereOnly) {
  110686. // place, scale and rotate the particle bbox within the SPS local system, then update it
  110687. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  110688. var tempMin = tempVectors[1];
  110689. var tempMax = tempVectors[2];
  110690. tempMin.setAll(Number.MAX_VALUE);
  110691. tempMax.setAll(-Number.MAX_VALUE);
  110692. for (var b = 0; b < 8; b++) {
  110693. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  110694. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  110695. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  110696. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  110697. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  110698. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  110699. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  110700. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  110701. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  110702. tempMin.minimizeInPlaceFromFloats(x, y, z);
  110703. tempMax.maximizeInPlaceFromFloats(x, y, z);
  110704. }
  110705. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  110706. }
  110707. // place and scale the particle bouding sphere in the SPS local system, then update it
  110708. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  110709. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  110710. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  110711. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  110712. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  110713. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  110714. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  110715. }
  110716. // increment indexes for the next particle
  110717. index = idx + 3;
  110718. colorIndex = colidx + 4;
  110719. uvIndex = uvidx + 2;
  110720. }
  110721. // if the VBO must be updated
  110722. if (update) {
  110723. if (this._computeParticleColor) {
  110724. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  110725. }
  110726. if (this._computeParticleTexture) {
  110727. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  110728. }
  110729. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  110730. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  110731. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  110732. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  110733. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  110734. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  110735. for (var i = 0; i < normals32.length; i++) {
  110736. fixedNormal32[i] = normals32[i];
  110737. }
  110738. }
  110739. if (!mesh.areNormalsFrozen) {
  110740. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  110741. }
  110742. }
  110743. if (this._depthSort && this._depthSortParticles) {
  110744. var depthSortedParticles = this.depthSortedParticles;
  110745. depthSortedParticles.sort(depthSortFunction);
  110746. var dspl = depthSortedParticles.length;
  110747. var sid = 0;
  110748. for (var sorted = 0; sorted < dspl; sorted++) {
  110749. var lind = depthSortedParticles[sorted].indicesLength;
  110750. var sind = depthSortedParticles[sorted].ind;
  110751. for (var i = 0; i < lind; i++) {
  110752. indices32[sid] = indices[sind + i];
  110753. sid++;
  110754. }
  110755. }
  110756. mesh.updateIndices(indices32);
  110757. }
  110758. }
  110759. if (this._computeBoundingBox) {
  110760. if (mesh._boundingInfo) {
  110761. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  110762. }
  110763. else {
  110764. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  110765. }
  110766. }
  110767. this.afterUpdateParticles(start, end, update);
  110768. return this;
  110769. };
  110770. /**
  110771. * Disposes the SPS.
  110772. */
  110773. SolidParticleSystem.prototype.dispose = function () {
  110774. this.mesh.dispose();
  110775. this.vars = null;
  110776. // drop references to internal big arrays for the GC
  110777. this._positions = null;
  110778. this._indices = null;
  110779. this._normals = null;
  110780. this._uvs = null;
  110781. this._colors = null;
  110782. this._indices32 = null;
  110783. this._positions32 = null;
  110784. this._normals32 = null;
  110785. this._fixedNormal32 = null;
  110786. this._uvs32 = null;
  110787. this._colors32 = null;
  110788. this.pickedParticles = null;
  110789. };
  110790. /**
  110791. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110792. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110793. * @returns the SPS.
  110794. */
  110795. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  110796. if (!this._isVisibilityBoxLocked) {
  110797. this.mesh.refreshBoundingInfo();
  110798. }
  110799. return this;
  110800. };
  110801. /**
  110802. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110803. * @param size the size (float) of the visibility box
  110804. * note : this doesn't lock the SPS mesh bounding box.
  110805. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110806. */
  110807. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  110808. var vis = size / 2;
  110809. 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));
  110810. };
  110811. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  110812. /**
  110813. * Gets whether the SPS as always visible or not
  110814. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110815. */
  110816. get: function () {
  110817. return this._alwaysVisible;
  110818. },
  110819. /**
  110820. * Sets the SPS as always visible or not
  110821. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110822. */
  110823. set: function (val) {
  110824. this._alwaysVisible = val;
  110825. this.mesh.alwaysSelectAsActiveMesh = val;
  110826. },
  110827. enumerable: true,
  110828. configurable: true
  110829. });
  110830. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  110831. /**
  110832. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110833. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110834. */
  110835. get: function () {
  110836. return this._isVisibilityBoxLocked;
  110837. },
  110838. /**
  110839. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110840. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110841. */
  110842. set: function (val) {
  110843. this._isVisibilityBoxLocked = val;
  110844. var boundingInfo = this.mesh.getBoundingInfo();
  110845. boundingInfo.isLocked = val;
  110846. },
  110847. enumerable: true,
  110848. configurable: true
  110849. });
  110850. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  110851. /**
  110852. * Gets if `setParticles()` computes the particle rotations or not.
  110853. * Default value : true. The SPS is faster when it's set to false.
  110854. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110855. */
  110856. get: function () {
  110857. return this._computeParticleRotation;
  110858. },
  110859. /**
  110860. * Tells to `setParticles()` to compute the particle rotations or not.
  110861. * Default value : true. The SPS is faster when it's set to false.
  110862. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110863. */
  110864. set: function (val) {
  110865. this._computeParticleRotation = val;
  110866. },
  110867. enumerable: true,
  110868. configurable: true
  110869. });
  110870. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  110871. /**
  110872. * Gets if `setParticles()` computes the particle colors or not.
  110873. * Default value : true. The SPS is faster when it's set to false.
  110874. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110875. */
  110876. get: function () {
  110877. return this._computeParticleColor;
  110878. },
  110879. /**
  110880. * Tells to `setParticles()` to compute the particle colors or not.
  110881. * Default value : true. The SPS is faster when it's set to false.
  110882. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110883. */
  110884. set: function (val) {
  110885. this._computeParticleColor = val;
  110886. },
  110887. enumerable: true,
  110888. configurable: true
  110889. });
  110890. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  110891. /**
  110892. * Gets if `setParticles()` computes the particle textures or not.
  110893. * Default value : true. The SPS is faster when it's set to false.
  110894. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110895. */
  110896. get: function () {
  110897. return this._computeParticleTexture;
  110898. },
  110899. set: function (val) {
  110900. this._computeParticleTexture = val;
  110901. },
  110902. enumerable: true,
  110903. configurable: true
  110904. });
  110905. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  110906. /**
  110907. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110908. * Default value : false. The SPS is faster when it's set to false.
  110909. * Note : the particle custom vertex positions aren't stored values.
  110910. */
  110911. get: function () {
  110912. return this._computeParticleVertex;
  110913. },
  110914. /**
  110915. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110916. * Default value : false. The SPS is faster when it's set to false.
  110917. * Note : the particle custom vertex positions aren't stored values.
  110918. */
  110919. set: function (val) {
  110920. this._computeParticleVertex = val;
  110921. },
  110922. enumerable: true,
  110923. configurable: true
  110924. });
  110925. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  110926. /**
  110927. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110928. */
  110929. get: function () {
  110930. return this._computeBoundingBox;
  110931. },
  110932. /**
  110933. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110934. */
  110935. set: function (val) {
  110936. this._computeBoundingBox = val;
  110937. },
  110938. enumerable: true,
  110939. configurable: true
  110940. });
  110941. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  110942. /**
  110943. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110944. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110945. * Default : `true`
  110946. */
  110947. get: function () {
  110948. return this._depthSortParticles;
  110949. },
  110950. /**
  110951. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110952. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110953. * Default : `true`
  110954. */
  110955. set: function (val) {
  110956. this._depthSortParticles = val;
  110957. },
  110958. enumerable: true,
  110959. configurable: true
  110960. });
  110961. // =======================================================================
  110962. // Particle behavior logic
  110963. // these following methods may be overwritten by the user to fit his needs
  110964. /**
  110965. * This function does nothing. It may be overwritten to set all the particle first values.
  110966. * The SPS doesn't call this function, you may have to call it by your own.
  110967. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  110968. */
  110969. SolidParticleSystem.prototype.initParticles = function () {
  110970. };
  110971. /**
  110972. * This function does nothing. It may be overwritten to recycle a particle.
  110973. * The SPS doesn't call this function, you may have to call it by your own.
  110974. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  110975. * @param particle The particle to recycle
  110976. * @returns the recycled particle
  110977. */
  110978. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  110979. return particle;
  110980. };
  110981. /**
  110982. * Updates a particle : this function should be overwritten by the user.
  110983. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110984. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  110985. * @example : just set a particle position or velocity and recycle conditions
  110986. * @param particle The particle to update
  110987. * @returns the updated particle
  110988. */
  110989. SolidParticleSystem.prototype.updateParticle = function (particle) {
  110990. return particle;
  110991. };
  110992. /**
  110993. * Updates a vertex of a particle : it can be overwritten by the user.
  110994. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110995. * @param particle the current particle
  110996. * @param vertex the current index of the current particle
  110997. * @param pt the index of the current vertex in the particle shape
  110998. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  110999. * @example : just set a vertex particle position
  111000. * @returns the updated vertex
  111001. */
  111002. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  111003. return vertex;
  111004. };
  111005. /**
  111006. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111007. * This does nothing and may be overwritten by the user.
  111008. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111009. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111010. * @param update the boolean update value actually passed to setParticles()
  111011. */
  111012. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  111013. };
  111014. /**
  111015. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111016. * This will be passed three parameters.
  111017. * This does nothing and may be overwritten by the user.
  111018. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111019. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111020. * @param update the boolean update value actually passed to setParticles()
  111021. */
  111022. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  111023. };
  111024. return SolidParticleSystem;
  111025. }());
  111026. /***/ }),
  111027. /***/ "./Particles/subEmitter.ts":
  111028. /*!*********************************!*\
  111029. !*** ./Particles/subEmitter.ts ***!
  111030. \*********************************/
  111031. /*! exports provided: SubEmitterType, SubEmitter */
  111032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111033. "use strict";
  111034. __webpack_require__.r(__webpack_exports__);
  111035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  111036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  111037. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111038. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111039. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  111040. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  111041. /**
  111042. * Type of sub emitter
  111043. */
  111044. var SubEmitterType;
  111045. (function (SubEmitterType) {
  111046. /**
  111047. * Attached to the particle over it's lifetime
  111048. */
  111049. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  111050. /**
  111051. * Created when the particle dies
  111052. */
  111053. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  111054. })(SubEmitterType || (SubEmitterType = {}));
  111055. /**
  111056. * Sub emitter class used to emit particles from an existing particle
  111057. */
  111058. var SubEmitter = /** @class */ (function () {
  111059. /**
  111060. * Creates a sub emitter
  111061. * @param particleSystem the particle system to be used by the sub emitter
  111062. */
  111063. function SubEmitter(
  111064. /**
  111065. * the particle system to be used by the sub emitter
  111066. */
  111067. particleSystem) {
  111068. this.particleSystem = particleSystem;
  111069. /**
  111070. * Type of the submitter (Default: END)
  111071. */
  111072. this.type = SubEmitterType.END;
  111073. /**
  111074. * 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)
  111075. * Note: This only is supported when using an emitter of type Mesh
  111076. */
  111077. this.inheritDirection = false;
  111078. /**
  111079. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  111080. */
  111081. this.inheritedVelocityAmount = 0;
  111082. // Create mesh as emitter to support rotation
  111083. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  111084. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  111085. }
  111086. // Automatically dispose of subemitter when system is disposed
  111087. particleSystem.onDisposeObservable.add(function () {
  111088. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  111089. particleSystem.emitter.dispose();
  111090. }
  111091. });
  111092. }
  111093. /**
  111094. * Clones the sub emitter
  111095. * @returns the cloned sub emitter
  111096. */
  111097. SubEmitter.prototype.clone = function () {
  111098. // Clone particle system
  111099. var emitter = this.particleSystem.emitter;
  111100. if (!emitter) {
  111101. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  111102. }
  111103. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  111104. emitter = emitter.clone();
  111105. }
  111106. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  111107. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  111108. emitter.isVisible = false;
  111109. }
  111110. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  111111. // Clone properties
  111112. clone.type = this.type;
  111113. clone.inheritDirection = this.inheritDirection;
  111114. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  111115. clone.particleSystem._disposeEmitterOnDispose = true;
  111116. clone.particleSystem.disposeOnStop = true;
  111117. return clone;
  111118. };
  111119. /**
  111120. * Serialize current object to a JSON object
  111121. * @returns the serialized object
  111122. */
  111123. SubEmitter.prototype.serialize = function () {
  111124. var serializationObject = {};
  111125. serializationObject.type = this.type;
  111126. serializationObject.inheritDirection = this.inheritDirection;
  111127. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  111128. serializationObject.particleSystem = this.particleSystem.serialize();
  111129. return serializationObject;
  111130. };
  111131. /** @hidden */
  111132. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  111133. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  111134. };
  111135. /**
  111136. * Creates a new SubEmitter from a serialized JSON version
  111137. * @param serializationObject defines the JSON object to read from
  111138. * @param scene defines the hosting scene
  111139. * @param rootUrl defines the rootUrl for data loading
  111140. * @returns a new SubEmitter
  111141. */
  111142. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  111143. var system = serializationObject.particleSystem;
  111144. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  111145. subEmitter.type = serializationObject.type;
  111146. subEmitter.inheritDirection = serializationObject.inheritDirection;
  111147. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  111148. subEmitter.particleSystem._isSubEmitter = true;
  111149. return subEmitter;
  111150. };
  111151. /** Release associated resources */
  111152. SubEmitter.prototype.dispose = function () {
  111153. this.particleSystem.dispose();
  111154. };
  111155. return SubEmitter;
  111156. }());
  111157. /***/ }),
  111158. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  111159. /*!*****************************************!*\
  111160. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  111161. \*****************************************/
  111162. /*! exports provided: AmmoJSPlugin */
  111163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111164. "use strict";
  111165. __webpack_require__.r(__webpack_exports__);
  111166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  111167. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  111168. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  111169. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  111170. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  111171. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  111172. /**
  111173. * AmmoJS Physics plugin
  111174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111175. * @see https://github.com/kripken/ammo.js/
  111176. */
  111177. var AmmoJSPlugin = /** @class */ (function () {
  111178. /**
  111179. * Initializes the ammoJS plugin
  111180. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111181. * @param ammoInjection can be used to inject your own ammo reference
  111182. */
  111183. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  111184. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  111185. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  111186. var _this = this;
  111187. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  111188. /**
  111189. * Reference to the Ammo library
  111190. */
  111191. this.bjsAMMO = {};
  111192. /**
  111193. * Name of the plugin
  111194. */
  111195. this.name = "AmmoJSPlugin";
  111196. this._timeStep = 1 / 60;
  111197. this._fixedTimeStep = 1 / 60;
  111198. this._maxSteps = 5;
  111199. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  111200. this._tmpContactCallbackResult = false;
  111201. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  111202. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  111203. if (typeof ammoInjection === "function") {
  111204. ammoInjection(this.bjsAMMO);
  111205. }
  111206. else {
  111207. this.bjsAMMO = ammoInjection;
  111208. }
  111209. if (!this.isSupported()) {
  111210. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  111211. return;
  111212. }
  111213. // Initialize the physics world
  111214. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  111215. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  111216. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  111217. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  111218. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  111219. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  111220. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  111221. // Create temp ammo variables
  111222. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  111223. this._tmpAmmoTransform.setIdentity();
  111224. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  111225. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  111226. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  111227. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  111228. }
  111229. /**
  111230. * Sets the gravity of the physics world (m/(s^2))
  111231. * @param gravity Gravity to set
  111232. */
  111233. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  111234. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  111235. this.world.setGravity(this._tmpAmmoVectorA);
  111236. };
  111237. /**
  111238. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111239. * @param timeStep timestep to use in seconds
  111240. */
  111241. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  111242. this._timeStep = timeStep;
  111243. };
  111244. /**
  111245. * 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)
  111246. * @param fixedTimeStep fixedTimeStep to use in seconds
  111247. */
  111248. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  111249. this._fixedTimeStep = fixedTimeStep;
  111250. };
  111251. /**
  111252. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111253. * @param maxSteps the maximum number of steps by the physics engine per frame
  111254. */
  111255. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  111256. this._maxSteps = maxSteps;
  111257. };
  111258. /**
  111259. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111260. * @returns the current timestep in seconds
  111261. */
  111262. AmmoJSPlugin.prototype.getTimeStep = function () {
  111263. return this._timeStep;
  111264. };
  111265. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  111266. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  111267. this._tmpContactCallbackResult = false;
  111268. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  111269. return this._tmpContactCallbackResult;
  111270. };
  111271. // Ammo's collision events have some weird quirks
  111272. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  111273. // so only fire event if both contactTest and contactPairTest have a hit
  111274. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  111275. this._tmpContactCallbackResult = false;
  111276. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  111277. return this._tmpContactCallbackResult;
  111278. };
  111279. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  111280. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  111281. //
  111282. // When maxSteps is 0 do the entire simulation in one step
  111283. // 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)
  111284. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  111285. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  111286. if (timeStep === void 0) { timeStep = 1 / 60; }
  111287. if (maxSteps === void 0) { maxSteps = 10; }
  111288. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  111289. if (maxSteps == 0) {
  111290. this.world.stepSimulation(timeStep, 0);
  111291. }
  111292. else {
  111293. while (maxSteps > 0 && timeStep > 0) {
  111294. if (timeStep - fixedTimeStep < fixedTimeStep) {
  111295. this.world.stepSimulation(timeStep, 0);
  111296. timeStep = 0;
  111297. }
  111298. else {
  111299. timeStep -= fixedTimeStep;
  111300. this.world.stepSimulation(fixedTimeStep, 0);
  111301. }
  111302. maxSteps--;
  111303. }
  111304. }
  111305. };
  111306. /**
  111307. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  111308. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  111309. * After the step the babylon meshes are set to the position of the physics imposters
  111310. * @param delta amount of time to step forward
  111311. * @param impostors array of imposters to update before/after the step
  111312. */
  111313. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  111314. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  111315. var impostor = impostors_1[_i];
  111316. // Update physics world objects to match babylon world
  111317. impostor.beforeStep();
  111318. }
  111319. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  111320. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  111321. var mainImpostor = impostors_2[_a];
  111322. // After physics update make babylon world objects match physics world objects
  111323. mainImpostor.afterStep();
  111324. // Handle collision event
  111325. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  111326. if (this._isImpostorInContact(mainImpostor)) {
  111327. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  111328. var collideCallback = _c[_b];
  111329. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  111330. var otherImpostor = _e[_d];
  111331. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  111332. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  111333. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  111334. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  111335. }
  111336. }
  111337. }
  111338. }
  111339. }
  111340. }
  111341. }
  111342. };
  111343. /**
  111344. * Applies an implulse on the imposter
  111345. * @param impostor imposter to apply impulse
  111346. * @param force amount of force to be applied to the imposter
  111347. * @param contactPoint the location to apply the impulse on the imposter
  111348. */
  111349. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  111350. impostor.physicsBody.activate();
  111351. var worldPoint = this._tmpAmmoVectorA;
  111352. var impulse = this._tmpAmmoVectorB;
  111353. // Convert contactPoint into world space
  111354. if (impostor.object && impostor.object.getWorldMatrix) {
  111355. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  111356. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  111357. contactPoint = this._tmpVector;
  111358. }
  111359. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  111360. impulse.setValue(force.x, force.y, force.z);
  111361. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  111362. };
  111363. /**
  111364. * Applies a force on the imposter
  111365. * @param impostor imposter to apply force
  111366. * @param force amount of force to be applied to the imposter
  111367. * @param contactPoint the location to apply the force on the imposter
  111368. */
  111369. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  111370. impostor.physicsBody.activate();
  111371. var worldPoint = this._tmpAmmoVectorA;
  111372. var impulse = this._tmpAmmoVectorB;
  111373. // Convert contactPoint into world space
  111374. if (impostor.object && impostor.object.getWorldMatrix) {
  111375. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  111376. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  111377. contactPoint = this._tmpVector;
  111378. }
  111379. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  111380. impulse.setValue(force.x, force.y, force.z);
  111381. impostor.physicsBody.applyForce(impulse, worldPoint);
  111382. };
  111383. /**
  111384. * Creates a physics body using the plugin
  111385. * @param impostor the imposter to create the physics body on
  111386. */
  111387. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  111388. impostor._pluginData = { toDispose: [] };
  111389. //parent-child relationship
  111390. if (impostor.parent) {
  111391. if (impostor.physicsBody) {
  111392. this.removePhysicsBody(impostor);
  111393. impostor.forceUpdate();
  111394. }
  111395. return;
  111396. }
  111397. if (impostor.isBodyInitRequired()) {
  111398. var colShape = this._createShape(impostor);
  111399. var mass = impostor.getParam("mass");
  111400. impostor._pluginData.mass = mass;
  111401. var localInertia = new Ammo.btVector3(0, 0, 0);
  111402. var startTransform = new Ammo.btTransform();
  111403. startTransform.setIdentity();
  111404. if (mass !== 0) {
  111405. colShape.calculateLocalInertia(mass, localInertia);
  111406. }
  111407. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  111408. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  111409. startTransform.setOrigin(this._tmpAmmoVectorA);
  111410. startTransform.setRotation(this._tmpAmmoQuaternion);
  111411. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  111412. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  111413. var body = new Ammo.btRigidBody(rbInfo);
  111414. // Make objects kinematic if it's mass is 0
  111415. if (mass === 0) {
  111416. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  111417. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  111418. }
  111419. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  111420. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  111421. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  111422. }
  111423. this.world.addRigidBody(body);
  111424. impostor.physicsBody = body;
  111425. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  111426. this.setBodyFriction(impostor, impostor.getParam("friction"));
  111427. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  111428. }
  111429. };
  111430. /**
  111431. * Removes the physics body from the imposter and disposes of the body's memory
  111432. * @param impostor imposter to remove the physics body from
  111433. */
  111434. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  111435. var _this = this;
  111436. if (this.world) {
  111437. this.world.removeRigidBody(impostor.physicsBody);
  111438. impostor._pluginData.toDispose.forEach(function (d) {
  111439. _this.bjsAMMO.destroy(d);
  111440. });
  111441. }
  111442. };
  111443. /**
  111444. * Generates a joint
  111445. * @param impostorJoint the imposter joint to create the joint with
  111446. */
  111447. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  111448. var mainBody = impostorJoint.mainImpostor.physicsBody;
  111449. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  111450. if (!mainBody || !connectedBody) {
  111451. return;
  111452. }
  111453. var jointData = impostorJoint.joint.jointData;
  111454. if (!jointData.mainPivot) {
  111455. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  111456. }
  111457. if (!jointData.connectedPivot) {
  111458. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  111459. }
  111460. var joint;
  111461. switch (impostorJoint.joint.type) {
  111462. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  111463. var distance = jointData.maxDistance;
  111464. if (distance) {
  111465. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  111466. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  111467. }
  111468. 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));
  111469. break;
  111470. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  111471. if (!jointData.mainAxis) {
  111472. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  111473. }
  111474. if (!jointData.connectedAxis) {
  111475. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  111476. }
  111477. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  111478. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  111479. 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);
  111480. break;
  111481. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  111482. 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));
  111483. break;
  111484. default:
  111485. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  111486. 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));
  111487. break;
  111488. }
  111489. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  111490. impostorJoint.joint.physicsJoint = joint;
  111491. };
  111492. /**
  111493. * Removes a joint
  111494. * @param impostorJoint the imposter joint to remove the joint from
  111495. */
  111496. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  111497. if (this.world) {
  111498. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  111499. }
  111500. };
  111501. // adds all verticies (including child verticies) to the triangle mesh
  111502. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  111503. var _this = this;
  111504. var triangleCount = 0;
  111505. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  111506. var indices = object.getIndices();
  111507. if (!indices) {
  111508. indices = [];
  111509. }
  111510. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  111511. if (!vertexPositions) {
  111512. vertexPositions = [];
  111513. }
  111514. object.computeWorldMatrix(false);
  111515. var faceCount = indices.length / 3;
  111516. for (var i = 0; i < faceCount; i++) {
  111517. var triPoints = [];
  111518. for (var point = 0; point < 3; point++) {
  111519. 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]);
  111520. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  111521. v.subtractInPlace(topLevelObject.position);
  111522. var vec;
  111523. if (point == 0) {
  111524. vec = this._tmpAmmoVectorA;
  111525. }
  111526. else if (point == 1) {
  111527. vec = this._tmpAmmoVectorB;
  111528. }
  111529. else {
  111530. vec = this._tmpAmmoVectorC;
  111531. }
  111532. vec.setValue(v.x, v.y, v.z);
  111533. triPoints.push(vec);
  111534. }
  111535. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  111536. triangleCount++;
  111537. }
  111538. object.getChildMeshes().forEach(function (m) {
  111539. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  111540. });
  111541. }
  111542. return triangleCount;
  111543. };
  111544. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  111545. var _this = this;
  111546. if (ignoreChildren === void 0) { ignoreChildren = false; }
  111547. var object = impostor.object;
  111548. var returnValue;
  111549. var extendSize = impostor.getObjectExtendSize();
  111550. if (!ignoreChildren) {
  111551. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  111552. returnValue = new Ammo.btCompoundShape();
  111553. // Add shape of all children to the compound shape
  111554. var childrenAdded = 0;
  111555. meshChildren.forEach(function (childMesh) {
  111556. var childImpostor = childMesh.getPhysicsImpostor();
  111557. if (childImpostor) {
  111558. var shape = _this._createShape(childImpostor);
  111559. // Position needs to be scaled based on parent's scaling
  111560. var parentMat = childMesh.parent.getWorldMatrix().clone();
  111561. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  111562. parentMat.decompose(s);
  111563. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  111564. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  111565. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  111566. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  111567. childImpostor.dispose();
  111568. childrenAdded++;
  111569. }
  111570. });
  111571. if (childrenAdded > 0) {
  111572. // Add parents shape as a child if present
  111573. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  111574. var shape = this._createShape(impostor, true);
  111575. if (shape) {
  111576. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  111577. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  111578. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  111579. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  111580. }
  111581. }
  111582. return returnValue;
  111583. }
  111584. else {
  111585. // If no children with impostors create the actual shape below instead
  111586. Ammo.destroy(returnValue);
  111587. returnValue = null;
  111588. }
  111589. }
  111590. switch (impostor.type) {
  111591. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  111592. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  111593. break;
  111594. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  111595. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  111596. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  111597. break;
  111598. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  111599. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  111600. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  111601. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  111602. break;
  111603. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  111604. var tetraMesh = new Ammo.btTriangleMesh();
  111605. impostor._pluginData.toDispose.concat([tetraMesh]);
  111606. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  111607. if (triangeCount == 0) {
  111608. returnValue = new Ammo.btCompoundShape();
  111609. }
  111610. else {
  111611. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  111612. }
  111613. break;
  111614. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  111615. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  111616. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  111617. break;
  111618. default:
  111619. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  111620. break;
  111621. }
  111622. return returnValue;
  111623. };
  111624. /**
  111625. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111626. * @param impostor imposter containing the physics body and babylon object
  111627. */
  111628. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  111629. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  111630. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  111631. if (!impostor.object.rotationQuaternion) {
  111632. if (impostor.object.rotation) {
  111633. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  111634. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  111635. }
  111636. }
  111637. else {
  111638. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  111639. }
  111640. };
  111641. /**
  111642. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111643. * @param impostor imposter containing the physics body and babylon object
  111644. * @param newPosition new position
  111645. * @param newRotation new rotation
  111646. */
  111647. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  111648. var trans = impostor.physicsBody.getWorldTransform();
  111649. // If rotation/position has changed update and activate riged body
  111650. if (trans.getOrigin().x() != newPosition.x ||
  111651. trans.getOrigin().y() != newPosition.y ||
  111652. trans.getOrigin().z() != newPosition.z ||
  111653. trans.getRotation().x() != newRotation.x ||
  111654. trans.getRotation().y() != newRotation.y ||
  111655. trans.getRotation().z() != newRotation.z ||
  111656. trans.getRotation().w() != newRotation.w) {
  111657. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  111658. trans.setOrigin(this._tmpAmmoVectorA);
  111659. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  111660. trans.setRotation(this._tmpAmmoQuaternion);
  111661. impostor.physicsBody.setWorldTransform(trans);
  111662. if (impostor.mass == 0) {
  111663. // Kinematic objects must be updated using motion state
  111664. var motionState = impostor.physicsBody.getMotionState();
  111665. if (motionState) {
  111666. motionState.setWorldTransform(trans);
  111667. }
  111668. }
  111669. else {
  111670. impostor.physicsBody.activate();
  111671. }
  111672. }
  111673. };
  111674. /**
  111675. * If this plugin is supported
  111676. * @returns true if its supported
  111677. */
  111678. AmmoJSPlugin.prototype.isSupported = function () {
  111679. return this.bjsAMMO !== undefined;
  111680. };
  111681. /**
  111682. * Sets the linear velocity of the physics body
  111683. * @param impostor imposter to set the velocity on
  111684. * @param velocity velocity to set
  111685. */
  111686. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  111687. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  111688. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  111689. };
  111690. /**
  111691. * Sets the angular velocity of the physics body
  111692. * @param impostor imposter to set the velocity on
  111693. * @param velocity velocity to set
  111694. */
  111695. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  111696. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  111697. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  111698. };
  111699. /**
  111700. * gets the linear velocity
  111701. * @param impostor imposter to get linear velocity from
  111702. * @returns linear velocity
  111703. */
  111704. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  111705. var v = impostor.physicsBody.getLinearVelocity();
  111706. if (!v) {
  111707. return null;
  111708. }
  111709. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  111710. };
  111711. /**
  111712. * gets the angular velocity
  111713. * @param impostor imposter to get angular velocity from
  111714. * @returns angular velocity
  111715. */
  111716. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  111717. var v = impostor.physicsBody.getAngularVelocity();
  111718. if (!v) {
  111719. return null;
  111720. }
  111721. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  111722. };
  111723. /**
  111724. * Sets the mass of physics body
  111725. * @param impostor imposter to set the mass on
  111726. * @param mass mass to set
  111727. */
  111728. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  111729. impostor.physicsBody.setMassProps(mass);
  111730. impostor._pluginData.mass = mass;
  111731. };
  111732. /**
  111733. * Gets the mass of the physics body
  111734. * @param impostor imposter to get the mass from
  111735. * @returns mass
  111736. */
  111737. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  111738. return impostor._pluginData.mass;
  111739. };
  111740. /**
  111741. * Gets friction of the impostor
  111742. * @param impostor impostor to get friction from
  111743. * @returns friction value
  111744. */
  111745. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  111746. return impostor._pluginData.friction;
  111747. };
  111748. /**
  111749. * Sets friction of the impostor
  111750. * @param impostor impostor to set friction on
  111751. * @param friction friction value
  111752. */
  111753. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  111754. impostor.physicsBody.setFriction(friction);
  111755. impostor._pluginData.friction = friction;
  111756. };
  111757. /**
  111758. * Gets restitution of the impostor
  111759. * @param impostor impostor to get restitution from
  111760. * @returns restitution value
  111761. */
  111762. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  111763. return impostor._pluginData.restitution;
  111764. };
  111765. /**
  111766. * Sets resitution of the impostor
  111767. * @param impostor impostor to set resitution on
  111768. * @param restitution resitution value
  111769. */
  111770. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  111771. impostor.physicsBody.setRestitution(restitution);
  111772. impostor._pluginData.restitution = restitution;
  111773. };
  111774. /**
  111775. * Sleeps the physics body and stops it from being active
  111776. * @param impostor impostor to sleep
  111777. */
  111778. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  111779. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  111780. };
  111781. /**
  111782. * Activates the physics body
  111783. * @param impostor impostor to activate
  111784. */
  111785. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  111786. impostor.physicsBody.activate();
  111787. };
  111788. /**
  111789. * Updates the distance parameters of the joint
  111790. * @param joint joint to update
  111791. * @param maxDistance maximum distance of the joint
  111792. * @param minDistance minimum distance of the joint
  111793. */
  111794. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  111795. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  111796. };
  111797. /**
  111798. * Sets a motor on the joint
  111799. * @param joint joint to set motor on
  111800. * @param speed speed of the motor
  111801. * @param maxForce maximum force of the motor
  111802. * @param motorIndex index of the motor
  111803. */
  111804. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  111805. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  111806. };
  111807. /**
  111808. * Sets the motors limit
  111809. * @param joint joint to set limit on
  111810. * @param upperLimit upper limit
  111811. * @param lowerLimit lower limit
  111812. */
  111813. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  111814. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  111815. };
  111816. /**
  111817. * Syncs the position and rotation of a mesh with the impostor
  111818. * @param mesh mesh to sync
  111819. * @param impostor impostor to update the mesh with
  111820. */
  111821. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  111822. var body = impostor.physicsBody;
  111823. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  111824. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  111825. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  111826. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  111827. if (mesh.rotationQuaternion) {
  111828. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  111829. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  111830. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  111831. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  111832. }
  111833. };
  111834. /**
  111835. * Gets the radius of the impostor
  111836. * @param impostor impostor to get radius from
  111837. * @returns the radius
  111838. */
  111839. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  111840. var exntend = impostor.getObjectExtendSize();
  111841. return exntend.x / 2;
  111842. };
  111843. /**
  111844. * Gets the box size of the impostor
  111845. * @param impostor impostor to get box size from
  111846. * @param result the resulting box size
  111847. */
  111848. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  111849. var exntend = impostor.getObjectExtendSize();
  111850. result.x = exntend.x;
  111851. result.y = exntend.y;
  111852. result.z = exntend.z;
  111853. };
  111854. /**
  111855. * Disposes of the impostor
  111856. */
  111857. AmmoJSPlugin.prototype.dispose = function () {
  111858. // Dispose of world
  111859. Ammo.destroy(this.world);
  111860. Ammo.destroy(this._solver);
  111861. Ammo.destroy(this._overlappingPairCache);
  111862. Ammo.destroy(this._dispatcher);
  111863. Ammo.destroy(this._collisionConfiguration);
  111864. // Dispose of tmp variables
  111865. Ammo.destroy(this._tmpAmmoVectorA);
  111866. Ammo.destroy(this._tmpAmmoVectorB);
  111867. Ammo.destroy(this._tmpAmmoVectorC);
  111868. Ammo.destroy(this._tmpAmmoTransform);
  111869. Ammo.destroy(this._tmpAmmoQuaternion);
  111870. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  111871. this.world = null;
  111872. };
  111873. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  111874. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  111875. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  111876. return AmmoJSPlugin;
  111877. }());
  111878. /***/ }),
  111879. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  111880. /*!*******************************************!*\
  111881. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  111882. \*******************************************/
  111883. /*! exports provided: CannonJSPlugin */
  111884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111885. "use strict";
  111886. __webpack_require__.r(__webpack_exports__);
  111887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  111888. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  111889. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  111890. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  111891. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  111892. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  111893. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  111894. /** @hidden */
  111895. var CannonJSPlugin = /** @class */ (function () {
  111896. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  111897. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  111898. if (iterations === void 0) { iterations = 10; }
  111899. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  111900. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  111901. this.name = "CannonJSPlugin";
  111902. this._physicsMaterials = new Array();
  111903. this._fixedTimeStep = 1 / 60;
  111904. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  111905. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  111906. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  111907. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  111908. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  111909. this.BJSCANNON = cannonInjection;
  111910. if (!this.isSupported()) {
  111911. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  111912. return;
  111913. }
  111914. this._extendNamespace();
  111915. this.world = new this.BJSCANNON.World();
  111916. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  111917. this.world.solver.iterations = iterations;
  111918. }
  111919. CannonJSPlugin.prototype.setGravity = function (gravity) {
  111920. this.world.gravity.copy(gravity);
  111921. };
  111922. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  111923. this._fixedTimeStep = timeStep;
  111924. };
  111925. CannonJSPlugin.prototype.getTimeStep = function () {
  111926. return this._fixedTimeStep;
  111927. };
  111928. CannonJSPlugin.prototype.executeStep = function (delta) {
  111929. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  111930. };
  111931. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  111932. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  111933. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  111934. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  111935. };
  111936. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  111937. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  111938. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  111939. impostor.physicsBody.applyForce(impulse, worldPoint);
  111940. };
  111941. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  111942. //parent-child relationship. Does this impostor has a parent impostor?
  111943. if (impostor.parent) {
  111944. if (impostor.physicsBody) {
  111945. this.removePhysicsBody(impostor);
  111946. //TODO is that needed?
  111947. impostor.forceUpdate();
  111948. }
  111949. return;
  111950. }
  111951. //should a new body be created for this impostor?
  111952. if (impostor.isBodyInitRequired()) {
  111953. var shape = this._createShape(impostor);
  111954. //unregister events, if body is being changed
  111955. var oldBody = impostor.physicsBody;
  111956. if (oldBody) {
  111957. this.removePhysicsBody(impostor);
  111958. }
  111959. //create the body and material
  111960. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  111961. var bodyCreationObject = {
  111962. mass: impostor.getParam("mass"),
  111963. material: material
  111964. };
  111965. // A simple extend, in case native options were used.
  111966. var nativeOptions = impostor.getParam("nativeOptions");
  111967. for (var key in nativeOptions) {
  111968. if (nativeOptions.hasOwnProperty(key)) {
  111969. bodyCreationObject[key] = nativeOptions[key];
  111970. }
  111971. }
  111972. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  111973. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  111974. this.world.addEventListener("preStep", impostor.beforeStep);
  111975. this.world.addEventListener("postStep", impostor.afterStep);
  111976. impostor.physicsBody.addShape(shape);
  111977. this.world.add(impostor.physicsBody);
  111978. //try to keep the body moving in the right direction by taking old properties.
  111979. //Should be tested!
  111980. if (oldBody) {
  111981. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  111982. impostor.physicsBody[param].copy(oldBody[param]);
  111983. });
  111984. }
  111985. this._processChildMeshes(impostor);
  111986. }
  111987. //now update the body's transformation
  111988. this._updatePhysicsBodyTransformation(impostor);
  111989. };
  111990. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  111991. var _this = this;
  111992. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  111993. var currentRotation = mainImpostor.object.rotationQuaternion;
  111994. if (meshChildren.length) {
  111995. var processMesh = function (localPosition, mesh) {
  111996. if (!currentRotation || !mesh.rotationQuaternion) {
  111997. return;
  111998. }
  111999. var childImpostor = mesh.getPhysicsImpostor();
  112000. if (childImpostor) {
  112001. var parent = childImpostor.parent;
  112002. if (parent !== mainImpostor) {
  112003. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  112004. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  112005. if (childImpostor.physicsBody) {
  112006. _this.removePhysicsBody(childImpostor);
  112007. childImpostor.physicsBody = null;
  112008. }
  112009. childImpostor.parent = mainImpostor;
  112010. childImpostor.resetUpdateFlags();
  112011. 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));
  112012. //Add the mass of the children.
  112013. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  112014. }
  112015. }
  112016. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  112017. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  112018. };
  112019. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  112020. }
  112021. };
  112022. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  112023. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  112024. this.world.removeEventListener("preStep", impostor.beforeStep);
  112025. this.world.removeEventListener("postStep", impostor.afterStep);
  112026. this.world.remove(impostor.physicsBody);
  112027. };
  112028. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  112029. var mainBody = impostorJoint.mainImpostor.physicsBody;
  112030. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  112031. if (!mainBody || !connectedBody) {
  112032. return;
  112033. }
  112034. var constraint;
  112035. var jointData = impostorJoint.joint.jointData;
  112036. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  112037. var constraintData = {
  112038. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  112039. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  112040. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  112041. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  112042. maxForce: jointData.nativeParams.maxForce,
  112043. collideConnected: !!jointData.collision
  112044. };
  112045. switch (impostorJoint.joint.type) {
  112046. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  112047. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  112048. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  112049. break;
  112050. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  112051. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  112052. break;
  112053. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  112054. var springData = jointData;
  112055. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  112056. restLength: springData.length,
  112057. stiffness: springData.stiffness,
  112058. damping: springData.damping,
  112059. localAnchorA: constraintData.pivotA,
  112060. localAnchorB: constraintData.pivotB
  112061. });
  112062. break;
  112063. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  112064. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  112065. break;
  112066. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  112067. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  112068. default:
  112069. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  112070. break;
  112071. }
  112072. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  112073. constraint.collideConnected = !!jointData.collision;
  112074. impostorJoint.joint.physicsJoint = constraint;
  112075. //don't add spring as constraint, as it is not one.
  112076. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  112077. this.world.addConstraint(constraint);
  112078. }
  112079. else {
  112080. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  112081. constraint.applyForce();
  112082. };
  112083. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  112084. }
  112085. };
  112086. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  112087. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  112088. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  112089. }
  112090. else {
  112091. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  112092. }
  112093. };
  112094. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  112095. var index;
  112096. var mat;
  112097. for (index = 0; index < this._physicsMaterials.length; index++) {
  112098. mat = this._physicsMaterials[index];
  112099. if (mat.friction === friction && mat.restitution === restitution) {
  112100. return mat;
  112101. }
  112102. }
  112103. var currentMat = new this.BJSCANNON.Material(name);
  112104. currentMat.friction = friction;
  112105. currentMat.restitution = restitution;
  112106. this._physicsMaterials.push(currentMat);
  112107. return currentMat;
  112108. };
  112109. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  112110. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  112111. };
  112112. CannonJSPlugin.prototype._createShape = function (impostor) {
  112113. var object = impostor.object;
  112114. var returnValue;
  112115. var extendSize = impostor.getObjectExtendSize();
  112116. switch (impostor.type) {
  112117. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  112118. var radiusX = extendSize.x;
  112119. var radiusY = extendSize.y;
  112120. var radiusZ = extendSize.z;
  112121. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  112122. break;
  112123. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  112124. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  112125. var nativeParams = impostor.getParam("nativeOptions");
  112126. if (!nativeParams) {
  112127. nativeParams = {};
  112128. }
  112129. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  112130. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  112131. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  112132. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  112133. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  112134. // Rotate 90 degrees as this shape is horizontal in cannon
  112135. var quat = new this.BJSCANNON.Quaternion();
  112136. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  112137. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  112138. returnValue.transformAllPoints(translation, quat);
  112139. break;
  112140. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  112141. var box = extendSize.scale(0.5);
  112142. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  112143. break;
  112144. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  112145. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  112146. returnValue = new this.BJSCANNON.Plane();
  112147. break;
  112148. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  112149. // should transform the vertex data to world coordinates!!
  112150. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  112151. var rawFaces = object.getIndices ? object.getIndices() : [];
  112152. if (!rawVerts) {
  112153. return;
  112154. }
  112155. // get only scale! so the object could transform correctly.
  112156. var oldPosition = object.position.clone();
  112157. var oldRotation = object.rotation && object.rotation.clone();
  112158. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  112159. object.position.copyFromFloats(0, 0, 0);
  112160. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  112161. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  112162. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  112163. var transform = object.computeWorldMatrix(true);
  112164. // convert rawVerts to object space
  112165. var temp = new Array();
  112166. var index;
  112167. for (index = 0; index < rawVerts.length; index += 3) {
  112168. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  112169. }
  112170. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  112171. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  112172. //now set back the transformation!
  112173. object.position.copyFrom(oldPosition);
  112174. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  112175. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  112176. break;
  112177. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  112178. var oldPosition2 = object.position.clone();
  112179. var oldRotation2 = object.rotation && object.rotation.clone();
  112180. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  112181. object.position.copyFromFloats(0, 0, 0);
  112182. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  112183. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  112184. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  112185. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  112186. returnValue = this._createHeightmap(object);
  112187. object.position.copyFrom(oldPosition2);
  112188. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  112189. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  112190. object.computeWorldMatrix(true);
  112191. break;
  112192. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  112193. returnValue = new this.BJSCANNON.Particle();
  112194. break;
  112195. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  112196. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  112197. break;
  112198. }
  112199. return returnValue;
  112200. };
  112201. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  112202. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  112203. var transform = object.computeWorldMatrix(true);
  112204. // convert rawVerts to object space
  112205. var temp = new Array();
  112206. var index;
  112207. for (index = 0; index < pos.length; index += 3) {
  112208. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  112209. }
  112210. pos = temp;
  112211. var matrix = new Array();
  112212. //For now pointDepth will not be used and will be automatically calculated.
  112213. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  112214. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  112215. var boundingInfo = object.getBoundingInfo();
  112216. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  112217. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  112218. var elementSize = dim * 2 / arraySize;
  112219. for (var i = 0; i < pos.length; i = i + 3) {
  112220. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  112221. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  112222. var y = -pos[i + 2] + minY;
  112223. if (!matrix[x]) {
  112224. matrix[x] = [];
  112225. }
  112226. if (!matrix[x][z]) {
  112227. matrix[x][z] = y;
  112228. }
  112229. matrix[x][z] = Math.max(y, matrix[x][z]);
  112230. }
  112231. for (var x = 0; x <= arraySize; ++x) {
  112232. if (!matrix[x]) {
  112233. var loc = 1;
  112234. while (!matrix[(x + loc) % arraySize]) {
  112235. loc++;
  112236. }
  112237. matrix[x] = matrix[(x + loc) % arraySize].slice();
  112238. //console.log("missing x", x);
  112239. }
  112240. for (var z = 0; z <= arraySize; ++z) {
  112241. if (!matrix[x][z]) {
  112242. var loc = 1;
  112243. var newValue;
  112244. while (newValue === undefined) {
  112245. newValue = matrix[x][(z + loc++) % arraySize];
  112246. }
  112247. matrix[x][z] = newValue;
  112248. }
  112249. }
  112250. }
  112251. var shape = new this.BJSCANNON.Heightfield(matrix, {
  112252. elementSize: elementSize
  112253. });
  112254. //For future reference, needed for body transformation
  112255. shape.minY = minY;
  112256. return shape;
  112257. };
  112258. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  112259. var object = impostor.object;
  112260. //make sure it is updated...
  112261. object.computeWorldMatrix && object.computeWorldMatrix(true);
  112262. // The delta between the mesh position and the mesh bounding box center
  112263. var bInfo = object.getBoundingInfo();
  112264. if (!bInfo) {
  112265. return;
  112266. }
  112267. var center = impostor.getObjectCenter();
  112268. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  112269. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  112270. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  112271. this._tmpPosition.copyFrom(center);
  112272. var quaternion = object.rotationQuaternion;
  112273. if (!quaternion) {
  112274. return;
  112275. }
  112276. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  112277. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  112278. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  112279. //-90 DEG in X, precalculated
  112280. quaternion = quaternion.multiply(this._minus90X);
  112281. //Invert! (Precalculated, 90 deg in X)
  112282. //No need to clone. this will never change.
  112283. impostor.setDeltaRotation(this._plus90X);
  112284. }
  112285. //If it is a heightfield, if should be centered.
  112286. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  112287. var mesh = object;
  112288. var boundingInfo = mesh.getBoundingInfo();
  112289. //calculate the correct body position:
  112290. var rotationQuaternion = mesh.rotationQuaternion;
  112291. mesh.rotationQuaternion = this._tmpUnityRotation;
  112292. mesh.computeWorldMatrix(true);
  112293. //get original center with no rotation
  112294. var c = center.clone();
  112295. var oldPivot = mesh.getPivotMatrix();
  112296. if (oldPivot) {
  112297. // create a copy the pivot Matrix as it is modified in place
  112298. oldPivot = oldPivot.clone();
  112299. }
  112300. else {
  112301. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  112302. }
  112303. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  112304. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  112305. mesh.setPreTransformMatrix(p);
  112306. mesh.computeWorldMatrix(true);
  112307. //calculate the translation
  112308. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  112309. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  112310. //add it inverted to the delta
  112311. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  112312. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  112313. //rotation is back
  112314. mesh.rotationQuaternion = rotationQuaternion;
  112315. mesh.setPreTransformMatrix(oldPivot);
  112316. mesh.computeWorldMatrix(true);
  112317. }
  112318. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  112319. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  112320. //this._tmpPosition.copyFrom(object.position);
  112321. }
  112322. impostor.setDeltaPosition(this._tmpDeltaPosition);
  112323. //Now update the impostor object
  112324. impostor.physicsBody.position.copy(this._tmpPosition);
  112325. impostor.physicsBody.quaternion.copy(quaternion);
  112326. };
  112327. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  112328. impostor.object.position.copyFrom(impostor.physicsBody.position);
  112329. if (impostor.object.rotationQuaternion) {
  112330. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  112331. }
  112332. };
  112333. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  112334. impostor.physicsBody.position.copy(newPosition);
  112335. impostor.physicsBody.quaternion.copy(newRotation);
  112336. };
  112337. CannonJSPlugin.prototype.isSupported = function () {
  112338. return this.BJSCANNON !== undefined;
  112339. };
  112340. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  112341. impostor.physicsBody.velocity.copy(velocity);
  112342. };
  112343. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  112344. impostor.physicsBody.angularVelocity.copy(velocity);
  112345. };
  112346. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  112347. var v = impostor.physicsBody.velocity;
  112348. if (!v) {
  112349. return null;
  112350. }
  112351. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  112352. };
  112353. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  112354. var v = impostor.physicsBody.angularVelocity;
  112355. if (!v) {
  112356. return null;
  112357. }
  112358. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  112359. };
  112360. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  112361. impostor.physicsBody.mass = mass;
  112362. impostor.physicsBody.updateMassProperties();
  112363. };
  112364. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  112365. return impostor.physicsBody.mass;
  112366. };
  112367. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  112368. return impostor.physicsBody.material.friction;
  112369. };
  112370. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  112371. impostor.physicsBody.material.friction = friction;
  112372. };
  112373. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  112374. return impostor.physicsBody.material.restitution;
  112375. };
  112376. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  112377. impostor.physicsBody.material.restitution = restitution;
  112378. };
  112379. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  112380. impostor.physicsBody.sleep();
  112381. };
  112382. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  112383. impostor.physicsBody.wakeUp();
  112384. };
  112385. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  112386. joint.physicsJoint.distance = maxDistance;
  112387. };
  112388. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  112389. // if (!motorIndex) {
  112390. // joint.physicsJoint.enableMotor();
  112391. // }
  112392. // }
  112393. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  112394. // if (!motorIndex) {
  112395. // joint.physicsJoint.disableMotor();
  112396. // }
  112397. // }
  112398. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  112399. if (!motorIndex) {
  112400. joint.physicsJoint.enableMotor();
  112401. joint.physicsJoint.setMotorSpeed(speed);
  112402. if (maxForce) {
  112403. this.setLimit(joint, maxForce);
  112404. }
  112405. }
  112406. };
  112407. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  112408. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  112409. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  112410. };
  112411. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  112412. var body = impostor.physicsBody;
  112413. mesh.position.x = body.position.x;
  112414. mesh.position.y = body.position.y;
  112415. mesh.position.z = body.position.z;
  112416. if (mesh.rotationQuaternion) {
  112417. mesh.rotationQuaternion.x = body.quaternion.x;
  112418. mesh.rotationQuaternion.y = body.quaternion.y;
  112419. mesh.rotationQuaternion.z = body.quaternion.z;
  112420. mesh.rotationQuaternion.w = body.quaternion.w;
  112421. }
  112422. };
  112423. CannonJSPlugin.prototype.getRadius = function (impostor) {
  112424. var shape = impostor.physicsBody.shapes[0];
  112425. return shape.boundingSphereRadius;
  112426. };
  112427. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  112428. var shape = impostor.physicsBody.shapes[0];
  112429. result.x = shape.halfExtents.x * 2;
  112430. result.y = shape.halfExtents.y * 2;
  112431. result.z = shape.halfExtents.z * 2;
  112432. };
  112433. CannonJSPlugin.prototype.dispose = function () {
  112434. };
  112435. CannonJSPlugin.prototype._extendNamespace = function () {
  112436. //this will force cannon to execute at least one step when using interpolation
  112437. var step_tmp1 = new this.BJSCANNON.Vec3();
  112438. var Engine = this.BJSCANNON;
  112439. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  112440. maxSubSteps = maxSubSteps || 10;
  112441. timeSinceLastCalled = timeSinceLastCalled || 0;
  112442. if (timeSinceLastCalled === 0) {
  112443. this.internalStep(dt);
  112444. this.time += dt;
  112445. }
  112446. else {
  112447. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  112448. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  112449. var t0 = performance.now();
  112450. for (var i = 0; i !== internalSteps; i++) {
  112451. this.internalStep(dt);
  112452. if (performance.now() - t0 > dt * 1000) {
  112453. break;
  112454. }
  112455. }
  112456. this.time += timeSinceLastCalled;
  112457. var h = this.time % dt;
  112458. var h_div_dt = h / dt;
  112459. var interpvelo = step_tmp1;
  112460. var bodies = this.bodies;
  112461. for (var j = 0; j !== bodies.length; j++) {
  112462. var b = bodies[j];
  112463. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  112464. b.position.vsub(b.previousPosition, interpvelo);
  112465. interpvelo.scale(h_div_dt, interpvelo);
  112466. b.position.vadd(interpvelo, b.interpolatedPosition);
  112467. }
  112468. else {
  112469. b.interpolatedPosition.copy(b.position);
  112470. b.interpolatedQuaternion.copy(b.quaternion);
  112471. }
  112472. }
  112473. }
  112474. };
  112475. };
  112476. return CannonJSPlugin;
  112477. }());
  112478. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  112479. /***/ }),
  112480. /***/ "./Physics/Plugins/index.ts":
  112481. /*!**********************************!*\
  112482. !*** ./Physics/Plugins/index.ts ***!
  112483. \**********************************/
  112484. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  112485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112486. "use strict";
  112487. __webpack_require__.r(__webpack_exports__);
  112488. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  112489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  112490. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  112491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  112492. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  112493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  112494. /***/ }),
  112495. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  112496. /*!*****************************************!*\
  112497. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  112498. \*****************************************/
  112499. /*! exports provided: OimoJSPlugin */
  112500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112501. "use strict";
  112502. __webpack_require__.r(__webpack_exports__);
  112503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  112504. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  112505. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  112506. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  112507. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  112508. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  112509. /** @hidden */
  112510. var OimoJSPlugin = /** @class */ (function () {
  112511. function OimoJSPlugin(iterations, oimoInjection) {
  112512. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  112513. this.name = "OimoJSPlugin";
  112514. this._tmpImpostorsArray = [];
  112515. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  112516. this.BJSOIMO = oimoInjection;
  112517. this.world = new this.BJSOIMO.World({
  112518. iterations: iterations
  112519. });
  112520. this.world.clear();
  112521. }
  112522. OimoJSPlugin.prototype.setGravity = function (gravity) {
  112523. this.world.gravity.copy(gravity);
  112524. };
  112525. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  112526. this.world.timeStep = timeStep;
  112527. };
  112528. OimoJSPlugin.prototype.getTimeStep = function () {
  112529. return this.world.timeStep;
  112530. };
  112531. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  112532. var _this = this;
  112533. impostors.forEach(function (impostor) {
  112534. impostor.beforeStep();
  112535. });
  112536. this.world.step();
  112537. impostors.forEach(function (impostor) {
  112538. impostor.afterStep();
  112539. //update the ordered impostors array
  112540. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  112541. });
  112542. //check for collisions
  112543. var contact = this.world.contacts;
  112544. while (contact !== null) {
  112545. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  112546. contact = contact.next;
  112547. continue;
  112548. }
  112549. //is this body colliding with any other? get the impostor
  112550. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  112551. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  112552. if (!mainImpostor || !collidingImpostor) {
  112553. contact = contact.next;
  112554. continue;
  112555. }
  112556. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  112557. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  112558. contact = contact.next;
  112559. }
  112560. };
  112561. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  112562. var mass = impostor.physicsBody.mass;
  112563. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  112564. };
  112565. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  112566. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  112567. this.applyImpulse(impostor, force, contactPoint);
  112568. };
  112569. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  112570. var _this = this;
  112571. //parent-child relationship. Does this impostor has a parent impostor?
  112572. if (impostor.parent) {
  112573. if (impostor.physicsBody) {
  112574. this.removePhysicsBody(impostor);
  112575. //TODO is that needed?
  112576. impostor.forceUpdate();
  112577. }
  112578. return;
  112579. }
  112580. if (impostor.isBodyInitRequired()) {
  112581. var bodyConfig = {
  112582. name: impostor.uniqueId,
  112583. //Oimo must have mass, also for static objects.
  112584. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  112585. size: [],
  112586. type: [],
  112587. pos: [],
  112588. posShape: [],
  112589. rot: [],
  112590. rotShape: [],
  112591. move: impostor.getParam("mass") !== 0,
  112592. density: impostor.getParam("mass"),
  112593. friction: impostor.getParam("friction"),
  112594. restitution: impostor.getParam("restitution"),
  112595. //Supporting older versions of Oimo
  112596. world: this.world
  112597. };
  112598. var impostors = [impostor];
  112599. var addToArray = function (parent) {
  112600. if (!parent.getChildMeshes) {
  112601. return;
  112602. }
  112603. parent.getChildMeshes().forEach(function (m) {
  112604. if (m.physicsImpostor) {
  112605. impostors.push(m.physicsImpostor);
  112606. //m.physicsImpostor._init();
  112607. }
  112608. });
  112609. };
  112610. addToArray(impostor.object);
  112611. var checkWithEpsilon_1 = function (value) {
  112612. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  112613. };
  112614. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  112615. impostors.forEach(function (i) {
  112616. if (!i.object.rotationQuaternion) {
  112617. return;
  112618. }
  112619. //get the correct bounding box
  112620. var oldQuaternion = i.object.rotationQuaternion;
  112621. globalQuaternion_1 = oldQuaternion.clone();
  112622. var rot = oldQuaternion.toEulerAngles();
  112623. var extendSize = i.getObjectExtendSize();
  112624. var radToDeg = 57.295779513082320876;
  112625. if (i === impostor) {
  112626. var center = impostor.getObjectCenter();
  112627. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  112628. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  112629. //Can also use Array.prototype.push.apply
  112630. bodyConfig.pos.push(center.x);
  112631. bodyConfig.pos.push(center.y);
  112632. bodyConfig.pos.push(center.z);
  112633. bodyConfig.posShape.push(0, 0, 0);
  112634. bodyConfig.rotShape.push(0, 0, 0);
  112635. }
  112636. else {
  112637. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  112638. bodyConfig.posShape.push(localPosition.x);
  112639. bodyConfig.posShape.push(localPosition.y);
  112640. bodyConfig.posShape.push(localPosition.z);
  112641. bodyConfig.pos.push(0, 0, 0);
  112642. bodyConfig.rotShape.push(rot.x * radToDeg);
  112643. bodyConfig.rotShape.push(rot.y * radToDeg);
  112644. bodyConfig.rotShape.push(rot.z * radToDeg);
  112645. }
  112646. // register mesh
  112647. switch (i.type) {
  112648. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  112649. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  112650. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  112651. var radiusX = extendSize.x;
  112652. var radiusY = extendSize.y;
  112653. var radiusZ = extendSize.z;
  112654. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  112655. bodyConfig.type.push('sphere');
  112656. //due to the way oimo works with compounds, add 3 times
  112657. bodyConfig.size.push(size);
  112658. bodyConfig.size.push(size);
  112659. bodyConfig.size.push(size);
  112660. break;
  112661. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  112662. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  112663. var sizeY = checkWithEpsilon_1(extendSize.y);
  112664. bodyConfig.type.push('cylinder');
  112665. bodyConfig.size.push(sizeX);
  112666. bodyConfig.size.push(sizeY);
  112667. //due to the way oimo works with compounds, add one more value.
  112668. bodyConfig.size.push(sizeY);
  112669. break;
  112670. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  112671. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  112672. default:
  112673. var sizeX = checkWithEpsilon_1(extendSize.x);
  112674. var sizeY = checkWithEpsilon_1(extendSize.y);
  112675. var sizeZ = checkWithEpsilon_1(extendSize.z);
  112676. bodyConfig.type.push('box');
  112677. //if (i === impostor) {
  112678. bodyConfig.size.push(sizeX);
  112679. bodyConfig.size.push(sizeY);
  112680. bodyConfig.size.push(sizeZ);
  112681. //} else {
  112682. // bodyConfig.size.push(0,0,0);
  112683. //}
  112684. break;
  112685. }
  112686. //actually not needed, but hey...
  112687. i.object.rotationQuaternion = oldQuaternion;
  112688. });
  112689. impostor.physicsBody = this.world.add(bodyConfig);
  112690. // set the quaternion, ignoring the previously defined (euler) rotation
  112691. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  112692. // update with delta 0, so the body will reveive the new rotation.
  112693. impostor.physicsBody.updatePosition(0);
  112694. }
  112695. else {
  112696. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  112697. }
  112698. impostor.setDeltaPosition(this._tmpPositionVector);
  112699. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  112700. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  112701. };
  112702. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  112703. //impostor.physicsBody.dispose();
  112704. //Same as : (older oimo versions)
  112705. this.world.removeRigidBody(impostor.physicsBody);
  112706. };
  112707. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  112708. var mainBody = impostorJoint.mainImpostor.physicsBody;
  112709. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  112710. if (!mainBody || !connectedBody) {
  112711. return;
  112712. }
  112713. var jointData = impostorJoint.joint.jointData;
  112714. var options = jointData.nativeParams || {};
  112715. var type;
  112716. var nativeJointData = {
  112717. body1: mainBody,
  112718. body2: connectedBody,
  112719. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  112720. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  112721. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  112722. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  112723. min: options.min,
  112724. max: options.max,
  112725. collision: options.collision || jointData.collision,
  112726. spring: options.spring,
  112727. //supporting older version of Oimo
  112728. world: this.world
  112729. };
  112730. switch (impostorJoint.joint.type) {
  112731. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  112732. type = "jointBall";
  112733. break;
  112734. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  112735. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  112736. var springData = jointData;
  112737. nativeJointData.min = springData.length || nativeJointData.min;
  112738. //Max should also be set, just make sure it is at least min
  112739. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  112740. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  112741. type = "jointDistance";
  112742. nativeJointData.max = jointData.maxDistance;
  112743. break;
  112744. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  112745. type = "jointPrisme";
  112746. break;
  112747. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  112748. type = "jointSlide";
  112749. break;
  112750. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  112751. type = "jointWheel";
  112752. break;
  112753. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  112754. default:
  112755. type = "jointHinge";
  112756. break;
  112757. }
  112758. nativeJointData.type = type;
  112759. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  112760. };
  112761. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  112762. //Bug in Oimo prevents us from disposing a joint in the playground
  112763. //joint.joint.physicsJoint.dispose();
  112764. //So we will bruteforce it!
  112765. try {
  112766. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  112767. }
  112768. catch (e) {
  112769. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  112770. }
  112771. };
  112772. OimoJSPlugin.prototype.isSupported = function () {
  112773. return this.BJSOIMO !== undefined;
  112774. };
  112775. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  112776. if (!impostor.physicsBody.sleeping) {
  112777. //TODO check that
  112778. /*if (impostor.physicsBody.shapes.next) {
  112779. var parentShape = this._getLastShape(impostor.physicsBody);
  112780. impostor.object.position.copyFrom(parentShape.position);
  112781. console.log(parentShape.position);
  112782. } else {*/
  112783. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  112784. //}
  112785. if (impostor.object.rotationQuaternion) {
  112786. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  112787. }
  112788. }
  112789. };
  112790. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  112791. var body = impostor.physicsBody;
  112792. body.position.copy(newPosition);
  112793. body.orientation.copy(newRotation);
  112794. body.syncShapes();
  112795. body.awake();
  112796. };
  112797. /*private _getLastShape(body: any): any {
  112798. var lastShape = body.shapes;
  112799. while (lastShape.next) {
  112800. lastShape = lastShape.next;
  112801. }
  112802. return lastShape;
  112803. }*/
  112804. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  112805. impostor.physicsBody.linearVelocity.copy(velocity);
  112806. };
  112807. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  112808. impostor.physicsBody.angularVelocity.copy(velocity);
  112809. };
  112810. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  112811. var v = impostor.physicsBody.linearVelocity;
  112812. if (!v) {
  112813. return null;
  112814. }
  112815. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  112816. };
  112817. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  112818. var v = impostor.physicsBody.angularVelocity;
  112819. if (!v) {
  112820. return null;
  112821. }
  112822. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  112823. };
  112824. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  112825. var staticBody = mass === 0;
  112826. //this will actually set the body's density and not its mass.
  112827. //But this is how oimo treats the mass variable.
  112828. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  112829. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  112830. };
  112831. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  112832. return impostor.physicsBody.shapes.density;
  112833. };
  112834. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  112835. return impostor.physicsBody.shapes.friction;
  112836. };
  112837. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  112838. impostor.physicsBody.shapes.friction = friction;
  112839. };
  112840. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  112841. return impostor.physicsBody.shapes.restitution;
  112842. };
  112843. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  112844. impostor.physicsBody.shapes.restitution = restitution;
  112845. };
  112846. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  112847. impostor.physicsBody.sleep();
  112848. };
  112849. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  112850. impostor.physicsBody.awake();
  112851. };
  112852. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  112853. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  112854. if (minDistance !== void 0) {
  112855. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  112856. }
  112857. };
  112858. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  112859. if (force !== undefined) {
  112860. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  112861. }
  112862. else {
  112863. force = 1e6;
  112864. }
  112865. speed *= -1;
  112866. //TODO separate rotational and transational motors.
  112867. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  112868. if (motor) {
  112869. motor.setMotor(speed, force);
  112870. }
  112871. };
  112872. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  112873. //TODO separate rotational and transational motors.
  112874. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  112875. if (motor) {
  112876. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  112877. }
  112878. };
  112879. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  112880. var body = impostor.physicsBody;
  112881. mesh.position.x = body.position.x;
  112882. mesh.position.y = body.position.y;
  112883. mesh.position.z = body.position.z;
  112884. if (mesh.rotationQuaternion) {
  112885. mesh.rotationQuaternion.x = body.orientation.x;
  112886. mesh.rotationQuaternion.y = body.orientation.y;
  112887. mesh.rotationQuaternion.z = body.orientation.z;
  112888. mesh.rotationQuaternion.w = body.orientation.s;
  112889. }
  112890. };
  112891. OimoJSPlugin.prototype.getRadius = function (impostor) {
  112892. return impostor.physicsBody.shapes.radius;
  112893. };
  112894. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  112895. var shape = impostor.physicsBody.shapes;
  112896. result.x = shape.halfWidth * 2;
  112897. result.y = shape.halfHeight * 2;
  112898. result.z = shape.halfDepth * 2;
  112899. };
  112900. OimoJSPlugin.prototype.dispose = function () {
  112901. this.world.clear();
  112902. };
  112903. return OimoJSPlugin;
  112904. }());
  112905. /***/ }),
  112906. /***/ "./Physics/index.ts":
  112907. /*!**************************!*\
  112908. !*** ./Physics/index.ts ***!
  112909. \**************************/
  112910. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  112911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112912. "use strict";
  112913. __webpack_require__.r(__webpack_exports__);
  112914. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  112915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  112916. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  112917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  112918. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  112919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  112920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  112921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  112922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  112923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  112924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  112925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  112926. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  112927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  112928. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  112929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  112930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  112931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  112932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  112933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  112934. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  112935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  112936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  112937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  112938. /***/ }),
  112939. /***/ "./Physics/physicsEngine.ts":
  112940. /*!**********************************!*\
  112941. !*** ./Physics/physicsEngine.ts ***!
  112942. \**********************************/
  112943. /*! exports provided: PhysicsEngine */
  112944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112945. "use strict";
  112946. __webpack_require__.r(__webpack_exports__);
  112947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  112948. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112949. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  112950. /**
  112951. * Class used to control physics engine
  112952. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  112953. */
  112954. var PhysicsEngine = /** @class */ (function () {
  112955. /**
  112956. * Creates a new Physics Engine
  112957. * @param gravity defines the gravity vector used by the simulation
  112958. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  112959. */
  112960. function PhysicsEngine(gravity, _physicsPlugin) {
  112961. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  112962. this._physicsPlugin = _physicsPlugin;
  112963. this._impostors = [];
  112964. this._joints = [];
  112965. if (!this._physicsPlugin.isSupported()) {
  112966. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  112967. + "Please make sure it is included.");
  112968. }
  112969. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  112970. this.setGravity(gravity);
  112971. this.setTimeStep();
  112972. }
  112973. /**
  112974. * Factory used to create the default physics plugin.
  112975. * @returns The default physics plugin
  112976. */
  112977. PhysicsEngine.DefaultPluginFactory = function () {
  112978. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  112979. };
  112980. /**
  112981. * Sets the gravity vector used by the simulation
  112982. * @param gravity defines the gravity vector to use
  112983. */
  112984. PhysicsEngine.prototype.setGravity = function (gravity) {
  112985. this.gravity = gravity;
  112986. this._physicsPlugin.setGravity(this.gravity);
  112987. };
  112988. /**
  112989. * Set the time step of the physics engine.
  112990. * Default is 1/60.
  112991. * To slow it down, enter 1/600 for example.
  112992. * To speed it up, 1/30
  112993. * @param newTimeStep defines the new timestep to apply to this world.
  112994. */
  112995. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  112996. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  112997. this._physicsPlugin.setTimeStep(newTimeStep);
  112998. };
  112999. /**
  113000. * Get the time step of the physics engine.
  113001. * @returns the current time step
  113002. */
  113003. PhysicsEngine.prototype.getTimeStep = function () {
  113004. return this._physicsPlugin.getTimeStep();
  113005. };
  113006. /**
  113007. * Release all resources
  113008. */
  113009. PhysicsEngine.prototype.dispose = function () {
  113010. this._impostors.forEach(function (impostor) {
  113011. impostor.dispose();
  113012. });
  113013. this._physicsPlugin.dispose();
  113014. };
  113015. /**
  113016. * Gets the name of the current physics plugin
  113017. * @returns the name of the plugin
  113018. */
  113019. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  113020. return this._physicsPlugin.name;
  113021. };
  113022. /**
  113023. * Adding a new impostor for the impostor tracking.
  113024. * This will be done by the impostor itself.
  113025. * @param impostor the impostor to add
  113026. */
  113027. PhysicsEngine.prototype.addImpostor = function (impostor) {
  113028. impostor.uniqueId = this._impostors.push(impostor);
  113029. //if no parent, generate the body
  113030. if (!impostor.parent) {
  113031. this._physicsPlugin.generatePhysicsBody(impostor);
  113032. }
  113033. };
  113034. /**
  113035. * Remove an impostor from the engine.
  113036. * This impostor and its mesh will not longer be updated by the physics engine.
  113037. * @param impostor the impostor to remove
  113038. */
  113039. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  113040. var index = this._impostors.indexOf(impostor);
  113041. if (index > -1) {
  113042. var removed = this._impostors.splice(index, 1);
  113043. //Is it needed?
  113044. if (removed.length) {
  113045. //this will also remove it from the world.
  113046. removed[0].physicsBody = null;
  113047. }
  113048. }
  113049. };
  113050. /**
  113051. * Add a joint to the physics engine
  113052. * @param mainImpostor defines the main impostor to which the joint is added.
  113053. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113054. * @param joint defines the joint that will connect both impostors.
  113055. */
  113056. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  113057. var impostorJoint = {
  113058. mainImpostor: mainImpostor,
  113059. connectedImpostor: connectedImpostor,
  113060. joint: joint
  113061. };
  113062. joint.physicsPlugin = this._physicsPlugin;
  113063. this._joints.push(impostorJoint);
  113064. this._physicsPlugin.generateJoint(impostorJoint);
  113065. };
  113066. /**
  113067. * Removes a joint from the simulation
  113068. * @param mainImpostor defines the impostor used with the joint
  113069. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113070. * @param joint defines the joint to remove
  113071. */
  113072. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  113073. var matchingJoints = this._joints.filter(function (impostorJoint) {
  113074. return (impostorJoint.connectedImpostor === connectedImpostor
  113075. && impostorJoint.joint === joint
  113076. && impostorJoint.mainImpostor === mainImpostor);
  113077. });
  113078. if (matchingJoints.length) {
  113079. this._physicsPlugin.removeJoint(matchingJoints[0]);
  113080. //TODO remove it from the list as well
  113081. }
  113082. };
  113083. /**
  113084. * Called by the scene. No need to call it.
  113085. * @param delta defines the timespam between frames
  113086. */
  113087. PhysicsEngine.prototype._step = function (delta) {
  113088. var _this = this;
  113089. //check if any mesh has no body / requires an update
  113090. this._impostors.forEach(function (impostor) {
  113091. if (impostor.isBodyInitRequired()) {
  113092. _this._physicsPlugin.generatePhysicsBody(impostor);
  113093. }
  113094. });
  113095. if (delta > 0.1) {
  113096. delta = 0.1;
  113097. }
  113098. else if (delta <= 0) {
  113099. delta = 1.0 / 60.0;
  113100. }
  113101. this._physicsPlugin.executeStep(delta, this._impostors);
  113102. };
  113103. /**
  113104. * Gets the current plugin used to run the simulation
  113105. * @returns current plugin
  113106. */
  113107. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  113108. return this._physicsPlugin;
  113109. };
  113110. /**
  113111. * Gets the list of physic impostors
  113112. * @returns an array of PhysicsImpostor
  113113. */
  113114. PhysicsEngine.prototype.getImpostors = function () {
  113115. return this._impostors;
  113116. };
  113117. /**
  113118. * Gets the impostor for a physics enabled object
  113119. * @param object defines the object impersonated by the impostor
  113120. * @returns the PhysicsImpostor or null if not found
  113121. */
  113122. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  113123. for (var i = 0; i < this._impostors.length; ++i) {
  113124. if (this._impostors[i].object === object) {
  113125. return this._impostors[i];
  113126. }
  113127. }
  113128. return null;
  113129. };
  113130. /**
  113131. * Gets the impostor for a physics body object
  113132. * @param body defines physics body used by the impostor
  113133. * @returns the PhysicsImpostor or null if not found
  113134. */
  113135. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  113136. for (var i = 0; i < this._impostors.length; ++i) {
  113137. if (this._impostors[i].physicsBody === body) {
  113138. return this._impostors[i];
  113139. }
  113140. }
  113141. return null;
  113142. };
  113143. /**
  113144. * Global value used to control the smallest number supported by the simulation
  113145. */
  113146. PhysicsEngine.Epsilon = 0.001;
  113147. return PhysicsEngine;
  113148. }());
  113149. /***/ }),
  113150. /***/ "./Physics/physicsEngineComponent.ts":
  113151. /*!*******************************************!*\
  113152. !*** ./Physics/physicsEngineComponent.ts ***!
  113153. \*******************************************/
  113154. /*! exports provided: PhysicsEngineSceneComponent */
  113155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113156. "use strict";
  113157. __webpack_require__.r(__webpack_exports__);
  113158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  113159. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  113160. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  113161. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  113162. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  113163. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  113164. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  113165. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  113166. /**
  113167. * Gets the current physics engine
  113168. * @returns a IPhysicsEngine or null if none attached
  113169. */
  113170. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  113171. return this._physicsEngine;
  113172. };
  113173. /**
  113174. * Enables physics to the current scene
  113175. * @param gravity defines the scene's gravity for the physics engine
  113176. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  113177. * @return a boolean indicating if the physics engine was initialized
  113178. */
  113179. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  113180. if (gravity === void 0) { gravity = null; }
  113181. if (this._physicsEngine) {
  113182. return true;
  113183. }
  113184. // Register the component to the scene
  113185. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  113186. if (!component) {
  113187. component = new PhysicsEngineSceneComponent(this);
  113188. this._addComponent(component);
  113189. }
  113190. try {
  113191. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  113192. return true;
  113193. }
  113194. catch (e) {
  113195. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  113196. return false;
  113197. }
  113198. };
  113199. /**
  113200. * Disables and disposes the physics engine associated with the scene
  113201. */
  113202. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  113203. if (!this._physicsEngine) {
  113204. return;
  113205. }
  113206. this._physicsEngine.dispose();
  113207. this._physicsEngine = null;
  113208. };
  113209. /**
  113210. * Gets a boolean indicating if there is an active physics engine
  113211. * @returns a boolean indicating if there is an active physics engine
  113212. */
  113213. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  113214. return this._physicsEngine !== undefined;
  113215. };
  113216. /**
  113217. * Deletes a physics compound impostor
  113218. * @param compound defines the compound to delete
  113219. */
  113220. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  113221. var mesh = compound.parts[0].mesh;
  113222. if (mesh.physicsImpostor) {
  113223. mesh.physicsImpostor.dispose( /*true*/);
  113224. mesh.physicsImpostor = null;
  113225. }
  113226. };
  113227. /** @hidden */
  113228. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  113229. if (this._physicsEngine) {
  113230. this.onBeforePhysicsObservable.notifyObservers(this);
  113231. this._physicsEngine._step(step / 1000);
  113232. this.onAfterPhysicsObservable.notifyObservers(this);
  113233. }
  113234. };
  113235. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  113236. get: function () {
  113237. return this._physicsImpostor;
  113238. },
  113239. set: function (value) {
  113240. var _this = this;
  113241. if (this._physicsImpostor === value) {
  113242. return;
  113243. }
  113244. if (this._disposePhysicsObserver) {
  113245. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  113246. }
  113247. this._physicsImpostor = value;
  113248. if (value) {
  113249. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  113250. // Physics
  113251. if (_this.physicsImpostor) {
  113252. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  113253. _this.physicsImpostor = null;
  113254. }
  113255. });
  113256. }
  113257. },
  113258. enumerable: true,
  113259. configurable: true
  113260. });
  113261. /**
  113262. * Gets the current physics impostor
  113263. * @see http://doc.babylonjs.com/features/physics_engine
  113264. * @returns a physics impostor or null
  113265. */
  113266. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  113267. return this.physicsImpostor;
  113268. };
  113269. /**
  113270. * Apply a physic impulse to the mesh
  113271. * @param force defines the force to apply
  113272. * @param contactPoint defines where to apply the force
  113273. * @returns the current mesh
  113274. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  113275. */
  113276. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  113277. if (!this.physicsImpostor) {
  113278. return this;
  113279. }
  113280. this.physicsImpostor.applyImpulse(force, contactPoint);
  113281. return this;
  113282. };
  113283. /**
  113284. * Creates a physic joint between two meshes
  113285. * @param otherMesh defines the other mesh to use
  113286. * @param pivot1 defines the pivot to use on this mesh
  113287. * @param pivot2 defines the pivot to use on the other mesh
  113288. * @param options defines additional options (can be plugin dependent)
  113289. * @returns the current mesh
  113290. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  113291. */
  113292. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  113293. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  113294. return this;
  113295. }
  113296. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  113297. mainPivot: pivot1,
  113298. connectedPivot: pivot2,
  113299. nativeParams: options
  113300. });
  113301. return this;
  113302. };
  113303. /**
  113304. * Defines the physics engine scene component responsible to manage a physics engine
  113305. */
  113306. var PhysicsEngineSceneComponent = /** @class */ (function () {
  113307. /**
  113308. * Creates a new instance of the component for the given scene
  113309. * @param scene Defines the scene to register the component in
  113310. */
  113311. function PhysicsEngineSceneComponent(scene) {
  113312. var _this = this;
  113313. /**
  113314. * The component name helpful to identify the component in the list of scene components.
  113315. */
  113316. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  113317. this.scene = scene;
  113318. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  113319. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  113320. // Replace the function used to get the deterministic frame time
  113321. this.scene.getDeterministicFrameTime = function () {
  113322. if (_this.scene._physicsEngine) {
  113323. return _this.scene._physicsEngine.getTimeStep() * 1000;
  113324. }
  113325. return 1000.0 / 60.0;
  113326. };
  113327. }
  113328. /**
  113329. * Registers the component in a given scene
  113330. */
  113331. PhysicsEngineSceneComponent.prototype.register = function () {
  113332. };
  113333. /**
  113334. * Rebuilds the elements related to this component in case of
  113335. * context lost for instance.
  113336. */
  113337. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  113338. // Nothing to do for this component
  113339. };
  113340. /**
  113341. * Disposes the component and the associated ressources
  113342. */
  113343. PhysicsEngineSceneComponent.prototype.dispose = function () {
  113344. this.scene.onBeforePhysicsObservable.clear();
  113345. this.scene.onAfterPhysicsObservable.clear();
  113346. if (this.scene._physicsEngine) {
  113347. this.scene.disablePhysicsEngine();
  113348. }
  113349. };
  113350. return PhysicsEngineSceneComponent;
  113351. }());
  113352. /***/ }),
  113353. /***/ "./Physics/physicsHelper.ts":
  113354. /*!**********************************!*\
  113355. !*** ./Physics/physicsHelper.ts ***!
  113356. \**********************************/
  113357. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  113358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113359. "use strict";
  113360. __webpack_require__.r(__webpack_exports__);
  113361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  113362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  113363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  113364. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  113365. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  113366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  113367. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  113368. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  113369. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  113370. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  113371. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  113372. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  113373. /**
  113374. * A helper for physics simulations
  113375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113376. */
  113377. var PhysicsHelper = /** @class */ (function () {
  113378. /**
  113379. * Initializes the Physics helper
  113380. * @param scene Babylon.js scene
  113381. */
  113382. function PhysicsHelper(scene) {
  113383. this._scene = scene;
  113384. this._physicsEngine = this._scene.getPhysicsEngine();
  113385. if (!this._physicsEngine) {
  113386. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  113387. }
  113388. }
  113389. /**
  113390. * Applies a radial explosion impulse
  113391. * @param origin the origin of the explosion
  113392. * @param radius the explosion radius
  113393. * @param strength the explosion strength
  113394. * @param falloff possible options: Constant & Linear. Defaults to Constant
  113395. * @returns A physics radial explosion event, or null
  113396. */
  113397. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  113398. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  113399. if (!this._physicsEngine) {
  113400. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  113401. return null;
  113402. }
  113403. var impostors = this._physicsEngine.getImpostors();
  113404. if (impostors.length === 0) {
  113405. return null;
  113406. }
  113407. var event = new PhysicsRadialExplosionEvent(this._scene);
  113408. impostors.forEach(function (impostor) {
  113409. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  113410. if (!impostorForceAndContactPoint) {
  113411. return;
  113412. }
  113413. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  113414. });
  113415. event.dispose(false);
  113416. return event;
  113417. };
  113418. /**
  113419. * Applies a radial explosion force
  113420. * @param origin the origin of the explosion
  113421. * @param radius the explosion radius
  113422. * @param strength the explosion strength
  113423. * @param falloff possible options: Constant & Linear. Defaults to Constant
  113424. * @returns A physics radial explosion event, or null
  113425. */
  113426. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  113427. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  113428. if (!this._physicsEngine) {
  113429. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  113430. return null;
  113431. }
  113432. var impostors = this._physicsEngine.getImpostors();
  113433. if (impostors.length === 0) {
  113434. return null;
  113435. }
  113436. var event = new PhysicsRadialExplosionEvent(this._scene);
  113437. impostors.forEach(function (impostor) {
  113438. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  113439. if (!impostorForceAndContactPoint) {
  113440. return;
  113441. }
  113442. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  113443. });
  113444. event.dispose(false);
  113445. return event;
  113446. };
  113447. /**
  113448. * Creates a gravitational field
  113449. * @param origin the origin of the explosion
  113450. * @param radius the explosion radius
  113451. * @param strength the explosion strength
  113452. * @param falloff possible options: Constant & Linear. Defaults to Constant
  113453. * @returns A physics gravitational field event, or null
  113454. */
  113455. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  113456. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  113457. if (!this._physicsEngine) {
  113458. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  113459. return null;
  113460. }
  113461. var impostors = this._physicsEngine.getImpostors();
  113462. if (impostors.length === 0) {
  113463. return null;
  113464. }
  113465. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  113466. event.dispose(false);
  113467. return event;
  113468. };
  113469. /**
  113470. * Creates a physics updraft event
  113471. * @param origin the origin of the updraft
  113472. * @param radius the radius of the updraft
  113473. * @param strength the strength of the updraft
  113474. * @param height the height of the updraft
  113475. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  113476. * @returns A physics updraft event, or null
  113477. */
  113478. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  113479. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  113480. if (!this._physicsEngine) {
  113481. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  113482. return null;
  113483. }
  113484. if (this._physicsEngine.getImpostors().length === 0) {
  113485. return null;
  113486. }
  113487. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  113488. event.dispose(false);
  113489. return event;
  113490. };
  113491. /**
  113492. * Creates a physics vortex event
  113493. * @param origin the of the vortex
  113494. * @param radius the radius of the vortex
  113495. * @param strength the strength of the vortex
  113496. * @param height the height of the vortex
  113497. * @returns a Physics vortex event, or null
  113498. * A physics vortex event or null
  113499. */
  113500. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  113501. if (!this._physicsEngine) {
  113502. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  113503. return null;
  113504. }
  113505. if (this._physicsEngine.getImpostors().length === 0) {
  113506. return null;
  113507. }
  113508. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  113509. event.dispose(false);
  113510. return event;
  113511. };
  113512. return PhysicsHelper;
  113513. }());
  113514. /**
  113515. * Represents a physics radial explosion event
  113516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113517. */
  113518. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  113519. /**
  113520. * Initializes a radial explosioin event
  113521. * @param scene BabylonJS scene
  113522. */
  113523. function PhysicsRadialExplosionEvent(scene) {
  113524. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  113525. this._rays = [];
  113526. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  113527. this._scene = scene;
  113528. }
  113529. /**
  113530. * Returns the data related to the radial explosion event (sphere & rays).
  113531. * @returns The radial explosion event data
  113532. */
  113533. PhysicsRadialExplosionEvent.prototype.getData = function () {
  113534. this._dataFetched = true;
  113535. return {
  113536. sphere: this._sphere,
  113537. rays: this._rays,
  113538. };
  113539. };
  113540. /**
  113541. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  113542. * @param impostor A physics imposter
  113543. * @param origin the origin of the explosion
  113544. * @param radius the explosion radius
  113545. * @param strength the explosion strength
  113546. * @param falloff possible options: Constant & Linear
  113547. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  113548. */
  113549. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  113550. if (impostor.mass === 0) {
  113551. return null;
  113552. }
  113553. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  113554. return null;
  113555. }
  113556. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  113557. return null;
  113558. }
  113559. var impostorObjectCenter = impostor.getObjectCenter();
  113560. var direction = impostorObjectCenter.subtract(origin);
  113561. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](origin, direction, radius);
  113562. this._rays.push(ray);
  113563. var hit = ray.intersectsMesh(impostor.object);
  113564. var contactPoint = hit.pickedPoint;
  113565. if (!contactPoint) {
  113566. return null;
  113567. }
  113568. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  113569. if (distanceFromOrigin > radius) {
  113570. return null;
  113571. }
  113572. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  113573. ? strength
  113574. : strength * (1 - (distanceFromOrigin / radius));
  113575. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  113576. return { force: force, contactPoint: contactPoint };
  113577. };
  113578. /**
  113579. * Disposes the sphere.
  113580. * @param force Specifies if the sphere should be disposed by force
  113581. */
  113582. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  113583. var _this = this;
  113584. if (force === void 0) { force = true; }
  113585. if (force) {
  113586. this._sphere.dispose();
  113587. }
  113588. else {
  113589. setTimeout(function () {
  113590. if (!_this._dataFetched) {
  113591. _this._sphere.dispose();
  113592. }
  113593. }, 0);
  113594. }
  113595. };
  113596. /*** Helpers ***/
  113597. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  113598. if (!this._sphere) {
  113599. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  113600. this._sphere.isVisible = false;
  113601. }
  113602. };
  113603. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  113604. var impostorObject = impostor.object;
  113605. this._prepareSphere();
  113606. this._sphere.position = origin;
  113607. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  113608. this._sphere._updateBoundingInfo();
  113609. this._sphere.computeWorldMatrix(true);
  113610. return this._sphere.intersectsMesh(impostorObject, true);
  113611. };
  113612. return PhysicsRadialExplosionEvent;
  113613. }());
  113614. /**
  113615. * Represents a gravitational field event
  113616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113617. */
  113618. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  113619. /**
  113620. * Initializes the physics gravitational field event
  113621. * @param physicsHelper A physics helper
  113622. * @param scene BabylonJS scene
  113623. * @param origin The origin position of the gravitational field event
  113624. * @param radius The radius of the gravitational field event
  113625. * @param strength The strength of the gravitational field event
  113626. * @param falloff The falloff for the gravitational field event
  113627. */
  113628. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  113629. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  113630. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  113631. this._physicsHelper = physicsHelper;
  113632. this._scene = scene;
  113633. this._origin = origin;
  113634. this._radius = radius;
  113635. this._strength = strength;
  113636. this._falloff = falloff;
  113637. this._tickCallback = this._tick.bind(this);
  113638. }
  113639. /**
  113640. * Returns the data related to the gravitational field event (sphere).
  113641. * @returns A gravitational field event
  113642. */
  113643. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  113644. this._dataFetched = true;
  113645. return {
  113646. sphere: this._sphere,
  113647. };
  113648. };
  113649. /**
  113650. * Enables the gravitational field.
  113651. */
  113652. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  113653. this._tickCallback.call(this);
  113654. this._scene.registerBeforeRender(this._tickCallback);
  113655. };
  113656. /**
  113657. * Disables the gravitational field.
  113658. */
  113659. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  113660. this._scene.unregisterBeforeRender(this._tickCallback);
  113661. };
  113662. /**
  113663. * Disposes the sphere.
  113664. * @param force The force to dispose from the gravitational field event
  113665. */
  113666. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  113667. var _this = this;
  113668. if (force === void 0) { force = true; }
  113669. if (force) {
  113670. this._sphere.dispose();
  113671. }
  113672. else {
  113673. setTimeout(function () {
  113674. if (!_this._dataFetched) {
  113675. _this._sphere.dispose();
  113676. }
  113677. }, 0);
  113678. }
  113679. };
  113680. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  113681. // Since the params won't change, we fetch the event only once
  113682. if (this._sphere) {
  113683. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  113684. }
  113685. else {
  113686. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  113687. if (radialExplosionEvent) {
  113688. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  113689. }
  113690. }
  113691. };
  113692. return PhysicsGravitationalFieldEvent;
  113693. }());
  113694. /**
  113695. * Represents a physics updraft event
  113696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113697. */
  113698. var PhysicsUpdraftEvent = /** @class */ (function () {
  113699. /**
  113700. * Initializes the physics updraft event
  113701. * @param _scene BabylonJS scene
  113702. * @param _origin The origin position of the updraft
  113703. * @param _radius The radius of the updraft
  113704. * @param _strength The strength of the updraft
  113705. * @param _height The height of the updraft
  113706. * @param _updraftMode The mode of the updraft
  113707. */
  113708. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  113709. this._scene = _scene;
  113710. this._origin = _origin;
  113711. this._radius = _radius;
  113712. this._strength = _strength;
  113713. this._height = _height;
  113714. this._updraftMode = _updraftMode;
  113715. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  113716. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  113717. 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
  113718. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  113719. this._physicsEngine = this._scene.getPhysicsEngine();
  113720. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  113721. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  113722. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  113723. this._originDirection = this._origin.subtract(this._originTop).normalize();
  113724. }
  113725. this._tickCallback = this._tick.bind(this);
  113726. this._prepareCylinder();
  113727. }
  113728. /**
  113729. * Returns the data related to the updraft event (cylinder).
  113730. * @returns A physics updraft event
  113731. */
  113732. PhysicsUpdraftEvent.prototype.getData = function () {
  113733. this._dataFetched = true;
  113734. return {
  113735. cylinder: this._cylinder,
  113736. };
  113737. };
  113738. /**
  113739. * Enables the updraft.
  113740. */
  113741. PhysicsUpdraftEvent.prototype.enable = function () {
  113742. this._tickCallback.call(this);
  113743. this._scene.registerBeforeRender(this._tickCallback);
  113744. };
  113745. /**
  113746. * Disables the cortex.
  113747. */
  113748. PhysicsUpdraftEvent.prototype.disable = function () {
  113749. this._scene.unregisterBeforeRender(this._tickCallback);
  113750. };
  113751. /**
  113752. * Disposes the sphere.
  113753. * @param force Specifies if the updraft should be disposed by force
  113754. */
  113755. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  113756. var _this = this;
  113757. if (force === void 0) { force = true; }
  113758. if (!this._cylinder) {
  113759. return;
  113760. }
  113761. if (force) {
  113762. this._cylinder.dispose();
  113763. }
  113764. else {
  113765. setTimeout(function () {
  113766. if (!_this._dataFetched) {
  113767. _this._cylinder.dispose();
  113768. }
  113769. }, 0);
  113770. }
  113771. };
  113772. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  113773. if (impostor.mass === 0) {
  113774. return null;
  113775. }
  113776. if (!this._intersectsWithCylinder(impostor)) {
  113777. return null;
  113778. }
  113779. var impostorObjectCenter = impostor.getObjectCenter();
  113780. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  113781. var direction = this._originDirection;
  113782. }
  113783. else {
  113784. var direction = impostorObjectCenter.subtract(this._originTop);
  113785. }
  113786. var multiplier = this._strength * -1;
  113787. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  113788. return { force: force, contactPoint: impostorObjectCenter };
  113789. };
  113790. PhysicsUpdraftEvent.prototype._tick = function () {
  113791. var _this = this;
  113792. this._physicsEngine.getImpostors().forEach(function (impostor) {
  113793. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  113794. if (!impostorForceAndContactPoint) {
  113795. return;
  113796. }
  113797. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  113798. });
  113799. };
  113800. /*** Helpers ***/
  113801. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  113802. if (!this._cylinder) {
  113803. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  113804. height: this._height,
  113805. diameter: this._radius * 2,
  113806. }, this._scene);
  113807. this._cylinder.isVisible = false;
  113808. }
  113809. };
  113810. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  113811. var impostorObject = impostor.object;
  113812. this._cylinder.position = this._cylinderPosition;
  113813. return this._cylinder.intersectsMesh(impostorObject, true);
  113814. };
  113815. return PhysicsUpdraftEvent;
  113816. }());
  113817. /**
  113818. * Represents a physics vortex event
  113819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113820. */
  113821. var PhysicsVortexEvent = /** @class */ (function () {
  113822. /**
  113823. * Initializes the physics vortex event
  113824. * @param _scene The BabylonJS scene
  113825. * @param _origin The origin position of the vortex
  113826. * @param _radius The radius of the vortex
  113827. * @param _strength The strength of the vortex
  113828. * @param _height The height of the vortex
  113829. */
  113830. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  113831. this._scene = _scene;
  113832. this._origin = _origin;
  113833. this._radius = _radius;
  113834. this._strength = _strength;
  113835. this._height = _height;
  113836. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  113837. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  113838. this._updraftMultiplier = 0.02;
  113839. 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
  113840. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  113841. this._physicsEngine = this._scene.getPhysicsEngine();
  113842. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  113843. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  113844. this._tickCallback = this._tick.bind(this);
  113845. this._prepareCylinder();
  113846. }
  113847. /**
  113848. * Returns the data related to the vortex event (cylinder).
  113849. * @returns The physics vortex event data
  113850. */
  113851. PhysicsVortexEvent.prototype.getData = function () {
  113852. this._dataFetched = true;
  113853. return {
  113854. cylinder: this._cylinder,
  113855. };
  113856. };
  113857. /**
  113858. * Enables the vortex.
  113859. */
  113860. PhysicsVortexEvent.prototype.enable = function () {
  113861. this._tickCallback.call(this);
  113862. this._scene.registerBeforeRender(this._tickCallback);
  113863. };
  113864. /**
  113865. * Disables the cortex.
  113866. */
  113867. PhysicsVortexEvent.prototype.disable = function () {
  113868. this._scene.unregisterBeforeRender(this._tickCallback);
  113869. };
  113870. /**
  113871. * Disposes the sphere.
  113872. * @param force
  113873. */
  113874. PhysicsVortexEvent.prototype.dispose = function (force) {
  113875. var _this = this;
  113876. if (force === void 0) { force = true; }
  113877. if (force) {
  113878. this._cylinder.dispose();
  113879. }
  113880. else {
  113881. setTimeout(function () {
  113882. if (!_this._dataFetched) {
  113883. _this._cylinder.dispose();
  113884. }
  113885. }, 0);
  113886. }
  113887. };
  113888. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  113889. if (impostor.mass === 0) {
  113890. return null;
  113891. }
  113892. if (!this._intersectsWithCylinder(impostor)) {
  113893. return null;
  113894. }
  113895. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  113896. return null;
  113897. }
  113898. var impostorObjectCenter = impostor.getObjectCenter();
  113899. 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)
  113900. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  113901. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  113902. var hit = ray.intersectsMesh(impostor.object);
  113903. var contactPoint = hit.pickedPoint;
  113904. if (!contactPoint) {
  113905. return null;
  113906. }
  113907. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  113908. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  113909. var directionToOrigin = contactPoint.normalize();
  113910. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  113911. directionToOrigin = directionToOrigin.negate();
  113912. }
  113913. // TODO: find a more physically based solution
  113914. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  113915. var forceX = directionToOrigin.x * this._strength / 8;
  113916. var forceY = directionToOrigin.y * this._updraftMultiplier;
  113917. var forceZ = directionToOrigin.z * this._strength / 8;
  113918. }
  113919. else {
  113920. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  113921. var forceY = this._originTop.y * this._updraftMultiplier;
  113922. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  113923. }
  113924. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  113925. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  113926. return { force: force, contactPoint: impostorObjectCenter };
  113927. };
  113928. PhysicsVortexEvent.prototype._tick = function () {
  113929. var _this = this;
  113930. this._physicsEngine.getImpostors().forEach(function (impostor) {
  113931. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  113932. if (!impostorForceAndContactPoint) {
  113933. return;
  113934. }
  113935. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  113936. });
  113937. };
  113938. /*** Helpers ***/
  113939. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  113940. if (!this._cylinder) {
  113941. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  113942. height: this._height,
  113943. diameter: this._radius * 2,
  113944. }, this._scene);
  113945. this._cylinder.isVisible = false;
  113946. }
  113947. };
  113948. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  113949. var impostorObject = impostor.object;
  113950. this._cylinder.position = this._cylinderPosition;
  113951. return this._cylinder.intersectsMesh(impostorObject, true);
  113952. };
  113953. return PhysicsVortexEvent;
  113954. }());
  113955. /**
  113956. * The strenght of the force in correspondence to the distance of the affected object
  113957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113958. */
  113959. var PhysicsRadialImpulseFalloff;
  113960. (function (PhysicsRadialImpulseFalloff) {
  113961. /** Defines that impulse is constant in strength across it's whole radius */
  113962. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  113963. /** DEfines that impulse gets weaker if it's further from the origin */
  113964. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  113965. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  113966. /**
  113967. * The strength of the force in correspondence to the distance of the affected object
  113968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113969. */
  113970. var PhysicsUpdraftMode;
  113971. (function (PhysicsUpdraftMode) {
  113972. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  113973. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  113974. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  113975. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  113976. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  113977. /***/ }),
  113978. /***/ "./Physics/physicsImpostor.ts":
  113979. /*!************************************!*\
  113980. !*** ./Physics/physicsImpostor.ts ***!
  113981. \************************************/
  113982. /*! exports provided: PhysicsImpostor */
  113983. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113984. "use strict";
  113985. __webpack_require__.r(__webpack_exports__);
  113986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  113987. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  113988. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  113989. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  113990. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  113991. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  113992. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  113993. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  113994. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  113995. mass: jsonObject.physicsMass,
  113996. friction: jsonObject.physicsFriction,
  113997. restitution: jsonObject.physicsRestitution
  113998. }, scene);
  113999. };
  114000. /**
  114001. * Represents a physics imposter
  114002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114003. */
  114004. var PhysicsImpostor = /** @class */ (function () {
  114005. /**
  114006. * Initializes the physics imposter
  114007. * @param object The physics-enabled object used as the physics imposter
  114008. * @param type The type of the physics imposter
  114009. * @param _options The options for the physics imposter
  114010. * @param _scene The Babylon scene
  114011. */
  114012. function PhysicsImpostor(
  114013. /**
  114014. * The physics-enabled object used as the physics imposter
  114015. */
  114016. object,
  114017. /**
  114018. * The type of the physics imposter
  114019. */
  114020. type, _options, _scene) {
  114021. if (_options === void 0) { _options = { mass: 0 }; }
  114022. var _this = this;
  114023. this.object = object;
  114024. this.type = type;
  114025. this._options = _options;
  114026. this._scene = _scene;
  114027. this._bodyUpdateRequired = false;
  114028. this._onBeforePhysicsStepCallbacks = new Array();
  114029. this._onAfterPhysicsStepCallbacks = new Array();
  114030. /** @hidden */
  114031. this._onPhysicsCollideCallbacks = [];
  114032. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  114033. this._isDisposed = false;
  114034. //temp variables for parent rotation calculations
  114035. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  114036. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  114037. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  114038. /**
  114039. * this function is executed by the physics engine.
  114040. */
  114041. this.beforeStep = function () {
  114042. if (!_this._physicsEngine) {
  114043. return;
  114044. }
  114045. _this.object.translate(_this._deltaPosition, -1);
  114046. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  114047. _this.object.computeWorldMatrix(false);
  114048. if (_this.object.parent && _this.object.rotationQuaternion) {
  114049. _this.getParentsRotation();
  114050. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  114051. }
  114052. else {
  114053. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  114054. }
  114055. if (!_this._options.disableBidirectionalTransformation) {
  114056. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  114057. }
  114058. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  114059. func(_this);
  114060. });
  114061. };
  114062. /**
  114063. * this function is executed by the physics engine
  114064. */
  114065. this.afterStep = function () {
  114066. if (!_this._physicsEngine) {
  114067. return;
  114068. }
  114069. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  114070. func(_this);
  114071. });
  114072. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  114073. // object has now its world rotation. needs to be converted to local.
  114074. if (_this.object.parent && _this.object.rotationQuaternion) {
  114075. _this.getParentsRotation();
  114076. _this._tmpQuat.conjugateInPlace();
  114077. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  114078. }
  114079. // take the position set and make it the absolute position of this object.
  114080. _this.object.setAbsolutePosition(_this.object.position);
  114081. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  114082. _this.object.translate(_this._deltaPosition, 1);
  114083. };
  114084. /**
  114085. * Legacy collision detection event support
  114086. */
  114087. this.onCollideEvent = null;
  114088. /**
  114089. * event and body object due to cannon's event-based architecture.
  114090. */
  114091. this.onCollide = function (e) {
  114092. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  114093. return;
  114094. }
  114095. if (!_this._physicsEngine) {
  114096. return;
  114097. }
  114098. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  114099. if (otherImpostor) {
  114100. // Legacy collision detection event support
  114101. if (_this.onCollideEvent) {
  114102. _this.onCollideEvent(_this, otherImpostor);
  114103. }
  114104. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  114105. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  114106. }).forEach(function (obj) {
  114107. obj.callback(_this, otherImpostor);
  114108. });
  114109. }
  114110. };
  114111. //sanity check!
  114112. if (!this.object) {
  114113. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  114114. return;
  114115. }
  114116. // Legacy support for old syntax.
  114117. if (!this._scene && object.getScene) {
  114118. this._scene = object.getScene();
  114119. }
  114120. if (!this._scene) {
  114121. return;
  114122. }
  114123. this._physicsEngine = this._scene.getPhysicsEngine();
  114124. if (!this._physicsEngine) {
  114125. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  114126. }
  114127. else {
  114128. //set the object's quaternion, if not set
  114129. if (!this.object.rotationQuaternion) {
  114130. if (this.object.rotation) {
  114131. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  114132. }
  114133. else {
  114134. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  114135. }
  114136. }
  114137. //default options params
  114138. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  114139. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  114140. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  114141. this._joints = [];
  114142. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  114143. if (!this.object.parent || this._options.ignoreParent) {
  114144. this._init();
  114145. }
  114146. else if (this.object.parent.physicsImpostor) {
  114147. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  114148. }
  114149. }
  114150. }
  114151. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  114152. /**
  114153. * Specifies if the physics imposter is disposed
  114154. */
  114155. get: function () {
  114156. return this._isDisposed;
  114157. },
  114158. enumerable: true,
  114159. configurable: true
  114160. });
  114161. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  114162. /**
  114163. * Gets the mass of the physics imposter
  114164. */
  114165. get: function () {
  114166. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  114167. },
  114168. set: function (value) {
  114169. this.setMass(value);
  114170. },
  114171. enumerable: true,
  114172. configurable: true
  114173. });
  114174. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  114175. /**
  114176. * Gets the coefficient of friction
  114177. */
  114178. get: function () {
  114179. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  114180. },
  114181. /**
  114182. * Sets the coefficient of friction
  114183. */
  114184. set: function (value) {
  114185. if (!this._physicsEngine) {
  114186. return;
  114187. }
  114188. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  114189. },
  114190. enumerable: true,
  114191. configurable: true
  114192. });
  114193. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  114194. /**
  114195. * Gets the coefficient of restitution
  114196. */
  114197. get: function () {
  114198. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  114199. },
  114200. /**
  114201. * Sets the coefficient of restitution
  114202. */
  114203. set: function (value) {
  114204. if (!this._physicsEngine) {
  114205. return;
  114206. }
  114207. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  114208. },
  114209. enumerable: true,
  114210. configurable: true
  114211. });
  114212. /**
  114213. * This function will completly initialize this impostor.
  114214. * It will create a new body - but only if this mesh has no parent.
  114215. * If it has, this impostor will not be used other than to define the impostor
  114216. * of the child mesh.
  114217. * @hidden
  114218. */
  114219. PhysicsImpostor.prototype._init = function () {
  114220. if (!this._physicsEngine) {
  114221. return;
  114222. }
  114223. this._physicsEngine.removeImpostor(this);
  114224. this.physicsBody = null;
  114225. this._parent = this._parent || this._getPhysicsParent();
  114226. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  114227. this._physicsEngine.addImpostor(this);
  114228. }
  114229. };
  114230. PhysicsImpostor.prototype._getPhysicsParent = function () {
  114231. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  114232. var parentMesh = this.object.parent;
  114233. return parentMesh.physicsImpostor;
  114234. }
  114235. return null;
  114236. };
  114237. /**
  114238. * Should a new body be generated.
  114239. * @returns boolean specifying if body initialization is required
  114240. */
  114241. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  114242. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  114243. };
  114244. /**
  114245. * Sets the updated scaling
  114246. * @param updated Specifies if the scaling is updated
  114247. */
  114248. PhysicsImpostor.prototype.setScalingUpdated = function () {
  114249. this.forceUpdate();
  114250. };
  114251. /**
  114252. * Force a regeneration of this or the parent's impostor's body.
  114253. * Use under cautious - This will remove all joints already implemented.
  114254. */
  114255. PhysicsImpostor.prototype.forceUpdate = function () {
  114256. this._init();
  114257. if (this.parent && !this._options.ignoreParent) {
  114258. this.parent.forceUpdate();
  114259. }
  114260. };
  114261. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  114262. /*public get mesh(): AbstractMesh {
  114263. return this._mesh;
  114264. }*/
  114265. /**
  114266. * Gets the body that holds this impostor. Either its own, or its parent.
  114267. */
  114268. get: function () {
  114269. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  114270. },
  114271. /**
  114272. * Set the physics body. Used mainly by the physics engine/plugin
  114273. */
  114274. set: function (physicsBody) {
  114275. if (this._physicsBody && this._physicsEngine) {
  114276. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  114277. }
  114278. this._physicsBody = physicsBody;
  114279. this.resetUpdateFlags();
  114280. },
  114281. enumerable: true,
  114282. configurable: true
  114283. });
  114284. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  114285. /**
  114286. * Get the parent of the physics imposter
  114287. * @returns Physics imposter or null
  114288. */
  114289. get: function () {
  114290. return !this._options.ignoreParent && this._parent ? this._parent : null;
  114291. },
  114292. /**
  114293. * Sets the parent of the physics imposter
  114294. */
  114295. set: function (value) {
  114296. this._parent = value;
  114297. },
  114298. enumerable: true,
  114299. configurable: true
  114300. });
  114301. /**
  114302. * Resets the update flags
  114303. */
  114304. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  114305. this._bodyUpdateRequired = false;
  114306. };
  114307. /**
  114308. * Gets the object extend size
  114309. * @returns the object extend size
  114310. */
  114311. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  114312. if (this.object.getBoundingInfo) {
  114313. var q = this.object.rotationQuaternion;
  114314. //reset rotation
  114315. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  114316. //calculate the world matrix with no rotation
  114317. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  114318. var boundingInfo = this.object.getBoundingInfo();
  114319. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  114320. //bring back the rotation
  114321. this.object.rotationQuaternion = q;
  114322. //calculate the world matrix with the new rotation
  114323. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  114324. return size;
  114325. }
  114326. else {
  114327. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  114328. }
  114329. };
  114330. /**
  114331. * Gets the object center
  114332. * @returns The object center
  114333. */
  114334. PhysicsImpostor.prototype.getObjectCenter = function () {
  114335. if (this.object.getBoundingInfo) {
  114336. var boundingInfo = this.object.getBoundingInfo();
  114337. return boundingInfo.boundingBox.centerWorld;
  114338. }
  114339. else {
  114340. return this.object.position;
  114341. }
  114342. };
  114343. /**
  114344. * Get a specific parametes from the options parameter
  114345. * @param paramName The object parameter name
  114346. * @returns The object parameter
  114347. */
  114348. PhysicsImpostor.prototype.getParam = function (paramName) {
  114349. return this._options[paramName];
  114350. };
  114351. /**
  114352. * Sets a specific parameter in the options given to the physics plugin
  114353. * @param paramName The parameter name
  114354. * @param value The value of the parameter
  114355. */
  114356. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  114357. this._options[paramName] = value;
  114358. this._bodyUpdateRequired = true;
  114359. };
  114360. /**
  114361. * Specifically change the body's mass option. Won't recreate the physics body object
  114362. * @param mass The mass of the physics imposter
  114363. */
  114364. PhysicsImpostor.prototype.setMass = function (mass) {
  114365. if (this.getParam("mass") !== mass) {
  114366. this.setParam("mass", mass);
  114367. }
  114368. if (this._physicsEngine) {
  114369. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  114370. }
  114371. };
  114372. /**
  114373. * Gets the linear velocity
  114374. * @returns linear velocity or null
  114375. */
  114376. PhysicsImpostor.prototype.getLinearVelocity = function () {
  114377. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  114378. };
  114379. /**
  114380. * Sets the linear velocity
  114381. * @param velocity linear velocity or null
  114382. */
  114383. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  114384. if (this._physicsEngine) {
  114385. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  114386. }
  114387. };
  114388. /**
  114389. * Gets the angular velocity
  114390. * @returns angular velocity or null
  114391. */
  114392. PhysicsImpostor.prototype.getAngularVelocity = function () {
  114393. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  114394. };
  114395. /**
  114396. * Sets the angular velocity
  114397. * @param velocity The velocity or null
  114398. */
  114399. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  114400. if (this._physicsEngine) {
  114401. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  114402. }
  114403. };
  114404. /**
  114405. * Execute a function with the physics plugin native code
  114406. * Provide a function the will have two variables - the world object and the physics body object
  114407. * @param func The function to execute with the physics plugin native code
  114408. */
  114409. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  114410. if (this._physicsEngine) {
  114411. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  114412. }
  114413. };
  114414. /**
  114415. * Register a function that will be executed before the physics world is stepping forward
  114416. * @param func The function to execute before the physics world is stepped forward
  114417. */
  114418. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  114419. this._onBeforePhysicsStepCallbacks.push(func);
  114420. };
  114421. /**
  114422. * Unregister a function that will be executed before the physics world is stepping forward
  114423. * @param func The function to execute before the physics world is stepped forward
  114424. */
  114425. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  114426. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  114427. if (index > -1) {
  114428. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  114429. }
  114430. else {
  114431. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  114432. }
  114433. };
  114434. /**
  114435. * Register a function that will be executed after the physics step
  114436. * @param func The function to execute after physics step
  114437. */
  114438. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  114439. this._onAfterPhysicsStepCallbacks.push(func);
  114440. };
  114441. /**
  114442. * Unregisters a function that will be executed after the physics step
  114443. * @param func The function to execute after physics step
  114444. */
  114445. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  114446. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  114447. if (index > -1) {
  114448. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  114449. }
  114450. else {
  114451. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  114452. }
  114453. };
  114454. /**
  114455. * register a function that will be executed when this impostor collides against a different body
  114456. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  114457. * @param func Callback that is executed on collision
  114458. */
  114459. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  114460. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  114461. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  114462. };
  114463. /**
  114464. * Unregisters the physics imposter on contact
  114465. * @param collideAgainst The physics object to collide against
  114466. * @param func Callback to execute on collision
  114467. */
  114468. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  114469. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  114470. var index = -1;
  114471. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  114472. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  114473. // chcek the arrays match
  114474. var sameList = cbDef.otherImpostors.every(function (impostor) {
  114475. return collidedAgainstList.indexOf(impostor) > -1;
  114476. });
  114477. if (sameList) {
  114478. index = idx;
  114479. }
  114480. return sameList;
  114481. }
  114482. return false;
  114483. });
  114484. if (found) {
  114485. this._onPhysicsCollideCallbacks.splice(index, 1);
  114486. }
  114487. else {
  114488. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  114489. }
  114490. };
  114491. /**
  114492. * Get the parent rotation
  114493. * @returns The parent rotation
  114494. */
  114495. PhysicsImpostor.prototype.getParentsRotation = function () {
  114496. var parent = this.object.parent;
  114497. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  114498. while (parent) {
  114499. if (parent.rotationQuaternion) {
  114500. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  114501. }
  114502. else {
  114503. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  114504. }
  114505. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  114506. parent = parent.parent;
  114507. }
  114508. return this._tmpQuat;
  114509. };
  114510. /**
  114511. * Apply a force
  114512. * @param force The force to apply
  114513. * @param contactPoint The contact point for the force
  114514. * @returns The physics imposter
  114515. */
  114516. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  114517. if (this._physicsEngine) {
  114518. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  114519. }
  114520. return this;
  114521. };
  114522. /**
  114523. * Apply an impulse
  114524. * @param force The impulse force
  114525. * @param contactPoint The contact point for the impulse force
  114526. * @returns The physics imposter
  114527. */
  114528. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  114529. if (this._physicsEngine) {
  114530. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  114531. }
  114532. return this;
  114533. };
  114534. /**
  114535. * A help function to create a joint
  114536. * @param otherImpostor A physics imposter used to create a joint
  114537. * @param jointType The type of joint
  114538. * @param jointData The data for the joint
  114539. * @returns The physics imposter
  114540. */
  114541. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  114542. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  114543. this.addJoint(otherImpostor, joint);
  114544. return this;
  114545. };
  114546. /**
  114547. * Add a joint to this impostor with a different impostor
  114548. * @param otherImpostor A physics imposter used to add a joint
  114549. * @param joint The joint to add
  114550. * @returns The physics imposter
  114551. */
  114552. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  114553. this._joints.push({
  114554. otherImpostor: otherImpostor,
  114555. joint: joint
  114556. });
  114557. if (this._physicsEngine) {
  114558. this._physicsEngine.addJoint(this, otherImpostor, joint);
  114559. }
  114560. return this;
  114561. };
  114562. /**
  114563. * Will keep this body still, in a sleep mode.
  114564. * @returns the physics imposter
  114565. */
  114566. PhysicsImpostor.prototype.sleep = function () {
  114567. if (this._physicsEngine) {
  114568. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  114569. }
  114570. return this;
  114571. };
  114572. /**
  114573. * Wake the body up.
  114574. * @returns The physics imposter
  114575. */
  114576. PhysicsImpostor.prototype.wakeUp = function () {
  114577. if (this._physicsEngine) {
  114578. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  114579. }
  114580. return this;
  114581. };
  114582. /**
  114583. * Clones the physics imposter
  114584. * @param newObject The physics imposter clones to this physics-enabled object
  114585. * @returns A nullable physics imposter
  114586. */
  114587. PhysicsImpostor.prototype.clone = function (newObject) {
  114588. if (!newObject) {
  114589. return null;
  114590. }
  114591. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  114592. };
  114593. /**
  114594. * Disposes the physics imposter
  114595. */
  114596. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  114597. var _this = this;
  114598. //no dispose if no physics engine is available.
  114599. if (!this._physicsEngine) {
  114600. return;
  114601. }
  114602. this._joints.forEach(function (j) {
  114603. if (_this._physicsEngine) {
  114604. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  114605. }
  114606. });
  114607. //dispose the physics body
  114608. this._physicsEngine.removeImpostor(this);
  114609. if (this.parent) {
  114610. this.parent.forceUpdate();
  114611. }
  114612. else {
  114613. /*this._object.getChildMeshes().forEach(function(mesh) {
  114614. if (mesh.physicsImpostor) {
  114615. if (disposeChildren) {
  114616. mesh.physicsImpostor.dispose();
  114617. mesh.physicsImpostor = null;
  114618. }
  114619. }
  114620. })*/
  114621. }
  114622. this._isDisposed = true;
  114623. };
  114624. /**
  114625. * Sets the delta position
  114626. * @param position The delta position amount
  114627. */
  114628. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  114629. this._deltaPosition.copyFrom(position);
  114630. };
  114631. /**
  114632. * Sets the delta rotation
  114633. * @param rotation The delta rotation amount
  114634. */
  114635. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  114636. if (!this._deltaRotation) {
  114637. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  114638. }
  114639. this._deltaRotation.copyFrom(rotation);
  114640. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  114641. };
  114642. /**
  114643. * Gets the box size of the physics imposter and stores the result in the input parameter
  114644. * @param result Stores the box size
  114645. * @returns The physics imposter
  114646. */
  114647. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  114648. if (this._physicsEngine) {
  114649. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  114650. }
  114651. return this;
  114652. };
  114653. /**
  114654. * Gets the radius of the physics imposter
  114655. * @returns Radius of the physics imposter
  114656. */
  114657. PhysicsImpostor.prototype.getRadius = function () {
  114658. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  114659. };
  114660. /**
  114661. * Sync a bone with this impostor
  114662. * @param bone The bone to sync to the impostor.
  114663. * @param boneMesh The mesh that the bone is influencing.
  114664. * @param jointPivot The pivot of the joint / bone in local space.
  114665. * @param distToJoint Optional distance from the impostor to the joint.
  114666. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  114667. */
  114668. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  114669. var tempVec = PhysicsImpostor._tmpVecs[0];
  114670. var mesh = this.object;
  114671. if (mesh.rotationQuaternion) {
  114672. if (adjustRotation) {
  114673. var tempQuat = PhysicsImpostor._tmpQuat;
  114674. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  114675. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  114676. }
  114677. else {
  114678. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  114679. }
  114680. }
  114681. tempVec.x = 0;
  114682. tempVec.y = 0;
  114683. tempVec.z = 0;
  114684. if (jointPivot) {
  114685. tempVec.x = jointPivot.x;
  114686. tempVec.y = jointPivot.y;
  114687. tempVec.z = jointPivot.z;
  114688. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  114689. if (distToJoint === undefined || distToJoint === null) {
  114690. distToJoint = jointPivot.length();
  114691. }
  114692. tempVec.x *= distToJoint;
  114693. tempVec.y *= distToJoint;
  114694. tempVec.z *= distToJoint;
  114695. }
  114696. if (bone.getParent()) {
  114697. tempVec.addInPlace(mesh.getAbsolutePosition());
  114698. bone.setAbsolutePosition(tempVec, boneMesh);
  114699. }
  114700. else {
  114701. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  114702. boneMesh.position.x -= tempVec.x;
  114703. boneMesh.position.y -= tempVec.y;
  114704. boneMesh.position.z -= tempVec.z;
  114705. }
  114706. };
  114707. /**
  114708. * Sync impostor to a bone
  114709. * @param bone The bone that the impostor will be synced to.
  114710. * @param boneMesh The mesh that the bone is influencing.
  114711. * @param jointPivot The pivot of the joint / bone in local space.
  114712. * @param distToJoint Optional distance from the impostor to the joint.
  114713. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  114714. * @param boneAxis Optional vector3 axis the bone is aligned with
  114715. */
  114716. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  114717. var mesh = this.object;
  114718. if (mesh.rotationQuaternion) {
  114719. if (adjustRotation) {
  114720. var tempQuat = PhysicsImpostor._tmpQuat;
  114721. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  114722. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  114723. }
  114724. else {
  114725. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  114726. }
  114727. }
  114728. var pos = PhysicsImpostor._tmpVecs[0];
  114729. var boneDir = PhysicsImpostor._tmpVecs[1];
  114730. if (!boneAxis) {
  114731. boneAxis = PhysicsImpostor._tmpVecs[2];
  114732. boneAxis.x = 0;
  114733. boneAxis.y = 1;
  114734. boneAxis.z = 0;
  114735. }
  114736. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  114737. bone.getAbsolutePositionToRef(boneMesh, pos);
  114738. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  114739. distToJoint = jointPivot.length();
  114740. }
  114741. if (distToJoint !== undefined && distToJoint !== null) {
  114742. pos.x += boneDir.x * distToJoint;
  114743. pos.y += boneDir.y * distToJoint;
  114744. pos.z += boneDir.z * distToJoint;
  114745. }
  114746. mesh.setAbsolutePosition(pos);
  114747. };
  114748. /**
  114749. * The default object size of the imposter
  114750. */
  114751. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  114752. /**
  114753. * The identity quaternion of the imposter
  114754. */
  114755. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  114756. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  114757. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  114758. //Impostor types
  114759. /**
  114760. * No-Imposter type
  114761. */
  114762. PhysicsImpostor.NoImpostor = 0;
  114763. /**
  114764. * Sphere-Imposter type
  114765. */
  114766. PhysicsImpostor.SphereImpostor = 1;
  114767. /**
  114768. * Box-Imposter type
  114769. */
  114770. PhysicsImpostor.BoxImpostor = 2;
  114771. /**
  114772. * Plane-Imposter type
  114773. */
  114774. PhysicsImpostor.PlaneImpostor = 3;
  114775. /**
  114776. * Mesh-imposter type
  114777. */
  114778. PhysicsImpostor.MeshImpostor = 4;
  114779. /**
  114780. * Cylinder-Imposter type
  114781. */
  114782. PhysicsImpostor.CylinderImpostor = 7;
  114783. /**
  114784. * Particle-Imposter type
  114785. */
  114786. PhysicsImpostor.ParticleImpostor = 8;
  114787. /**
  114788. * Heightmap-Imposter type
  114789. */
  114790. PhysicsImpostor.HeightmapImpostor = 9;
  114791. return PhysicsImpostor;
  114792. }());
  114793. /***/ }),
  114794. /***/ "./Physics/physicsJoint.ts":
  114795. /*!*********************************!*\
  114796. !*** ./Physics/physicsJoint.ts ***!
  114797. \*********************************/
  114798. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  114799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114800. "use strict";
  114801. __webpack_require__.r(__webpack_exports__);
  114802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  114803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  114804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  114805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  114806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  114807. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114808. /**
  114809. * This is a holder class for the physics joint created by the physics plugin
  114810. * It holds a set of functions to control the underlying joint
  114811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114812. */
  114813. var PhysicsJoint = /** @class */ (function () {
  114814. /**
  114815. * Initializes the physics joint
  114816. * @param type The type of the physics joint
  114817. * @param jointData The data for the physics joint
  114818. */
  114819. function PhysicsJoint(
  114820. /**
  114821. * The type of the physics joint
  114822. */
  114823. type,
  114824. /**
  114825. * The data for the physics joint
  114826. */
  114827. jointData) {
  114828. this.type = type;
  114829. this.jointData = jointData;
  114830. jointData.nativeParams = jointData.nativeParams || {};
  114831. }
  114832. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  114833. /**
  114834. * Gets the physics joint
  114835. */
  114836. get: function () {
  114837. return this._physicsJoint;
  114838. },
  114839. /**
  114840. * Sets the physics joint
  114841. */
  114842. set: function (newJoint) {
  114843. if (this._physicsJoint) {
  114844. //remove from the wolrd
  114845. }
  114846. this._physicsJoint = newJoint;
  114847. },
  114848. enumerable: true,
  114849. configurable: true
  114850. });
  114851. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  114852. /**
  114853. * Sets the physics plugin
  114854. */
  114855. set: function (physicsPlugin) {
  114856. this._physicsPlugin = physicsPlugin;
  114857. },
  114858. enumerable: true,
  114859. configurable: true
  114860. });
  114861. /**
  114862. * Execute a function that is physics-plugin specific.
  114863. * @param {Function} func the function that will be executed.
  114864. * It accepts two parameters: the physics world and the physics joint
  114865. */
  114866. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  114867. func(this._physicsPlugin.world, this._physicsJoint);
  114868. };
  114869. //TODO check if the native joints are the same
  114870. //Joint Types
  114871. /**
  114872. * Distance-Joint type
  114873. */
  114874. PhysicsJoint.DistanceJoint = 0;
  114875. /**
  114876. * Hinge-Joint type
  114877. */
  114878. PhysicsJoint.HingeJoint = 1;
  114879. /**
  114880. * Ball-and-Socket joint type
  114881. */
  114882. PhysicsJoint.BallAndSocketJoint = 2;
  114883. /**
  114884. * Wheel-Joint type
  114885. */
  114886. PhysicsJoint.WheelJoint = 3;
  114887. /**
  114888. * Slider-Joint type
  114889. */
  114890. PhysicsJoint.SliderJoint = 4;
  114891. //OIMO
  114892. /**
  114893. * Prismatic-Joint type
  114894. */
  114895. PhysicsJoint.PrismaticJoint = 5;
  114896. //
  114897. /**
  114898. * Universal-Joint type
  114899. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  114900. */
  114901. PhysicsJoint.UniversalJoint = 6;
  114902. /**
  114903. * Hinge-Joint 2 type
  114904. */
  114905. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  114906. //Cannon
  114907. /**
  114908. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  114909. */
  114910. PhysicsJoint.PointToPointJoint = 8;
  114911. //Cannon only at the moment
  114912. /**
  114913. * Spring-Joint type
  114914. */
  114915. PhysicsJoint.SpringJoint = 9;
  114916. /**
  114917. * Lock-Joint type
  114918. */
  114919. PhysicsJoint.LockJoint = 10;
  114920. return PhysicsJoint;
  114921. }());
  114922. /**
  114923. * A class representing a physics distance joint
  114924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114925. */
  114926. var DistanceJoint = /** @class */ (function (_super) {
  114927. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  114928. /**
  114929. *
  114930. * @param jointData The data for the Distance-Joint
  114931. */
  114932. function DistanceJoint(jointData) {
  114933. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  114934. }
  114935. /**
  114936. * Update the predefined distance.
  114937. * @param maxDistance The maximum preferred distance
  114938. * @param minDistance The minimum preferred distance
  114939. */
  114940. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  114941. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  114942. };
  114943. return DistanceJoint;
  114944. }(PhysicsJoint));
  114945. /**
  114946. * Represents a Motor-Enabled Joint
  114947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114948. */
  114949. var MotorEnabledJoint = /** @class */ (function (_super) {
  114950. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  114951. /**
  114952. * Initializes the Motor-Enabled Joint
  114953. * @param type The type of the joint
  114954. * @param jointData The physica joint data for the joint
  114955. */
  114956. function MotorEnabledJoint(type, jointData) {
  114957. return _super.call(this, type, jointData) || this;
  114958. }
  114959. /**
  114960. * Set the motor values.
  114961. * Attention, this function is plugin specific. Engines won't react 100% the same.
  114962. * @param force the force to apply
  114963. * @param maxForce max force for this motor.
  114964. */
  114965. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  114966. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  114967. };
  114968. /**
  114969. * Set the motor's limits.
  114970. * Attention, this function is plugin specific. Engines won't react 100% the same.
  114971. * @param upperLimit The upper limit of the motor
  114972. * @param lowerLimit The lower limit of the motor
  114973. */
  114974. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  114975. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  114976. };
  114977. return MotorEnabledJoint;
  114978. }(PhysicsJoint));
  114979. /**
  114980. * This class represents a single physics Hinge-Joint
  114981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114982. */
  114983. var HingeJoint = /** @class */ (function (_super) {
  114984. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  114985. /**
  114986. * Initializes the Hinge-Joint
  114987. * @param jointData The joint data for the Hinge-Joint
  114988. */
  114989. function HingeJoint(jointData) {
  114990. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  114991. }
  114992. /**
  114993. * Set the motor values.
  114994. * Attention, this function is plugin specific. Engines won't react 100% the same.
  114995. * @param {number} force the force to apply
  114996. * @param {number} maxForce max force for this motor.
  114997. */
  114998. HingeJoint.prototype.setMotor = function (force, maxForce) {
  114999. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  115000. };
  115001. /**
  115002. * Set the motor's limits.
  115003. * Attention, this function is plugin specific. Engines won't react 100% the same.
  115004. * @param upperLimit The upper limit of the motor
  115005. * @param lowerLimit The lower limit of the motor
  115006. */
  115007. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  115008. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  115009. };
  115010. return HingeJoint;
  115011. }(MotorEnabledJoint));
  115012. /**
  115013. * This class represents a dual hinge physics joint (same as wheel joint)
  115014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  115015. */
  115016. var Hinge2Joint = /** @class */ (function (_super) {
  115017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  115018. /**
  115019. * Initializes the Hinge2-Joint
  115020. * @param jointData The joint data for the Hinge2-Joint
  115021. */
  115022. function Hinge2Joint(jointData) {
  115023. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  115024. }
  115025. /**
  115026. * Set the motor values.
  115027. * Attention, this function is plugin specific. Engines won't react 100% the same.
  115028. * @param {number} targetSpeed the speed the motor is to reach
  115029. * @param {number} maxForce max force for this motor.
  115030. * @param {motorIndex} the motor's index, 0 or 1.
  115031. */
  115032. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  115033. if (motorIndex === void 0) { motorIndex = 0; }
  115034. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  115035. };
  115036. /**
  115037. * Set the motor limits.
  115038. * Attention, this function is plugin specific. Engines won't react 100% the same.
  115039. * @param {number} upperLimit the upper limit
  115040. * @param {number} lowerLimit lower limit
  115041. * @param {motorIndex} the motor's index, 0 or 1.
  115042. */
  115043. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  115044. if (motorIndex === void 0) { motorIndex = 0; }
  115045. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  115046. };
  115047. return Hinge2Joint;
  115048. }(MotorEnabledJoint));
  115049. /***/ }),
  115050. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  115051. /*!****************************************************************************!*\
  115052. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  115053. \****************************************************************************/
  115054. /*! exports provided: DefaultRenderingPipeline */
  115055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115056. "use strict";
  115057. __webpack_require__.r(__webpack_exports__);
  115058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  115059. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115060. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  115061. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  115062. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115063. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  115064. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  115065. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  115066. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  115067. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  115068. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  115069. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  115070. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115071. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115072. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  115073. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  115074. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  115075. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  115076. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  115077. /**
  115078. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  115079. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  115080. */
  115081. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  115082. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  115083. /**
  115084. * @constructor
  115085. * @param name - The rendering pipeline name (default: "")
  115086. * @param hdr - If high dynamic range textures should be used (default: true)
  115087. * @param scene - The scene linked to this pipeline (default: the last created scene)
  115088. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  115089. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  115090. */
  115091. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  115092. if (name === void 0) { name = ""; }
  115093. if (hdr === void 0) { hdr = true; }
  115094. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  115095. if (automaticBuild === void 0) { automaticBuild = true; }
  115096. var _this = _super.call(this, scene.getEngine(), name) || this;
  115097. _this._camerasToBeAttached = [];
  115098. /**
  115099. * ID of the sharpen post process,
  115100. */
  115101. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  115102. /**
  115103. * @ignore
  115104. * ID of the image processing post process;
  115105. */
  115106. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  115107. /**
  115108. * @ignore
  115109. * ID of the Fast Approximate Anti-Aliasing post process;
  115110. */
  115111. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  115112. /**
  115113. * ID of the chromatic aberration post process,
  115114. */
  115115. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  115116. /**
  115117. * ID of the grain post process
  115118. */
  115119. _this.GrainPostProcessId = "GrainPostProcessEffect";
  115120. /**
  115121. * Glow post process which adds a glow to emissive areas of the image
  115122. */
  115123. _this._glowLayer = null;
  115124. /**
  115125. * Animations which can be used to tweak settings over a period of time
  115126. */
  115127. _this.animations = [];
  115128. _this._imageProcessingConfigurationObserver = null;
  115129. // Values
  115130. _this._sharpenEnabled = false;
  115131. _this._bloomEnabled = false;
  115132. _this._depthOfFieldEnabled = false;
  115133. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  115134. _this._fxaaEnabled = false;
  115135. _this._imageProcessingEnabled = true;
  115136. _this._bloomScale = 0.5;
  115137. _this._chromaticAberrationEnabled = false;
  115138. _this._grainEnabled = false;
  115139. _this._buildAllowed = true;
  115140. _this._resizeObserver = null;
  115141. _this._hardwareScaleLevel = 1.0;
  115142. _this._bloomKernel = 64;
  115143. /**
  115144. * Specifies the weight of the bloom in the final rendering
  115145. */
  115146. _this._bloomWeight = 0.15;
  115147. /**
  115148. * Specifies the luma threshold for the area that will be blurred by the bloom
  115149. */
  115150. _this._bloomThreshold = 0.9;
  115151. _this._samples = 1;
  115152. _this._hasCleared = false;
  115153. _this._prevPostProcess = null;
  115154. _this._prevPrevPostProcess = null;
  115155. _this._depthOfFieldSceneObserver = null;
  115156. _this._cameras = cameras || scene.cameras;
  115157. _this._cameras = _this._cameras.slice();
  115158. _this._camerasToBeAttached = _this._cameras.slice();
  115159. _this._buildAllowed = automaticBuild;
  115160. // Initialize
  115161. _this._scene = scene;
  115162. var caps = _this._scene.getEngine().getCaps();
  115163. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  115164. // Misc
  115165. if (_this._hdr) {
  115166. if (caps.textureHalfFloatRender) {
  115167. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  115168. }
  115169. else if (caps.textureFloatRender) {
  115170. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  115171. }
  115172. }
  115173. else {
  115174. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  115175. }
  115176. // Attach
  115177. scene.postProcessRenderPipelineManager.addPipeline(_this);
  115178. var engine = _this._scene.getEngine();
  115179. // Create post processes before hand so they can be modified before enabled.
  115180. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  115181. _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);
  115182. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  115183. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  115184. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  115185. _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);
  115186. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  115187. _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);
  115188. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  115189. _this._resizeObserver = engine.onResizeObservable.add(function () {
  115190. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  115191. _this.bloomKernel = _this.bloomKernel;
  115192. });
  115193. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  115194. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  115195. });
  115196. _this._buildPipeline();
  115197. return _this;
  115198. }
  115199. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  115200. /**
  115201. * Gets active scene
  115202. */
  115203. get: function () {
  115204. return this._scene;
  115205. },
  115206. enumerable: true,
  115207. configurable: true
  115208. });
  115209. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  115210. get: function () {
  115211. return this._sharpenEnabled;
  115212. },
  115213. /**
  115214. * Enable or disable the sharpen process from the pipeline
  115215. */
  115216. set: function (enabled) {
  115217. if (this._sharpenEnabled === enabled) {
  115218. return;
  115219. }
  115220. this._sharpenEnabled = enabled;
  115221. this._buildPipeline();
  115222. },
  115223. enumerable: true,
  115224. configurable: true
  115225. });
  115226. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  115227. /**
  115228. * Specifies the size of the bloom blur kernel, relative to the final output size
  115229. */
  115230. get: function () {
  115231. return this._bloomKernel;
  115232. },
  115233. set: function (value) {
  115234. this._bloomKernel = value;
  115235. this.bloom.kernel = value / this._hardwareScaleLevel;
  115236. },
  115237. enumerable: true,
  115238. configurable: true
  115239. });
  115240. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  115241. get: function () {
  115242. return this._bloomWeight;
  115243. },
  115244. /**
  115245. * The strength of the bloom.
  115246. */
  115247. set: function (value) {
  115248. if (this._bloomWeight === value) {
  115249. return;
  115250. }
  115251. this.bloom.weight = value;
  115252. this._bloomWeight = value;
  115253. },
  115254. enumerable: true,
  115255. configurable: true
  115256. });
  115257. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  115258. get: function () {
  115259. return this._bloomThreshold;
  115260. },
  115261. /**
  115262. * The strength of the bloom.
  115263. */
  115264. set: function (value) {
  115265. if (this._bloomThreshold === value) {
  115266. return;
  115267. }
  115268. this.bloom.threshold = value;
  115269. this._bloomThreshold = value;
  115270. },
  115271. enumerable: true,
  115272. configurable: true
  115273. });
  115274. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  115275. get: function () {
  115276. return this._bloomScale;
  115277. },
  115278. /**
  115279. * The scale of the bloom, lower value will provide better performance.
  115280. */
  115281. set: function (value) {
  115282. if (this._bloomScale === value) {
  115283. return;
  115284. }
  115285. this._bloomScale = value;
  115286. // recreate bloom and dispose old as this setting is not dynamic
  115287. this._rebuildBloom();
  115288. this._buildPipeline();
  115289. },
  115290. enumerable: true,
  115291. configurable: true
  115292. });
  115293. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  115294. get: function () {
  115295. return this._bloomEnabled;
  115296. },
  115297. /**
  115298. * Enable or disable the bloom from the pipeline
  115299. */
  115300. set: function (enabled) {
  115301. if (this._bloomEnabled === enabled) {
  115302. return;
  115303. }
  115304. this._bloomEnabled = enabled;
  115305. this._buildPipeline();
  115306. },
  115307. enumerable: true,
  115308. configurable: true
  115309. });
  115310. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  115311. // recreate bloom and dispose old as this setting is not dynamic
  115312. var oldBloom = this.bloom;
  115313. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  115314. this.bloom.threshold = oldBloom.threshold;
  115315. for (var i = 0; i < this._cameras.length; i++) {
  115316. oldBloom.disposeEffects(this._cameras[i]);
  115317. }
  115318. };
  115319. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  115320. /**
  115321. * If the depth of field is enabled.
  115322. */
  115323. get: function () {
  115324. return this._depthOfFieldEnabled;
  115325. },
  115326. set: function (enabled) {
  115327. if (this._depthOfFieldEnabled === enabled) {
  115328. return;
  115329. }
  115330. this._depthOfFieldEnabled = enabled;
  115331. this._buildPipeline();
  115332. },
  115333. enumerable: true,
  115334. configurable: true
  115335. });
  115336. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  115337. /**
  115338. * Blur level of the depth of field effect. (Higher blur will effect performance)
  115339. */
  115340. get: function () {
  115341. return this._depthOfFieldBlurLevel;
  115342. },
  115343. set: function (value) {
  115344. if (this._depthOfFieldBlurLevel === value) {
  115345. return;
  115346. }
  115347. this._depthOfFieldBlurLevel = value;
  115348. // recreate dof and dispose old as this setting is not dynamic
  115349. var oldDof = this.depthOfField;
  115350. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  115351. this.depthOfField.focalLength = oldDof.focalLength;
  115352. this.depthOfField.focusDistance = oldDof.focusDistance;
  115353. this.depthOfField.fStop = oldDof.fStop;
  115354. this.depthOfField.lensSize = oldDof.lensSize;
  115355. for (var i = 0; i < this._cameras.length; i++) {
  115356. oldDof.disposeEffects(this._cameras[i]);
  115357. }
  115358. this._buildPipeline();
  115359. },
  115360. enumerable: true,
  115361. configurable: true
  115362. });
  115363. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  115364. get: function () {
  115365. return this._fxaaEnabled;
  115366. },
  115367. /**
  115368. * If the anti aliasing is enabled.
  115369. */
  115370. set: function (enabled) {
  115371. if (this._fxaaEnabled === enabled) {
  115372. return;
  115373. }
  115374. this._fxaaEnabled = enabled;
  115375. this._buildPipeline();
  115376. },
  115377. enumerable: true,
  115378. configurable: true
  115379. });
  115380. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  115381. get: function () {
  115382. return this._samples;
  115383. },
  115384. /**
  115385. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  115386. */
  115387. set: function (sampleCount) {
  115388. if (this._samples === sampleCount) {
  115389. return;
  115390. }
  115391. this._samples = sampleCount;
  115392. this._buildPipeline();
  115393. },
  115394. enumerable: true,
  115395. configurable: true
  115396. });
  115397. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  115398. get: function () {
  115399. return this._imageProcessingEnabled;
  115400. },
  115401. /**
  115402. * If image processing is enabled.
  115403. */
  115404. set: function (enabled) {
  115405. if (this._imageProcessingEnabled === enabled) {
  115406. return;
  115407. }
  115408. this._imageProcessingEnabled = enabled;
  115409. this._buildPipeline();
  115410. },
  115411. enumerable: true,
  115412. configurable: true
  115413. });
  115414. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  115415. get: function () {
  115416. return this._glowLayer != null;
  115417. },
  115418. /**
  115419. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  115420. */
  115421. set: function (enabled) {
  115422. if (enabled && !this._glowLayer) {
  115423. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  115424. }
  115425. else if (!enabled && this._glowLayer) {
  115426. this._glowLayer.dispose();
  115427. this._glowLayer = null;
  115428. }
  115429. },
  115430. enumerable: true,
  115431. configurable: true
  115432. });
  115433. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  115434. get: function () {
  115435. return this._chromaticAberrationEnabled;
  115436. },
  115437. /**
  115438. * Enable or disable the chromaticAberration process from the pipeline
  115439. */
  115440. set: function (enabled) {
  115441. if (this._chromaticAberrationEnabled === enabled) {
  115442. return;
  115443. }
  115444. this._chromaticAberrationEnabled = enabled;
  115445. this._buildPipeline();
  115446. },
  115447. enumerable: true,
  115448. configurable: true
  115449. });
  115450. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  115451. get: function () {
  115452. return this._grainEnabled;
  115453. },
  115454. /**
  115455. * Enable or disable the grain process from the pipeline
  115456. */
  115457. set: function (enabled) {
  115458. if (this._grainEnabled === enabled) {
  115459. return;
  115460. }
  115461. this._grainEnabled = enabled;
  115462. this._buildPipeline();
  115463. },
  115464. enumerable: true,
  115465. configurable: true
  115466. });
  115467. /**
  115468. * Get the class name
  115469. * @returns "DefaultRenderingPipeline"
  115470. */
  115471. DefaultRenderingPipeline.prototype.getClassName = function () {
  115472. return "DefaultRenderingPipeline";
  115473. };
  115474. /**
  115475. * Force the compilation of the entire pipeline.
  115476. */
  115477. DefaultRenderingPipeline.prototype.prepare = function () {
  115478. var previousState = this._buildAllowed;
  115479. this._buildAllowed = true;
  115480. this._buildPipeline();
  115481. this._buildAllowed = previousState;
  115482. };
  115483. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  115484. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  115485. if (this._hasCleared) {
  115486. postProcess.autoClear = false;
  115487. }
  115488. else {
  115489. postProcess.autoClear = true;
  115490. this._scene.autoClear = false;
  115491. this._hasCleared = true;
  115492. }
  115493. if (!skipTextureSharing) {
  115494. if (this._prevPrevPostProcess) {
  115495. postProcess.shareOutputWith(this._prevPrevPostProcess);
  115496. }
  115497. else {
  115498. postProcess.useOwnOutput();
  115499. }
  115500. if (this._prevPostProcess) {
  115501. this._prevPrevPostProcess = this._prevPostProcess;
  115502. }
  115503. this._prevPostProcess = postProcess;
  115504. }
  115505. };
  115506. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  115507. var _this = this;
  115508. if (!this._buildAllowed) {
  115509. return;
  115510. }
  115511. this._scene.autoClear = true;
  115512. var engine = this._scene.getEngine();
  115513. this._disposePostProcesses();
  115514. if (this._cameras !== null) {
  115515. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  115516. // get back cameras to be used to reattach pipeline
  115517. this._cameras = this._camerasToBeAttached.slice();
  115518. }
  115519. this._reset();
  115520. this._prevPostProcess = null;
  115521. this._prevPrevPostProcess = null;
  115522. this._hasCleared = false;
  115523. if (this.depthOfFieldEnabled) {
  115524. // Multi camera suport
  115525. if (this._cameras.length > 1) {
  115526. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  115527. var camera = _a[_i];
  115528. var depthRenderer = this._scene.enableDepthRenderer(camera);
  115529. depthRenderer.useOnlyInActiveCamera = true;
  115530. }
  115531. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  115532. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  115533. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  115534. }
  115535. });
  115536. }
  115537. else {
  115538. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  115539. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  115540. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  115541. }
  115542. if (!this.depthOfField._isReady()) {
  115543. this.depthOfField._updateEffects();
  115544. }
  115545. this.addEffect(this.depthOfField);
  115546. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  115547. }
  115548. else {
  115549. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  115550. }
  115551. if (this.bloomEnabled) {
  115552. if (!this.bloom._isReady()) {
  115553. this.bloom._updateEffects();
  115554. }
  115555. this.addEffect(this.bloom);
  115556. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  115557. }
  115558. if (this._imageProcessingEnabled) {
  115559. 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);
  115560. if (this._hdr) {
  115561. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  115562. this._setAutoClearAndTextureSharing(this.imageProcessing);
  115563. }
  115564. else {
  115565. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  115566. }
  115567. }
  115568. if (this.sharpenEnabled) {
  115569. if (!this.sharpen.isReady()) {
  115570. this.sharpen.updateEffect();
  115571. }
  115572. this.addEffect(this._sharpenEffect);
  115573. this._setAutoClearAndTextureSharing(this.sharpen);
  115574. }
  115575. if (this.grainEnabled) {
  115576. if (!this.grain.isReady()) {
  115577. this.grain.updateEffect();
  115578. }
  115579. this.addEffect(this._grainEffect);
  115580. this._setAutoClearAndTextureSharing(this.grain);
  115581. }
  115582. if (this.chromaticAberrationEnabled) {
  115583. if (!this.chromaticAberration.isReady()) {
  115584. this.chromaticAberration.updateEffect();
  115585. }
  115586. this.addEffect(this._chromaticAberrationEffect);
  115587. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  115588. }
  115589. if (this.fxaaEnabled) {
  115590. 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);
  115591. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  115592. this._setAutoClearAndTextureSharing(this.fxaa, true);
  115593. }
  115594. if (this._cameras !== null) {
  115595. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  115596. }
  115597. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  115598. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  115599. }
  115600. };
  115601. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  115602. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  115603. for (var i = 0; i < this._cameras.length; i++) {
  115604. var camera = this._cameras[i];
  115605. if (this.imageProcessing) {
  115606. this.imageProcessing.dispose(camera);
  115607. }
  115608. if (this.fxaa) {
  115609. this.fxaa.dispose(camera);
  115610. }
  115611. // These are created in the constructor and should not be disposed on every pipeline change
  115612. if (disposeNonRecreated) {
  115613. if (this.sharpen) {
  115614. this.sharpen.dispose(camera);
  115615. }
  115616. if (this.depthOfField) {
  115617. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  115618. this.depthOfField.disposeEffects(camera);
  115619. }
  115620. if (this.bloom) {
  115621. this.bloom.disposeEffects(camera);
  115622. }
  115623. if (this.chromaticAberration) {
  115624. this.chromaticAberration.dispose(camera);
  115625. }
  115626. if (this.grain) {
  115627. this.grain.dispose(camera);
  115628. }
  115629. if (this._glowLayer) {
  115630. this._glowLayer.dispose();
  115631. }
  115632. }
  115633. }
  115634. this.imageProcessing = null;
  115635. this.fxaa = null;
  115636. if (disposeNonRecreated) {
  115637. this.sharpen = null;
  115638. this._sharpenEffect = null;
  115639. this.depthOfField = null;
  115640. this.bloom = null;
  115641. this.chromaticAberration = null;
  115642. this._chromaticAberrationEffect = null;
  115643. this.grain = null;
  115644. this._grainEffect = null;
  115645. this._glowLayer = null;
  115646. }
  115647. };
  115648. /**
  115649. * Adds a camera to the pipeline
  115650. * @param camera the camera to be added
  115651. */
  115652. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  115653. this._camerasToBeAttached.push(camera);
  115654. this._buildPipeline();
  115655. };
  115656. /**
  115657. * Removes a camera from the pipeline
  115658. * @param camera the camera to remove
  115659. */
  115660. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  115661. var index = this._camerasToBeAttached.indexOf(camera);
  115662. this._camerasToBeAttached.splice(index, 1);
  115663. this._buildPipeline();
  115664. };
  115665. /**
  115666. * Dispose of the pipeline and stop all post processes
  115667. */
  115668. DefaultRenderingPipeline.prototype.dispose = function () {
  115669. this._disposePostProcesses(true);
  115670. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  115671. this._scene.autoClear = true;
  115672. if (this._resizeObserver) {
  115673. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  115674. this._resizeObserver = null;
  115675. }
  115676. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  115677. _super.prototype.dispose.call(this);
  115678. };
  115679. /**
  115680. * Serialize the rendering pipeline (Used when exporting)
  115681. * @returns the serialized object
  115682. */
  115683. DefaultRenderingPipeline.prototype.serialize = function () {
  115684. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  115685. serializationObject.customType = "DefaultRenderingPipeline";
  115686. return serializationObject;
  115687. };
  115688. /**
  115689. * Parse the serialized pipeline
  115690. * @param source Source pipeline.
  115691. * @param scene The scene to load the pipeline to.
  115692. * @param rootUrl The URL of the serialized pipeline.
  115693. * @returns An instantiated pipeline from the serialized object.
  115694. */
  115695. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  115696. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  115697. };
  115698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115700. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  115701. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115702. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115703. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  115704. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115706. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  115707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115709. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  115710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115711. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115712. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  115713. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115714. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115715. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  115716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115718. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  115719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115721. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  115722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115724. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  115725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115727. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  115728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115730. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  115731. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115733. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  115734. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115735. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115736. ], DefaultRenderingPipeline.prototype, "samples", null);
  115737. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115738. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115739. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  115740. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115742. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  115743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115745. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  115746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115748. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  115749. return DefaultRenderingPipeline;
  115750. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  115751. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  115752. /***/ }),
  115753. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  115754. /*!*********************************************************!*\
  115755. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  115756. \*********************************************************/
  115757. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  115758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115759. "use strict";
  115760. __webpack_require__.r(__webpack_exports__);
  115761. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  115762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  115763. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  115764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  115765. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  115766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  115767. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  115768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  115769. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  115770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  115771. /***/ }),
  115772. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  115773. /*!*************************************************************************!*\
  115774. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  115775. \*************************************************************************/
  115776. /*! exports provided: LensRenderingPipeline */
  115777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115778. "use strict";
  115779. __webpack_require__.r(__webpack_exports__);
  115780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  115781. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115782. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115783. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  115784. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  115785. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115786. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115787. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  115788. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  115789. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  115790. /**
  115791. * BABYLON.JS Chromatic Aberration GLSL Shader
  115792. * Author: Olivier Guyot
  115793. * Separates very slightly R, G and B colors on the edges of the screen
  115794. * Inspired by Francois Tarlier & Martins Upitis
  115795. */
  115796. var LensRenderingPipeline = /** @class */ (function (_super) {
  115797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  115798. /**
  115799. * @constructor
  115800. *
  115801. * Effect parameters are as follow:
  115802. * {
  115803. * chromatic_aberration: number; // from 0 to x (1 for realism)
  115804. * edge_blur: number; // from 0 to x (1 for realism)
  115805. * distortion: number; // from 0 to x (1 for realism)
  115806. * grain_amount: number; // from 0 to 1
  115807. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  115808. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  115809. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  115810. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  115811. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  115812. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  115813. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  115814. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  115815. * }
  115816. * Note: if an effect parameter is unset, effect is disabled
  115817. *
  115818. * @param name The rendering pipeline name
  115819. * @param parameters - An object containing all parameters (see above)
  115820. * @param scene The scene linked to this pipeline
  115821. * @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)
  115822. * @param cameras The array of cameras that the rendering pipeline will be attached to
  115823. */
  115824. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  115825. if (ratio === void 0) { ratio = 1.0; }
  115826. var _this = _super.call(this, scene.getEngine(), name) || this;
  115827. // Lens effects can be of the following:
  115828. // - chromatic aberration (slight shift of RGB colors)
  115829. // - blur on the edge of the lens
  115830. // - lens distortion
  115831. // - depth-of-field blur & highlights enhancing
  115832. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  115833. // - grain effect (noise or custom texture)
  115834. // Two additional texture samplers are needed:
  115835. // - depth map (for depth-of-field)
  115836. // - grain texture
  115837. /**
  115838. * @ignore
  115839. * The chromatic aberration PostProcess id in the pipeline
  115840. */
  115841. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  115842. /**
  115843. * @ignore
  115844. * The highlights enhancing PostProcess id in the pipeline
  115845. */
  115846. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  115847. /**
  115848. * @ignore
  115849. * The depth-of-field PostProcess id in the pipeline
  115850. */
  115851. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  115852. _this._scene = scene;
  115853. // Fetch texture samplers
  115854. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  115855. if (parameters.grain_texture) {
  115856. _this._grainTexture = parameters.grain_texture;
  115857. }
  115858. else {
  115859. _this._createGrainTexture();
  115860. }
  115861. // save parameters
  115862. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  115863. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  115864. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  115865. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  115866. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  115867. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  115868. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  115869. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  115870. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  115871. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  115872. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  115873. // Create effects
  115874. _this._createChromaticAberrationPostProcess(ratio);
  115875. _this._createHighlightsPostProcess(ratio);
  115876. _this._createDepthOfFieldPostProcess(ratio / 4);
  115877. // Set up pipeline
  115878. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  115879. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  115880. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  115881. if (_this._highlightsGain === -1) {
  115882. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  115883. }
  115884. // Finish
  115885. scene.postProcessRenderPipelineManager.addPipeline(_this);
  115886. if (cameras) {
  115887. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  115888. }
  115889. return _this;
  115890. }
  115891. // public methods (self explanatory)
  115892. /**
  115893. * Sets the amount of blur at the edges
  115894. * @param amount blur amount
  115895. */
  115896. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  115897. /**
  115898. * Sets edge blur to 0
  115899. */
  115900. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  115901. /**
  115902. * Sets the amout of grain
  115903. * @param amount Amount of grain
  115904. */
  115905. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  115906. /**
  115907. * Set grain amount to 0
  115908. */
  115909. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  115910. /**
  115911. * Sets the chromatic aberration amount
  115912. * @param amount amount of chromatic aberration
  115913. */
  115914. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  115915. /**
  115916. * Sets chromatic aberration amount to 0
  115917. */
  115918. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  115919. /**
  115920. * Sets the EdgeDistortion amount
  115921. * @param amount amount of EdgeDistortion
  115922. */
  115923. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  115924. /**
  115925. * Sets edge distortion to 0
  115926. */
  115927. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  115928. /**
  115929. * Sets the FocusDistance amount
  115930. * @param amount amount of FocusDistance
  115931. */
  115932. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  115933. /**
  115934. * Disables depth of field
  115935. */
  115936. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  115937. /**
  115938. * Sets the Aperture amount
  115939. * @param amount amount of Aperture
  115940. */
  115941. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  115942. /**
  115943. * Sets the DarkenOutOfFocus amount
  115944. * @param amount amount of DarkenOutOfFocus
  115945. */
  115946. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  115947. /**
  115948. * Creates a pentagon bokeh effect
  115949. */
  115950. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  115951. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  115952. };
  115953. /**
  115954. * Disables the pentagon bokeh effect
  115955. */
  115956. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  115957. this._highlightsPostProcess.updateEffect();
  115958. };
  115959. /**
  115960. * Enables noise blur
  115961. */
  115962. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  115963. /**
  115964. * Disables noise blur
  115965. */
  115966. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  115967. /**
  115968. * Sets the HighlightsGain amount
  115969. * @param amount amount of HighlightsGain
  115970. */
  115971. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  115972. this._highlightsGain = amount;
  115973. };
  115974. /**
  115975. * Sets the HighlightsThreshold amount
  115976. * @param amount amount of HighlightsThreshold
  115977. */
  115978. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  115979. if (this._highlightsGain === -1) {
  115980. this._highlightsGain = 1.0;
  115981. }
  115982. this._highlightsThreshold = amount;
  115983. };
  115984. /**
  115985. * Disables highlights
  115986. */
  115987. LensRenderingPipeline.prototype.disableHighlights = function () {
  115988. this._highlightsGain = -1;
  115989. };
  115990. /**
  115991. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  115992. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  115993. */
  115994. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  115995. if (disableDepthRender === void 0) { disableDepthRender = false; }
  115996. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  115997. this._chromaticAberrationPostProcess = null;
  115998. this._highlightsPostProcess = null;
  115999. this._depthOfFieldPostProcess = null;
  116000. this._grainTexture.dispose();
  116001. if (disableDepthRender) {
  116002. this._scene.disableDepthRenderer();
  116003. }
  116004. };
  116005. // colors shifting and distortion
  116006. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  116007. var _this = this;
  116008. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  116009. [], // samplers
  116010. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  116011. this._chromaticAberrationPostProcess.onApply = function (effect) {
  116012. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  116013. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  116014. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  116015. effect.setFloat('radialIntensity', 1);
  116016. effect.setFloat2('direction', 17, 17);
  116017. effect.setFloat2('centerPosition', 0.5, 0.5);
  116018. };
  116019. };
  116020. // highlights enhancing
  116021. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  116022. var _this = this;
  116023. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  116024. [], // samplers
  116025. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  116026. this._highlightsPostProcess.onApply = function (effect) {
  116027. effect.setFloat('gain', _this._highlightsGain);
  116028. effect.setFloat('threshold', _this._highlightsThreshold);
  116029. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  116030. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  116031. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  116032. };
  116033. };
  116034. // colors shifting and distortion
  116035. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  116036. var _this = this;
  116037. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  116038. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  116039. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  116040. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  116041. this._depthOfFieldPostProcess.onApply = function (effect) {
  116042. effect.setTexture("depthSampler", _this._depthTexture);
  116043. effect.setTexture("grainSampler", _this._grainTexture);
  116044. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  116045. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  116046. effect.setFloat('grain_amount', _this._grainAmount);
  116047. effect.setBool('blur_noise', _this._blurNoise);
  116048. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  116049. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  116050. effect.setFloat('distortion', _this._distortion);
  116051. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  116052. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  116053. effect.setFloat('aperture', _this._dofAperture);
  116054. effect.setFloat('darken', _this._dofDarken);
  116055. effect.setFloat('edge_blur', _this._edgeBlur);
  116056. effect.setBool('highlights', (_this._highlightsGain !== -1));
  116057. if (_this._scene.activeCamera) {
  116058. effect.setFloat('near', _this._scene.activeCamera.minZ);
  116059. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  116060. }
  116061. };
  116062. };
  116063. // creates a black and white random noise texture, 512x512
  116064. LensRenderingPipeline.prototype._createGrainTexture = function () {
  116065. var size = 512;
  116066. 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);
  116067. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  116068. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  116069. var context = this._grainTexture.getContext();
  116070. var rand = function (min, max) {
  116071. return Math.random() * (max - min) + min;
  116072. };
  116073. var value;
  116074. for (var x = 0; x < size; x++) {
  116075. for (var y = 0; y < size; y++) {
  116076. value = Math.floor(rand(0.42, 0.58) * 255);
  116077. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  116078. context.fillRect(x, y, 1, 1);
  116079. }
  116080. }
  116081. this._grainTexture.update(false);
  116082. };
  116083. return LensRenderingPipeline;
  116084. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  116085. /***/ }),
  116086. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  116087. /*!**************************************************************************!*\
  116088. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  116089. \**************************************************************************/
  116090. /*! exports provided: SSAO2RenderingPipeline */
  116091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116092. "use strict";
  116093. __webpack_require__.r(__webpack_exports__);
  116094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  116095. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116096. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  116097. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  116098. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  116099. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116100. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  116101. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  116102. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  116103. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116104. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  116105. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  116106. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  116107. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  116108. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  116109. /**
  116110. * Render pipeline to produce ssao effect
  116111. */
  116112. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  116113. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  116114. /**
  116115. * @constructor
  116116. * @param name The rendering pipeline name
  116117. * @param scene The scene linked to this pipeline
  116118. * @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 }
  116119. * @param cameras The array of cameras that the rendering pipeline will be attached to
  116120. */
  116121. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  116122. var _this = _super.call(this, scene.getEngine(), name) || this;
  116123. // Members
  116124. /**
  116125. * @ignore
  116126. * The PassPostProcess id in the pipeline that contains the original scene color
  116127. */
  116128. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  116129. /**
  116130. * @ignore
  116131. * The SSAO PostProcess id in the pipeline
  116132. */
  116133. _this.SSAORenderEffect = "SSAORenderEffect";
  116134. /**
  116135. * @ignore
  116136. * The horizontal blur PostProcess id in the pipeline
  116137. */
  116138. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  116139. /**
  116140. * @ignore
  116141. * The vertical blur PostProcess id in the pipeline
  116142. */
  116143. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  116144. /**
  116145. * @ignore
  116146. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  116147. */
  116148. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  116149. /**
  116150. * The output strength of the SSAO post-process. Default value is 1.0.
  116151. */
  116152. _this.totalStrength = 1.0;
  116153. /**
  116154. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  116155. */
  116156. _this.maxZ = 100.0;
  116157. /**
  116158. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  116159. */
  116160. _this.minZAspect = 0.2;
  116161. _this._samples = 8;
  116162. _this._textureSamples = 1;
  116163. _this._expensiveBlur = true;
  116164. /**
  116165. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  116166. */
  116167. _this.radius = 2.0;
  116168. /**
  116169. * The base color of the SSAO post-process
  116170. * The final result is "base + ssao" between [0, 1]
  116171. */
  116172. _this.base = 0;
  116173. _this._firstUpdate = true;
  116174. _this._bits = new Uint32Array(1);
  116175. _this._scene = scene;
  116176. _this._ratio = ratio;
  116177. if (!_this.isSupported) {
  116178. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  116179. return _this;
  116180. }
  116181. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  116182. var blurRatio = _this._ratio.blurRatio || ratio;
  116183. // Set up assets
  116184. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  116185. _this._createRandomTexture();
  116186. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  116187. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  116188. _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);
  116189. _this._originalColorPostProcess.samples = _this.textureSamples;
  116190. _this._createSSAOPostProcess(1.0);
  116191. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  116192. _this._createSSAOCombinePostProcess(blurRatio);
  116193. // Set up pipeline
  116194. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  116195. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  116196. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  116197. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  116198. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  116199. // Finish
  116200. scene.postProcessRenderPipelineManager.addPipeline(_this);
  116201. if (cameras) {
  116202. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  116203. }
  116204. return _this;
  116205. }
  116206. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  116207. get: function () {
  116208. return this._samples;
  116209. },
  116210. /**
  116211. * Number of samples used for the SSAO calculations. Default value is 8
  116212. */
  116213. set: function (n) {
  116214. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  116215. this._samples = n;
  116216. this._sampleSphere = this._generateHemisphere();
  116217. this._firstUpdate = true;
  116218. },
  116219. enumerable: true,
  116220. configurable: true
  116221. });
  116222. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  116223. get: function () {
  116224. return this._textureSamples;
  116225. },
  116226. /**
  116227. * Number of samples to use for antialiasing
  116228. */
  116229. set: function (n) {
  116230. this._textureSamples = n;
  116231. this._originalColorPostProcess.samples = n;
  116232. this._blurHPostProcess.samples = n;
  116233. this._blurVPostProcess.samples = n;
  116234. this._ssaoPostProcess.samples = n;
  116235. this._ssaoCombinePostProcess.samples = n;
  116236. },
  116237. enumerable: true,
  116238. configurable: true
  116239. });
  116240. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  116241. get: function () {
  116242. return this._expensiveBlur;
  116243. },
  116244. /**
  116245. * If bilateral blur should be used
  116246. */
  116247. set: function (b) {
  116248. 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"]);
  116249. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  116250. this._expensiveBlur = b;
  116251. this._firstUpdate = true;
  116252. },
  116253. enumerable: true,
  116254. configurable: true
  116255. });
  116256. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  116257. /**
  116258. * Support test.
  116259. */
  116260. get: function () {
  116261. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  116262. if (!engine) {
  116263. return false;
  116264. }
  116265. return engine.getCaps().drawBuffersExtension;
  116266. },
  116267. enumerable: true,
  116268. configurable: true
  116269. });
  116270. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  116271. /**
  116272. * Gets active scene
  116273. */
  116274. get: function () {
  116275. return this._scene;
  116276. },
  116277. enumerable: true,
  116278. configurable: true
  116279. });
  116280. // Public Methods
  116281. /**
  116282. * Get the class name
  116283. * @returns "SSAO2RenderingPipeline"
  116284. */
  116285. SSAO2RenderingPipeline.prototype.getClassName = function () {
  116286. return "SSAO2RenderingPipeline";
  116287. };
  116288. /**
  116289. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  116290. */
  116291. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  116292. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  116293. for (var i = 0; i < this._scene.cameras.length; i++) {
  116294. var camera = this._scene.cameras[i];
  116295. this._originalColorPostProcess.dispose(camera);
  116296. this._ssaoPostProcess.dispose(camera);
  116297. this._blurHPostProcess.dispose(camera);
  116298. this._blurVPostProcess.dispose(camera);
  116299. this._ssaoCombinePostProcess.dispose(camera);
  116300. }
  116301. this._randomTexture.dispose();
  116302. if (disableGeometryBufferRenderer) {
  116303. this._scene.disableGeometryBufferRenderer();
  116304. }
  116305. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  116306. _super.prototype.dispose.call(this);
  116307. };
  116308. // Private Methods
  116309. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  116310. var _this = this;
  116311. this._samplerOffsets = [];
  116312. var expensive = this.expensiveBlur;
  116313. for (var i = -8; i < 8; i++) {
  116314. this._samplerOffsets.push(i * 2 + 0.5);
  116315. }
  116316. 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");
  116317. this._blurHPostProcess.onApply = function (effect) {
  116318. if (!_this._scene.activeCamera) {
  116319. return;
  116320. }
  116321. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  116322. effect.setFloat("near", _this._scene.activeCamera.minZ);
  116323. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  116324. effect.setFloat("radius", _this.radius);
  116325. effect.setTexture("depthSampler", _this._depthTexture);
  116326. if (_this._firstUpdate) {
  116327. effect.setArray("samplerOffsets", _this._samplerOffsets);
  116328. }
  116329. };
  116330. 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");
  116331. this._blurVPostProcess.onApply = function (effect) {
  116332. if (!_this._scene.activeCamera) {
  116333. return;
  116334. }
  116335. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  116336. effect.setFloat("near", _this._scene.activeCamera.minZ);
  116337. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  116338. effect.setFloat("radius", _this.radius);
  116339. effect.setTexture("depthSampler", _this._depthTexture);
  116340. if (_this._firstUpdate) {
  116341. effect.setArray("samplerOffsets", _this._samplerOffsets);
  116342. _this._firstUpdate = false;
  116343. }
  116344. };
  116345. this._blurHPostProcess.samples = this.textureSamples;
  116346. this._blurVPostProcess.samples = this.textureSamples;
  116347. };
  116348. /** @hidden */
  116349. SSAO2RenderingPipeline.prototype._rebuild = function () {
  116350. this._firstUpdate = true;
  116351. _super.prototype._rebuild.call(this);
  116352. };
  116353. //Van der Corput radical inverse
  116354. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  116355. this._bits[0] = i;
  116356. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  116357. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  116358. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  116359. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  116360. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  116361. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  116362. };
  116363. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  116364. return [i / n, this._radicalInverse_VdC(i)];
  116365. };
  116366. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  116367. var phi = v * 2.0 * Math.PI;
  116368. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  116369. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  116370. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  116371. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  116372. };
  116373. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  116374. var numSamples = this.samples;
  116375. var result = [];
  116376. var vector;
  116377. var i = 0;
  116378. while (i < numSamples) {
  116379. if (numSamples < 16) {
  116380. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  116381. }
  116382. else {
  116383. var rand = this._hammersley(i, numSamples);
  116384. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  116385. }
  116386. result.push(vector.x, vector.y, vector.z);
  116387. i++;
  116388. }
  116389. return result;
  116390. };
  116391. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  116392. var _this = this;
  116393. var numSamples = this.samples;
  116394. this._sampleSphere = this._generateHemisphere();
  116395. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  116396. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  116397. "base", "range", "projection", "near", "far", "texelSize",
  116398. "xViewport", "yViewport", "maxZ", "minZAspect"
  116399. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  116400. this._ssaoPostProcess.onApply = function (effect) {
  116401. if (_this._firstUpdate) {
  116402. effect.setArray3("sampleSphere", _this._sampleSphere);
  116403. effect.setFloat("randTextureTiles", 32.0);
  116404. }
  116405. if (!_this._scene.activeCamera) {
  116406. return;
  116407. }
  116408. effect.setFloat("samplesFactor", 1 / _this.samples);
  116409. effect.setFloat("totalStrength", _this.totalStrength);
  116410. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  116411. effect.setFloat("radius", _this.radius);
  116412. effect.setFloat("maxZ", _this.maxZ);
  116413. effect.setFloat("minZAspect", _this.minZAspect);
  116414. effect.setFloat("base", _this.base);
  116415. effect.setFloat("near", _this._scene.activeCamera.minZ);
  116416. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  116417. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  116418. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  116419. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  116420. effect.setTexture("textureSampler", _this._depthTexture);
  116421. effect.setTexture("normalSampler", _this._normalTexture);
  116422. effect.setTexture("randomSampler", _this._randomTexture);
  116423. };
  116424. this._ssaoPostProcess.samples = this.textureSamples;
  116425. };
  116426. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  116427. var _this = this;
  116428. 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);
  116429. this._ssaoCombinePostProcess.onApply = function (effect) {
  116430. var viewport = _this._scene.activeCamera.viewport;
  116431. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  116432. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  116433. };
  116434. this._ssaoCombinePostProcess.samples = this.textureSamples;
  116435. };
  116436. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  116437. var size = 128;
  116438. 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);
  116439. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  116440. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  116441. var context = this._randomTexture.getContext();
  116442. var rand = function (min, max) {
  116443. return Math.random() * (max - min) + min;
  116444. };
  116445. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  116446. for (var x = 0; x < size; x++) {
  116447. for (var y = 0; y < size; y++) {
  116448. randVector.x = rand(0.0, 1.0);
  116449. randVector.y = rand(0.0, 1.0);
  116450. randVector.z = 0.0;
  116451. randVector.normalize();
  116452. randVector.scaleInPlace(255);
  116453. randVector.x = Math.floor(randVector.x);
  116454. randVector.y = Math.floor(randVector.y);
  116455. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  116456. context.fillRect(x, y, 1, 1);
  116457. }
  116458. }
  116459. this._randomTexture.update(false);
  116460. };
  116461. /**
  116462. * Serialize the rendering pipeline (Used when exporting)
  116463. * @returns the serialized object
  116464. */
  116465. SSAO2RenderingPipeline.prototype.serialize = function () {
  116466. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  116467. serializationObject.customType = "SSAO2RenderingPipeline";
  116468. return serializationObject;
  116469. };
  116470. /**
  116471. * Parse the serialized pipeline
  116472. * @param source Source pipeline.
  116473. * @param scene The scene to load the pipeline to.
  116474. * @param rootUrl The URL of the serialized pipeline.
  116475. * @returns An instantiated pipeline from the serialized object.
  116476. */
  116477. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  116478. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  116479. };
  116480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116482. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  116483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116485. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  116486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116488. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  116489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  116491. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  116492. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116493. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  116494. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  116495. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116496. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116497. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  116498. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116499. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  116500. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  116501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116502. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116503. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  116504. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116505. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116506. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  116507. return SSAO2RenderingPipeline;
  116508. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  116509. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  116510. /***/ }),
  116511. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  116512. /*!*************************************************************************!*\
  116513. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  116514. \*************************************************************************/
  116515. /*! exports provided: SSAORenderingPipeline */
  116516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116517. "use strict";
  116518. __webpack_require__.r(__webpack_exports__);
  116519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  116520. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116521. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  116522. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116523. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  116524. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  116525. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  116526. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116527. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  116528. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116529. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  116530. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  116531. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  116532. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  116533. /**
  116534. * Render pipeline to produce ssao effect
  116535. */
  116536. var SSAORenderingPipeline = /** @class */ (function (_super) {
  116537. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  116538. /**
  116539. * @constructor
  116540. * @param name - The rendering pipeline name
  116541. * @param scene - The scene linked to this pipeline
  116542. * @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 }
  116543. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  116544. */
  116545. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  116546. var _this = _super.call(this, scene.getEngine(), name) || this;
  116547. // Members
  116548. /**
  116549. * @ignore
  116550. * The PassPostProcess id in the pipeline that contains the original scene color
  116551. */
  116552. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  116553. /**
  116554. * @ignore
  116555. * The SSAO PostProcess id in the pipeline
  116556. */
  116557. _this.SSAORenderEffect = "SSAORenderEffect";
  116558. /**
  116559. * @ignore
  116560. * The horizontal blur PostProcess id in the pipeline
  116561. */
  116562. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  116563. /**
  116564. * @ignore
  116565. * The vertical blur PostProcess id in the pipeline
  116566. */
  116567. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  116568. /**
  116569. * @ignore
  116570. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  116571. */
  116572. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  116573. /**
  116574. * The output strength of the SSAO post-process. Default value is 1.0.
  116575. */
  116576. _this.totalStrength = 1.0;
  116577. /**
  116578. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  116579. */
  116580. _this.radius = 0.0001;
  116581. /**
  116582. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  116583. * Must not be equal to fallOff and superior to fallOff.
  116584. * Default value is 0.0075
  116585. */
  116586. _this.area = 0.0075;
  116587. /**
  116588. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  116589. * Must not be equal to area and inferior to area.
  116590. * Default value is 0.000001
  116591. */
  116592. _this.fallOff = 0.000001;
  116593. /**
  116594. * The base color of the SSAO post-process
  116595. * The final result is "base + ssao" between [0, 1]
  116596. */
  116597. _this.base = 0.5;
  116598. _this._firstUpdate = true;
  116599. _this._scene = scene;
  116600. // Set up assets
  116601. _this._createRandomTexture();
  116602. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  116603. var ssaoRatio = ratio.ssaoRatio || ratio;
  116604. var combineRatio = ratio.combineRatio || ratio;
  116605. _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);
  116606. _this._createSSAOPostProcess(ssaoRatio);
  116607. _this._createBlurPostProcess(ssaoRatio);
  116608. _this._createSSAOCombinePostProcess(combineRatio);
  116609. // Set up pipeline
  116610. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  116611. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  116612. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  116613. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  116614. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  116615. // Finish
  116616. scene.postProcessRenderPipelineManager.addPipeline(_this);
  116617. if (cameras) {
  116618. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  116619. }
  116620. return _this;
  116621. }
  116622. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  116623. /**
  116624. * Gets active scene
  116625. */
  116626. get: function () {
  116627. return this._scene;
  116628. },
  116629. enumerable: true,
  116630. configurable: true
  116631. });
  116632. // Public Methods
  116633. /**
  116634. * Get the class name
  116635. * @returns "SSAORenderingPipeline"
  116636. */
  116637. SSAORenderingPipeline.prototype.getClassName = function () {
  116638. return "SSAORenderingPipeline";
  116639. };
  116640. /**
  116641. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  116642. */
  116643. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  116644. if (disableDepthRender === void 0) { disableDepthRender = false; }
  116645. for (var i = 0; i < this._scene.cameras.length; i++) {
  116646. var camera = this._scene.cameras[i];
  116647. this._originalColorPostProcess.dispose(camera);
  116648. this._ssaoPostProcess.dispose(camera);
  116649. this._blurHPostProcess.dispose(camera);
  116650. this._blurVPostProcess.dispose(camera);
  116651. this._ssaoCombinePostProcess.dispose(camera);
  116652. }
  116653. this._randomTexture.dispose();
  116654. if (disableDepthRender) {
  116655. this._scene.disableDepthRenderer();
  116656. }
  116657. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  116658. _super.prototype.dispose.call(this);
  116659. };
  116660. // Private Methods
  116661. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  116662. var _this = this;
  116663. var size = 16;
  116664. 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);
  116665. 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);
  116666. this._blurHPostProcess.onActivateObservable.add(function () {
  116667. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  116668. _this._blurHPostProcess.kernel = size * dw;
  116669. });
  116670. this._blurVPostProcess.onActivateObservable.add(function () {
  116671. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  116672. _this._blurVPostProcess.kernel = size * dw;
  116673. });
  116674. };
  116675. /** @hidden */
  116676. SSAORenderingPipeline.prototype._rebuild = function () {
  116677. this._firstUpdate = true;
  116678. _super.prototype._rebuild.call(this);
  116679. };
  116680. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  116681. var _this = this;
  116682. var numSamples = 16;
  116683. var sampleSphere = [
  116684. 0.5381, 0.1856, -0.4319,
  116685. 0.1379, 0.2486, 0.4430,
  116686. 0.3371, 0.5679, -0.0057,
  116687. -0.6999, -0.0451, -0.0019,
  116688. 0.0689, -0.1598, -0.8547,
  116689. 0.0560, 0.0069, -0.1843,
  116690. -0.0146, 0.1402, 0.0762,
  116691. 0.0100, -0.1924, -0.0344,
  116692. -0.3577, -0.5301, -0.4358,
  116693. -0.3169, 0.1063, 0.0158,
  116694. 0.0103, -0.5869, 0.0046,
  116695. -0.0897, -0.4940, 0.3287,
  116696. 0.7119, -0.0154, -0.0918,
  116697. -0.0533, 0.0596, -0.5411,
  116698. 0.0352, -0.0631, 0.5460,
  116699. -0.4776, 0.2847, -0.0271
  116700. ];
  116701. var samplesFactor = 1.0 / numSamples;
  116702. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  116703. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  116704. "area", "fallOff", "base", "range", "viewport"
  116705. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  116706. this._ssaoPostProcess.onApply = function (effect) {
  116707. if (_this._firstUpdate) {
  116708. effect.setArray3("sampleSphere", sampleSphere);
  116709. effect.setFloat("samplesFactor", samplesFactor);
  116710. effect.setFloat("randTextureTiles", 4.0);
  116711. }
  116712. effect.setFloat("totalStrength", _this.totalStrength);
  116713. effect.setFloat("radius", _this.radius);
  116714. effect.setFloat("area", _this.area);
  116715. effect.setFloat("fallOff", _this.fallOff);
  116716. effect.setFloat("base", _this.base);
  116717. effect.setTexture("textureSampler", _this._depthTexture);
  116718. effect.setTexture("randomSampler", _this._randomTexture);
  116719. };
  116720. };
  116721. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  116722. var _this = this;
  116723. 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);
  116724. this._ssaoCombinePostProcess.onApply = function (effect) {
  116725. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  116726. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  116727. };
  116728. };
  116729. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  116730. var size = 512;
  116731. 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);
  116732. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  116733. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  116734. var context = this._randomTexture.getContext();
  116735. var rand = function (min, max) {
  116736. return Math.random() * (max - min) + min;
  116737. };
  116738. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  116739. for (var x = 0; x < size; x++) {
  116740. for (var y = 0; y < size; y++) {
  116741. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  116742. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  116743. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  116744. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  116745. context.fillRect(x, y, 1, 1);
  116746. }
  116747. }
  116748. this._randomTexture.update(false);
  116749. };
  116750. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116751. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116752. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  116753. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116754. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116755. ], SSAORenderingPipeline.prototype, "radius", void 0);
  116756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116758. ], SSAORenderingPipeline.prototype, "area", void 0);
  116759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116761. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  116762. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116763. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116764. ], SSAORenderingPipeline.prototype, "base", void 0);
  116765. return SSAORenderingPipeline;
  116766. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  116767. /***/ }),
  116768. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  116769. /*!*****************************************************************************!*\
  116770. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  116771. \*****************************************************************************/
  116772. /*! exports provided: StandardRenderingPipeline */
  116773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116774. "use strict";
  116775. __webpack_require__.r(__webpack_exports__);
  116776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  116777. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116778. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  116779. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  116780. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  116781. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  116782. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116783. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  116784. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  116785. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116786. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116787. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  116788. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  116789. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  116790. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  116791. /**
  116792. * Standard rendering pipeline
  116793. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  116794. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  116795. */
  116796. var StandardRenderingPipeline = /** @class */ (function (_super) {
  116797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  116798. /**
  116799. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  116800. * @constructor
  116801. * @param name The rendering pipeline name
  116802. * @param scene The scene linked to this pipeline
  116803. * @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)
  116804. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  116805. * @param cameras The array of cameras that the rendering pipeline will be attached to
  116806. */
  116807. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  116808. if (originalPostProcess === void 0) { originalPostProcess = null; }
  116809. var _this = _super.call(this, scene.getEngine(), name) || this;
  116810. /**
  116811. * Post-process used to down scale an image x4
  116812. */
  116813. _this.downSampleX4PostProcess = null;
  116814. /**
  116815. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  116816. */
  116817. _this.brightPassPostProcess = null;
  116818. /**
  116819. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  116820. */
  116821. _this.blurHPostProcesses = [];
  116822. /**
  116823. * Post-process array storing all the vertical blur post-processes used by the pipeline
  116824. */
  116825. _this.blurVPostProcesses = [];
  116826. /**
  116827. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  116828. */
  116829. _this.textureAdderPostProcess = null;
  116830. /**
  116831. * Post-process used to create volumetric lighting effect
  116832. */
  116833. _this.volumetricLightPostProcess = null;
  116834. /**
  116835. * Post-process used to smooth the previous volumetric light post-process on the X axis
  116836. */
  116837. _this.volumetricLightSmoothXPostProcess = null;
  116838. /**
  116839. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  116840. */
  116841. _this.volumetricLightSmoothYPostProcess = null;
  116842. /**
  116843. * Post-process used to merge the volumetric light effect and the real scene color
  116844. */
  116845. _this.volumetricLightMergePostProces = null;
  116846. /**
  116847. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  116848. */
  116849. _this.volumetricLightFinalPostProcess = null;
  116850. /**
  116851. * Base post-process used to calculate the average luminance of the final image for HDR
  116852. */
  116853. _this.luminancePostProcess = null;
  116854. /**
  116855. * Post-processes used to create down sample post-processes in order to get
  116856. * the average luminance of the final image for HDR
  116857. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  116858. */
  116859. _this.luminanceDownSamplePostProcesses = [];
  116860. /**
  116861. * Post-process used to create a HDR effect (light adaptation)
  116862. */
  116863. _this.hdrPostProcess = null;
  116864. /**
  116865. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  116866. */
  116867. _this.textureAdderFinalPostProcess = null;
  116868. /**
  116869. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  116870. */
  116871. _this.lensFlareFinalPostProcess = null;
  116872. /**
  116873. * Post-process used to merge the final HDR post-process and the real scene color
  116874. */
  116875. _this.hdrFinalPostProcess = null;
  116876. /**
  116877. * Post-process used to create a lens flare effect
  116878. */
  116879. _this.lensFlarePostProcess = null;
  116880. /**
  116881. * Post-process that merges the result of the lens flare post-process and the real scene color
  116882. */
  116883. _this.lensFlareComposePostProcess = null;
  116884. /**
  116885. * Post-process used to create a motion blur effect
  116886. */
  116887. _this.motionBlurPostProcess = null;
  116888. /**
  116889. * Post-process used to create a depth of field effect
  116890. */
  116891. _this.depthOfFieldPostProcess = null;
  116892. /**
  116893. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  116894. */
  116895. _this.fxaaPostProcess = null;
  116896. // Values
  116897. /**
  116898. * Represents the brightness threshold in order to configure the illuminated surfaces
  116899. */
  116900. _this.brightThreshold = 1.0;
  116901. /**
  116902. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  116903. */
  116904. _this.blurWidth = 512.0;
  116905. /**
  116906. * Sets if the blur for highlighted surfaces must be only horizontal
  116907. */
  116908. _this.horizontalBlur = false;
  116909. /**
  116910. * Sets the overall exposure used by the pipeline
  116911. */
  116912. _this.exposure = 1.0;
  116913. /**
  116914. * Texture used typically to simulate "dirty" on camera lens
  116915. */
  116916. _this.lensTexture = null;
  116917. /**
  116918. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  116919. */
  116920. _this.volumetricLightCoefficient = 0.2;
  116921. /**
  116922. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  116923. */
  116924. _this.volumetricLightPower = 4.0;
  116925. /**
  116926. * Used the set the blur intensity to smooth the volumetric lights
  116927. */
  116928. _this.volumetricLightBlurScale = 64.0;
  116929. /**
  116930. * Light (spot or directional) used to generate the volumetric lights rays
  116931. * The source light must have a shadow generate so the pipeline can get its
  116932. * depth map
  116933. */
  116934. _this.sourceLight = null;
  116935. /**
  116936. * For eye adaptation, represents the minimum luminance the eye can see
  116937. */
  116938. _this.hdrMinimumLuminance = 1.0;
  116939. /**
  116940. * For eye adaptation, represents the decrease luminance speed
  116941. */
  116942. _this.hdrDecreaseRate = 0.5;
  116943. /**
  116944. * For eye adaptation, represents the increase luminance speed
  116945. */
  116946. _this.hdrIncreaseRate = 0.5;
  116947. /**
  116948. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  116949. */
  116950. _this.lensColorTexture = null;
  116951. /**
  116952. * The overall strengh for the lens flare effect
  116953. */
  116954. _this.lensFlareStrength = 20.0;
  116955. /**
  116956. * Dispersion coefficient for lens flare ghosts
  116957. */
  116958. _this.lensFlareGhostDispersal = 1.4;
  116959. /**
  116960. * Main lens flare halo width
  116961. */
  116962. _this.lensFlareHaloWidth = 0.7;
  116963. /**
  116964. * Based on the lens distortion effect, defines how much the lens flare result
  116965. * is distorted
  116966. */
  116967. _this.lensFlareDistortionStrength = 16.0;
  116968. /**
  116969. * Lens star texture must be used to simulate rays on the flares and is available
  116970. * in the documentation
  116971. */
  116972. _this.lensStarTexture = null;
  116973. /**
  116974. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  116975. * flare effect by taking account of the dirt texture
  116976. */
  116977. _this.lensFlareDirtTexture = null;
  116978. /**
  116979. * Represents the focal length for the depth of field effect
  116980. */
  116981. _this.depthOfFieldDistance = 10.0;
  116982. /**
  116983. * Represents the blur intensity for the blurred part of the depth of field effect
  116984. */
  116985. _this.depthOfFieldBlurWidth = 64.0;
  116986. /**
  116987. * For motion blur, defines how much the image is blurred by the movement
  116988. */
  116989. _this.motionStrength = 1.0;
  116990. /**
  116991. * List of animations for the pipeline (IAnimatable implementation)
  116992. */
  116993. _this.animations = [];
  116994. _this._currentDepthOfFieldSource = null;
  116995. _this._hdrCurrentLuminance = 1.0;
  116996. // Getters and setters
  116997. _this._bloomEnabled = false;
  116998. _this._depthOfFieldEnabled = false;
  116999. _this._vlsEnabled = false;
  117000. _this._lensFlareEnabled = false;
  117001. _this._hdrEnabled = false;
  117002. _this._motionBlurEnabled = false;
  117003. _this._fxaaEnabled = false;
  117004. _this._motionBlurSamples = 64.0;
  117005. _this._volumetricLightStepsCount = 50.0;
  117006. _this._samples = 1;
  117007. _this._cameras = cameras || [];
  117008. // Initialize
  117009. _this._scene = scene;
  117010. _this._basePostProcess = originalPostProcess;
  117011. _this._ratio = ratio;
  117012. // Misc
  117013. _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;
  117014. // Finish
  117015. scene.postProcessRenderPipelineManager.addPipeline(_this);
  117016. _this._buildPipeline();
  117017. return _this;
  117018. }
  117019. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  117020. /**
  117021. * @ignore
  117022. * Specifies if the bloom pipeline is enabled
  117023. */
  117024. get: function () {
  117025. return this._bloomEnabled;
  117026. },
  117027. set: function (enabled) {
  117028. if (this._bloomEnabled === enabled) {
  117029. return;
  117030. }
  117031. this._bloomEnabled = enabled;
  117032. this._buildPipeline();
  117033. },
  117034. enumerable: true,
  117035. configurable: true
  117036. });
  117037. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  117038. /**
  117039. * @ignore
  117040. * Specifies if the depth of field pipeline is enabed
  117041. */
  117042. get: function () {
  117043. return this._depthOfFieldEnabled;
  117044. },
  117045. set: function (enabled) {
  117046. if (this._depthOfFieldEnabled === enabled) {
  117047. return;
  117048. }
  117049. this._depthOfFieldEnabled = enabled;
  117050. this._buildPipeline();
  117051. },
  117052. enumerable: true,
  117053. configurable: true
  117054. });
  117055. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  117056. /**
  117057. * @ignore
  117058. * Specifies if the lens flare pipeline is enabed
  117059. */
  117060. get: function () {
  117061. return this._lensFlareEnabled;
  117062. },
  117063. set: function (enabled) {
  117064. if (this._lensFlareEnabled === enabled) {
  117065. return;
  117066. }
  117067. this._lensFlareEnabled = enabled;
  117068. this._buildPipeline();
  117069. },
  117070. enumerable: true,
  117071. configurable: true
  117072. });
  117073. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  117074. /**
  117075. * @ignore
  117076. * Specifies if the HDR pipeline is enabled
  117077. */
  117078. get: function () {
  117079. return this._hdrEnabled;
  117080. },
  117081. set: function (enabled) {
  117082. if (this._hdrEnabled === enabled) {
  117083. return;
  117084. }
  117085. this._hdrEnabled = enabled;
  117086. this._buildPipeline();
  117087. },
  117088. enumerable: true,
  117089. configurable: true
  117090. });
  117091. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  117092. /**
  117093. * @ignore
  117094. * Specifies if the volumetric lights scattering effect is enabled
  117095. */
  117096. get: function () {
  117097. return this._vlsEnabled;
  117098. },
  117099. set: function (enabled) {
  117100. if (this._vlsEnabled === enabled) {
  117101. return;
  117102. }
  117103. if (enabled) {
  117104. var geometry = this._scene.enableGeometryBufferRenderer();
  117105. if (!geometry) {
  117106. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  117107. return;
  117108. }
  117109. }
  117110. this._vlsEnabled = enabled;
  117111. this._buildPipeline();
  117112. },
  117113. enumerable: true,
  117114. configurable: true
  117115. });
  117116. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  117117. /**
  117118. * @ignore
  117119. * Specifies if the motion blur effect is enabled
  117120. */
  117121. get: function () {
  117122. return this._motionBlurEnabled;
  117123. },
  117124. set: function (enabled) {
  117125. if (this._motionBlurEnabled === enabled) {
  117126. return;
  117127. }
  117128. this._motionBlurEnabled = enabled;
  117129. this._buildPipeline();
  117130. },
  117131. enumerable: true,
  117132. configurable: true
  117133. });
  117134. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  117135. /**
  117136. * Specifies if anti-aliasing is enabled
  117137. */
  117138. get: function () {
  117139. return this._fxaaEnabled;
  117140. },
  117141. set: function (enabled) {
  117142. if (this._fxaaEnabled === enabled) {
  117143. return;
  117144. }
  117145. this._fxaaEnabled = enabled;
  117146. this._buildPipeline();
  117147. },
  117148. enumerable: true,
  117149. configurable: true
  117150. });
  117151. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  117152. /**
  117153. * Specifies the number of steps used to calculate the volumetric lights
  117154. * Typically in interval [50, 200]
  117155. */
  117156. get: function () {
  117157. return this._volumetricLightStepsCount;
  117158. },
  117159. set: function (count) {
  117160. if (this.volumetricLightPostProcess) {
  117161. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  117162. }
  117163. this._volumetricLightStepsCount = count;
  117164. },
  117165. enumerable: true,
  117166. configurable: true
  117167. });
  117168. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  117169. /**
  117170. * Specifies the number of samples used for the motion blur effect
  117171. * Typically in interval [16, 64]
  117172. */
  117173. get: function () {
  117174. return this._motionBlurSamples;
  117175. },
  117176. set: function (samples) {
  117177. if (this.motionBlurPostProcess) {
  117178. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  117179. }
  117180. this._motionBlurSamples = samples;
  117181. },
  117182. enumerable: true,
  117183. configurable: true
  117184. });
  117185. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  117186. /**
  117187. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  117188. */
  117189. get: function () {
  117190. return this._samples;
  117191. },
  117192. set: function (sampleCount) {
  117193. if (this._samples === sampleCount) {
  117194. return;
  117195. }
  117196. this._samples = sampleCount;
  117197. this._buildPipeline();
  117198. },
  117199. enumerable: true,
  117200. configurable: true
  117201. });
  117202. StandardRenderingPipeline.prototype._buildPipeline = function () {
  117203. var _this = this;
  117204. var ratio = this._ratio;
  117205. var scene = this._scene;
  117206. this._disposePostProcesses();
  117207. this._reset();
  117208. // Create pass post-process
  117209. if (!this._basePostProcess) {
  117210. 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);
  117211. this.originalPostProcess.onApply = function () {
  117212. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  117213. };
  117214. }
  117215. else {
  117216. this.originalPostProcess = this._basePostProcess;
  117217. }
  117218. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  117219. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  117220. }
  117221. this._currentDepthOfFieldSource = this.originalPostProcess;
  117222. if (this._bloomEnabled) {
  117223. // Create down sample X4 post-process
  117224. this._createDownSampleX4PostProcess(scene, ratio / 2);
  117225. // Create bright pass post-process
  117226. this._createBrightPassPostProcess(scene, ratio / 2);
  117227. // Create gaussian blur post-processes (down sampling blurs)
  117228. this._createBlurPostProcesses(scene, ratio / 4, 1);
  117229. // Create texture adder post-process
  117230. this._createTextureAdderPostProcess(scene, ratio);
  117231. // Create depth-of-field source post-process
  117232. 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);
  117233. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  117234. }
  117235. if (this._vlsEnabled) {
  117236. // Create volumetric light
  117237. this._createVolumetricLightPostProcess(scene, ratio);
  117238. // Create volumetric light final post-process
  117239. 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);
  117240. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  117241. }
  117242. if (this._lensFlareEnabled) {
  117243. // Create lens flare post-process
  117244. this._createLensFlarePostProcess(scene, ratio);
  117245. // Create depth-of-field source post-process post lens-flare and disable it now
  117246. 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);
  117247. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  117248. }
  117249. if (this._hdrEnabled) {
  117250. // Create luminance
  117251. this._createLuminancePostProcesses(scene, this._floatTextureType);
  117252. // Create HDR
  117253. this._createHdrPostProcess(scene, ratio);
  117254. // Create depth-of-field source post-process post hdr and disable it now
  117255. 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);
  117256. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  117257. }
  117258. if (this._depthOfFieldEnabled) {
  117259. // Create gaussian blur used by depth-of-field
  117260. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  117261. // Create depth-of-field post-process
  117262. this._createDepthOfFieldPostProcess(scene, ratio);
  117263. }
  117264. if (this._motionBlurEnabled) {
  117265. // Create motion blur post-process
  117266. this._createMotionBlurPostProcess(scene, ratio);
  117267. }
  117268. if (this._fxaaEnabled) {
  117269. // Create fxaa post-process
  117270. 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);
  117271. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  117272. }
  117273. if (this._cameras !== null) {
  117274. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  117275. }
  117276. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  117277. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  117278. }
  117279. };
  117280. // Down Sample X4 Post-Processs
  117281. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  117282. var _this = this;
  117283. var downSampleX4Offsets = new Array(32);
  117284. 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);
  117285. this.downSampleX4PostProcess.onApply = function (effect) {
  117286. var id = 0;
  117287. var width = _this.downSampleX4PostProcess.width;
  117288. var height = _this.downSampleX4PostProcess.height;
  117289. for (var i = -2; i < 2; i++) {
  117290. for (var j = -2; j < 2; j++) {
  117291. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  117292. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  117293. id += 2;
  117294. }
  117295. }
  117296. effect.setArray2("dsOffsets", downSampleX4Offsets);
  117297. };
  117298. // Add to pipeline
  117299. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  117300. };
  117301. // Brightpass Post-Process
  117302. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  117303. var _this = this;
  117304. var brightOffsets = new Array(8);
  117305. 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);
  117306. this.brightPassPostProcess.onApply = function (effect) {
  117307. var sU = (1.0 / _this.brightPassPostProcess.width);
  117308. var sV = (1.0 / _this.brightPassPostProcess.height);
  117309. brightOffsets[0] = -0.5 * sU;
  117310. brightOffsets[1] = 0.5 * sV;
  117311. brightOffsets[2] = 0.5 * sU;
  117312. brightOffsets[3] = 0.5 * sV;
  117313. brightOffsets[4] = -0.5 * sU;
  117314. brightOffsets[5] = -0.5 * sV;
  117315. brightOffsets[6] = 0.5 * sU;
  117316. brightOffsets[7] = -0.5 * sV;
  117317. effect.setArray2("dsOffsets", brightOffsets);
  117318. effect.setFloat("brightThreshold", _this.brightThreshold);
  117319. };
  117320. // Add to pipeline
  117321. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  117322. };
  117323. // Create blur H&V post-processes
  117324. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  117325. var _this = this;
  117326. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  117327. var engine = scene.getEngine();
  117328. 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);
  117329. 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);
  117330. blurX.onActivateObservable.add(function () {
  117331. var dw = blurX.width / engine.getRenderWidth();
  117332. blurX.kernel = _this[blurWidthKey] * dw;
  117333. });
  117334. blurY.onActivateObservable.add(function () {
  117335. var dw = blurY.height / engine.getRenderHeight();
  117336. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  117337. });
  117338. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  117339. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  117340. this.blurHPostProcesses.push(blurX);
  117341. this.blurVPostProcesses.push(blurY);
  117342. };
  117343. // Create texture adder post-process
  117344. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  117345. var _this = this;
  117346. 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);
  117347. this.textureAdderPostProcess.onApply = function (effect) {
  117348. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  117349. effect.setTexture("lensSampler", _this.lensTexture);
  117350. effect.setFloat("exposure", _this.exposure);
  117351. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  117352. };
  117353. // Add to pipeline
  117354. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  117355. };
  117356. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  117357. var _this = this;
  117358. var geometryRenderer = scene.enableGeometryBufferRenderer();
  117359. geometryRenderer.enablePosition = true;
  117360. var geometry = geometryRenderer.getGBuffer();
  117361. // Base post-process
  117362. 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));
  117363. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  117364. this.volumetricLightPostProcess.onApply = function (effect) {
  117365. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  117366. var generator = _this.sourceLight.getShadowGenerator();
  117367. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  117368. effect.setTexture("positionSampler", geometry.textures[2]);
  117369. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  117370. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  117371. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  117372. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  117373. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  117374. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  117375. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  117376. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  117377. effect.setVector2("depthValues", depthValues);
  117378. }
  117379. };
  117380. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  117381. // Smooth
  117382. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  117383. // Merge
  117384. 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");
  117385. this.volumetricLightMergePostProces.onApply = function (effect) {
  117386. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  117387. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  117388. };
  117389. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  117390. };
  117391. // Create luminance
  117392. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  117393. var _this = this;
  117394. // Create luminance
  117395. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  117396. 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);
  117397. var offsets = [];
  117398. this.luminancePostProcess.onApply = function (effect) {
  117399. var sU = (1.0 / _this.luminancePostProcess.width);
  117400. var sV = (1.0 / _this.luminancePostProcess.height);
  117401. offsets[0] = -0.5 * sU;
  117402. offsets[1] = 0.5 * sV;
  117403. offsets[2] = 0.5 * sU;
  117404. offsets[3] = 0.5 * sV;
  117405. offsets[4] = -0.5 * sU;
  117406. offsets[5] = -0.5 * sV;
  117407. offsets[6] = 0.5 * sU;
  117408. offsets[7] = -0.5 * sV;
  117409. effect.setArray2("lumOffsets", offsets);
  117410. };
  117411. // Add to pipeline
  117412. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  117413. // Create down sample luminance
  117414. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  117415. var size = Math.pow(3, i);
  117416. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  117417. if (i === 0) {
  117418. defines += "#define FINAL_DOWN_SAMPLER";
  117419. }
  117420. 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);
  117421. this.luminanceDownSamplePostProcesses.push(postProcess);
  117422. }
  117423. // Create callbacks and add effects
  117424. var lastLuminance = this.luminancePostProcess;
  117425. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  117426. var downSampleOffsets = new Array(18);
  117427. pp.onApply = function (effect) {
  117428. if (!lastLuminance) {
  117429. return;
  117430. }
  117431. var id = 0;
  117432. for (var x = -1; x < 2; x++) {
  117433. for (var y = -1; y < 2; y++) {
  117434. downSampleOffsets[id] = x / lastLuminance.width;
  117435. downSampleOffsets[id + 1] = y / lastLuminance.height;
  117436. id += 2;
  117437. }
  117438. }
  117439. effect.setArray2("dsOffsets", downSampleOffsets);
  117440. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  117441. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  117442. lastLuminance = _this.luminancePostProcess;
  117443. }
  117444. else {
  117445. lastLuminance = pp;
  117446. }
  117447. };
  117448. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  117449. pp.onAfterRender = function () {
  117450. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  117451. 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);
  117452. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  117453. };
  117454. }
  117455. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  117456. });
  117457. };
  117458. // Create HDR post-process
  117459. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  117460. var _this = this;
  117461. 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);
  117462. var outputLiminance = 1;
  117463. var time = 0;
  117464. var lastTime = 0;
  117465. this.hdrPostProcess.onApply = function (effect) {
  117466. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  117467. time += scene.getEngine().getDeltaTime();
  117468. if (outputLiminance < 0) {
  117469. outputLiminance = _this._hdrCurrentLuminance;
  117470. }
  117471. else {
  117472. var dt = (lastTime - time) / 1000.0;
  117473. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  117474. outputLiminance += _this.hdrDecreaseRate * dt;
  117475. }
  117476. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  117477. outputLiminance -= _this.hdrIncreaseRate * dt;
  117478. }
  117479. else {
  117480. outputLiminance = _this._hdrCurrentLuminance;
  117481. }
  117482. }
  117483. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  117484. effect.setFloat("averageLuminance", outputLiminance);
  117485. lastTime = time;
  117486. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  117487. };
  117488. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  117489. };
  117490. // Create lens flare post-process
  117491. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  117492. var _this = this;
  117493. 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);
  117494. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  117495. this._createBlurPostProcesses(scene, ratio / 4, 2);
  117496. 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);
  117497. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  117498. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  117499. // Lens flare
  117500. this.lensFlarePostProcess.onApply = function (effect) {
  117501. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  117502. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  117503. effect.setFloat("strength", _this.lensFlareStrength);
  117504. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  117505. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  117506. // Shift
  117507. resolution.x = _this.lensFlarePostProcess.width;
  117508. resolution.y = _this.lensFlarePostProcess.height;
  117509. effect.setVector2("resolution", resolution);
  117510. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  117511. };
  117512. // Compose
  117513. 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);
  117514. 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);
  117515. this.lensFlareComposePostProcess.onApply = function (effect) {
  117516. if (!_this._scene.activeCamera) {
  117517. return;
  117518. }
  117519. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  117520. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  117521. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  117522. // Lens start rotation matrix
  117523. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  117524. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  117525. 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));
  117526. camRot *= 4.0;
  117527. 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);
  117528. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  117529. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  117530. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  117531. };
  117532. };
  117533. // Create depth-of-field post-process
  117534. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  117535. var _this = this;
  117536. 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);
  117537. this.depthOfFieldPostProcess.onApply = function (effect) {
  117538. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  117539. effect.setTexture("depthSampler", _this._getDepthTexture());
  117540. effect.setFloat("distance", _this.depthOfFieldDistance);
  117541. };
  117542. // Add to pipeline
  117543. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  117544. };
  117545. // Create motion blur post-process
  117546. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  117547. var _this = this;
  117548. 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);
  117549. var motionScale = 0;
  117550. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  117551. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  117552. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  117553. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  117554. this.motionBlurPostProcess.onApply = function (effect) {
  117555. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  117556. viewProjection.invertToRef(invViewProjection);
  117557. effect.setMatrix("inverseViewProjection", invViewProjection);
  117558. effect.setMatrix("prevViewProjection", prevViewProjection);
  117559. prevViewProjection = viewProjection;
  117560. screenSize.x = _this.motionBlurPostProcess.width;
  117561. screenSize.y = _this.motionBlurPostProcess.height;
  117562. effect.setVector2("screenSize", screenSize);
  117563. motionScale = scene.getEngine().getFps() / 60.0;
  117564. effect.setFloat("motionScale", motionScale);
  117565. effect.setFloat("motionStrength", _this.motionStrength);
  117566. effect.setTexture("depthSampler", _this._getDepthTexture());
  117567. };
  117568. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  117569. };
  117570. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  117571. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  117572. var renderer = this._scene.enableGeometryBufferRenderer();
  117573. return renderer.getGBuffer().textures[0];
  117574. }
  117575. return this._scene.enableDepthRenderer().getDepthMap();
  117576. };
  117577. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  117578. for (var i = 0; i < this._cameras.length; i++) {
  117579. var camera = this._cameras[i];
  117580. if (this.originalPostProcess) {
  117581. this.originalPostProcess.dispose(camera);
  117582. }
  117583. if (this.downSampleX4PostProcess) {
  117584. this.downSampleX4PostProcess.dispose(camera);
  117585. }
  117586. if (this.brightPassPostProcess) {
  117587. this.brightPassPostProcess.dispose(camera);
  117588. }
  117589. if (this.textureAdderPostProcess) {
  117590. this.textureAdderPostProcess.dispose(camera);
  117591. }
  117592. if (this.textureAdderFinalPostProcess) {
  117593. this.textureAdderFinalPostProcess.dispose(camera);
  117594. }
  117595. if (this.volumetricLightPostProcess) {
  117596. this.volumetricLightPostProcess.dispose(camera);
  117597. }
  117598. if (this.volumetricLightSmoothXPostProcess) {
  117599. this.volumetricLightSmoothXPostProcess.dispose(camera);
  117600. }
  117601. if (this.volumetricLightSmoothYPostProcess) {
  117602. this.volumetricLightSmoothYPostProcess.dispose(camera);
  117603. }
  117604. if (this.volumetricLightMergePostProces) {
  117605. this.volumetricLightMergePostProces.dispose(camera);
  117606. }
  117607. if (this.volumetricLightFinalPostProcess) {
  117608. this.volumetricLightFinalPostProcess.dispose(camera);
  117609. }
  117610. if (this.lensFlarePostProcess) {
  117611. this.lensFlarePostProcess.dispose(camera);
  117612. }
  117613. if (this.lensFlareComposePostProcess) {
  117614. this.lensFlareComposePostProcess.dispose(camera);
  117615. }
  117616. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  117617. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  117618. }
  117619. if (this.luminancePostProcess) {
  117620. this.luminancePostProcess.dispose(camera);
  117621. }
  117622. if (this.hdrPostProcess) {
  117623. this.hdrPostProcess.dispose(camera);
  117624. }
  117625. if (this.hdrFinalPostProcess) {
  117626. this.hdrFinalPostProcess.dispose(camera);
  117627. }
  117628. if (this.depthOfFieldPostProcess) {
  117629. this.depthOfFieldPostProcess.dispose(camera);
  117630. }
  117631. if (this.motionBlurPostProcess) {
  117632. this.motionBlurPostProcess.dispose(camera);
  117633. }
  117634. if (this.fxaaPostProcess) {
  117635. this.fxaaPostProcess.dispose(camera);
  117636. }
  117637. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  117638. this.blurHPostProcesses[j].dispose(camera);
  117639. }
  117640. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  117641. this.blurVPostProcesses[j].dispose(camera);
  117642. }
  117643. }
  117644. this.originalPostProcess = null;
  117645. this.downSampleX4PostProcess = null;
  117646. this.brightPassPostProcess = null;
  117647. this.textureAdderPostProcess = null;
  117648. this.textureAdderFinalPostProcess = null;
  117649. this.volumetricLightPostProcess = null;
  117650. this.volumetricLightSmoothXPostProcess = null;
  117651. this.volumetricLightSmoothYPostProcess = null;
  117652. this.volumetricLightMergePostProces = null;
  117653. this.volumetricLightFinalPostProcess = null;
  117654. this.lensFlarePostProcess = null;
  117655. this.lensFlareComposePostProcess = null;
  117656. this.luminancePostProcess = null;
  117657. this.hdrPostProcess = null;
  117658. this.hdrFinalPostProcess = null;
  117659. this.depthOfFieldPostProcess = null;
  117660. this.motionBlurPostProcess = null;
  117661. this.fxaaPostProcess = null;
  117662. this.luminanceDownSamplePostProcesses = [];
  117663. this.blurHPostProcesses = [];
  117664. this.blurVPostProcesses = [];
  117665. };
  117666. /**
  117667. * Dispose of the pipeline and stop all post processes
  117668. */
  117669. StandardRenderingPipeline.prototype.dispose = function () {
  117670. this._disposePostProcesses();
  117671. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  117672. _super.prototype.dispose.call(this);
  117673. };
  117674. /**
  117675. * Serialize the rendering pipeline (Used when exporting)
  117676. * @returns the serialized object
  117677. */
  117678. StandardRenderingPipeline.prototype.serialize = function () {
  117679. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  117680. if (this.sourceLight) {
  117681. serializationObject.sourceLightId = this.sourceLight.id;
  117682. }
  117683. serializationObject.customType = "StandardRenderingPipeline";
  117684. return serializationObject;
  117685. };
  117686. /**
  117687. * Parse the serialized pipeline
  117688. * @param source Source pipeline.
  117689. * @param scene The scene to load the pipeline to.
  117690. * @param rootUrl The URL of the serialized pipeline.
  117691. * @returns An instantiated pipeline from the serialized object.
  117692. */
  117693. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  117694. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  117695. if (source.sourceLightId) {
  117696. p.sourceLight = scene.getLightByID(source.sourceLightId);
  117697. }
  117698. return p;
  117699. };
  117700. /**
  117701. * Luminance steps
  117702. */
  117703. StandardRenderingPipeline.LuminanceSteps = 6;
  117704. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117706. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  117707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117709. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  117710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117711. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117712. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  117713. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117714. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117715. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  117716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  117718. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  117719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117721. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  117722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117724. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  117725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117727. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  117728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117730. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  117731. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117733. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  117734. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117735. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117736. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  117737. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117738. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  117739. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  117740. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117742. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  117743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117745. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  117746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117748. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  117749. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117750. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117751. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  117752. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  117754. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  117755. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  117757. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  117758. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117759. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117760. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  117761. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117762. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117763. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  117764. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117765. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117766. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  117767. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117768. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117769. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  117770. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117771. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117772. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  117773. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117774. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117775. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  117776. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117777. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117778. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  117779. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117780. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117781. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  117782. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117783. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117784. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  117785. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117786. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117787. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  117788. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117790. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  117791. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117792. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117793. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  117794. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117795. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117796. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  117797. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117798. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117799. ], StandardRenderingPipeline.prototype, "samples", null);
  117800. return StandardRenderingPipeline;
  117801. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  117802. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  117803. /***/ }),
  117804. /***/ "./PostProcesses/RenderPipeline/index.ts":
  117805. /*!***********************************************!*\
  117806. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  117807. \***********************************************/
  117808. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  117809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117810. "use strict";
  117811. __webpack_require__.r(__webpack_exports__);
  117812. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  117813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  117814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  117815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  117816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  117817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  117818. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  117820. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  117821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  117822. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  117823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  117824. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  117825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  117826. /***/ }),
  117827. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  117828. /*!*****************************************************************!*\
  117829. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  117830. \*****************************************************************/
  117831. /*! exports provided: PostProcessRenderEffect */
  117832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117833. "use strict";
  117834. __webpack_require__.r(__webpack_exports__);
  117835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  117836. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  117837. /**
  117838. * This represents a set of one or more post processes in Babylon.
  117839. * A post process can be used to apply a shader to a texture after it is rendered.
  117840. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117841. */
  117842. var PostProcessRenderEffect = /** @class */ (function () {
  117843. /**
  117844. * Instantiates a post process render effect.
  117845. * A post process can be used to apply a shader to a texture after it is rendered.
  117846. * @param engine The engine the effect is tied to
  117847. * @param name The name of the effect
  117848. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117849. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117850. */
  117851. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  117852. this._name = name;
  117853. this._singleInstance = singleInstance || true;
  117854. this._getPostProcesses = getPostProcesses;
  117855. this._cameras = {};
  117856. this._indicesForCamera = {};
  117857. this._postProcesses = {};
  117858. }
  117859. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  117860. /**
  117861. * Checks if all the post processes in the effect are supported.
  117862. */
  117863. get: function () {
  117864. for (var index in this._postProcesses) {
  117865. if (this._postProcesses.hasOwnProperty(index)) {
  117866. var pps = this._postProcesses[index];
  117867. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  117868. if (!pps[ppIndex].isSupported) {
  117869. return false;
  117870. }
  117871. }
  117872. }
  117873. }
  117874. return true;
  117875. },
  117876. enumerable: true,
  117877. configurable: true
  117878. });
  117879. /**
  117880. * Updates the current state of the effect
  117881. * @hidden
  117882. */
  117883. PostProcessRenderEffect.prototype._update = function () {
  117884. };
  117885. /**
  117886. * Attaches the effect on cameras
  117887. * @param cameras The camera to attach to.
  117888. * @hidden
  117889. */
  117890. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  117891. var _this = this;
  117892. var cameraKey;
  117893. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  117894. if (!cams) {
  117895. return;
  117896. }
  117897. for (var i = 0; i < cams.length; i++) {
  117898. var camera = cams[i];
  117899. var cameraName = camera.name;
  117900. if (this._singleInstance) {
  117901. cameraKey = 0;
  117902. }
  117903. else {
  117904. cameraKey = cameraName;
  117905. }
  117906. if (!this._postProcesses[cameraKey]) {
  117907. var postProcess = this._getPostProcesses();
  117908. if (postProcess) {
  117909. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  117910. }
  117911. }
  117912. if (!this._indicesForCamera[cameraName]) {
  117913. this._indicesForCamera[cameraName] = [];
  117914. }
  117915. this._postProcesses[cameraKey].forEach(function (postProcess) {
  117916. var index = camera.attachPostProcess(postProcess);
  117917. _this._indicesForCamera[cameraName].push(index);
  117918. });
  117919. if (!this._cameras[cameraName]) {
  117920. this._cameras[cameraName] = camera;
  117921. }
  117922. }
  117923. };
  117924. /**
  117925. * Detatches the effect on cameras
  117926. * @param cameras The camera to detatch from.
  117927. * @hidden
  117928. */
  117929. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  117930. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  117931. if (!cams) {
  117932. return;
  117933. }
  117934. for (var i = 0; i < cams.length; i++) {
  117935. var camera = cams[i];
  117936. var cameraName = camera.name;
  117937. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  117938. if (postProcesses) {
  117939. postProcesses.forEach(function (postProcess) {
  117940. camera.detachPostProcess(postProcess);
  117941. });
  117942. }
  117943. if (this._cameras[cameraName]) {
  117944. this._cameras[cameraName] = null;
  117945. }
  117946. }
  117947. };
  117948. /**
  117949. * Enables the effect on given cameras
  117950. * @param cameras The camera to enable.
  117951. * @hidden
  117952. */
  117953. PostProcessRenderEffect.prototype._enable = function (cameras) {
  117954. var _this = this;
  117955. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  117956. if (!cams) {
  117957. return;
  117958. }
  117959. for (var i = 0; i < cams.length; i++) {
  117960. var camera = cams[i];
  117961. var cameraName = camera.name;
  117962. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  117963. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  117964. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  117965. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  117966. });
  117967. }
  117968. }
  117969. }
  117970. };
  117971. /**
  117972. * Disables the effect on the given cameras
  117973. * @param cameras The camera to disable.
  117974. * @hidden
  117975. */
  117976. PostProcessRenderEffect.prototype._disable = function (cameras) {
  117977. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  117978. if (!cams) {
  117979. return;
  117980. }
  117981. for (var i = 0; i < cams.length; i++) {
  117982. var camera = cams[i];
  117983. var cameraName = camera.name;
  117984. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  117985. camera.detachPostProcess(postProcess);
  117986. });
  117987. }
  117988. };
  117989. /**
  117990. * Gets a list of the post processes contained in the effect.
  117991. * @param camera The camera to get the post processes on.
  117992. * @returns The list of the post processes in the effect.
  117993. */
  117994. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  117995. if (this._singleInstance) {
  117996. return this._postProcesses[0];
  117997. }
  117998. else {
  117999. if (!camera) {
  118000. return null;
  118001. }
  118002. return this._postProcesses[camera.name];
  118003. }
  118004. };
  118005. return PostProcessRenderEffect;
  118006. }());
  118007. /***/ }),
  118008. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  118009. /*!*******************************************************************!*\
  118010. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  118011. \*******************************************************************/
  118012. /*! exports provided: PostProcessRenderPipeline */
  118013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118014. "use strict";
  118015. __webpack_require__.r(__webpack_exports__);
  118016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  118017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118018. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  118019. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  118020. /**
  118021. * PostProcessRenderPipeline
  118022. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118023. */
  118024. var PostProcessRenderPipeline = /** @class */ (function () {
  118025. /**
  118026. * Initializes a PostProcessRenderPipeline
  118027. * @param engine engine to add the pipeline to
  118028. * @param name name of the pipeline
  118029. */
  118030. function PostProcessRenderPipeline(engine, name) {
  118031. this.engine = engine;
  118032. this._name = name;
  118033. this._renderEffects = {};
  118034. this._renderEffectsForIsolatedPass = new Array();
  118035. this._cameras = [];
  118036. }
  118037. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  118038. /**
  118039. * Gets pipeline name
  118040. */
  118041. get: function () {
  118042. return this._name;
  118043. },
  118044. enumerable: true,
  118045. configurable: true
  118046. });
  118047. /**
  118048. * Gets the class name
  118049. * @returns "PostProcessRenderPipeline"
  118050. */
  118051. PostProcessRenderPipeline.prototype.getClassName = function () {
  118052. return "PostProcessRenderPipeline";
  118053. };
  118054. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  118055. /**
  118056. * If all the render effects in the pipeline are supported
  118057. */
  118058. get: function () {
  118059. for (var renderEffectName in this._renderEffects) {
  118060. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  118061. if (!this._renderEffects[renderEffectName].isSupported) {
  118062. return false;
  118063. }
  118064. }
  118065. }
  118066. return true;
  118067. },
  118068. enumerable: true,
  118069. configurable: true
  118070. });
  118071. /**
  118072. * Adds an effect to the pipeline
  118073. * @param renderEffect the effect to add
  118074. */
  118075. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  118076. this._renderEffects[renderEffect._name] = renderEffect;
  118077. };
  118078. // private
  118079. /** @hidden */
  118080. PostProcessRenderPipeline.prototype._rebuild = function () {
  118081. };
  118082. /** @hidden */
  118083. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  118084. var renderEffects = this._renderEffects[renderEffectName];
  118085. if (!renderEffects) {
  118086. return;
  118087. }
  118088. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  118089. };
  118090. /** @hidden */
  118091. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  118092. var renderEffects = this._renderEffects[renderEffectName];
  118093. if (!renderEffects) {
  118094. return;
  118095. }
  118096. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  118097. };
  118098. /** @hidden */
  118099. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  118100. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  118101. if (!cams) {
  118102. return;
  118103. }
  118104. var indicesToDelete = [];
  118105. var i;
  118106. for (i = 0; i < cams.length; i++) {
  118107. var camera = cams[i];
  118108. var cameraName = camera.name;
  118109. if (this._cameras.indexOf(camera) === -1) {
  118110. this._cameras[cameraName] = camera;
  118111. }
  118112. else if (unique) {
  118113. indicesToDelete.push(i);
  118114. }
  118115. }
  118116. for (i = 0; i < indicesToDelete.length; i++) {
  118117. cameras.splice(indicesToDelete[i], 1);
  118118. }
  118119. for (var renderEffectName in this._renderEffects) {
  118120. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  118121. this._renderEffects[renderEffectName]._attachCameras(cams);
  118122. }
  118123. }
  118124. };
  118125. /** @hidden */
  118126. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  118127. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  118128. if (!cams) {
  118129. return;
  118130. }
  118131. for (var renderEffectName in this._renderEffects) {
  118132. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  118133. this._renderEffects[renderEffectName]._detachCameras(cams);
  118134. }
  118135. }
  118136. for (var i = 0; i < cams.length; i++) {
  118137. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  118138. }
  118139. };
  118140. /** @hidden */
  118141. PostProcessRenderPipeline.prototype._update = function () {
  118142. for (var renderEffectName in this._renderEffects) {
  118143. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  118144. this._renderEffects[renderEffectName]._update();
  118145. }
  118146. }
  118147. for (var i = 0; i < this._cameras.length; i++) {
  118148. var cameraName = this._cameras[i].name;
  118149. if (this._renderEffectsForIsolatedPass[cameraName]) {
  118150. this._renderEffectsForIsolatedPass[cameraName]._update();
  118151. }
  118152. }
  118153. };
  118154. /** @hidden */
  118155. PostProcessRenderPipeline.prototype._reset = function () {
  118156. this._renderEffects = {};
  118157. this._renderEffectsForIsolatedPass = new Array();
  118158. };
  118159. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  118160. // 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)
  118161. var effectKeys = Object.keys(this._renderEffects);
  118162. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  118163. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  118164. if (postProcesses) {
  118165. postProcesses[0].samples = sampleCount;
  118166. return true;
  118167. }
  118168. }
  118169. return false;
  118170. };
  118171. /**
  118172. * Disposes of the pipeline
  118173. */
  118174. PostProcessRenderPipeline.prototype.dispose = function () {
  118175. // Must be implemented by children
  118176. };
  118177. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118178. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  118179. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  118180. return PostProcessRenderPipeline;
  118181. }());
  118182. /***/ }),
  118183. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  118184. /*!**************************************************************************!*\
  118185. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  118186. \**************************************************************************/
  118187. /*! exports provided: PostProcessRenderPipelineManager */
  118188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118189. "use strict";
  118190. __webpack_require__.r(__webpack_exports__);
  118191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  118192. /**
  118193. * PostProcessRenderPipelineManager class
  118194. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118195. */
  118196. var PostProcessRenderPipelineManager = /** @class */ (function () {
  118197. /**
  118198. * Initializes a PostProcessRenderPipelineManager
  118199. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118200. */
  118201. function PostProcessRenderPipelineManager() {
  118202. this._renderPipelines = {};
  118203. }
  118204. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  118205. /**
  118206. * Gets the list of supported render pipelines
  118207. */
  118208. get: function () {
  118209. var result = [];
  118210. for (var renderPipelineName in this._renderPipelines) {
  118211. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  118212. var pipeline = this._renderPipelines[renderPipelineName];
  118213. if (pipeline.isSupported) {
  118214. result.push(pipeline);
  118215. }
  118216. }
  118217. }
  118218. return result;
  118219. },
  118220. enumerable: true,
  118221. configurable: true
  118222. });
  118223. /**
  118224. * Adds a pipeline to the manager
  118225. * @param renderPipeline The pipeline to add
  118226. */
  118227. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  118228. this._renderPipelines[renderPipeline._name] = renderPipeline;
  118229. };
  118230. /**
  118231. * Attaches a camera to the pipeline
  118232. * @param renderPipelineName The name of the pipeline to attach to
  118233. * @param cameras the camera to attach
  118234. * @param unique if the camera can be attached multiple times to the pipeline
  118235. */
  118236. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  118237. if (unique === void 0) { unique = false; }
  118238. var renderPipeline = this._renderPipelines[renderPipelineName];
  118239. if (!renderPipeline) {
  118240. return;
  118241. }
  118242. renderPipeline._attachCameras(cameras, unique);
  118243. };
  118244. /**
  118245. * Detaches a camera from the pipeline
  118246. * @param renderPipelineName The name of the pipeline to detach from
  118247. * @param cameras the camera to detach
  118248. */
  118249. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  118250. var renderPipeline = this._renderPipelines[renderPipelineName];
  118251. if (!renderPipeline) {
  118252. return;
  118253. }
  118254. renderPipeline._detachCameras(cameras);
  118255. };
  118256. /**
  118257. * Enables an effect by name on a pipeline
  118258. * @param renderPipelineName the name of the pipeline to enable the effect in
  118259. * @param renderEffectName the name of the effect to enable
  118260. * @param cameras the cameras that the effect should be enabled on
  118261. */
  118262. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  118263. var renderPipeline = this._renderPipelines[renderPipelineName];
  118264. if (!renderPipeline) {
  118265. return;
  118266. }
  118267. renderPipeline._enableEffect(renderEffectName, cameras);
  118268. };
  118269. /**
  118270. * Disables an effect by name on a pipeline
  118271. * @param renderPipelineName the name of the pipeline to disable the effect in
  118272. * @param renderEffectName the name of the effect to disable
  118273. * @param cameras the cameras that the effect should be disabled on
  118274. */
  118275. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  118276. var renderPipeline = this._renderPipelines[renderPipelineName];
  118277. if (!renderPipeline) {
  118278. return;
  118279. }
  118280. renderPipeline._disableEffect(renderEffectName, cameras);
  118281. };
  118282. /**
  118283. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  118284. */
  118285. PostProcessRenderPipelineManager.prototype.update = function () {
  118286. for (var renderPipelineName in this._renderPipelines) {
  118287. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  118288. var pipeline = this._renderPipelines[renderPipelineName];
  118289. if (!pipeline.isSupported) {
  118290. pipeline.dispose();
  118291. delete this._renderPipelines[renderPipelineName];
  118292. }
  118293. else {
  118294. pipeline._update();
  118295. }
  118296. }
  118297. }
  118298. };
  118299. /** @hidden */
  118300. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  118301. for (var renderPipelineName in this._renderPipelines) {
  118302. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  118303. var pipeline = this._renderPipelines[renderPipelineName];
  118304. pipeline._rebuild();
  118305. }
  118306. }
  118307. };
  118308. /**
  118309. * Disposes of the manager and pipelines
  118310. */
  118311. PostProcessRenderPipelineManager.prototype.dispose = function () {
  118312. for (var renderPipelineName in this._renderPipelines) {
  118313. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  118314. var pipeline = this._renderPipelines[renderPipelineName];
  118315. pipeline.dispose();
  118316. }
  118317. }
  118318. };
  118319. return PostProcessRenderPipelineManager;
  118320. }());
  118321. /***/ }),
  118322. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  118323. /*!****************************************************************************************!*\
  118324. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  118325. \****************************************************************************************/
  118326. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  118327. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118328. "use strict";
  118329. __webpack_require__.r(__webpack_exports__);
  118330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  118331. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  118332. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  118333. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  118334. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  118335. get: function () {
  118336. if (!this._postProcessRenderPipelineManager) {
  118337. // Register the G Buffer component to the scene.
  118338. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  118339. if (!component) {
  118340. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  118341. this._addComponent(component);
  118342. }
  118343. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  118344. }
  118345. return this._postProcessRenderPipelineManager;
  118346. },
  118347. enumerable: true,
  118348. configurable: true
  118349. });
  118350. /**
  118351. * Defines the Render Pipeline scene component responsible to rendering pipelines
  118352. */
  118353. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  118354. /**
  118355. * Creates a new instance of the component for the given scene
  118356. * @param scene Defines the scene to register the component in
  118357. */
  118358. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  118359. /**
  118360. * The component name helpfull to identify the component in the list of scene components.
  118361. */
  118362. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  118363. this.scene = scene;
  118364. }
  118365. /**
  118366. * Registers the component in a given scene
  118367. */
  118368. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  118369. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  118370. };
  118371. /**
  118372. * Rebuilds the elements related to this component in case of
  118373. * context lost for instance.
  118374. */
  118375. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  118376. if (this.scene._postProcessRenderPipelineManager) {
  118377. this.scene._postProcessRenderPipelineManager._rebuild();
  118378. }
  118379. };
  118380. /**
  118381. * Disposes the component and the associated ressources
  118382. */
  118383. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  118384. if (this.scene._postProcessRenderPipelineManager) {
  118385. this.scene._postProcessRenderPipelineManager.dispose();
  118386. }
  118387. };
  118388. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  118389. if (this.scene._postProcessRenderPipelineManager) {
  118390. this.scene._postProcessRenderPipelineManager.update();
  118391. }
  118392. };
  118393. return PostProcessRenderPipelineManagerSceneComponent;
  118394. }());
  118395. /***/ }),
  118396. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  118397. /*!**********************************************!*\
  118398. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  118399. \**********************************************/
  118400. /*! exports provided: AnaglyphPostProcess */
  118401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118402. "use strict";
  118403. __webpack_require__.r(__webpack_exports__);
  118404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  118405. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118406. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118407. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  118408. /**
  118409. * Postprocess used to generate anaglyphic rendering
  118410. */
  118411. var AnaglyphPostProcess = /** @class */ (function (_super) {
  118412. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  118413. /**
  118414. * Creates a new AnaglyphPostProcess
  118415. * @param name defines postprocess name
  118416. * @param options defines creation options or target ratio scale
  118417. * @param rigCameras defines cameras using this postprocess
  118418. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  118419. * @param engine defines hosting engine
  118420. * @param reusable defines if the postprocess will be reused multiple times per frame
  118421. */
  118422. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  118423. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  118424. _this._passedProcess = rigCameras[0]._rigPostProcess;
  118425. _this.onApplyObservable.add(function (effect) {
  118426. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  118427. });
  118428. return _this;
  118429. }
  118430. return AnaglyphPostProcess;
  118431. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118432. /***/ }),
  118433. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  118434. /*!***************************************************!*\
  118435. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  118436. \***************************************************/
  118437. /*! exports provided: BlackAndWhitePostProcess */
  118438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118439. "use strict";
  118440. __webpack_require__.r(__webpack_exports__);
  118441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  118442. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118443. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118444. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  118445. /**
  118446. * Post process used to render in black and white
  118447. */
  118448. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  118449. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  118450. /**
  118451. * Creates a black and white post process
  118452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  118453. * @param name The name of the effect.
  118454. * @param options The required width/height ratio to downsize to before computing the render pass.
  118455. * @param camera The camera to apply the render pass to.
  118456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118457. * @param engine The engine which the post process will be applied. (default: current engine)
  118458. * @param reusable If the post process can be reused on the same frame. (default: false)
  118459. */
  118460. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  118461. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  118462. /**
  118463. * Linear about to convert he result to black and white (default: 1)
  118464. */
  118465. _this.degree = 1;
  118466. _this.onApplyObservable.add(function (effect) {
  118467. effect.setFloat("degree", _this.degree);
  118468. });
  118469. return _this;
  118470. }
  118471. return BlackAndWhitePostProcess;
  118472. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118473. /***/ }),
  118474. /***/ "./PostProcesses/bloomEffect.ts":
  118475. /*!**************************************!*\
  118476. !*** ./PostProcesses/bloomEffect.ts ***!
  118477. \**************************************/
  118478. /*! exports provided: BloomEffect */
  118479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118480. "use strict";
  118481. __webpack_require__.r(__webpack_exports__);
  118482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  118483. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118484. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118485. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  118486. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  118487. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  118488. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118489. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118490. /**
  118491. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118492. */
  118493. var BloomEffect = /** @class */ (function (_super) {
  118494. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  118495. /**
  118496. * Creates a new instance of @see BloomEffect
  118497. * @param scene The scene the effect belongs to.
  118498. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118499. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118500. * @param bloomWeight The the strength of bloom.
  118501. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118502. * @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)
  118503. */
  118504. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  118505. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  118506. if (blockCompilation === void 0) { blockCompilation = false; }
  118507. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  118508. return _this._effects;
  118509. }, true) || this;
  118510. _this.bloomScale = bloomScale;
  118511. /**
  118512. * @hidden Internal
  118513. */
  118514. _this._effects = [];
  118515. _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);
  118516. _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);
  118517. _this._blurX.alwaysForcePOT = true;
  118518. _this._blurX.autoClear = false;
  118519. _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);
  118520. _this._blurY.alwaysForcePOT = true;
  118521. _this._blurY.autoClear = false;
  118522. _this.kernel = bloomKernel;
  118523. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  118524. _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);
  118525. _this._merge.autoClear = false;
  118526. _this._effects.push(_this._merge);
  118527. return _this;
  118528. }
  118529. Object.defineProperty(BloomEffect.prototype, "threshold", {
  118530. /**
  118531. * The luminance threshold to find bright areas of the image to bloom.
  118532. */
  118533. get: function () {
  118534. return this._downscale.threshold;
  118535. },
  118536. set: function (value) {
  118537. this._downscale.threshold = value;
  118538. },
  118539. enumerable: true,
  118540. configurable: true
  118541. });
  118542. Object.defineProperty(BloomEffect.prototype, "weight", {
  118543. /**
  118544. * The strength of the bloom.
  118545. */
  118546. get: function () {
  118547. return this._merge.weight;
  118548. },
  118549. set: function (value) {
  118550. this._merge.weight = value;
  118551. },
  118552. enumerable: true,
  118553. configurable: true
  118554. });
  118555. Object.defineProperty(BloomEffect.prototype, "kernel", {
  118556. /**
  118557. * Specifies the size of the bloom blur kernel, relative to the final output size
  118558. */
  118559. get: function () {
  118560. return this._blurX.kernel / this.bloomScale;
  118561. },
  118562. set: function (value) {
  118563. this._blurX.kernel = value * this.bloomScale;
  118564. this._blurY.kernel = value * this.bloomScale;
  118565. },
  118566. enumerable: true,
  118567. configurable: true
  118568. });
  118569. /**
  118570. * Disposes each of the internal effects for a given camera.
  118571. * @param camera The camera to dispose the effect on.
  118572. */
  118573. BloomEffect.prototype.disposeEffects = function (camera) {
  118574. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118575. this._effects[effectIndex].dispose(camera);
  118576. }
  118577. };
  118578. /**
  118579. * @hidden Internal
  118580. */
  118581. BloomEffect.prototype._updateEffects = function () {
  118582. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118583. this._effects[effectIndex].updateEffect();
  118584. }
  118585. };
  118586. /**
  118587. * Internal
  118588. * @returns if all the contained post processes are ready.
  118589. * @hidden
  118590. */
  118591. BloomEffect.prototype._isReady = function () {
  118592. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118593. if (!this._effects[effectIndex].isReady()) {
  118594. return false;
  118595. }
  118596. }
  118597. return true;
  118598. };
  118599. return BloomEffect;
  118600. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  118601. /***/ }),
  118602. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  118603. /*!************************************************!*\
  118604. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  118605. \************************************************/
  118606. /*! exports provided: BloomMergePostProcess */
  118607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118608. "use strict";
  118609. __webpack_require__.r(__webpack_exports__);
  118610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  118611. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118612. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118613. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118614. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  118615. /**
  118616. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118617. */
  118618. var BloomMergePostProcess = /** @class */ (function (_super) {
  118619. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  118620. /**
  118621. * Creates a new instance of @see BloomMergePostProcess
  118622. * @param name The name of the effect.
  118623. * @param originalFromInput Post process which's input will be used for the merge.
  118624. * @param blurred Blurred highlights post process which's output will be used.
  118625. * @param weight Weight of the bloom to be added to the original input.
  118626. * @param options The required width/height ratio to downsize to before computing the render pass.
  118627. * @param camera The camera to apply the render pass to.
  118628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118629. * @param engine The engine which the post process will be applied. (default: current engine)
  118630. * @param reusable If the post process can be reused on the same frame. (default: false)
  118631. * @param textureType Type of textures used when performing the post process. (default: 0)
  118632. * @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)
  118633. */
  118634. function BloomMergePostProcess(name, originalFromInput, blurred,
  118635. /** Weight of the bloom to be added to the original input. */
  118636. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118637. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118638. if (blockCompilation === void 0) { blockCompilation = false; }
  118639. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  118640. _this.weight = weight;
  118641. _this.onApplyObservable.add(function (effect) {
  118642. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  118643. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  118644. effect.setFloat("bloomWeight", _this.weight);
  118645. });
  118646. if (!blockCompilation) {
  118647. _this.updateEffect();
  118648. }
  118649. return _this;
  118650. }
  118651. return BloomMergePostProcess;
  118652. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118653. /***/ }),
  118654. /***/ "./PostProcesses/blurPostProcess.ts":
  118655. /*!******************************************!*\
  118656. !*** ./PostProcesses/blurPostProcess.ts ***!
  118657. \******************************************/
  118658. /*! exports provided: BlurPostProcess */
  118659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118660. "use strict";
  118661. __webpack_require__.r(__webpack_exports__);
  118662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  118663. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118664. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118665. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118666. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118667. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  118668. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  118669. /**
  118670. * The Blur Post Process which blurs an image based on a kernel and direction.
  118671. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  118672. */
  118673. var BlurPostProcess = /** @class */ (function (_super) {
  118674. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  118675. /**
  118676. * Creates a new instance BlurPostProcess
  118677. * @param name The name of the effect.
  118678. * @param direction The direction in which to blur the image.
  118679. * @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.
  118680. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  118681. * @param camera The camera to apply the render pass to.
  118682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118683. * @param engine The engine which the post process will be applied. (default: current engine)
  118684. * @param reusable If the post process can be reused on the same frame. (default: false)
  118685. * @param textureType Type of textures used when performing the post process. (default: 0)
  118686. * @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)
  118687. */
  118688. function BlurPostProcess(name,
  118689. /** The direction in which to blur the image. */
  118690. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  118691. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  118692. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118693. if (defines === void 0) { defines = ""; }
  118694. if (blockCompilation === void 0) { blockCompilation = false; }
  118695. 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;
  118696. _this.direction = direction;
  118697. _this.blockCompilation = blockCompilation;
  118698. _this._packedFloat = false;
  118699. _this._staticDefines = "";
  118700. _this._staticDefines = defines;
  118701. _this.onApplyObservable.add(function (effect) {
  118702. if (_this._outputTexture) {
  118703. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  118704. }
  118705. else {
  118706. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  118707. }
  118708. });
  118709. _this.kernel = kernel;
  118710. return _this;
  118711. }
  118712. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  118713. /**
  118714. * Gets the length in pixels of the blur sample region
  118715. */
  118716. get: function () {
  118717. return this._idealKernel;
  118718. },
  118719. /**
  118720. * Sets the length in pixels of the blur sample region
  118721. */
  118722. set: function (v) {
  118723. if (this._idealKernel === v) {
  118724. return;
  118725. }
  118726. v = Math.max(v, 1);
  118727. this._idealKernel = v;
  118728. this._kernel = this._nearestBestKernel(v);
  118729. if (!this.blockCompilation) {
  118730. this._updateParameters();
  118731. }
  118732. },
  118733. enumerable: true,
  118734. configurable: true
  118735. });
  118736. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  118737. /**
  118738. * Gets wether or not the blur is unpacking/repacking floats
  118739. */
  118740. get: function () {
  118741. return this._packedFloat;
  118742. },
  118743. /**
  118744. * Sets wether or not the blur needs to unpack/repack floats
  118745. */
  118746. set: function (v) {
  118747. if (this._packedFloat === v) {
  118748. return;
  118749. }
  118750. this._packedFloat = v;
  118751. if (!this.blockCompilation) {
  118752. this._updateParameters();
  118753. }
  118754. },
  118755. enumerable: true,
  118756. configurable: true
  118757. });
  118758. /**
  118759. * Updates the effect with the current post process compile time values and recompiles the shader.
  118760. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118761. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118762. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118763. * @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
  118764. * @param onCompiled Called when the shader has been compiled.
  118765. * @param onError Called if there is an error when compiling a shader.
  118766. */
  118767. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  118768. if (defines === void 0) { defines = null; }
  118769. if (uniforms === void 0) { uniforms = null; }
  118770. if (samplers === void 0) { samplers = null; }
  118771. this._updateParameters(onCompiled, onError);
  118772. };
  118773. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  118774. // Generate sampling offsets and weights
  118775. var N = this._kernel;
  118776. var centerIndex = (N - 1) / 2;
  118777. // Generate Gaussian sampling weights over kernel
  118778. var offsets = [];
  118779. var weights = [];
  118780. var totalWeight = 0;
  118781. for (var i = 0; i < N; i++) {
  118782. var u = i / (N - 1);
  118783. var w = this._gaussianWeight(u * 2.0 - 1);
  118784. offsets[i] = (i - centerIndex);
  118785. weights[i] = w;
  118786. totalWeight += w;
  118787. }
  118788. // Normalize weights
  118789. for (var i = 0; i < weights.length; i++) {
  118790. weights[i] /= totalWeight;
  118791. }
  118792. // Optimize: combine samples to take advantage of hardware linear sampling
  118793. // Walk from left to center, combining pairs (symmetrically)
  118794. var linearSamplingWeights = [];
  118795. var linearSamplingOffsets = [];
  118796. var linearSamplingMap = [];
  118797. for (var i = 0; i <= centerIndex; i += 2) {
  118798. var j = Math.min(i + 1, Math.floor(centerIndex));
  118799. var singleCenterSample = i === j;
  118800. if (singleCenterSample) {
  118801. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  118802. }
  118803. else {
  118804. var sharedCell = j === centerIndex;
  118805. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  118806. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  118807. if (offsetLinear === 0) {
  118808. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  118809. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  118810. }
  118811. else {
  118812. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  118813. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  118814. }
  118815. }
  118816. }
  118817. for (var i = 0; i < linearSamplingMap.length; i++) {
  118818. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  118819. linearSamplingWeights[i] = linearSamplingMap[i].w;
  118820. }
  118821. // Replace with optimized
  118822. offsets = linearSamplingOffsets;
  118823. weights = linearSamplingWeights;
  118824. // Generate shaders
  118825. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  118826. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  118827. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  118828. var defines = "";
  118829. defines += this._staticDefines;
  118830. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  118831. if (this._staticDefines.indexOf("DOF") != -1) {
  118832. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  118833. varyingCount--;
  118834. }
  118835. for (var i = 0; i < varyingCount; i++) {
  118836. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  118837. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  118838. }
  118839. var depCount = 0;
  118840. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  118841. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  118842. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  118843. depCount++;
  118844. }
  118845. if (this.packedFloat) {
  118846. defines += "#define PACKEDFLOAT 1";
  118847. }
  118848. this.blockCompilation = false;
  118849. _super.prototype.updateEffect.call(this, defines, null, null, {
  118850. varyingCount: varyingCount,
  118851. depCount: depCount
  118852. }, onCompiled, onError);
  118853. };
  118854. /**
  118855. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  118856. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  118857. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  118858. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  118859. * The gaps between physical kernels are compensated for in the weighting of the samples
  118860. * @param idealKernel Ideal blur kernel.
  118861. * @return Nearest best kernel.
  118862. */
  118863. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  118864. var v = Math.round(idealKernel);
  118865. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  118866. var k = _a[_i];
  118867. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  118868. return Math.max(k, 3);
  118869. }
  118870. }
  118871. return Math.max(v, 3);
  118872. };
  118873. /**
  118874. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  118875. * @param x The point on the Gaussian distribution to sample.
  118876. * @return the value of the Gaussian function at x.
  118877. */
  118878. BlurPostProcess.prototype._gaussianWeight = function (x) {
  118879. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  118880. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  118881. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  118882. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  118883. // truncated at around 1.3% of peak strength.
  118884. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  118885. var sigma = (1 / 3);
  118886. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  118887. var exponent = -((x * x) / (2.0 * sigma * sigma));
  118888. var weight = (1.0 / denominator) * Math.exp(exponent);
  118889. return weight;
  118890. };
  118891. /**
  118892. * Generates a string that can be used as a floating point number in GLSL.
  118893. * @param x Value to print.
  118894. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  118895. * @return GLSL float string.
  118896. */
  118897. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  118898. if (decimalFigures === void 0) { decimalFigures = 8; }
  118899. return x.toFixed(decimalFigures).replace(/0+$/, '');
  118900. };
  118901. return BlurPostProcess;
  118902. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118903. /***/ }),
  118904. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  118905. /*!*********************************************************!*\
  118906. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  118907. \*********************************************************/
  118908. /*! exports provided: ChromaticAberrationPostProcess */
  118909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118910. "use strict";
  118911. __webpack_require__.r(__webpack_exports__);
  118912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  118913. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118914. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118915. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118916. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118917. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  118918. /**
  118919. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118920. */
  118921. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  118922. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  118923. /**
  118924. * Creates a new instance ChromaticAberrationPostProcess
  118925. * @param name The name of the effect.
  118926. * @param screenWidth The width of the screen to apply the effect on.
  118927. * @param screenHeight The height of the screen to apply the effect on.
  118928. * @param options The required width/height ratio to downsize to before computing the render pass.
  118929. * @param camera The camera to apply the render pass to.
  118930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118931. * @param engine The engine which the post process will be applied. (default: current engine)
  118932. * @param reusable If the post process can be reused on the same frame. (default: false)
  118933. * @param textureType Type of textures used when performing the post process. (default: 0)
  118934. * @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)
  118935. */
  118936. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118937. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118938. if (blockCompilation === void 0) { blockCompilation = false; }
  118939. 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;
  118940. /**
  118941. * The amount of seperation of rgb channels (default: 30)
  118942. */
  118943. _this.aberrationAmount = 30;
  118944. /**
  118945. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118946. */
  118947. _this.radialIntensity = 0;
  118948. /**
  118949. * 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))
  118950. */
  118951. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  118952. /**
  118953. * 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))
  118954. */
  118955. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  118956. _this.onApplyObservable.add(function (effect) {
  118957. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  118958. effect.setFloat('screen_width', screenWidth);
  118959. effect.setFloat('screen_height', screenHeight);
  118960. effect.setFloat('radialIntensity', _this.radialIntensity);
  118961. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  118962. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  118963. });
  118964. return _this;
  118965. }
  118966. return ChromaticAberrationPostProcess;
  118967. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118968. /***/ }),
  118969. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  118970. /*!*******************************************************!*\
  118971. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  118972. \*******************************************************/
  118973. /*! exports provided: CircleOfConfusionPostProcess */
  118974. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118975. "use strict";
  118976. __webpack_require__.r(__webpack_exports__);
  118977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  118978. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118979. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118980. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118981. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118982. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  118983. /**
  118984. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118985. */
  118986. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  118987. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  118988. /**
  118989. * Creates a new instance CircleOfConfusionPostProcess
  118990. * @param name The name of the effect.
  118991. * @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.
  118992. * @param options The required width/height ratio to downsize to before computing the render pass.
  118993. * @param camera The camera to apply the render pass to.
  118994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118995. * @param engine The engine which the post process will be applied. (default: current engine)
  118996. * @param reusable If the post process can be reused on the same frame. (default: false)
  118997. * @param textureType Type of textures used when performing the post process. (default: 0)
  118998. * @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)
  118999. */
  119000. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119001. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119002. if (blockCompilation === void 0) { blockCompilation = false; }
  119003. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119004. /**
  119005. * 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.
  119006. */
  119007. _this.lensSize = 50;
  119008. /**
  119009. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  119010. */
  119011. _this.fStop = 1.4;
  119012. /**
  119013. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  119014. */
  119015. _this.focusDistance = 2000;
  119016. /**
  119017. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  119018. */
  119019. _this.focalLength = 50;
  119020. _this._depthTexture = null;
  119021. _this._depthTexture = depthTexture;
  119022. _this.onApplyObservable.add(function (effect) {
  119023. if (!_this._depthTexture) {
  119024. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  119025. return;
  119026. }
  119027. effect.setTexture("depthSampler", _this._depthTexture);
  119028. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  119029. var aperture = _this.lensSize / _this.fStop;
  119030. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  119031. effect.setFloat('focusDistance', _this.focusDistance);
  119032. effect.setFloat('cocPrecalculation', cocPrecalculation);
  119033. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  119034. });
  119035. return _this;
  119036. }
  119037. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  119038. /**
  119039. * 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.
  119040. */
  119041. set: function (value) {
  119042. this._depthTexture = value;
  119043. },
  119044. enumerable: true,
  119045. configurable: true
  119046. });
  119047. return CircleOfConfusionPostProcess;
  119048. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119049. /***/ }),
  119050. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  119051. /*!*****************************************************!*\
  119052. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  119053. \*****************************************************/
  119054. /*! exports provided: ColorCorrectionPostProcess */
  119055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119056. "use strict";
  119057. __webpack_require__.r(__webpack_exports__);
  119058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  119059. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119060. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119061. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119062. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  119063. /**
  119064. *
  119065. * This post-process allows the modification of rendered colors by using
  119066. * a 'look-up table' (LUT). This effect is also called Color Grading.
  119067. *
  119068. * The object needs to be provided an url to a texture containing the color
  119069. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  119070. * Use an image editing software to tweak the LUT to match your needs.
  119071. *
  119072. * For an example of a color LUT, see here:
  119073. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  119074. * For explanations on color grading, see here:
  119075. * @see http://udn.epicgames.com/Three/ColorGrading.html
  119076. *
  119077. */
  119078. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  119079. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  119080. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  119081. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  119082. _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);
  119083. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  119084. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  119085. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  119086. _this.onApply = function (effect) {
  119087. effect.setTexture("colorTable", _this._colorTableTexture);
  119088. };
  119089. return _this;
  119090. }
  119091. return ColorCorrectionPostProcess;
  119092. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119093. /***/ }),
  119094. /***/ "./PostProcesses/convolutionPostProcess.ts":
  119095. /*!*************************************************!*\
  119096. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  119097. \*************************************************/
  119098. /*! exports provided: ConvolutionPostProcess */
  119099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119100. "use strict";
  119101. __webpack_require__.r(__webpack_exports__);
  119102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  119103. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119104. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119105. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119106. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  119107. /**
  119108. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  119109. * input texture to perform effects such as edge detection or sharpening
  119110. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119111. */
  119112. var ConvolutionPostProcess = /** @class */ (function (_super) {
  119113. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  119114. /**
  119115. * Creates a new instance ConvolutionPostProcess
  119116. * @param name The name of the effect.
  119117. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  119118. * @param options The required width/height ratio to downsize to before computing the render pass.
  119119. * @param camera The camera to apply the render pass to.
  119120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119121. * @param engine The engine which the post process will be applied. (default: current engine)
  119122. * @param reusable If the post process can be reused on the same frame. (default: false)
  119123. * @param textureType Type of textures used when performing the post process. (default: 0)
  119124. */
  119125. function ConvolutionPostProcess(name,
  119126. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  119127. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  119128. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119129. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  119130. _this.kernel = kernel;
  119131. _this.onApply = function (effect) {
  119132. effect.setFloat2("screenSize", _this.width, _this.height);
  119133. effect.setArray("kernel", _this.kernel);
  119134. };
  119135. return _this;
  119136. }
  119137. // Statics
  119138. /**
  119139. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119140. */
  119141. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  119142. /**
  119143. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119144. */
  119145. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  119146. /**
  119147. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119148. */
  119149. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  119150. /**
  119151. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119152. */
  119153. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  119154. /**
  119155. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119156. */
  119157. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  119158. /**
  119159. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119160. */
  119161. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  119162. return ConvolutionPostProcess;
  119163. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119164. /***/ }),
  119165. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  119166. /*!******************************************************!*\
  119167. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  119168. \******************************************************/
  119169. /*! exports provided: DepthOfFieldBlurPostProcess */
  119170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119171. "use strict";
  119172. __webpack_require__.r(__webpack_exports__);
  119173. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  119174. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119175. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119176. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  119177. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119178. /**
  119179. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  119180. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  119181. * based on samples that have a large difference in distance than the center pixel.
  119182. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  119183. */
  119184. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  119185. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  119186. /**
  119187. * Creates a new instance CircleOfConfusionPostProcess
  119188. * @param name The name of the effect.
  119189. * @param scene The scene the effect belongs to.
  119190. * @param direction The direction the blur should be applied.
  119191. * @param kernel The size of the kernel used to blur.
  119192. * @param options The required width/height ratio to downsize to before computing the render pass.
  119193. * @param camera The camera to apply the render pass to.
  119194. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  119195. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  119196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119197. * @param engine The engine which the post process will be applied. (default: current engine)
  119198. * @param reusable If the post process can be reused on the same frame. (default: false)
  119199. * @param textureType Type of textures used when performing the post process. (default: 0)
  119200. * @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)
  119201. */
  119202. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  119203. if (imageToBlur === void 0) { imageToBlur = null; }
  119204. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  119205. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119206. if (blockCompilation === void 0) { blockCompilation = false; }
  119207. 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;
  119208. _this.direction = direction;
  119209. _this.onApplyObservable.add(function (effect) {
  119210. if (imageToBlur != null) {
  119211. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  119212. }
  119213. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  119214. if (scene.activeCamera) {
  119215. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  119216. }
  119217. });
  119218. return _this;
  119219. }
  119220. return DepthOfFieldBlurPostProcess;
  119221. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  119222. /***/ }),
  119223. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  119224. /*!*********************************************!*\
  119225. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  119226. \*********************************************/
  119227. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  119228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119229. "use strict";
  119230. __webpack_require__.r(__webpack_exports__);
  119231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  119232. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  119233. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119234. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119235. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119236. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119237. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  119238. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  119239. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  119240. /**
  119241. * Specifies the level of max blur that should be applied when using the depth of field effect
  119242. */
  119243. var DepthOfFieldEffectBlurLevel;
  119244. (function (DepthOfFieldEffectBlurLevel) {
  119245. /**
  119246. * Subtle blur
  119247. */
  119248. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  119249. /**
  119250. * Medium blur
  119251. */
  119252. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  119253. /**
  119254. * Large blur
  119255. */
  119256. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  119257. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  119258. /**
  119259. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  119260. */
  119261. var DepthOfFieldEffect = /** @class */ (function (_super) {
  119262. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  119263. /**
  119264. * Creates a new instance DepthOfFieldEffect
  119265. * @param scene The scene the effect belongs to.
  119266. * @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.
  119267. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  119268. * @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)
  119269. */
  119270. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  119271. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  119272. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  119273. if (blockCompilation === void 0) { blockCompilation = false; }
  119274. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  119275. return _this._effects;
  119276. }, true) || this;
  119277. /**
  119278. * @hidden Internal post processes in depth of field effect
  119279. */
  119280. _this._effects = [];
  119281. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  119282. _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);
  119283. // 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)
  119284. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  119285. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  119286. _this._depthOfFieldBlurY = [];
  119287. _this._depthOfFieldBlurX = [];
  119288. var blurCount = 1;
  119289. var kernelSize = 15;
  119290. switch (blurLevel) {
  119291. case DepthOfFieldEffectBlurLevel.High: {
  119292. blurCount = 3;
  119293. kernelSize = 51;
  119294. break;
  119295. }
  119296. case DepthOfFieldEffectBlurLevel.Medium: {
  119297. blurCount = 2;
  119298. kernelSize = 31;
  119299. break;
  119300. }
  119301. default: {
  119302. kernelSize = 15;
  119303. blurCount = 1;
  119304. break;
  119305. }
  119306. }
  119307. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  119308. var ratio = 1.0;
  119309. for (var i = 0; i < blurCount; i++) {
  119310. 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);
  119311. blurY.autoClear = false;
  119312. ratio = 0.75 / Math.pow(2, i);
  119313. 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);
  119314. blurX.autoClear = false;
  119315. _this._depthOfFieldBlurY.push(blurY);
  119316. _this._depthOfFieldBlurX.push(blurX);
  119317. }
  119318. // Set all post processes on the effect.
  119319. _this._effects = [_this._circleOfConfusion];
  119320. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  119321. _this._effects.push(_this._depthOfFieldBlurY[i]);
  119322. _this._effects.push(_this._depthOfFieldBlurX[i]);
  119323. }
  119324. // Merge blurred images with original image based on circleOfConfusion
  119325. _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);
  119326. _this._dofMerge.autoClear = false;
  119327. _this._effects.push(_this._dofMerge);
  119328. return _this;
  119329. }
  119330. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  119331. get: function () {
  119332. return this._circleOfConfusion.focalLength;
  119333. },
  119334. /**
  119335. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  119336. */
  119337. set: function (value) {
  119338. this._circleOfConfusion.focalLength = value;
  119339. },
  119340. enumerable: true,
  119341. configurable: true
  119342. });
  119343. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  119344. get: function () {
  119345. return this._circleOfConfusion.fStop;
  119346. },
  119347. /**
  119348. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  119349. */
  119350. set: function (value) {
  119351. this._circleOfConfusion.fStop = value;
  119352. },
  119353. enumerable: true,
  119354. configurable: true
  119355. });
  119356. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  119357. get: function () {
  119358. return this._circleOfConfusion.focusDistance;
  119359. },
  119360. /**
  119361. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  119362. */
  119363. set: function (value) {
  119364. this._circleOfConfusion.focusDistance = value;
  119365. },
  119366. enumerable: true,
  119367. configurable: true
  119368. });
  119369. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  119370. get: function () {
  119371. return this._circleOfConfusion.lensSize;
  119372. },
  119373. /**
  119374. * 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.
  119375. */
  119376. set: function (value) {
  119377. this._circleOfConfusion.lensSize = value;
  119378. },
  119379. enumerable: true,
  119380. configurable: true
  119381. });
  119382. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  119383. /**
  119384. * 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.
  119385. */
  119386. set: function (value) {
  119387. this._circleOfConfusion.depthTexture = value;
  119388. },
  119389. enumerable: true,
  119390. configurable: true
  119391. });
  119392. /**
  119393. * Disposes each of the internal effects for a given camera.
  119394. * @param camera The camera to dispose the effect on.
  119395. */
  119396. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  119397. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  119398. this._effects[effectIndex].dispose(camera);
  119399. }
  119400. };
  119401. /**
  119402. * @hidden Internal
  119403. */
  119404. DepthOfFieldEffect.prototype._updateEffects = function () {
  119405. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  119406. this._effects[effectIndex].updateEffect();
  119407. }
  119408. };
  119409. /**
  119410. * Internal
  119411. * @returns if all the contained post processes are ready.
  119412. * @hidden
  119413. */
  119414. DepthOfFieldEffect.prototype._isReady = function () {
  119415. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  119416. if (!this._effects[effectIndex].isReady()) {
  119417. return false;
  119418. }
  119419. }
  119420. return true;
  119421. };
  119422. return DepthOfFieldEffect;
  119423. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  119424. /***/ }),
  119425. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  119426. /*!*******************************************************!*\
  119427. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  119428. \*******************************************************/
  119429. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  119430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119431. "use strict";
  119432. __webpack_require__.r(__webpack_exports__);
  119433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  119434. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  119435. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119436. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119437. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119438. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  119439. /**
  119440. * Options to be set when merging outputs from the default pipeline.
  119441. */
  119442. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  119443. function DepthOfFieldMergePostProcessOptions() {
  119444. }
  119445. return DepthOfFieldMergePostProcessOptions;
  119446. }());
  119447. /**
  119448. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  119449. */
  119450. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  119451. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  119452. /**
  119453. * Creates a new instance of DepthOfFieldMergePostProcess
  119454. * @param name The name of the effect.
  119455. * @param originalFromInput Post process which's input will be used for the merge.
  119456. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  119457. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  119458. * @param options The required width/height ratio to downsize to before computing the render pass.
  119459. * @param camera The camera to apply the render pass to.
  119460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119461. * @param engine The engine which the post process will be applied. (default: current engine)
  119462. * @param reusable If the post process can be reused on the same frame. (default: false)
  119463. * @param textureType Type of textures used when performing the post process. (default: 0)
  119464. * @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)
  119465. */
  119466. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119467. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119468. if (blockCompilation === void 0) { blockCompilation = false; }
  119469. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  119470. _this.blurSteps = blurSteps;
  119471. _this.onApplyObservable.add(function (effect) {
  119472. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  119473. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  119474. blurSteps.forEach(function (step, index) {
  119475. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  119476. });
  119477. });
  119478. if (!blockCompilation) {
  119479. _this.updateEffect();
  119480. }
  119481. return _this;
  119482. }
  119483. /**
  119484. * Updates the effect with the current post process compile time values and recompiles the shader.
  119485. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  119486. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  119487. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  119488. * @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
  119489. * @param onCompiled Called when the shader has been compiled.
  119490. * @param onError Called if there is an error when compiling a shader.
  119491. */
  119492. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  119493. if (defines === void 0) { defines = null; }
  119494. if (uniforms === void 0) { uniforms = null; }
  119495. if (samplers === void 0) { samplers = null; }
  119496. if (!defines) {
  119497. defines = "";
  119498. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  119499. }
  119500. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  119501. };
  119502. return DepthOfFieldMergePostProcess;
  119503. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119504. /***/ }),
  119505. /***/ "./PostProcesses/displayPassPostProcess.ts":
  119506. /*!*************************************************!*\
  119507. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  119508. \*************************************************/
  119509. /*! exports provided: DisplayPassPostProcess */
  119510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119511. "use strict";
  119512. __webpack_require__.r(__webpack_exports__);
  119513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  119514. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119515. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119516. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  119517. /**
  119518. * DisplayPassPostProcess which produces an output the same as it's input
  119519. */
  119520. var DisplayPassPostProcess = /** @class */ (function (_super) {
  119521. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  119522. /**
  119523. * Creates the DisplayPassPostProcess
  119524. * @param name The name of the effect.
  119525. * @param options The required width/height ratio to downsize to before computing the render pass.
  119526. * @param camera The camera to apply the render pass to.
  119527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119528. * @param engine The engine which the post process will be applied. (default: current engine)
  119529. * @param reusable If the post process can be reused on the same frame. (default: false)
  119530. */
  119531. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  119532. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  119533. }
  119534. return DisplayPassPostProcess;
  119535. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119536. /***/ }),
  119537. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  119538. /*!*******************************************************!*\
  119539. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  119540. \*******************************************************/
  119541. /*! exports provided: ExtractHighlightsPostProcess */
  119542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119543. "use strict";
  119544. __webpack_require__.r(__webpack_exports__);
  119545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  119546. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119547. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119548. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119549. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119550. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  119551. /**
  119552. * 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.
  119553. */
  119554. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  119555. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  119556. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119557. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119558. if (blockCompilation === void 0) { blockCompilation = false; }
  119559. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119560. /**
  119561. * The luminance threshold, pixels below this value will be set to black.
  119562. */
  119563. _this.threshold = 0.9;
  119564. /** @hidden */
  119565. _this._exposure = 1;
  119566. /**
  119567. * Post process which has the input texture to be used when performing highlight extraction
  119568. * @hidden
  119569. */
  119570. _this._inputPostProcess = null;
  119571. _this.onApplyObservable.add(function (effect) {
  119572. if (_this._inputPostProcess) {
  119573. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  119574. }
  119575. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  119576. effect.setFloat('exposure', _this._exposure);
  119577. });
  119578. return _this;
  119579. }
  119580. return ExtractHighlightsPostProcess;
  119581. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119582. /***/ }),
  119583. /***/ "./PostProcesses/filterPostProcess.ts":
  119584. /*!********************************************!*\
  119585. !*** ./PostProcesses/filterPostProcess.ts ***!
  119586. \********************************************/
  119587. /*! exports provided: FilterPostProcess */
  119588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119589. "use strict";
  119590. __webpack_require__.r(__webpack_exports__);
  119591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  119592. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119593. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119594. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  119595. /**
  119596. * Applies a kernel filter to the image
  119597. */
  119598. var FilterPostProcess = /** @class */ (function (_super) {
  119599. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  119600. /**
  119601. *
  119602. * @param name The name of the effect.
  119603. * @param kernelMatrix The matrix to be applied to the image
  119604. * @param options The required width/height ratio to downsize to before computing the render pass.
  119605. * @param camera The camera to apply the render pass to.
  119606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119607. * @param engine The engine which the post process will be applied. (default: current engine)
  119608. * @param reusable If the post process can be reused on the same frame. (default: false)
  119609. */
  119610. function FilterPostProcess(name,
  119611. /** The matrix to be applied to the image */
  119612. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  119613. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  119614. _this.kernelMatrix = kernelMatrix;
  119615. _this.onApply = function (effect) {
  119616. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  119617. };
  119618. return _this;
  119619. }
  119620. return FilterPostProcess;
  119621. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119622. /***/ }),
  119623. /***/ "./PostProcesses/fxaaPostProcess.ts":
  119624. /*!******************************************!*\
  119625. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  119626. \******************************************/
  119627. /*! exports provided: FxaaPostProcess */
  119628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119629. "use strict";
  119630. __webpack_require__.r(__webpack_exports__);
  119631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  119632. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119633. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119634. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119635. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119636. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  119637. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  119638. /**
  119639. * Fxaa post process
  119640. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  119641. */
  119642. var FxaaPostProcess = /** @class */ (function (_super) {
  119643. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  119644. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  119645. if (camera === void 0) { camera = null; }
  119646. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119647. 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;
  119648. var defines = _this._getDefines();
  119649. _this.updateEffect(defines);
  119650. _this.onApplyObservable.add(function (effect) {
  119651. var texelSize = _this.texelSize;
  119652. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  119653. });
  119654. return _this;
  119655. }
  119656. FxaaPostProcess.prototype._getDefines = function () {
  119657. var engine = this.getEngine();
  119658. if (!engine) {
  119659. return null;
  119660. }
  119661. var glInfo = engine.getGlInfo();
  119662. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  119663. return "#define MALI 1\n";
  119664. }
  119665. return null;
  119666. };
  119667. return FxaaPostProcess;
  119668. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119669. /***/ }),
  119670. /***/ "./PostProcesses/grainPostProcess.ts":
  119671. /*!*******************************************!*\
  119672. !*** ./PostProcesses/grainPostProcess.ts ***!
  119673. \*******************************************/
  119674. /*! exports provided: GrainPostProcess */
  119675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119676. "use strict";
  119677. __webpack_require__.r(__webpack_exports__);
  119678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  119679. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119680. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119681. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119682. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  119683. /**
  119684. * The GrainPostProcess adds noise to the image at mid luminance levels
  119685. */
  119686. var GrainPostProcess = /** @class */ (function (_super) {
  119687. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  119688. /**
  119689. * Creates a new instance of @see GrainPostProcess
  119690. * @param name The name of the effect.
  119691. * @param options The required width/height ratio to downsize to before computing the render pass.
  119692. * @param camera The camera to apply the render pass to.
  119693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119694. * @param engine The engine which the post process will be applied. (default: current engine)
  119695. * @param reusable If the post process can be reused on the same frame. (default: false)
  119696. * @param textureType Type of textures used when performing the post process. (default: 0)
  119697. * @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)
  119698. */
  119699. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119700. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119701. if (blockCompilation === void 0) { blockCompilation = false; }
  119702. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119703. /**
  119704. * The intensity of the grain added (default: 30)
  119705. */
  119706. _this.intensity = 30;
  119707. /**
  119708. * If the grain should be randomized on every frame
  119709. */
  119710. _this.animated = false;
  119711. _this.onApplyObservable.add(function (effect) {
  119712. effect.setFloat('intensity', _this.intensity);
  119713. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  119714. });
  119715. return _this;
  119716. }
  119717. return GrainPostProcess;
  119718. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119719. /***/ }),
  119720. /***/ "./PostProcesses/highlightsPostProcess.ts":
  119721. /*!************************************************!*\
  119722. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  119723. \************************************************/
  119724. /*! exports provided: HighlightsPostProcess */
  119725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119726. "use strict";
  119727. __webpack_require__.r(__webpack_exports__);
  119728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  119729. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119730. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119731. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119732. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  119733. /**
  119734. * Extracts highlights from the image
  119735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119736. */
  119737. var HighlightsPostProcess = /** @class */ (function (_super) {
  119738. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  119739. /**
  119740. * Extracts highlights from the image
  119741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119742. * @param name The name of the effect.
  119743. * @param options The required width/height ratio to downsize to before computing the render pass.
  119744. * @param camera The camera to apply the render pass to.
  119745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119746. * @param engine The engine which the post process will be applied. (default: current engine)
  119747. * @param reusable If the post process can be reused on the same frame. (default: false)
  119748. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  119749. */
  119750. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  119751. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119752. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  119753. }
  119754. return HighlightsPostProcess;
  119755. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119756. /***/ }),
  119757. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  119758. /*!*****************************************************!*\
  119759. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  119760. \*****************************************************/
  119761. /*! exports provided: ImageProcessingPostProcess */
  119762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119763. "use strict";
  119764. __webpack_require__.r(__webpack_exports__);
  119765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  119766. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119767. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119768. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  119769. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119770. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  119771. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119772. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  119773. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  119774. /**
  119775. * ImageProcessingPostProcess
  119776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  119777. */
  119778. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  119779. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  119780. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  119781. if (camera === void 0) { camera = null; }
  119782. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119783. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  119784. _this._fromLinearSpace = true;
  119785. /**
  119786. * Defines cache preventing GC.
  119787. */
  119788. _this._defines = {
  119789. IMAGEPROCESSING: false,
  119790. VIGNETTE: false,
  119791. VIGNETTEBLENDMODEMULTIPLY: false,
  119792. VIGNETTEBLENDMODEOPAQUE: false,
  119793. TONEMAPPING: false,
  119794. TONEMAPPING_ACES: false,
  119795. CONTRAST: false,
  119796. COLORCURVES: false,
  119797. COLORGRADING: false,
  119798. COLORGRADING3D: false,
  119799. FROMLINEARSPACE: false,
  119800. SAMPLER3DGREENDEPTH: false,
  119801. SAMPLER3DBGRMAP: false,
  119802. IMAGEPROCESSINGPOSTPROCESS: false,
  119803. EXPOSURE: false,
  119804. };
  119805. // Setup the configuration as forced by the constructor. This would then not force the
  119806. // scene materials output in linear space and let untouched the default forward pass.
  119807. if (imageProcessingConfiguration) {
  119808. imageProcessingConfiguration.applyByPostProcess = true;
  119809. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  119810. // This will cause the shader to be compiled
  119811. _this.fromLinearSpace = false;
  119812. }
  119813. // Setup the default processing configuration to the scene.
  119814. else {
  119815. _this._attachImageProcessingConfiguration(null, true);
  119816. _this.imageProcessingConfiguration.applyByPostProcess = true;
  119817. }
  119818. _this.onApply = function (effect) {
  119819. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  119820. };
  119821. return _this;
  119822. }
  119823. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  119824. /**
  119825. * Gets the image processing configuration used either in this material.
  119826. */
  119827. get: function () {
  119828. return this._imageProcessingConfiguration;
  119829. },
  119830. /**
  119831. * Sets the Default image processing configuration used either in the this material.
  119832. *
  119833. * If sets to null, the scene one is in use.
  119834. */
  119835. set: function (value) {
  119836. this._attachImageProcessingConfiguration(value);
  119837. },
  119838. enumerable: true,
  119839. configurable: true
  119840. });
  119841. /**
  119842. * Attaches a new image processing configuration to the PBR Material.
  119843. * @param configuration
  119844. */
  119845. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  119846. var _this = this;
  119847. if (doNotBuild === void 0) { doNotBuild = false; }
  119848. if (configuration === this._imageProcessingConfiguration) {
  119849. return;
  119850. }
  119851. // Detaches observer.
  119852. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  119853. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  119854. }
  119855. // Pick the scene configuration if needed.
  119856. if (!configuration) {
  119857. var scene = null;
  119858. var engine = this.getEngine();
  119859. var camera = this.getCamera();
  119860. if (camera) {
  119861. scene = camera.getScene();
  119862. }
  119863. else if (engine && engine.scenes) {
  119864. var scenes = engine.scenes;
  119865. scene = scenes[scenes.length - 1];
  119866. }
  119867. else {
  119868. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  119869. }
  119870. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  119871. }
  119872. else {
  119873. this._imageProcessingConfiguration = configuration;
  119874. }
  119875. // Attaches observer.
  119876. if (this._imageProcessingConfiguration) {
  119877. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  119878. _this._updateParameters();
  119879. });
  119880. }
  119881. // Ensure the effect will be rebuilt.
  119882. if (!doNotBuild) {
  119883. this._updateParameters();
  119884. }
  119885. };
  119886. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  119887. /**
  119888. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  119889. */
  119890. get: function () {
  119891. return this.imageProcessingConfiguration.colorCurves;
  119892. },
  119893. /**
  119894. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  119895. */
  119896. set: function (value) {
  119897. this.imageProcessingConfiguration.colorCurves = value;
  119898. },
  119899. enumerable: true,
  119900. configurable: true
  119901. });
  119902. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  119903. /**
  119904. * Gets wether the color curves effect is enabled.
  119905. */
  119906. get: function () {
  119907. return this.imageProcessingConfiguration.colorCurvesEnabled;
  119908. },
  119909. /**
  119910. * Sets wether the color curves effect is enabled.
  119911. */
  119912. set: function (value) {
  119913. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  119914. },
  119915. enumerable: true,
  119916. configurable: true
  119917. });
  119918. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  119919. /**
  119920. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  119921. */
  119922. get: function () {
  119923. return this.imageProcessingConfiguration.colorGradingTexture;
  119924. },
  119925. /**
  119926. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  119927. */
  119928. set: function (value) {
  119929. this.imageProcessingConfiguration.colorGradingTexture = value;
  119930. },
  119931. enumerable: true,
  119932. configurable: true
  119933. });
  119934. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  119935. /**
  119936. * Gets wether the color grading effect is enabled.
  119937. */
  119938. get: function () {
  119939. return this.imageProcessingConfiguration.colorGradingEnabled;
  119940. },
  119941. /**
  119942. * Gets wether the color grading effect is enabled.
  119943. */
  119944. set: function (value) {
  119945. this.imageProcessingConfiguration.colorGradingEnabled = value;
  119946. },
  119947. enumerable: true,
  119948. configurable: true
  119949. });
  119950. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  119951. /**
  119952. * Gets exposure used in the effect.
  119953. */
  119954. get: function () {
  119955. return this.imageProcessingConfiguration.exposure;
  119956. },
  119957. /**
  119958. * Sets exposure used in the effect.
  119959. */
  119960. set: function (value) {
  119961. this.imageProcessingConfiguration.exposure = value;
  119962. },
  119963. enumerable: true,
  119964. configurable: true
  119965. });
  119966. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  119967. /**
  119968. * Gets wether tonemapping is enabled or not.
  119969. */
  119970. get: function () {
  119971. return this._imageProcessingConfiguration.toneMappingEnabled;
  119972. },
  119973. /**
  119974. * Sets wether tonemapping is enabled or not
  119975. */
  119976. set: function (value) {
  119977. this._imageProcessingConfiguration.toneMappingEnabled = value;
  119978. },
  119979. enumerable: true,
  119980. configurable: true
  119981. });
  119982. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  119983. /**
  119984. * Gets the type of tone mapping effect.
  119985. */
  119986. get: function () {
  119987. return this._imageProcessingConfiguration.toneMappingType;
  119988. },
  119989. /**
  119990. * Sets the type of tone mapping effect.
  119991. */
  119992. set: function (value) {
  119993. this._imageProcessingConfiguration.toneMappingType = value;
  119994. },
  119995. enumerable: true,
  119996. configurable: true
  119997. });
  119998. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  119999. /**
  120000. * Gets contrast used in the effect.
  120001. */
  120002. get: function () {
  120003. return this.imageProcessingConfiguration.contrast;
  120004. },
  120005. /**
  120006. * Sets contrast used in the effect.
  120007. */
  120008. set: function (value) {
  120009. this.imageProcessingConfiguration.contrast = value;
  120010. },
  120011. enumerable: true,
  120012. configurable: true
  120013. });
  120014. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  120015. /**
  120016. * Gets Vignette stretch size.
  120017. */
  120018. get: function () {
  120019. return this.imageProcessingConfiguration.vignetteStretch;
  120020. },
  120021. /**
  120022. * Sets Vignette stretch size.
  120023. */
  120024. set: function (value) {
  120025. this.imageProcessingConfiguration.vignetteStretch = value;
  120026. },
  120027. enumerable: true,
  120028. configurable: true
  120029. });
  120030. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  120031. /**
  120032. * Gets Vignette centre X Offset.
  120033. */
  120034. get: function () {
  120035. return this.imageProcessingConfiguration.vignetteCentreX;
  120036. },
  120037. /**
  120038. * Sets Vignette centre X Offset.
  120039. */
  120040. set: function (value) {
  120041. this.imageProcessingConfiguration.vignetteCentreX = value;
  120042. },
  120043. enumerable: true,
  120044. configurable: true
  120045. });
  120046. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  120047. /**
  120048. * Gets Vignette centre Y Offset.
  120049. */
  120050. get: function () {
  120051. return this.imageProcessingConfiguration.vignetteCentreY;
  120052. },
  120053. /**
  120054. * Sets Vignette centre Y Offset.
  120055. */
  120056. set: function (value) {
  120057. this.imageProcessingConfiguration.vignetteCentreY = value;
  120058. },
  120059. enumerable: true,
  120060. configurable: true
  120061. });
  120062. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  120063. /**
  120064. * Gets Vignette weight or intensity of the vignette effect.
  120065. */
  120066. get: function () {
  120067. return this.imageProcessingConfiguration.vignetteWeight;
  120068. },
  120069. /**
  120070. * Sets Vignette weight or intensity of the vignette effect.
  120071. */
  120072. set: function (value) {
  120073. this.imageProcessingConfiguration.vignetteWeight = value;
  120074. },
  120075. enumerable: true,
  120076. configurable: true
  120077. });
  120078. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  120079. /**
  120080. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  120081. * if vignetteEnabled is set to true.
  120082. */
  120083. get: function () {
  120084. return this.imageProcessingConfiguration.vignetteColor;
  120085. },
  120086. /**
  120087. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  120088. * if vignetteEnabled is set to true.
  120089. */
  120090. set: function (value) {
  120091. this.imageProcessingConfiguration.vignetteColor = value;
  120092. },
  120093. enumerable: true,
  120094. configurable: true
  120095. });
  120096. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  120097. /**
  120098. * Gets Camera field of view used by the Vignette effect.
  120099. */
  120100. get: function () {
  120101. return this.imageProcessingConfiguration.vignetteCameraFov;
  120102. },
  120103. /**
  120104. * Sets Camera field of view used by the Vignette effect.
  120105. */
  120106. set: function (value) {
  120107. this.imageProcessingConfiguration.vignetteCameraFov = value;
  120108. },
  120109. enumerable: true,
  120110. configurable: true
  120111. });
  120112. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  120113. /**
  120114. * Gets the vignette blend mode allowing different kind of effect.
  120115. */
  120116. get: function () {
  120117. return this.imageProcessingConfiguration.vignetteBlendMode;
  120118. },
  120119. /**
  120120. * Sets the vignette blend mode allowing different kind of effect.
  120121. */
  120122. set: function (value) {
  120123. this.imageProcessingConfiguration.vignetteBlendMode = value;
  120124. },
  120125. enumerable: true,
  120126. configurable: true
  120127. });
  120128. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  120129. /**
  120130. * Gets wether the vignette effect is enabled.
  120131. */
  120132. get: function () {
  120133. return this.imageProcessingConfiguration.vignetteEnabled;
  120134. },
  120135. /**
  120136. * Sets wether the vignette effect is enabled.
  120137. */
  120138. set: function (value) {
  120139. this.imageProcessingConfiguration.vignetteEnabled = value;
  120140. },
  120141. enumerable: true,
  120142. configurable: true
  120143. });
  120144. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  120145. /**
  120146. * Gets wether the input of the processing is in Gamma or Linear Space.
  120147. */
  120148. get: function () {
  120149. return this._fromLinearSpace;
  120150. },
  120151. /**
  120152. * Sets wether the input of the processing is in Gamma or Linear Space.
  120153. */
  120154. set: function (value) {
  120155. if (this._fromLinearSpace === value) {
  120156. return;
  120157. }
  120158. this._fromLinearSpace = value;
  120159. this._updateParameters();
  120160. },
  120161. enumerable: true,
  120162. configurable: true
  120163. });
  120164. /**
  120165. * "ImageProcessingPostProcess"
  120166. * @returns "ImageProcessingPostProcess"
  120167. */
  120168. ImageProcessingPostProcess.prototype.getClassName = function () {
  120169. return "ImageProcessingPostProcess";
  120170. };
  120171. ImageProcessingPostProcess.prototype._updateParameters = function () {
  120172. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  120173. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  120174. var defines = "";
  120175. for (var define in this._defines) {
  120176. if (this._defines[define]) {
  120177. defines += "#define " + define + ";\r\n";
  120178. }
  120179. }
  120180. var samplers = ["textureSampler"];
  120181. var uniforms = ["scale"];
  120182. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  120183. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  120184. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  120185. }
  120186. this.updateEffect(defines, uniforms, samplers);
  120187. };
  120188. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  120189. _super.prototype.dispose.call(this, camera);
  120190. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  120191. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  120192. }
  120193. if (this._imageProcessingConfiguration) {
  120194. this.imageProcessingConfiguration.applyByPostProcess = false;
  120195. }
  120196. };
  120197. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120198. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120199. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  120200. return ImageProcessingPostProcess;
  120201. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  120202. /***/ }),
  120203. /***/ "./PostProcesses/index.ts":
  120204. /*!********************************!*\
  120205. !*** ./PostProcesses/index.ts ***!
  120206. \********************************/
  120207. /*! 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 */
  120208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120209. "use strict";
  120210. __webpack_require__.r(__webpack_exports__);
  120211. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  120212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  120213. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  120214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  120215. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  120216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  120217. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  120218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  120219. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  120220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  120221. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  120222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  120223. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  120224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  120225. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  120226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  120227. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  120228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  120229. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  120230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  120231. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  120232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  120233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  120234. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  120235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  120236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  120237. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  120238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  120239. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  120240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  120241. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  120242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  120243. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  120244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  120245. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  120246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  120247. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  120248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  120249. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  120250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  120251. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  120252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  120253. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  120254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  120255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  120256. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  120258. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  120259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  120260. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  120261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  120262. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  120263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  120264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  120265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  120266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  120267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  120268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  120269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  120270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  120271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  120272. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  120273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  120274. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  120275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  120276. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  120277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  120278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  120279. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  120280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  120281. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  120282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  120283. /***/ }),
  120284. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  120285. /*!************************************************!*\
  120286. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  120287. \************************************************/
  120288. /*! exports provided: MotionBlurPostProcess */
  120289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120290. "use strict";
  120291. __webpack_require__.r(__webpack_exports__);
  120292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  120293. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120294. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  120295. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120296. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120297. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120298. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  120299. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animatable */ "./Animations/animatable.ts");
  120300. /* harmony import */ var _Rendering_geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  120301. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  120302. /**
  120303. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  120304. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  120305. * As an example, all you have to do is to create the post-process:
  120306. * var mb = new BABYLON.MotionBlurPostProcess(
  120307. * 'mb', // The name of the effect.
  120308. * scene, // The scene containing the objects to blur according to their velocity.
  120309. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  120310. * camera // The camera to apply the render pass to.
  120311. * );
  120312. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  120313. */
  120314. var MotionBlurPostProcess = /** @class */ (function (_super) {
  120315. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  120316. /**
  120317. * Creates a new instance MotionBlurPostProcess
  120318. * @param name The name of the effect.
  120319. * @param scene The scene containing the objects to blur according to their velocity.
  120320. * @param options The required width/height ratio to downsize to before computing the render pass.
  120321. * @param camera The camera to apply the render pass to.
  120322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120323. * @param engine The engine which the post process will be applied. (default: current engine)
  120324. * @param reusable If the post process can be reused on the same frame. (default: false)
  120325. * @param textureType Type of textures used when performing the post process. (default: 0)
  120326. * @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)
  120327. */
  120328. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  120329. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  120330. if (blockCompilation === void 0) { blockCompilation = false; }
  120331. 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;
  120332. /**
  120333. * Defines how much the image is blurred by the movement. Default value is equal to 1
  120334. */
  120335. _this.motionStrength = 1;
  120336. _this._motionBlurSamples = 32;
  120337. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  120338. if (!_this._geometryBufferRenderer) {
  120339. // Geometry buffer renderer is not supported. So, work as a passthrough.
  120340. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  120341. _this.updateEffect();
  120342. }
  120343. else {
  120344. // Geometry buffer renderer is supported.
  120345. _this._geometryBufferRenderer.enableVelocity = true;
  120346. _this.onApply = function (effect) {
  120347. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  120348. effect.setFloat("motionScale", scene.getAnimationRatio());
  120349. effect.setFloat("motionStrength", _this.motionStrength);
  120350. if (_this._geometryBufferRenderer) {
  120351. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  120352. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  120353. }
  120354. };
  120355. }
  120356. return _this;
  120357. }
  120358. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  120359. /**
  120360. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  120361. */
  120362. get: function () {
  120363. return this._motionBlurSamples;
  120364. },
  120365. /**
  120366. * Sets the number of iterations to be used for motion blur quality
  120367. */
  120368. set: function (samples) {
  120369. this._motionBlurSamples = samples;
  120370. if (this._geometryBufferRenderer) {
  120371. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  120372. }
  120373. },
  120374. enumerable: true,
  120375. configurable: true
  120376. });
  120377. /**
  120378. * Disposes the post process.
  120379. * @param camera The camera to dispose the post process on.
  120380. */
  120381. MotionBlurPostProcess.prototype.dispose = function (camera) {
  120382. if (this._geometryBufferRenderer) {
  120383. // Clear previous transformation matrices dictionary used to compute objects velocities
  120384. this._geometryBufferRenderer._previousTransformationMatrices = {};
  120385. }
  120386. _super.prototype.dispose.call(this, camera);
  120387. };
  120388. return MotionBlurPostProcess;
  120389. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  120390. /***/ }),
  120391. /***/ "./PostProcesses/passPostProcess.ts":
  120392. /*!******************************************!*\
  120393. !*** ./PostProcesses/passPostProcess.ts ***!
  120394. \******************************************/
  120395. /*! exports provided: PassPostProcess, PassCubePostProcess */
  120396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120397. "use strict";
  120398. __webpack_require__.r(__webpack_exports__);
  120399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  120400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  120401. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120402. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120403. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120404. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  120405. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  120406. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  120407. /**
  120408. * PassPostProcess which produces an output the same as it's input
  120409. */
  120410. var PassPostProcess = /** @class */ (function (_super) {
  120411. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  120412. /**
  120413. * Creates the PassPostProcess
  120414. * @param name The name of the effect.
  120415. * @param options The required width/height ratio to downsize to before computing the render pass.
  120416. * @param camera The camera to apply the render pass to.
  120417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120418. * @param engine The engine which the post process will be applied. (default: current engine)
  120419. * @param reusable If the post process can be reused on the same frame. (default: false)
  120420. * @param textureType The type of texture to be used when performing the post processing.
  120421. * @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)
  120422. */
  120423. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  120424. if (camera === void 0) { camera = null; }
  120425. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  120426. if (blockCompilation === void 0) { blockCompilation = false; }
  120427. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  120428. }
  120429. return PassPostProcess;
  120430. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  120431. /**
  120432. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  120433. */
  120434. var PassCubePostProcess = /** @class */ (function (_super) {
  120435. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  120436. /**
  120437. * Creates the PassCubePostProcess
  120438. * @param name The name of the effect.
  120439. * @param options The required width/height ratio to downsize to before computing the render pass.
  120440. * @param camera The camera to apply the render pass to.
  120441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120442. * @param engine The engine which the post process will be applied. (default: current engine)
  120443. * @param reusable If the post process can be reused on the same frame. (default: false)
  120444. * @param textureType The type of texture to be used when performing the post processing.
  120445. * @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)
  120446. */
  120447. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  120448. if (camera === void 0) { camera = null; }
  120449. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  120450. if (blockCompilation === void 0) { blockCompilation = false; }
  120451. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  120452. _this._face = 0;
  120453. return _this;
  120454. }
  120455. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  120456. /**
  120457. * Gets or sets the cube face to display.
  120458. * * 0 is +X
  120459. * * 1 is -X
  120460. * * 2 is +Y
  120461. * * 3 is -Y
  120462. * * 4 is +Z
  120463. * * 5 is -Z
  120464. */
  120465. get: function () {
  120466. return this._face;
  120467. },
  120468. set: function (value) {
  120469. if (value < 0 || value > 5) {
  120470. return;
  120471. }
  120472. this._face = value;
  120473. switch (this._face) {
  120474. case 0:
  120475. this.updateEffect("#define POSITIVEX");
  120476. break;
  120477. case 1:
  120478. this.updateEffect("#define NEGATIVEX");
  120479. break;
  120480. case 2:
  120481. this.updateEffect("#define POSITIVEY");
  120482. break;
  120483. case 3:
  120484. this.updateEffect("#define NEGATIVEY");
  120485. break;
  120486. case 4:
  120487. this.updateEffect("#define POSITIVEZ");
  120488. break;
  120489. case 5:
  120490. this.updateEffect("#define NEGATIVEZ");
  120491. break;
  120492. }
  120493. },
  120494. enumerable: true,
  120495. configurable: true
  120496. });
  120497. return PassCubePostProcess;
  120498. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  120499. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  120500. 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);
  120501. };
  120502. /***/ }),
  120503. /***/ "./PostProcesses/postProcess.ts":
  120504. /*!**************************************!*\
  120505. !*** ./PostProcesses/postProcess.ts ***!
  120506. \**************************************/
  120507. /*! exports provided: PostProcess */
  120508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120509. "use strict";
  120510. __webpack_require__.r(__webpack_exports__);
  120511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  120512. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  120513. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  120514. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  120515. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120516. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120517. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  120518. /**
  120519. * PostProcess can be used to apply a shader to a texture after it has been rendered
  120520. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120521. */
  120522. var PostProcess = /** @class */ (function () {
  120523. /**
  120524. * Creates a new instance PostProcess
  120525. * @param name The name of the PostProcess.
  120526. * @param fragmentUrl The url of the fragment shader to be used.
  120527. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  120528. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  120529. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  120530. * @param camera The camera to apply the render pass to.
  120531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120532. * @param engine The engine which the post process will be applied. (default: current engine)
  120533. * @param reusable If the post process can be reused on the same frame. (default: false)
  120534. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  120535. * @param textureType Type of textures used when performing the post process. (default: 0)
  120536. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  120537. * @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
  120538. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  120539. */
  120540. function PostProcess(
  120541. /** Name of the PostProcess. */
  120542. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  120543. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  120544. if (defines === void 0) { defines = null; }
  120545. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  120546. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  120547. if (blockCompilation === void 0) { blockCompilation = false; }
  120548. this.name = name;
  120549. /**
  120550. * Width of the texture to apply the post process on
  120551. */
  120552. this.width = -1;
  120553. /**
  120554. * Height of the texture to apply the post process on
  120555. */
  120556. this.height = -1;
  120557. /**
  120558. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  120559. * @hidden
  120560. */
  120561. this._outputTexture = null;
  120562. /**
  120563. * If the buffer needs to be cleared before applying the post process. (default: true)
  120564. * Should be set to false if shader will overwrite all previous pixels.
  120565. */
  120566. this.autoClear = true;
  120567. /**
  120568. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  120569. */
  120570. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  120571. /**
  120572. * Animations to be used for the post processing
  120573. */
  120574. this.animations = new Array();
  120575. /**
  120576. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  120577. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  120578. */
  120579. this.enablePixelPerfectMode = false;
  120580. /**
  120581. * Force the postprocess to be applied without taking in account viewport
  120582. */
  120583. this.forceFullscreenViewport = true;
  120584. /**
  120585. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  120586. *
  120587. * | Value | Type | Description |
  120588. * | ----- | ----------------------------------- | ----------- |
  120589. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  120590. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  120591. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  120592. *
  120593. */
  120594. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  120595. /**
  120596. * Force textures to be a power of two (default: false)
  120597. */
  120598. this.alwaysForcePOT = false;
  120599. this._samples = 1;
  120600. /**
  120601. * Modify the scale of the post process to be the same as the viewport (default: false)
  120602. */
  120603. this.adaptScaleToCurrentViewport = false;
  120604. this._reusable = false;
  120605. /**
  120606. * Smart array of input and output textures for the post process.
  120607. * @hidden
  120608. */
  120609. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  120610. /**
  120611. * The index in _textures that corresponds to the output texture.
  120612. * @hidden
  120613. */
  120614. this._currentRenderTextureInd = 0;
  120615. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  120616. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  120617. // Events
  120618. /**
  120619. * An event triggered when the postprocess is activated.
  120620. */
  120621. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120622. /**
  120623. * An event triggered when the postprocess changes its size.
  120624. */
  120625. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120626. /**
  120627. * An event triggered when the postprocess applies its effect.
  120628. */
  120629. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120630. /**
  120631. * An event triggered before rendering the postprocess
  120632. */
  120633. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120634. /**
  120635. * An event triggered after rendering the postprocess
  120636. */
  120637. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120638. if (camera != null) {
  120639. this._camera = camera;
  120640. this._scene = camera.getScene();
  120641. camera.attachPostProcess(this);
  120642. this._engine = this._scene.getEngine();
  120643. this._scene.postProcesses.push(this);
  120644. this.uniqueId = this._scene.getUniqueId();
  120645. }
  120646. else if (engine) {
  120647. this._engine = engine;
  120648. this._engine.postProcesses.push(this);
  120649. }
  120650. this._options = options;
  120651. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  120652. this._reusable = reusable || false;
  120653. this._textureType = textureType;
  120654. this._samplers = samplers || [];
  120655. this._samplers.push("textureSampler");
  120656. this._fragmentUrl = fragmentUrl;
  120657. this._vertexUrl = vertexUrl;
  120658. this._parameters = parameters || [];
  120659. this._parameters.push("scale");
  120660. this._indexParameters = indexParameters;
  120661. if (!blockCompilation) {
  120662. this.updateEffect(defines);
  120663. }
  120664. }
  120665. Object.defineProperty(PostProcess.prototype, "samples", {
  120666. /**
  120667. * Number of sample textures (default: 1)
  120668. */
  120669. get: function () {
  120670. return this._samples;
  120671. },
  120672. set: function (n) {
  120673. var _this = this;
  120674. this._samples = n;
  120675. this._textures.forEach(function (texture) {
  120676. if (texture.samples !== _this._samples) {
  120677. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  120678. }
  120679. });
  120680. },
  120681. enumerable: true,
  120682. configurable: true
  120683. });
  120684. /**
  120685. * Returns the fragment url or shader name used in the post process.
  120686. * @returns the fragment url or name in the shader store.
  120687. */
  120688. PostProcess.prototype.getEffectName = function () {
  120689. return this._fragmentUrl;
  120690. };
  120691. Object.defineProperty(PostProcess.prototype, "onActivate", {
  120692. /**
  120693. * A function that is added to the onActivateObservable
  120694. */
  120695. set: function (callback) {
  120696. if (this._onActivateObserver) {
  120697. this.onActivateObservable.remove(this._onActivateObserver);
  120698. }
  120699. if (callback) {
  120700. this._onActivateObserver = this.onActivateObservable.add(callback);
  120701. }
  120702. },
  120703. enumerable: true,
  120704. configurable: true
  120705. });
  120706. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  120707. /**
  120708. * A function that is added to the onSizeChangedObservable
  120709. */
  120710. set: function (callback) {
  120711. if (this._onSizeChangedObserver) {
  120712. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  120713. }
  120714. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  120715. },
  120716. enumerable: true,
  120717. configurable: true
  120718. });
  120719. Object.defineProperty(PostProcess.prototype, "onApply", {
  120720. /**
  120721. * A function that is added to the onApplyObservable
  120722. */
  120723. set: function (callback) {
  120724. if (this._onApplyObserver) {
  120725. this.onApplyObservable.remove(this._onApplyObserver);
  120726. }
  120727. this._onApplyObserver = this.onApplyObservable.add(callback);
  120728. },
  120729. enumerable: true,
  120730. configurable: true
  120731. });
  120732. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  120733. /**
  120734. * A function that is added to the onBeforeRenderObservable
  120735. */
  120736. set: function (callback) {
  120737. if (this._onBeforeRenderObserver) {
  120738. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  120739. }
  120740. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  120741. },
  120742. enumerable: true,
  120743. configurable: true
  120744. });
  120745. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  120746. /**
  120747. * A function that is added to the onAfterRenderObservable
  120748. */
  120749. set: function (callback) {
  120750. if (this._onAfterRenderObserver) {
  120751. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  120752. }
  120753. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  120754. },
  120755. enumerable: true,
  120756. configurable: true
  120757. });
  120758. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  120759. /**
  120760. * 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
  120761. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  120762. */
  120763. get: function () {
  120764. return this._textures.data[this._currentRenderTextureInd];
  120765. },
  120766. set: function (value) {
  120767. this._forcedOutputTexture = value;
  120768. },
  120769. enumerable: true,
  120770. configurable: true
  120771. });
  120772. /**
  120773. * Gets the camera which post process is applied to.
  120774. * @returns The camera the post process is applied to.
  120775. */
  120776. PostProcess.prototype.getCamera = function () {
  120777. return this._camera;
  120778. };
  120779. Object.defineProperty(PostProcess.prototype, "texelSize", {
  120780. /**
  120781. * Gets the texel size of the postprocess.
  120782. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  120783. */
  120784. get: function () {
  120785. if (this._shareOutputWithPostProcess) {
  120786. return this._shareOutputWithPostProcess.texelSize;
  120787. }
  120788. if (this._forcedOutputTexture) {
  120789. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  120790. }
  120791. return this._texelSize;
  120792. },
  120793. enumerable: true,
  120794. configurable: true
  120795. });
  120796. /**
  120797. * Gets a string idenfifying the name of the class
  120798. * @returns "PostProcess" string
  120799. */
  120800. PostProcess.prototype.getClassName = function () {
  120801. return "PostProcess";
  120802. };
  120803. /**
  120804. * Gets the engine which this post process belongs to.
  120805. * @returns The engine the post process was enabled with.
  120806. */
  120807. PostProcess.prototype.getEngine = function () {
  120808. return this._engine;
  120809. };
  120810. /**
  120811. * The effect that is created when initializing the post process.
  120812. * @returns The created effect corrisponding the the postprocess.
  120813. */
  120814. PostProcess.prototype.getEffect = function () {
  120815. return this._effect;
  120816. };
  120817. /**
  120818. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  120819. * @param postProcess The post process to share the output with.
  120820. * @returns This post process.
  120821. */
  120822. PostProcess.prototype.shareOutputWith = function (postProcess) {
  120823. this._disposeTextures();
  120824. this._shareOutputWithPostProcess = postProcess;
  120825. return this;
  120826. };
  120827. /**
  120828. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  120829. * This should be called if the post process that shares output with this post process is disabled/disposed.
  120830. */
  120831. PostProcess.prototype.useOwnOutput = function () {
  120832. if (this._textures.length == 0) {
  120833. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  120834. }
  120835. this._shareOutputWithPostProcess = null;
  120836. };
  120837. /**
  120838. * Updates the effect with the current post process compile time values and recompiles the shader.
  120839. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  120840. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  120841. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  120842. * @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
  120843. * @param onCompiled Called when the shader has been compiled.
  120844. * @param onError Called if there is an error when compiling a shader.
  120845. */
  120846. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  120847. if (defines === void 0) { defines = null; }
  120848. if (uniforms === void 0) { uniforms = null; }
  120849. if (samplers === void 0) { samplers = null; }
  120850. 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);
  120851. };
  120852. /**
  120853. * The post process is reusable if it can be used multiple times within one frame.
  120854. * @returns If the post process is reusable
  120855. */
  120856. PostProcess.prototype.isReusable = function () {
  120857. return this._reusable;
  120858. };
  120859. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  120860. PostProcess.prototype.markTextureDirty = function () {
  120861. this.width = -1;
  120862. };
  120863. /**
  120864. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  120865. * 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.
  120866. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  120867. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  120868. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  120869. * @returns The target texture that was bound to be written to.
  120870. */
  120871. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  120872. var _this = this;
  120873. if (sourceTexture === void 0) { sourceTexture = null; }
  120874. camera = camera || this._camera;
  120875. var scene = camera.getScene();
  120876. var engine = scene.getEngine();
  120877. var maxSize = engine.getCaps().maxTextureSize;
  120878. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  120879. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  120880. // 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
  120881. var webVRCamera = camera.parent;
  120882. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  120883. requiredWidth /= 2;
  120884. }
  120885. var desiredWidth = (this._options.width || requiredWidth);
  120886. var desiredHeight = this._options.height || requiredHeight;
  120887. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  120888. if (this.adaptScaleToCurrentViewport) {
  120889. var currentViewport = engine.currentViewport;
  120890. if (currentViewport) {
  120891. desiredWidth *= currentViewport.width;
  120892. desiredHeight *= currentViewport.height;
  120893. }
  120894. }
  120895. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  120896. if (!this._options.width) {
  120897. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  120898. }
  120899. if (!this._options.height) {
  120900. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  120901. }
  120902. }
  120903. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  120904. if (this._textures.length > 0) {
  120905. for (var i = 0; i < this._textures.length; i++) {
  120906. this._engine._releaseTexture(this._textures.data[i]);
  120907. }
  120908. this._textures.reset();
  120909. }
  120910. this.width = desiredWidth;
  120911. this.height = desiredHeight;
  120912. var textureSize = { width: this.width, height: this.height };
  120913. var textureOptions = {
  120914. generateMipMaps: false,
  120915. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  120916. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  120917. samplingMode: this.renderTargetSamplingMode,
  120918. type: this._textureType
  120919. };
  120920. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  120921. if (this._reusable) {
  120922. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  120923. }
  120924. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  120925. this.onSizeChangedObservable.notifyObservers(this);
  120926. }
  120927. this._textures.forEach(function (texture) {
  120928. if (texture.samples !== _this.samples) {
  120929. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  120930. }
  120931. });
  120932. }
  120933. var target;
  120934. if (this._shareOutputWithPostProcess) {
  120935. target = this._shareOutputWithPostProcess.inputTexture;
  120936. }
  120937. else if (this._forcedOutputTexture) {
  120938. target = this._forcedOutputTexture;
  120939. this.width = this._forcedOutputTexture.width;
  120940. this.height = this._forcedOutputTexture.height;
  120941. }
  120942. else {
  120943. target = this.inputTexture;
  120944. }
  120945. // Bind the input of this post process to be used as the output of the previous post process.
  120946. if (this.enablePixelPerfectMode) {
  120947. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  120948. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  120949. }
  120950. else {
  120951. this._scaleRatio.copyFromFloats(1, 1);
  120952. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  120953. }
  120954. this.onActivateObservable.notifyObservers(camera);
  120955. // Clear
  120956. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  120957. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  120958. }
  120959. if (this._reusable) {
  120960. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  120961. }
  120962. return target;
  120963. };
  120964. Object.defineProperty(PostProcess.prototype, "isSupported", {
  120965. /**
  120966. * If the post process is supported.
  120967. */
  120968. get: function () {
  120969. return this._effect.isSupported;
  120970. },
  120971. enumerable: true,
  120972. configurable: true
  120973. });
  120974. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  120975. /**
  120976. * The aspect ratio of the output texture.
  120977. */
  120978. get: function () {
  120979. if (this._shareOutputWithPostProcess) {
  120980. return this._shareOutputWithPostProcess.aspectRatio;
  120981. }
  120982. if (this._forcedOutputTexture) {
  120983. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  120984. }
  120985. return this.width / this.height;
  120986. },
  120987. enumerable: true,
  120988. configurable: true
  120989. });
  120990. /**
  120991. * Get a value indicating if the post-process is ready to be used
  120992. * @returns true if the post-process is ready (shader is compiled)
  120993. */
  120994. PostProcess.prototype.isReady = function () {
  120995. return this._effect && this._effect.isReady();
  120996. };
  120997. /**
  120998. * Binds all textures and uniforms to the shader, this will be run on every pass.
  120999. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  121000. */
  121001. PostProcess.prototype.apply = function () {
  121002. // Check
  121003. if (!this._effect || !this._effect.isReady()) {
  121004. return null;
  121005. }
  121006. // States
  121007. this._engine.enableEffect(this._effect);
  121008. this._engine.setState(false);
  121009. this._engine.setDepthBuffer(false);
  121010. this._engine.setDepthWrite(false);
  121011. // Alpha
  121012. this._engine.setAlphaMode(this.alphaMode);
  121013. if (this.alphaConstants) {
  121014. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  121015. }
  121016. // Bind the output texture of the preivous post process as the input to this post process.
  121017. var source;
  121018. if (this._shareOutputWithPostProcess) {
  121019. source = this._shareOutputWithPostProcess.inputTexture;
  121020. }
  121021. else if (this._forcedOutputTexture) {
  121022. source = this._forcedOutputTexture;
  121023. }
  121024. else {
  121025. source = this.inputTexture;
  121026. }
  121027. this._effect._bindTexture("textureSampler", source);
  121028. // Parameters
  121029. this._effect.setVector2("scale", this._scaleRatio);
  121030. this.onApplyObservable.notifyObservers(this._effect);
  121031. return this._effect;
  121032. };
  121033. PostProcess.prototype._disposeTextures = function () {
  121034. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  121035. return;
  121036. }
  121037. if (this._textures.length > 0) {
  121038. for (var i = 0; i < this._textures.length; i++) {
  121039. this._engine._releaseTexture(this._textures.data[i]);
  121040. }
  121041. }
  121042. this._textures.dispose();
  121043. };
  121044. /**
  121045. * Disposes the post process.
  121046. * @param camera The camera to dispose the post process on.
  121047. */
  121048. PostProcess.prototype.dispose = function (camera) {
  121049. camera = camera || this._camera;
  121050. this._disposeTextures();
  121051. if (this._scene) {
  121052. var index_1 = this._scene.postProcesses.indexOf(this);
  121053. if (index_1 !== -1) {
  121054. this._scene.postProcesses.splice(index_1, 1);
  121055. }
  121056. }
  121057. else {
  121058. var index_2 = this._engine.postProcesses.indexOf(this);
  121059. if (index_2 !== -1) {
  121060. this._engine.postProcesses.splice(index_2, 1);
  121061. }
  121062. }
  121063. if (!camera) {
  121064. return;
  121065. }
  121066. camera.detachPostProcess(this);
  121067. var index = camera._postProcesses.indexOf(this);
  121068. if (index === 0 && camera._postProcesses.length > 0) {
  121069. var firstPostProcess = this._camera._getFirstPostProcess();
  121070. if (firstPostProcess) {
  121071. firstPostProcess.markTextureDirty();
  121072. }
  121073. }
  121074. this.onActivateObservable.clear();
  121075. this.onAfterRenderObservable.clear();
  121076. this.onApplyObservable.clear();
  121077. this.onBeforeRenderObservable.clear();
  121078. this.onSizeChangedObservable.clear();
  121079. };
  121080. return PostProcess;
  121081. }());
  121082. /***/ }),
  121083. /***/ "./PostProcesses/postProcessManager.ts":
  121084. /*!*********************************************!*\
  121085. !*** ./PostProcesses/postProcessManager.ts ***!
  121086. \*********************************************/
  121087. /*! exports provided: PostProcessManager */
  121088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121089. "use strict";
  121090. __webpack_require__.r(__webpack_exports__);
  121091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  121092. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121093. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121094. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121095. /**
  121096. * PostProcessManager is used to manage one or more post processes or post process pipelines
  121097. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121098. */
  121099. var PostProcessManager = /** @class */ (function () {
  121100. /**
  121101. * Creates a new instance PostProcess
  121102. * @param scene The scene that the post process is associated with.
  121103. */
  121104. function PostProcessManager(scene) {
  121105. this._vertexBuffers = {};
  121106. this._scene = scene;
  121107. }
  121108. PostProcessManager.prototype._prepareBuffers = function () {
  121109. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  121110. return;
  121111. }
  121112. // VBO
  121113. var vertices = [];
  121114. vertices.push(1, 1);
  121115. vertices.push(-1, 1);
  121116. vertices.push(-1, -1);
  121117. vertices.push(1, -1);
  121118. 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);
  121119. this._buildIndexBuffer();
  121120. };
  121121. PostProcessManager.prototype._buildIndexBuffer = function () {
  121122. // Indices
  121123. var indices = [];
  121124. indices.push(0);
  121125. indices.push(1);
  121126. indices.push(2);
  121127. indices.push(0);
  121128. indices.push(2);
  121129. indices.push(3);
  121130. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  121131. };
  121132. /**
  121133. * Rebuilds the vertex buffers of the manager.
  121134. * @hidden
  121135. */
  121136. PostProcessManager.prototype._rebuild = function () {
  121137. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  121138. if (!vb) {
  121139. return;
  121140. }
  121141. vb._rebuild();
  121142. this._buildIndexBuffer();
  121143. };
  121144. // Methods
  121145. /**
  121146. * Prepares a frame to be run through a post process.
  121147. * @param sourceTexture The input texture to the post procesess. (default: null)
  121148. * @param postProcesses An array of post processes to be run. (default: null)
  121149. * @returns True if the post processes were able to be run.
  121150. * @hidden
  121151. */
  121152. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  121153. if (sourceTexture === void 0) { sourceTexture = null; }
  121154. if (postProcesses === void 0) { postProcesses = null; }
  121155. var camera = this._scene.activeCamera;
  121156. if (!camera) {
  121157. return false;
  121158. }
  121159. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  121160. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  121161. return false;
  121162. }
  121163. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  121164. return true;
  121165. };
  121166. /**
  121167. * Manually render a set of post processes to a texture.
  121168. * @param postProcesses An array of post processes to be run.
  121169. * @param targetTexture The target texture to render to.
  121170. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  121171. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  121172. * @param lodLevel defines which lod of the texture to render to
  121173. */
  121174. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  121175. if (targetTexture === void 0) { targetTexture = null; }
  121176. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  121177. if (faceIndex === void 0) { faceIndex = 0; }
  121178. if (lodLevel === void 0) { lodLevel = 0; }
  121179. var engine = this._scene.getEngine();
  121180. for (var index = 0; index < postProcesses.length; index++) {
  121181. if (index < postProcesses.length - 1) {
  121182. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  121183. }
  121184. else {
  121185. if (targetTexture) {
  121186. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  121187. }
  121188. else {
  121189. engine.restoreDefaultFramebuffer();
  121190. }
  121191. }
  121192. var pp = postProcesses[index];
  121193. var effect = pp.apply();
  121194. if (effect) {
  121195. pp.onBeforeRenderObservable.notifyObservers(effect);
  121196. // VBOs
  121197. this._prepareBuffers();
  121198. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  121199. // Draw order
  121200. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  121201. pp.onAfterRenderObservable.notifyObservers(effect);
  121202. }
  121203. }
  121204. // Restore depth buffer
  121205. engine.setDepthBuffer(true);
  121206. engine.setDepthWrite(true);
  121207. };
  121208. /**
  121209. * Finalize the result of the output of the postprocesses.
  121210. * @param doNotPresent If true the result will not be displayed to the screen.
  121211. * @param targetTexture The target texture to render to.
  121212. * @param faceIndex The index of the face to bind the target texture to.
  121213. * @param postProcesses The array of post processes to render.
  121214. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  121215. * @hidden
  121216. */
  121217. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  121218. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  121219. var camera = this._scene.activeCamera;
  121220. if (!camera) {
  121221. return;
  121222. }
  121223. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  121224. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  121225. return;
  121226. }
  121227. var engine = this._scene.getEngine();
  121228. for (var index = 0, len = postProcesses.length; index < len; index++) {
  121229. var pp = postProcesses[index];
  121230. if (index < len - 1) {
  121231. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  121232. }
  121233. else {
  121234. if (targetTexture) {
  121235. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  121236. pp._outputTexture = targetTexture;
  121237. }
  121238. else {
  121239. engine.restoreDefaultFramebuffer();
  121240. pp._outputTexture = null;
  121241. }
  121242. }
  121243. if (doNotPresent) {
  121244. break;
  121245. }
  121246. var effect = pp.apply();
  121247. if (effect) {
  121248. pp.onBeforeRenderObservable.notifyObservers(effect);
  121249. // VBOs
  121250. this._prepareBuffers();
  121251. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  121252. // Draw order
  121253. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  121254. pp.onAfterRenderObservable.notifyObservers(effect);
  121255. }
  121256. }
  121257. // Restore states
  121258. engine.setDepthBuffer(true);
  121259. engine.setDepthWrite(true);
  121260. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121261. };
  121262. /**
  121263. * Disposes of the post process manager.
  121264. */
  121265. PostProcessManager.prototype.dispose = function () {
  121266. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  121267. if (buffer) {
  121268. buffer.dispose();
  121269. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  121270. }
  121271. if (this._indexBuffer) {
  121272. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  121273. this._indexBuffer = null;
  121274. }
  121275. };
  121276. return PostProcessManager;
  121277. }());
  121278. /***/ }),
  121279. /***/ "./PostProcesses/refractionPostProcess.ts":
  121280. /*!************************************************!*\
  121281. !*** ./PostProcesses/refractionPostProcess.ts ***!
  121282. \************************************************/
  121283. /*! exports provided: RefractionPostProcess */
  121284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121285. "use strict";
  121286. __webpack_require__.r(__webpack_exports__);
  121287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  121288. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121289. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121290. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121291. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  121292. /**
  121293. * Post process which applies a refractin texture
  121294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121295. */
  121296. var RefractionPostProcess = /** @class */ (function (_super) {
  121297. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  121298. /**
  121299. * Initializes the RefractionPostProcess
  121300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121301. * @param name The name of the effect.
  121302. * @param refractionTextureUrl Url of the refraction texture to use
  121303. * @param color the base color of the refraction (used to taint the rendering)
  121304. * @param depth simulated refraction depth
  121305. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  121306. * @param camera The camera to apply the render pass to.
  121307. * @param options The required width/height ratio to downsize to before computing the render pass.
  121308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121309. * @param engine The engine which the post process will be applied. (default: current engine)
  121310. * @param reusable If the post process can be reused on the same frame. (default: false)
  121311. */
  121312. function RefractionPostProcess(name, refractionTextureUrl,
  121313. /** the base color of the refraction (used to taint the rendering) */
  121314. color,
  121315. /** simulated refraction depth */
  121316. depth,
  121317. /** the coefficient of the base color (0 to remove base color tainting) */
  121318. colorLevel, options, camera, samplingMode, engine, reusable) {
  121319. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  121320. _this.color = color;
  121321. _this.depth = depth;
  121322. _this.colorLevel = colorLevel;
  121323. _this._ownRefractionTexture = true;
  121324. _this.onActivateObservable.add(function (cam) {
  121325. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  121326. });
  121327. _this.onApplyObservable.add(function (effect) {
  121328. effect.setColor3("baseColor", _this.color);
  121329. effect.setFloat("depth", _this.depth);
  121330. effect.setFloat("colorLevel", _this.colorLevel);
  121331. effect.setTexture("refractionSampler", _this._refTexture);
  121332. });
  121333. return _this;
  121334. }
  121335. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  121336. /**
  121337. * Gets or sets the refraction texture
  121338. * Please note that you are responsible for disposing the texture if you set it manually
  121339. */
  121340. get: function () {
  121341. return this._refTexture;
  121342. },
  121343. set: function (value) {
  121344. if (this._refTexture && this._ownRefractionTexture) {
  121345. this._refTexture.dispose();
  121346. }
  121347. this._refTexture = value;
  121348. this._ownRefractionTexture = false;
  121349. },
  121350. enumerable: true,
  121351. configurable: true
  121352. });
  121353. // Methods
  121354. /**
  121355. * Disposes of the post process
  121356. * @param camera Camera to dispose post process on
  121357. */
  121358. RefractionPostProcess.prototype.dispose = function (camera) {
  121359. if (this._refTexture && this._ownRefractionTexture) {
  121360. this._refTexture.dispose();
  121361. this._refTexture = null;
  121362. }
  121363. _super.prototype.dispose.call(this, camera);
  121364. };
  121365. return RefractionPostProcess;
  121366. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  121367. /***/ }),
  121368. /***/ "./PostProcesses/sharpenPostProcess.ts":
  121369. /*!*********************************************!*\
  121370. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  121371. \*********************************************/
  121372. /*! exports provided: SharpenPostProcess */
  121373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121374. "use strict";
  121375. __webpack_require__.r(__webpack_exports__);
  121376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  121377. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121378. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121379. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121380. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  121381. /**
  121382. * The SharpenPostProcess applies a sharpen kernel to every pixel
  121383. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121384. */
  121385. var SharpenPostProcess = /** @class */ (function (_super) {
  121386. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  121387. /**
  121388. * Creates a new instance ConvolutionPostProcess
  121389. * @param name The name of the effect.
  121390. * @param options The required width/height ratio to downsize to before computing the render pass.
  121391. * @param camera The camera to apply the render pass to.
  121392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121393. * @param engine The engine which the post process will be applied. (default: current engine)
  121394. * @param reusable If the post process can be reused on the same frame. (default: false)
  121395. * @param textureType Type of textures used when performing the post process. (default: 0)
  121396. * @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)
  121397. */
  121398. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121399. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121400. if (blockCompilation === void 0) { blockCompilation = false; }
  121401. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  121402. /**
  121403. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  121404. */
  121405. _this.colorAmount = 1.0;
  121406. /**
  121407. * How much sharpness should be applied (default: 0.3)
  121408. */
  121409. _this.edgeAmount = 0.3;
  121410. _this.onApply = function (effect) {
  121411. effect.setFloat2("screenSize", _this.width, _this.height);
  121412. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  121413. };
  121414. return _this;
  121415. }
  121416. return SharpenPostProcess;
  121417. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121418. /***/ }),
  121419. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  121420. /*!***********************************************************!*\
  121421. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  121422. \***********************************************************/
  121423. /*! exports provided: StereoscopicInterlacePostProcess */
  121424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121425. "use strict";
  121426. __webpack_require__.r(__webpack_exports__);
  121427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  121428. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121429. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121430. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121431. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  121432. /**
  121433. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  121434. */
  121435. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  121436. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  121437. /**
  121438. * Initializes a StereoscopicInterlacePostProcess
  121439. * @param name The name of the effect.
  121440. * @param rigCameras The rig cameras to be appled to the post process
  121441. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  121442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121443. * @param engine The engine which the post process will be applied. (default: current engine)
  121444. * @param reusable If the post process can be reused on the same frame. (default: false)
  121445. */
  121446. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  121447. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  121448. _this._passedProcess = rigCameras[0]._rigPostProcess;
  121449. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  121450. _this.onSizeChangedObservable.add(function () {
  121451. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  121452. });
  121453. _this.onApplyObservable.add(function (effect) {
  121454. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  121455. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  121456. });
  121457. return _this;
  121458. }
  121459. return StereoscopicInterlacePostProcess;
  121460. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  121461. /***/ }),
  121462. /***/ "./PostProcesses/tonemapPostProcess.ts":
  121463. /*!*********************************************!*\
  121464. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  121465. \*********************************************/
  121466. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  121467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121468. "use strict";
  121469. __webpack_require__.r(__webpack_exports__);
  121470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  121471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  121472. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121473. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121474. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121475. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  121476. /** Defines operator used for tonemapping */
  121477. var TonemappingOperator;
  121478. (function (TonemappingOperator) {
  121479. /** Hable */
  121480. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  121481. /** Reinhard */
  121482. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  121483. /** HejiDawson */
  121484. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  121485. /** Photographic */
  121486. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  121487. })(TonemappingOperator || (TonemappingOperator = {}));
  121488. /**
  121489. * Defines a post process to apply tone mapping
  121490. */
  121491. var TonemapPostProcess = /** @class */ (function (_super) {
  121492. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  121493. /**
  121494. * Creates a new TonemapPostProcess
  121495. * @param name defines the name of the postprocess
  121496. * @param _operator defines the operator to use
  121497. * @param exposureAdjustment defines the required exposure adjustement
  121498. * @param camera defines the camera to use (can be null)
  121499. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  121500. * @param engine defines the hosting engine (can be ignore if camera is set)
  121501. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121502. */
  121503. function TonemapPostProcess(name, _operator,
  121504. /** Defines the required exposure adjustement */
  121505. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  121506. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  121507. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121508. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  121509. _this._operator = _operator;
  121510. _this.exposureAdjustment = exposureAdjustment;
  121511. var defines = "#define ";
  121512. if (_this._operator === TonemappingOperator.Hable) {
  121513. defines += "HABLE_TONEMAPPING";
  121514. }
  121515. else if (_this._operator === TonemappingOperator.Reinhard) {
  121516. defines += "REINHARD_TONEMAPPING";
  121517. }
  121518. else if (_this._operator === TonemappingOperator.HejiDawson) {
  121519. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  121520. }
  121521. else if (_this._operator === TonemappingOperator.Photographic) {
  121522. defines += "PHOTOGRAPHIC_TONEMAPPING";
  121523. }
  121524. //sadly a second call to create the effect.
  121525. _this.updateEffect(defines);
  121526. _this.onApply = function (effect) {
  121527. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  121528. };
  121529. return _this;
  121530. }
  121531. return TonemapPostProcess;
  121532. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121533. /***/ }),
  121534. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  121535. /*!***************************************************************!*\
  121536. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  121537. \***************************************************************/
  121538. /*! exports provided: VolumetricLightScatteringPostProcess */
  121539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121540. "use strict";
  121541. __webpack_require__.r(__webpack_exports__);
  121542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  121543. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121544. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  121545. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  121546. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121547. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121548. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  121549. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  121550. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121551. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  121552. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121553. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  121554. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121555. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121556. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  121557. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  121558. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  121559. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  121560. /**
  121561. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  121562. */
  121563. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  121564. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  121565. /**
  121566. * @constructor
  121567. * @param name The post-process name
  121568. * @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)
  121569. * @param camera The camera that the post-process will be attached to
  121570. * @param mesh The mesh used to create the light scattering
  121571. * @param samples The post-process quality, default 100
  121572. * @param samplingModeThe post-process filtering mode
  121573. * @param engine The babylon engine
  121574. * @param reusable If the post-process is reusable
  121575. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  121576. */
  121577. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  121578. if (samples === void 0) { samples = 100; }
  121579. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  121580. 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;
  121581. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  121582. /**
  121583. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  121584. */
  121585. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  121586. /**
  121587. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  121588. */
  121589. _this.useCustomMeshPosition = false;
  121590. /**
  121591. * If the post-process should inverse the light scattering direction
  121592. */
  121593. _this.invert = true;
  121594. /**
  121595. * Array containing the excluded meshes not rendered in the internal pass
  121596. */
  121597. _this.excludedMeshes = new Array();
  121598. /**
  121599. * Controls the overall intensity of the post-process
  121600. */
  121601. _this.exposure = 0.3;
  121602. /**
  121603. * Dissipates each sample's contribution in range [0, 1]
  121604. */
  121605. _this.decay = 0.96815;
  121606. /**
  121607. * Controls the overall intensity of each sample
  121608. */
  121609. _this.weight = 0.58767;
  121610. /**
  121611. * Controls the density of each sample
  121612. */
  121613. _this.density = 0.926;
  121614. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  121615. engine = scene.getEngine();
  121616. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  121617. // Configure mesh
  121618. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  121619. // Configure
  121620. _this._createPass(scene, ratio.passRatio || ratio);
  121621. _this.onActivate = function (camera) {
  121622. if (!_this.isSupported) {
  121623. _this.dispose(camera);
  121624. }
  121625. _this.onActivate = null;
  121626. };
  121627. _this.onApplyObservable.add(function (effect) {
  121628. _this._updateMeshScreenCoordinates(scene);
  121629. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  121630. effect.setFloat("exposure", _this.exposure);
  121631. effect.setFloat("decay", _this.decay);
  121632. effect.setFloat("weight", _this.weight);
  121633. effect.setFloat("density", _this.density);
  121634. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  121635. });
  121636. return _this;
  121637. }
  121638. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  121639. /**
  121640. * @hidden
  121641. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  121642. */
  121643. get: function () {
  121644. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  121645. return false;
  121646. },
  121647. set: function (useDiffuseColor) {
  121648. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  121649. },
  121650. enumerable: true,
  121651. configurable: true
  121652. });
  121653. /**
  121654. * Returns the string "VolumetricLightScatteringPostProcess"
  121655. * @returns "VolumetricLightScatteringPostProcess"
  121656. */
  121657. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  121658. return "VolumetricLightScatteringPostProcess";
  121659. };
  121660. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  121661. var mesh = subMesh.getMesh();
  121662. // Render this.mesh as default
  121663. if (mesh === this.mesh && mesh.material) {
  121664. return mesh.material.isReady(mesh);
  121665. }
  121666. var defines = [];
  121667. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  121668. var material = subMesh.getMaterial();
  121669. // Alpha test
  121670. if (material) {
  121671. if (material.needAlphaTesting()) {
  121672. defines.push("#define ALPHATEST");
  121673. }
  121674. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  121675. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  121676. defines.push("#define UV1");
  121677. }
  121678. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  121679. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  121680. defines.push("#define UV2");
  121681. }
  121682. }
  121683. // Bones
  121684. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121685. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  121686. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  121687. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121688. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  121689. }
  121690. else {
  121691. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121692. }
  121693. // Instances
  121694. if (useInstances) {
  121695. defines.push("#define INSTANCES");
  121696. attribs.push("world0");
  121697. attribs.push("world1");
  121698. attribs.push("world2");
  121699. attribs.push("world3");
  121700. }
  121701. // Get correct effect
  121702. var join = defines.join("\n");
  121703. if (this._cachedDefines !== join) {
  121704. this._cachedDefines = join;
  121705. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  121706. }
  121707. return this._volumetricLightScatteringPass.isReady();
  121708. };
  121709. /**
  121710. * Sets the new light position for light scattering effect
  121711. * @param position The new custom light position
  121712. */
  121713. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  121714. this.customMeshPosition = position;
  121715. };
  121716. /**
  121717. * Returns the light position for light scattering effect
  121718. * @return Vector3 The custom light position
  121719. */
  121720. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  121721. return this.customMeshPosition;
  121722. };
  121723. /**
  121724. * Disposes the internal assets and detaches the post-process from the camera
  121725. */
  121726. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  121727. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  121728. if (rttIndex !== -1) {
  121729. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  121730. }
  121731. this._volumetricLightScatteringRTT.dispose();
  121732. _super.prototype.dispose.call(this, camera);
  121733. };
  121734. /**
  121735. * Returns the render target texture used by the post-process
  121736. * @return the render target texture used by the post-process
  121737. */
  121738. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  121739. return this._volumetricLightScatteringRTT;
  121740. };
  121741. // Private methods
  121742. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  121743. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  121744. return true;
  121745. }
  121746. return false;
  121747. };
  121748. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  121749. var _this = this;
  121750. var engine = scene.getEngine();
  121751. 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);
  121752. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  121753. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  121754. this._volumetricLightScatteringRTT.renderList = null;
  121755. this._volumetricLightScatteringRTT.renderParticles = false;
  121756. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  121757. var camera = this.getCamera();
  121758. if (camera) {
  121759. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  121760. }
  121761. else {
  121762. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  121763. }
  121764. // Custom render function for submeshes
  121765. var renderSubMesh = function (subMesh) {
  121766. var mesh = subMesh.getRenderingMesh();
  121767. if (_this._meshExcluded(mesh)) {
  121768. return;
  121769. }
  121770. var material = subMesh.getMaterial();
  121771. if (!material) {
  121772. return;
  121773. }
  121774. var scene = mesh.getScene();
  121775. var engine = scene.getEngine();
  121776. // Culling
  121777. engine.setState(material.backFaceCulling);
  121778. // Managing instances
  121779. var batch = mesh._getInstancesRenderList(subMesh._id);
  121780. if (batch.mustReturn) {
  121781. return;
  121782. }
  121783. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  121784. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  121785. var effect = _this._volumetricLightScatteringPass;
  121786. if (mesh === _this.mesh) {
  121787. if (subMesh.effect) {
  121788. effect = subMesh.effect;
  121789. }
  121790. else {
  121791. effect = material.getEffect();
  121792. }
  121793. }
  121794. engine.enableEffect(effect);
  121795. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  121796. if (mesh === _this.mesh) {
  121797. material.bind(mesh.getWorldMatrix(), mesh);
  121798. }
  121799. else {
  121800. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  121801. // Alpha test
  121802. if (material && material.needAlphaTesting()) {
  121803. var alphaTexture = material.getAlphaTestTexture();
  121804. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  121805. if (alphaTexture) {
  121806. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121807. }
  121808. }
  121809. // Bones
  121810. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121811. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121812. }
  121813. }
  121814. // Draw
  121815. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  121816. }
  121817. };
  121818. // Render target texture callbacks
  121819. var savedSceneClearColor;
  121820. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  121821. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  121822. savedSceneClearColor = scene.clearColor;
  121823. scene.clearColor = sceneClearColor;
  121824. });
  121825. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  121826. scene.clearColor = savedSceneClearColor;
  121827. });
  121828. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  121829. var engine = scene.getEngine();
  121830. var index;
  121831. if (depthOnlySubMeshes.length) {
  121832. engine.setColorWrite(false);
  121833. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  121834. renderSubMesh(depthOnlySubMeshes.data[index]);
  121835. }
  121836. engine.setColorWrite(true);
  121837. }
  121838. for (index = 0; index < opaqueSubMeshes.length; index++) {
  121839. renderSubMesh(opaqueSubMeshes.data[index]);
  121840. }
  121841. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  121842. renderSubMesh(alphaTestSubMeshes.data[index]);
  121843. }
  121844. if (transparentSubMeshes.length) {
  121845. // Sort sub meshes
  121846. for (index = 0; index < transparentSubMeshes.length; index++) {
  121847. var submesh = transparentSubMeshes.data[index];
  121848. var boundingInfo = submesh.getBoundingInfo();
  121849. if (boundingInfo && scene.activeCamera) {
  121850. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  121851. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  121852. }
  121853. }
  121854. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  121855. sortedArray.sort(function (a, b) {
  121856. // Alpha index first
  121857. if (a._alphaIndex > b._alphaIndex) {
  121858. return 1;
  121859. }
  121860. if (a._alphaIndex < b._alphaIndex) {
  121861. return -1;
  121862. }
  121863. // Then distance to camera
  121864. if (a._distanceToCamera < b._distanceToCamera) {
  121865. return 1;
  121866. }
  121867. if (a._distanceToCamera > b._distanceToCamera) {
  121868. return -1;
  121869. }
  121870. return 0;
  121871. });
  121872. // Render sub meshes
  121873. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  121874. for (index = 0; index < sortedArray.length; index++) {
  121875. renderSubMesh(sortedArray[index]);
  121876. }
  121877. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  121878. }
  121879. };
  121880. };
  121881. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  121882. var transform = scene.getTransformMatrix();
  121883. var meshPosition;
  121884. if (this.useCustomMeshPosition) {
  121885. meshPosition = this.customMeshPosition;
  121886. }
  121887. else if (this.attachedNode) {
  121888. meshPosition = this.attachedNode.position;
  121889. }
  121890. else {
  121891. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  121892. }
  121893. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  121894. this._screenCoordinates.x = pos.x / this._viewPort.width;
  121895. this._screenCoordinates.y = pos.y / this._viewPort.height;
  121896. if (this.invert) {
  121897. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  121898. }
  121899. };
  121900. // Static methods
  121901. /**
  121902. * Creates a default mesh for the Volumeric Light Scattering post-process
  121903. * @param name The mesh name
  121904. * @param scene The scene where to create the mesh
  121905. * @return the default mesh
  121906. */
  121907. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  121908. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  121909. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  121910. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  121911. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  121912. mesh.material = material;
  121913. return mesh;
  121914. };
  121915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  121917. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  121918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121920. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  121921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121923. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  121924. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121925. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  121926. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  121927. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121929. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  121930. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121932. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  121933. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121935. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  121936. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121937. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121938. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  121939. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121941. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  121942. return VolumetricLightScatteringPostProcess;
  121943. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  121944. /***/ }),
  121945. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  121946. /*!************************************************************!*\
  121947. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  121948. \************************************************************/
  121949. /*! exports provided: VRDistortionCorrectionPostProcess */
  121950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121951. "use strict";
  121952. __webpack_require__.r(__webpack_exports__);
  121953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  121954. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121955. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121956. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121957. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121958. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  121959. /**
  121960. * VRDistortionCorrectionPostProcess used for mobile VR
  121961. */
  121962. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  121963. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  121964. /**
  121965. * Initializes the VRDistortionCorrectionPostProcess
  121966. * @param name The name of the effect.
  121967. * @param camera The camera to apply the render pass to.
  121968. * @param isRightEye If this is for the right eye distortion
  121969. * @param vrMetrics All the required metrics for the VR camera
  121970. */
  121971. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  121972. var _this = _super.call(this, name, "vrDistortionCorrection", [
  121973. 'LensCenter',
  121974. 'Scale',
  121975. 'ScaleIn',
  121976. 'HmdWarpParam'
  121977. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  121978. _this._isRightEye = isRightEye;
  121979. _this._distortionFactors = vrMetrics.distortionK;
  121980. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  121981. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  121982. _this.adaptScaleToCurrentViewport = true;
  121983. _this.onSizeChangedObservable.add(function () {
  121984. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  121985. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  121986. _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);
  121987. });
  121988. _this.onApplyObservable.add(function (effect) {
  121989. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  121990. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  121991. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  121992. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  121993. });
  121994. return _this;
  121995. }
  121996. return VRDistortionCorrectionPostProcess;
  121997. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  121998. /***/ }),
  121999. /***/ "./Probes/index.ts":
  122000. /*!*************************!*\
  122001. !*** ./Probes/index.ts ***!
  122002. \*************************/
  122003. /*! exports provided: ReflectionProbe */
  122004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122005. "use strict";
  122006. __webpack_require__.r(__webpack_exports__);
  122007. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  122008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  122009. /***/ }),
  122010. /***/ "./Probes/reflectionProbe.ts":
  122011. /*!***********************************!*\
  122012. !*** ./Probes/reflectionProbe.ts ***!
  122013. \***********************************/
  122014. /*! exports provided: ReflectionProbe */
  122015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122016. "use strict";
  122017. __webpack_require__.r(__webpack_exports__);
  122018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  122019. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122020. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  122021. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  122022. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122023. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  122024. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122025. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  122026. if (!this.reflectionProbes) {
  122027. return -1;
  122028. }
  122029. var index = this.reflectionProbes.indexOf(toRemove);
  122030. if (index !== -1) {
  122031. this.reflectionProbes.splice(index, 1);
  122032. }
  122033. return index;
  122034. };
  122035. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  122036. if (!this.reflectionProbes) {
  122037. this.reflectionProbes = [];
  122038. }
  122039. this.reflectionProbes.push(newReflectionProbe);
  122040. };
  122041. /**
  122042. * Class used to generate realtime reflection / refraction cube textures
  122043. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  122044. */
  122045. var ReflectionProbe = /** @class */ (function () {
  122046. /**
  122047. * Creates a new reflection probe
  122048. * @param name defines the name of the probe
  122049. * @param size defines the texture resolution (for each face)
  122050. * @param scene defines the hosting scene
  122051. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  122052. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  122053. */
  122054. function ReflectionProbe(
  122055. /** defines the name of the probe */
  122056. name, size, scene, generateMipMaps, useFloat) {
  122057. if (generateMipMaps === void 0) { generateMipMaps = true; }
  122058. if (useFloat === void 0) { useFloat = false; }
  122059. var _this = this;
  122060. this.name = name;
  122061. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  122062. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  122063. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  122064. this._invertYAxis = false;
  122065. /** Gets or sets probe position (center of the cube map) */
  122066. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  122067. this._scene = scene;
  122068. // Create the scene field if not exist.
  122069. if (!this._scene.reflectionProbes) {
  122070. this._scene.reflectionProbes = new Array();
  122071. }
  122072. this._scene.reflectionProbes.push(this);
  122073. 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);
  122074. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  122075. switch (faceIndex) {
  122076. case 0:
  122077. _this._add.copyFromFloats(1, 0, 0);
  122078. break;
  122079. case 1:
  122080. _this._add.copyFromFloats(-1, 0, 0);
  122081. break;
  122082. case 2:
  122083. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  122084. break;
  122085. case 3:
  122086. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  122087. break;
  122088. case 4:
  122089. _this._add.copyFromFloats(0, 0, 1);
  122090. break;
  122091. case 5:
  122092. _this._add.copyFromFloats(0, 0, -1);
  122093. break;
  122094. }
  122095. if (_this._attachedMesh) {
  122096. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  122097. }
  122098. _this.position.addToRef(_this._add, _this._target);
  122099. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  122100. if (scene.activeCamera) {
  122101. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  122102. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  122103. }
  122104. scene._forcedViewPosition = _this.position;
  122105. });
  122106. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  122107. scene._forcedViewPosition = null;
  122108. scene.updateTransformMatrix(true);
  122109. });
  122110. }
  122111. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  122112. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  122113. get: function () {
  122114. return this._renderTargetTexture.samples;
  122115. },
  122116. set: function (value) {
  122117. this._renderTargetTexture.samples = value;
  122118. },
  122119. enumerable: true,
  122120. configurable: true
  122121. });
  122122. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  122123. /** Gets or sets the refresh rate to use (on every frame by default) */
  122124. get: function () {
  122125. return this._renderTargetTexture.refreshRate;
  122126. },
  122127. set: function (value) {
  122128. this._renderTargetTexture.refreshRate = value;
  122129. },
  122130. enumerable: true,
  122131. configurable: true
  122132. });
  122133. /**
  122134. * Gets the hosting scene
  122135. * @returns a Scene
  122136. */
  122137. ReflectionProbe.prototype.getScene = function () {
  122138. return this._scene;
  122139. };
  122140. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  122141. /** Gets the internal CubeTexture used to render to */
  122142. get: function () {
  122143. return this._renderTargetTexture;
  122144. },
  122145. enumerable: true,
  122146. configurable: true
  122147. });
  122148. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  122149. /** Gets the list of meshes to render */
  122150. get: function () {
  122151. return this._renderTargetTexture.renderList;
  122152. },
  122153. enumerable: true,
  122154. configurable: true
  122155. });
  122156. /**
  122157. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  122158. * @param mesh defines the mesh to attach to
  122159. */
  122160. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  122161. this._attachedMesh = mesh;
  122162. };
  122163. /**
  122164. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  122165. * @param renderingGroupId The rendering group id corresponding to its index
  122166. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  122167. */
  122168. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  122169. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  122170. };
  122171. /**
  122172. * Clean all associated resources
  122173. */
  122174. ReflectionProbe.prototype.dispose = function () {
  122175. var index = this._scene.reflectionProbes.indexOf(this);
  122176. if (index !== -1) {
  122177. // Remove from the scene if found
  122178. this._scene.reflectionProbes.splice(index, 1);
  122179. }
  122180. if (this._renderTargetTexture) {
  122181. this._renderTargetTexture.dispose();
  122182. this._renderTargetTexture = null;
  122183. }
  122184. };
  122185. /**
  122186. * Converts the reflection probe information to a readable string for debug purpose.
  122187. * @param fullDetails Supports for multiple levels of logging within scene loading
  122188. * @returns the human readable reflection probe info
  122189. */
  122190. ReflectionProbe.prototype.toString = function (fullDetails) {
  122191. var ret = "Name: " + this.name;
  122192. if (fullDetails) {
  122193. ret += ", position: " + this.position.toString();
  122194. if (this._attachedMesh) {
  122195. ret += ", attached mesh: " + this._attachedMesh.name;
  122196. }
  122197. }
  122198. return ret;
  122199. };
  122200. /**
  122201. * Get the class name of the relfection probe.
  122202. * @returns "ReflectionProbe"
  122203. */
  122204. ReflectionProbe.prototype.getClassName = function () {
  122205. return "ReflectionProbe";
  122206. };
  122207. /**
  122208. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  122209. * @returns The JSON representation of the texture
  122210. */
  122211. ReflectionProbe.prototype.serialize = function () {
  122212. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  122213. serializationObject.isReflectionProbe = true;
  122214. return serializationObject;
  122215. };
  122216. /**
  122217. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  122218. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  122219. * @param scene Define the scene the parsed reflection probe should be instantiated in
  122220. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  122221. * @returns The parsed reflection probe if successful
  122222. */
  122223. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  122224. var reflectionProbe = null;
  122225. if (scene.reflectionProbes) {
  122226. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  122227. var rp = scene.reflectionProbes[index];
  122228. if (rp.name === parsedReflectionProbe.name) {
  122229. reflectionProbe = rp;
  122230. break;
  122231. }
  122232. }
  122233. }
  122234. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  122235. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  122236. if (parsedReflectionProbe._attachedMesh) {
  122237. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  122238. }
  122239. return reflectionProbe;
  122240. };
  122241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  122243. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  122244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  122246. ], ReflectionProbe.prototype, "position", void 0);
  122247. return ReflectionProbe;
  122248. }());
  122249. /***/ }),
  122250. /***/ "./Rendering/boundingBoxRenderer.ts":
  122251. /*!******************************************!*\
  122252. !*** ./Rendering/boundingBoxRenderer.ts ***!
  122253. \******************************************/
  122254. /*! exports provided: BoundingBoxRenderer */
  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__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  122259. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  122260. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  122261. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  122262. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  122263. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122264. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  122265. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  122266. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  122267. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  122268. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  122269. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  122270. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  122271. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  122272. get: function () {
  122273. return this._forceShowBoundingBoxes || false;
  122274. },
  122275. set: function (value) {
  122276. this._forceShowBoundingBoxes = value;
  122277. // Lazyly creates a BB renderer if needed.
  122278. if (value) {
  122279. this.getBoundingBoxRenderer();
  122280. }
  122281. },
  122282. enumerable: true,
  122283. configurable: true
  122284. });
  122285. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  122286. if (!this._boundingBoxRenderer) {
  122287. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  122288. }
  122289. return this._boundingBoxRenderer;
  122290. };
  122291. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  122292. get: function () {
  122293. return this._showBoundingBox || false;
  122294. },
  122295. set: function (value) {
  122296. this._showBoundingBox = value;
  122297. // Lazyly creates a BB renderer if needed.
  122298. if (value) {
  122299. this.getScene().getBoundingBoxRenderer();
  122300. }
  122301. },
  122302. enumerable: true,
  122303. configurable: true
  122304. });
  122305. /**
  122306. * Component responsible of rendering the bounding box of the meshes in a scene.
  122307. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  122308. */
  122309. var BoundingBoxRenderer = /** @class */ (function () {
  122310. /**
  122311. * Instantiates a new bounding box renderer in a scene.
  122312. * @param scene the scene the renderer renders in
  122313. */
  122314. function BoundingBoxRenderer(scene) {
  122315. /**
  122316. * The component name helpfull to identify the component in the list of scene components.
  122317. */
  122318. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  122319. /**
  122320. * Color of the bounding box lines placed in front of an object
  122321. */
  122322. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  122323. /**
  122324. * Color of the bounding box lines placed behind an object
  122325. */
  122326. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  122327. /**
  122328. * Defines if the renderer should show the back lines or not
  122329. */
  122330. this.showBackLines = true;
  122331. /**
  122332. * @hidden
  122333. */
  122334. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  122335. this._vertexBuffers = {};
  122336. this.scene = scene;
  122337. scene._addComponent(this);
  122338. }
  122339. /**
  122340. * Registers the component in a given scene
  122341. */
  122342. BoundingBoxRenderer.prototype.register = function () {
  122343. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  122344. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  122345. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  122346. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  122347. };
  122348. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  122349. if (mesh.showSubMeshesBoundingBox) {
  122350. var boundingInfo = subMesh.getBoundingInfo();
  122351. if (boundingInfo !== null && boundingInfo !== undefined) {
  122352. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  122353. this.renderList.push(boundingInfo.boundingBox);
  122354. }
  122355. }
  122356. };
  122357. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  122358. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  122359. var boundingInfo = sourceMesh.getBoundingInfo();
  122360. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  122361. this.renderList.push(boundingInfo.boundingBox);
  122362. }
  122363. };
  122364. BoundingBoxRenderer.prototype._prepareRessources = function () {
  122365. if (this._colorShader) {
  122366. return;
  122367. }
  122368. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  122369. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  122370. uniforms: ["world", "viewProjection", "color"]
  122371. });
  122372. var engine = this.scene.getEngine();
  122373. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  122374. 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);
  122375. this._createIndexBuffer();
  122376. };
  122377. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  122378. var engine = this.scene.getEngine();
  122379. 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]);
  122380. };
  122381. /**
  122382. * Rebuilds the elements related to this component in case of
  122383. * context lost for instance.
  122384. */
  122385. BoundingBoxRenderer.prototype.rebuild = function () {
  122386. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  122387. if (vb) {
  122388. vb._rebuild();
  122389. }
  122390. this._createIndexBuffer();
  122391. };
  122392. /**
  122393. * @hidden
  122394. */
  122395. BoundingBoxRenderer.prototype.reset = function () {
  122396. this.renderList.reset();
  122397. };
  122398. /**
  122399. * Render the bounding boxes of a specific rendering group
  122400. * @param renderingGroupId defines the rendering group to render
  122401. */
  122402. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  122403. if (this.renderList.length === 0) {
  122404. return;
  122405. }
  122406. this._prepareRessources();
  122407. if (!this._colorShader.isReady()) {
  122408. return;
  122409. }
  122410. var engine = this.scene.getEngine();
  122411. engine.setDepthWrite(false);
  122412. this._colorShader._preBind();
  122413. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  122414. var boundingBox = this.renderList.data[boundingBoxIndex];
  122415. if (boundingBox._tag !== renderingGroupId) {
  122416. continue;
  122417. }
  122418. var min = boundingBox.minimum;
  122419. var max = boundingBox.maximum;
  122420. var diff = max.subtract(min);
  122421. var median = min.add(diff.scale(0.5));
  122422. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  122423. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  122424. .multiply(boundingBox.getWorldMatrix());
  122425. // VBOs
  122426. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  122427. if (this.showBackLines) {
  122428. // Back
  122429. engine.setDepthFunctionToGreaterOrEqual();
  122430. this.scene.resetCachedMaterial();
  122431. this._colorShader.setColor4("color", this.backColor.toColor4());
  122432. this._colorShader.bind(worldMatrix);
  122433. // Draw order
  122434. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  122435. }
  122436. // Front
  122437. engine.setDepthFunctionToLess();
  122438. this.scene.resetCachedMaterial();
  122439. this._colorShader.setColor4("color", this.frontColor.toColor4());
  122440. this._colorShader.bind(worldMatrix);
  122441. // Draw order
  122442. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  122443. }
  122444. this._colorShader.unbind();
  122445. engine.setDepthFunctionToLessOrEqual();
  122446. engine.setDepthWrite(true);
  122447. };
  122448. /**
  122449. * In case of occlusion queries, we can render the occlusion bounding box through this method
  122450. * @param mesh Define the mesh to render the occlusion bounding box for
  122451. */
  122452. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  122453. this._prepareRessources();
  122454. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  122455. return;
  122456. }
  122457. var engine = this.scene.getEngine();
  122458. engine.setDepthWrite(false);
  122459. engine.setColorWrite(false);
  122460. this._colorShader._preBind();
  122461. var boundingBox = mesh._boundingInfo.boundingBox;
  122462. var min = boundingBox.minimum;
  122463. var max = boundingBox.maximum;
  122464. var diff = max.subtract(min);
  122465. var median = min.add(diff.scale(0.5));
  122466. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  122467. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  122468. .multiply(boundingBox.getWorldMatrix());
  122469. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  122470. engine.setDepthFunctionToLess();
  122471. this.scene.resetCachedMaterial();
  122472. this._colorShader.bind(worldMatrix);
  122473. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  122474. this._colorShader.unbind();
  122475. engine.setDepthFunctionToLessOrEqual();
  122476. engine.setDepthWrite(true);
  122477. engine.setColorWrite(true);
  122478. };
  122479. /**
  122480. * Dispose and release the resources attached to this renderer.
  122481. */
  122482. BoundingBoxRenderer.prototype.dispose = function () {
  122483. if (!this._colorShader) {
  122484. return;
  122485. }
  122486. this.renderList.dispose();
  122487. this._colorShader.dispose();
  122488. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  122489. if (buffer) {
  122490. buffer.dispose();
  122491. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  122492. }
  122493. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  122494. };
  122495. return BoundingBoxRenderer;
  122496. }());
  122497. /***/ }),
  122498. /***/ "./Rendering/depthRenderer.ts":
  122499. /*!************************************!*\
  122500. !*** ./Rendering/depthRenderer.ts ***!
  122501. \************************************/
  122502. /*! exports provided: DepthRenderer */
  122503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122504. "use strict";
  122505. __webpack_require__.r(__webpack_exports__);
  122506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  122507. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122508. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  122509. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122510. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  122511. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  122512. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122513. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  122514. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  122515. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  122516. /**
  122517. * This represents a depth renderer in Babylon.
  122518. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  122519. */
  122520. var DepthRenderer = /** @class */ (function () {
  122521. /**
  122522. * Instantiates a depth renderer
  122523. * @param scene The scene the renderer belongs to
  122524. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  122525. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  122526. */
  122527. function DepthRenderer(scene, type, camera) {
  122528. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  122529. if (camera === void 0) { camera = null; }
  122530. var _this = this;
  122531. /**
  122532. * Specifiess that the depth renderer will only be used within
  122533. * the camera it is created for.
  122534. * This can help forcing its rendering during the camera processing.
  122535. */
  122536. this.useOnlyInActiveCamera = false;
  122537. this._scene = scene;
  122538. DepthRenderer._SceneComponentInitialization(this._scene);
  122539. this._camera = camera;
  122540. var engine = scene.getEngine();
  122541. // Render target
  122542. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  122543. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  122544. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  122545. this._depthMap.refreshRate = 1;
  122546. this._depthMap.renderParticles = false;
  122547. this._depthMap.renderList = null;
  122548. // Camera to get depth map from to support multiple concurrent cameras
  122549. this._depthMap.activeCamera = this._camera;
  122550. this._depthMap.ignoreCameraViewport = true;
  122551. this._depthMap.useCameraPostProcesses = false;
  122552. // set default depth value to 1.0 (far away)
  122553. this._depthMap.onClearObservable.add(function (engine) {
  122554. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  122555. });
  122556. // Custom render function
  122557. var renderSubMesh = function (subMesh) {
  122558. var mesh = subMesh.getRenderingMesh();
  122559. var scene = _this._scene;
  122560. var engine = scene.getEngine();
  122561. var material = subMesh.getMaterial();
  122562. if (!material) {
  122563. return;
  122564. }
  122565. // Culling and reverse (right handed system)
  122566. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  122567. // Managing instances
  122568. var batch = mesh._getInstancesRenderList(subMesh._id);
  122569. if (batch.mustReturn) {
  122570. return;
  122571. }
  122572. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  122573. var camera = _this._camera || scene.activeCamera;
  122574. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  122575. engine.enableEffect(_this._effect);
  122576. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  122577. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  122578. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  122579. // Alpha test
  122580. if (material && material.needAlphaTesting()) {
  122581. var alphaTexture = material.getAlphaTestTexture();
  122582. if (alphaTexture) {
  122583. _this._effect.setTexture("diffuseSampler", alphaTexture);
  122584. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  122585. }
  122586. }
  122587. // Bones
  122588. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  122589. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  122590. }
  122591. // Draw
  122592. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  122593. }
  122594. };
  122595. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  122596. var index;
  122597. if (depthOnlySubMeshes.length) {
  122598. engine.setColorWrite(false);
  122599. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  122600. renderSubMesh(depthOnlySubMeshes.data[index]);
  122601. }
  122602. engine.setColorWrite(true);
  122603. }
  122604. for (index = 0; index < opaqueSubMeshes.length; index++) {
  122605. renderSubMesh(opaqueSubMeshes.data[index]);
  122606. }
  122607. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  122608. renderSubMesh(alphaTestSubMeshes.data[index]);
  122609. }
  122610. };
  122611. }
  122612. /**
  122613. * Creates the depth rendering effect and checks if the effect is ready.
  122614. * @param subMesh The submesh to be used to render the depth map of
  122615. * @param useInstances If multiple world instances should be used
  122616. * @returns if the depth renderer is ready to render the depth map
  122617. */
  122618. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  122619. var material = subMesh.getMaterial();
  122620. if (material.disableDepthWrite) {
  122621. return false;
  122622. }
  122623. var defines = [];
  122624. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  122625. var mesh = subMesh.getMesh();
  122626. // Alpha test
  122627. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  122628. defines.push("#define ALPHATEST");
  122629. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  122630. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  122631. defines.push("#define UV1");
  122632. }
  122633. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  122634. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  122635. defines.push("#define UV2");
  122636. }
  122637. }
  122638. // Bones
  122639. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  122640. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  122641. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  122642. if (mesh.numBoneInfluencers > 4) {
  122643. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  122644. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  122645. }
  122646. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  122647. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  122648. }
  122649. else {
  122650. defines.push("#define NUM_BONE_INFLUENCERS 0");
  122651. }
  122652. // Instances
  122653. if (useInstances) {
  122654. defines.push("#define INSTANCES");
  122655. attribs.push("world0");
  122656. attribs.push("world1");
  122657. attribs.push("world2");
  122658. attribs.push("world3");
  122659. }
  122660. // Get correct effect
  122661. var join = defines.join("\n");
  122662. if (this._cachedDefines !== join) {
  122663. this._cachedDefines = join;
  122664. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  122665. }
  122666. return this._effect.isReady();
  122667. };
  122668. /**
  122669. * Gets the texture which the depth map will be written to.
  122670. * @returns The depth map texture
  122671. */
  122672. DepthRenderer.prototype.getDepthMap = function () {
  122673. return this._depthMap;
  122674. };
  122675. /**
  122676. * Disposes of the depth renderer.
  122677. */
  122678. DepthRenderer.prototype.dispose = function () {
  122679. this._depthMap.dispose();
  122680. };
  122681. /** @hidden */
  122682. DepthRenderer._SceneComponentInitialization = function (_) {
  122683. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  122684. };
  122685. return DepthRenderer;
  122686. }());
  122687. /***/ }),
  122688. /***/ "./Rendering/depthRendererSceneComponent.ts":
  122689. /*!**************************************************!*\
  122690. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  122691. \**************************************************/
  122692. /*! exports provided: DepthRendererSceneComponent */
  122693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122694. "use strict";
  122695. __webpack_require__.r(__webpack_exports__);
  122696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  122697. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  122698. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  122699. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122700. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  122701. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  122702. camera = camera || this.activeCamera;
  122703. if (!camera) {
  122704. throw "No camera available to enable depth renderer";
  122705. }
  122706. if (!this._depthRenderer) {
  122707. this._depthRenderer = {};
  122708. }
  122709. if (!this._depthRenderer[camera.id]) {
  122710. var textureType = 0;
  122711. if (this.getEngine().getCaps().textureHalfFloatRender) {
  122712. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  122713. }
  122714. else if (this.getEngine().getCaps().textureFloatRender) {
  122715. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  122716. }
  122717. else {
  122718. throw "Depth renderer does not support int texture type";
  122719. }
  122720. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  122721. }
  122722. return this._depthRenderer[camera.id];
  122723. };
  122724. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  122725. camera = camera || this.activeCamera;
  122726. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  122727. return;
  122728. }
  122729. this._depthRenderer[camera.id].dispose();
  122730. delete this._depthRenderer[camera.id];
  122731. };
  122732. /**
  122733. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  122734. * in several rendering techniques.
  122735. */
  122736. var DepthRendererSceneComponent = /** @class */ (function () {
  122737. /**
  122738. * Creates a new instance of the component for the given scene
  122739. * @param scene Defines the scene to register the component in
  122740. */
  122741. function DepthRendererSceneComponent(scene) {
  122742. /**
  122743. * The component name helpfull to identify the component in the list of scene components.
  122744. */
  122745. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  122746. this.scene = scene;
  122747. }
  122748. /**
  122749. * Registers the component in a given scene
  122750. */
  122751. DepthRendererSceneComponent.prototype.register = function () {
  122752. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  122753. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  122754. };
  122755. /**
  122756. * Rebuilds the elements related to this component in case of
  122757. * context lost for instance.
  122758. */
  122759. DepthRendererSceneComponent.prototype.rebuild = function () {
  122760. // Nothing to do for this component
  122761. };
  122762. /**
  122763. * Disposes the component and the associated ressources
  122764. */
  122765. DepthRendererSceneComponent.prototype.dispose = function () {
  122766. for (var key in this.scene._depthRenderer) {
  122767. this.scene._depthRenderer[key].dispose();
  122768. }
  122769. };
  122770. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  122771. if (this.scene._depthRenderer) {
  122772. for (var key in this.scene._depthRenderer) {
  122773. var depthRenderer = this.scene._depthRenderer[key];
  122774. if (!depthRenderer.useOnlyInActiveCamera) {
  122775. renderTargets.push(depthRenderer.getDepthMap());
  122776. }
  122777. }
  122778. }
  122779. };
  122780. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  122781. if (this.scene._depthRenderer) {
  122782. for (var key in this.scene._depthRenderer) {
  122783. var depthRenderer = this.scene._depthRenderer[key];
  122784. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  122785. renderTargets.push(depthRenderer.getDepthMap());
  122786. }
  122787. }
  122788. }
  122789. };
  122790. return DepthRendererSceneComponent;
  122791. }());
  122792. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  122793. // Register the G Buffer component to the scene.
  122794. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  122795. if (!component) {
  122796. component = new DepthRendererSceneComponent(scene);
  122797. scene._addComponent(component);
  122798. }
  122799. };
  122800. /***/ }),
  122801. /***/ "./Rendering/edgesRenderer.ts":
  122802. /*!************************************!*\
  122803. !*** ./Rendering/edgesRenderer.ts ***!
  122804. \************************************/
  122805. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  122806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122807. "use strict";
  122808. __webpack_require__.r(__webpack_exports__);
  122809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  122810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  122811. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122812. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  122813. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  122814. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  122815. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122816. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  122817. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  122818. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  122819. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122820. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  122821. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  122822. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  122823. if (this._edgesRenderer) {
  122824. this._edgesRenderer.dispose();
  122825. this._edgesRenderer = null;
  122826. }
  122827. return this;
  122828. };
  122829. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  122830. if (epsilon === void 0) { epsilon = 0.95; }
  122831. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  122832. this.disableEdgesRendering();
  122833. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  122834. return this;
  122835. };
  122836. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  122837. get: function () {
  122838. return this._edgesRenderer;
  122839. },
  122840. enumerable: true,
  122841. configurable: true
  122842. });
  122843. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  122844. if (epsilon === void 0) { epsilon = 0.95; }
  122845. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  122846. this.disableEdgesRendering();
  122847. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  122848. return this;
  122849. };
  122850. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  122851. if (epsilon === void 0) { epsilon = 0.95; }
  122852. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  122853. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  122854. return this;
  122855. };
  122856. /**
  122857. * FaceAdjacencies Helper class to generate edges
  122858. */
  122859. var FaceAdjacencies = /** @class */ (function () {
  122860. function FaceAdjacencies() {
  122861. this.edges = new Array();
  122862. this.edgesConnectedCount = 0;
  122863. }
  122864. return FaceAdjacencies;
  122865. }());
  122866. /**
  122867. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  122868. */
  122869. var EdgesRenderer = /** @class */ (function () {
  122870. /**
  122871. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  122872. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  122873. * @param source Mesh used to create edges
  122874. * @param epsilon sum of angles in adjacency to check for edge
  122875. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  122876. * @param generateEdgesLines - should generate Lines or only prepare resources.
  122877. */
  122878. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  122879. if (epsilon === void 0) { epsilon = 0.95; }
  122880. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  122881. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  122882. var _this = this;
  122883. /**
  122884. * Define the size of the edges with an orthographic camera
  122885. */
  122886. this.edgesWidthScalerForOrthographic = 1000.0;
  122887. /**
  122888. * Define the size of the edges with a perspective camera
  122889. */
  122890. this.edgesWidthScalerForPerspective = 50.0;
  122891. this._linesPositions = new Array();
  122892. this._linesNormals = new Array();
  122893. this._linesIndices = new Array();
  122894. this._buffers = {};
  122895. this._checkVerticesInsteadOfIndices = false;
  122896. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  122897. this.isEnabled = true;
  122898. this._source = source;
  122899. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  122900. this._epsilon = epsilon;
  122901. this._prepareRessources();
  122902. if (generateEdgesLines) {
  122903. this._generateEdgesLines();
  122904. }
  122905. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  122906. _this._rebuild();
  122907. });
  122908. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  122909. _this.dispose();
  122910. });
  122911. }
  122912. EdgesRenderer.prototype._prepareRessources = function () {
  122913. if (this._lineShader) {
  122914. return;
  122915. }
  122916. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  122917. attributes: ["position", "normal"],
  122918. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  122919. });
  122920. this._lineShader.disableDepthWrite = true;
  122921. this._lineShader.backFaceCulling = false;
  122922. };
  122923. /** @hidden */
  122924. EdgesRenderer.prototype._rebuild = function () {
  122925. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  122926. if (buffer) {
  122927. buffer._rebuild();
  122928. }
  122929. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  122930. if (buffer) {
  122931. buffer._rebuild();
  122932. }
  122933. var scene = this._source.getScene();
  122934. var engine = scene.getEngine();
  122935. this._ib = engine.createIndexBuffer(this._linesIndices);
  122936. };
  122937. /**
  122938. * Releases the required resources for the edges renderer
  122939. */
  122940. EdgesRenderer.prototype.dispose = function () {
  122941. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  122942. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  122943. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  122944. if (buffer) {
  122945. buffer.dispose();
  122946. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  122947. }
  122948. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  122949. if (buffer) {
  122950. buffer.dispose();
  122951. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  122952. }
  122953. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  122954. this._lineShader.dispose();
  122955. };
  122956. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  122957. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  122958. return 0;
  122959. }
  122960. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  122961. return 1;
  122962. }
  122963. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  122964. return 2;
  122965. }
  122966. return -1;
  122967. };
  122968. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  122969. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  122970. return 0;
  122971. }
  122972. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  122973. return 1;
  122974. }
  122975. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  122976. return 2;
  122977. }
  122978. return -1;
  122979. };
  122980. /**
  122981. * Checks if the pair of p0 and p1 is en edge
  122982. * @param faceIndex
  122983. * @param edge
  122984. * @param faceNormals
  122985. * @param p0
  122986. * @param p1
  122987. * @private
  122988. */
  122989. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  122990. var needToCreateLine;
  122991. if (edge === undefined) {
  122992. needToCreateLine = true;
  122993. }
  122994. else {
  122995. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  122996. needToCreateLine = dotProduct < this._epsilon;
  122997. }
  122998. if (needToCreateLine) {
  122999. this.createLine(p0, p1, this._linesPositions.length / 3);
  123000. }
  123001. };
  123002. /**
  123003. * push line into the position, normal and index buffer
  123004. * @protected
  123005. */
  123006. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  123007. // Positions
  123008. 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);
  123009. // Normals
  123010. 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);
  123011. // Indices
  123012. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  123013. };
  123014. /**
  123015. * Generates lines edges from adjacencjes
  123016. * @private
  123017. */
  123018. EdgesRenderer.prototype._generateEdgesLines = function () {
  123019. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  123020. var indices = this._source.getIndices();
  123021. if (!indices || !positions) {
  123022. return;
  123023. }
  123024. // First let's find adjacencies
  123025. var adjacencies = new Array();
  123026. var faceNormals = new Array();
  123027. var index;
  123028. var faceAdjacencies;
  123029. // Prepare faces
  123030. for (index = 0; index < indices.length; index += 3) {
  123031. faceAdjacencies = new FaceAdjacencies();
  123032. var p0Index = indices[index];
  123033. var p1Index = indices[index + 1];
  123034. var p2Index = indices[index + 2];
  123035. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  123036. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  123037. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  123038. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  123039. faceNormal.normalize();
  123040. faceNormals.push(faceNormal);
  123041. adjacencies.push(faceAdjacencies);
  123042. }
  123043. // Scan
  123044. for (index = 0; index < adjacencies.length; index++) {
  123045. faceAdjacencies = adjacencies[index];
  123046. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  123047. var otherFaceAdjacencies = adjacencies[otherIndex];
  123048. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  123049. break;
  123050. }
  123051. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  123052. continue;
  123053. }
  123054. var otherP0 = indices[otherIndex * 3];
  123055. var otherP1 = indices[otherIndex * 3 + 1];
  123056. var otherP2 = indices[otherIndex * 3 + 2];
  123057. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  123058. var otherEdgeIndex = 0;
  123059. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  123060. continue;
  123061. }
  123062. switch (edgeIndex) {
  123063. case 0:
  123064. if (this._checkVerticesInsteadOfIndices) {
  123065. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  123066. }
  123067. else {
  123068. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  123069. }
  123070. break;
  123071. case 1:
  123072. if (this._checkVerticesInsteadOfIndices) {
  123073. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  123074. }
  123075. else {
  123076. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  123077. }
  123078. break;
  123079. case 2:
  123080. if (this._checkVerticesInsteadOfIndices) {
  123081. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  123082. }
  123083. else {
  123084. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  123085. }
  123086. break;
  123087. }
  123088. if (otherEdgeIndex === -1) {
  123089. continue;
  123090. }
  123091. faceAdjacencies.edges[edgeIndex] = otherIndex;
  123092. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  123093. faceAdjacencies.edgesConnectedCount++;
  123094. otherFaceAdjacencies.edgesConnectedCount++;
  123095. if (faceAdjacencies.edgesConnectedCount === 3) {
  123096. break;
  123097. }
  123098. }
  123099. }
  123100. }
  123101. // Create lines
  123102. for (index = 0; index < adjacencies.length; index++) {
  123103. // 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
  123104. var current = adjacencies[index];
  123105. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  123106. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  123107. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  123108. }
  123109. // Merge into a single mesh
  123110. var engine = this._source.getScene().getEngine();
  123111. 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);
  123112. 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);
  123113. this._ib = engine.createIndexBuffer(this._linesIndices);
  123114. this._indicesCount = this._linesIndices.length;
  123115. };
  123116. /**
  123117. * Checks wether or not the edges renderer is ready to render.
  123118. * @return true if ready, otherwise false.
  123119. */
  123120. EdgesRenderer.prototype.isReady = function () {
  123121. return this._lineShader.isReady();
  123122. };
  123123. /**
  123124. * Renders the edges of the attached mesh,
  123125. */
  123126. EdgesRenderer.prototype.render = function () {
  123127. var scene = this._source.getScene();
  123128. if (!this.isReady() || !scene.activeCamera) {
  123129. return;
  123130. }
  123131. var engine = scene.getEngine();
  123132. this._lineShader._preBind();
  123133. if (this._source.edgesColor.a !== 1) {
  123134. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  123135. }
  123136. else {
  123137. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  123138. }
  123139. // VBOs
  123140. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  123141. scene.resetCachedMaterial();
  123142. this._lineShader.setColor4("color", this._source.edgesColor);
  123143. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  123144. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  123145. }
  123146. else {
  123147. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  123148. }
  123149. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  123150. this._lineShader.bind(this._source.getWorldMatrix());
  123151. // Draw order
  123152. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  123153. this._lineShader.unbind();
  123154. };
  123155. return EdgesRenderer;
  123156. }());
  123157. /**
  123158. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  123159. */
  123160. var LineEdgesRenderer = /** @class */ (function (_super) {
  123161. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  123162. /**
  123163. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  123164. * @param source LineMesh used to generate edges
  123165. * @param epsilon not important (specified angle for edge detection)
  123166. * @param checkVerticesInsteadOfIndices not important for LineMesh
  123167. */
  123168. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  123169. if (epsilon === void 0) { epsilon = 0.95; }
  123170. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  123171. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  123172. _this._generateEdgesLines();
  123173. return _this;
  123174. }
  123175. /**
  123176. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  123177. */
  123178. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  123179. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  123180. var indices = this._source.getIndices();
  123181. if (!indices || !positions) {
  123182. return;
  123183. }
  123184. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  123185. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  123186. var len = indices.length - 1;
  123187. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  123188. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  123189. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  123190. this.createLine(p0, p1, offset);
  123191. }
  123192. // Merge into a single mesh
  123193. var engine = this._source.getScene().getEngine();
  123194. 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);
  123195. 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);
  123196. this._ib = engine.createIndexBuffer(this._linesIndices);
  123197. this._indicesCount = this._linesIndices.length;
  123198. };
  123199. return LineEdgesRenderer;
  123200. }(EdgesRenderer));
  123201. /***/ }),
  123202. /***/ "./Rendering/geometryBufferRenderer.ts":
  123203. /*!*********************************************!*\
  123204. !*** ./Rendering/geometryBufferRenderer.ts ***!
  123205. \*********************************************/
  123206. /*! exports provided: GeometryBufferRenderer */
  123207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123208. "use strict";
  123209. __webpack_require__.r(__webpack_exports__);
  123210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  123211. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123212. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  123213. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123214. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123215. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  123216. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  123217. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  123218. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  123219. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  123220. /**
  123221. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  123222. */
  123223. var GeometryBufferRenderer = /** @class */ (function () {
  123224. /**
  123225. * Creates a new G Buffer for the scene
  123226. * @param scene The scene the buffer belongs to
  123227. * @param ratio How big is the buffer related to the main canvas.
  123228. */
  123229. function GeometryBufferRenderer(scene, ratio) {
  123230. if (ratio === void 0) { ratio = 1; }
  123231. /**
  123232. * Dictionary used to store the previous transformation matrices of each rendered mesh
  123233. * in order to compute objects velocities when enableVelocity is set to "true"
  123234. * @hidden
  123235. */
  123236. this._previousTransformationMatrices = {};
  123237. this._enablePosition = false;
  123238. this._enableVelocity = false;
  123239. this._positionIndex = -1;
  123240. this._velocityIndex = -1;
  123241. this._scene = scene;
  123242. this._ratio = ratio;
  123243. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  123244. // Render target
  123245. this._createRenderTargets();
  123246. }
  123247. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  123248. /**
  123249. * Set the render list (meshes to be rendered) used in the G buffer.
  123250. */
  123251. set: function (meshes) {
  123252. this._multiRenderTarget.renderList = meshes;
  123253. },
  123254. enumerable: true,
  123255. configurable: true
  123256. });
  123257. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  123258. /**
  123259. * Gets wether or not G buffer are supported by the running hardware.
  123260. * This requires draw buffer supports
  123261. */
  123262. get: function () {
  123263. return this._multiRenderTarget.isSupported;
  123264. },
  123265. enumerable: true,
  123266. configurable: true
  123267. });
  123268. /**
  123269. * Returns the index of the given texture type in the G-Buffer textures array
  123270. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  123271. * @returns the index of the given texture type in the G-Buffer textures array
  123272. */
  123273. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  123274. switch (textureType) {
  123275. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  123276. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  123277. default: return -1;
  123278. }
  123279. };
  123280. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  123281. /**
  123282. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  123283. */
  123284. get: function () {
  123285. return this._enablePosition;
  123286. },
  123287. /**
  123288. * Sets whether or not objects positions are enabled for the G buffer.
  123289. */
  123290. set: function (enable) {
  123291. this._enablePosition = enable;
  123292. this.dispose();
  123293. this._createRenderTargets();
  123294. },
  123295. enumerable: true,
  123296. configurable: true
  123297. });
  123298. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  123299. /**
  123300. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  123301. */
  123302. get: function () {
  123303. return this._enableVelocity;
  123304. },
  123305. /**
  123306. * Sets wether or not objects velocities are enabled for the G buffer.
  123307. */
  123308. set: function (enable) {
  123309. this._enableVelocity = enable;
  123310. this.dispose();
  123311. this._createRenderTargets();
  123312. },
  123313. enumerable: true,
  123314. configurable: true
  123315. });
  123316. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  123317. /**
  123318. * Gets the scene associated with the buffer.
  123319. */
  123320. get: function () {
  123321. return this._scene;
  123322. },
  123323. enumerable: true,
  123324. configurable: true
  123325. });
  123326. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  123327. /**
  123328. * Gets the ratio used by the buffer during its creation.
  123329. * How big is the buffer related to the main canvas.
  123330. */
  123331. get: function () {
  123332. return this._ratio;
  123333. },
  123334. enumerable: true,
  123335. configurable: true
  123336. });
  123337. /**
  123338. * Checks wether everything is ready to render a submesh to the G buffer.
  123339. * @param subMesh the submesh to check readiness for
  123340. * @param useInstances is the mesh drawn using instance or not
  123341. * @returns true if ready otherwise false
  123342. */
  123343. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  123344. var material = subMesh.getMaterial();
  123345. if (material && material.disableDepthWrite) {
  123346. return false;
  123347. }
  123348. var defines = [];
  123349. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  123350. var mesh = subMesh.getMesh();
  123351. // Alpha test
  123352. if (material && material.needAlphaTesting()) {
  123353. defines.push("#define ALPHATEST");
  123354. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  123355. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  123356. defines.push("#define UV1");
  123357. }
  123358. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  123359. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  123360. defines.push("#define UV2");
  123361. }
  123362. }
  123363. // Buffers
  123364. if (this._enablePosition) {
  123365. defines.push("#define POSITION");
  123366. defines.push("#define POSITION_INDEX " + this._positionIndex);
  123367. }
  123368. if (this._enableVelocity) {
  123369. defines.push("#define VELOCITY");
  123370. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  123371. }
  123372. // Bones
  123373. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  123374. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  123375. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  123376. if (mesh.numBoneInfluencers > 4) {
  123377. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  123378. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  123379. }
  123380. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  123381. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  123382. }
  123383. else {
  123384. defines.push("#define NUM_BONE_INFLUENCERS 0");
  123385. }
  123386. // Instances
  123387. if (useInstances) {
  123388. defines.push("#define INSTANCES");
  123389. attribs.push("world0");
  123390. attribs.push("world1");
  123391. attribs.push("world2");
  123392. attribs.push("world3");
  123393. }
  123394. // Setup textures count
  123395. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  123396. // Get correct effect
  123397. var join = defines.join("\n");
  123398. if (this._cachedDefines !== join) {
  123399. this._cachedDefines = join;
  123400. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  123401. }
  123402. return this._effect.isReady();
  123403. };
  123404. /**
  123405. * Gets the current underlying G Buffer.
  123406. * @returns the buffer
  123407. */
  123408. GeometryBufferRenderer.prototype.getGBuffer = function () {
  123409. return this._multiRenderTarget;
  123410. };
  123411. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  123412. /**
  123413. * Gets the number of samples used to render the buffer (anti aliasing).
  123414. */
  123415. get: function () {
  123416. return this._multiRenderTarget.samples;
  123417. },
  123418. /**
  123419. * Sets the number of samples used to render the buffer (anti aliasing).
  123420. */
  123421. set: function (value) {
  123422. this._multiRenderTarget.samples = value;
  123423. },
  123424. enumerable: true,
  123425. configurable: true
  123426. });
  123427. /**
  123428. * Disposes the renderer and frees up associated resources.
  123429. */
  123430. GeometryBufferRenderer.prototype.dispose = function () {
  123431. this.getGBuffer().dispose();
  123432. };
  123433. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  123434. var _this = this;
  123435. var engine = this._scene.getEngine();
  123436. var count = 2;
  123437. if (this._enablePosition) {
  123438. this._positionIndex = count;
  123439. count++;
  123440. }
  123441. if (this._enableVelocity) {
  123442. this._velocityIndex = count;
  123443. count++;
  123444. }
  123445. 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 });
  123446. if (!this.isSupported) {
  123447. return;
  123448. }
  123449. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  123450. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  123451. this._multiRenderTarget.refreshRate = 1;
  123452. this._multiRenderTarget.renderParticles = false;
  123453. this._multiRenderTarget.renderList = null;
  123454. // set default depth value to 1.0 (far away)
  123455. this._multiRenderTarget.onClearObservable.add(function (engine) {
  123456. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  123457. });
  123458. // Custom render function
  123459. var renderSubMesh = function (subMesh) {
  123460. var mesh = subMesh.getRenderingMesh();
  123461. var scene = _this._scene;
  123462. var engine = scene.getEngine();
  123463. var material = subMesh.getMaterial();
  123464. if (!material) {
  123465. return;
  123466. }
  123467. // Velocity
  123468. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  123469. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  123470. }
  123471. // Culling
  123472. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  123473. // Managing instances
  123474. var batch = mesh._getInstancesRenderList(subMesh._id);
  123475. if (batch.mustReturn) {
  123476. return;
  123477. }
  123478. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  123479. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  123480. engine.enableEffect(_this._effect);
  123481. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  123482. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  123483. _this._effect.setMatrix("view", scene.getViewMatrix());
  123484. // Alpha test
  123485. if (material && material.needAlphaTesting()) {
  123486. var alphaTexture = material.getAlphaTestTexture();
  123487. if (alphaTexture) {
  123488. _this._effect.setTexture("diffuseSampler", alphaTexture);
  123489. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  123490. }
  123491. }
  123492. // Bones
  123493. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  123494. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  123495. }
  123496. // Velocity
  123497. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  123498. // Draw
  123499. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  123500. }
  123501. // Velocity
  123502. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  123503. };
  123504. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  123505. var index;
  123506. if (depthOnlySubMeshes.length) {
  123507. engine.setColorWrite(false);
  123508. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  123509. renderSubMesh(depthOnlySubMeshes.data[index]);
  123510. }
  123511. engine.setColorWrite(true);
  123512. }
  123513. for (index = 0; index < opaqueSubMeshes.length; index++) {
  123514. renderSubMesh(opaqueSubMeshes.data[index]);
  123515. }
  123516. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  123517. renderSubMesh(alphaTestSubMeshes.data[index]);
  123518. }
  123519. };
  123520. };
  123521. /**
  123522. * Constant used to retrieve the position texture index in the G-Buffer textures array
  123523. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  123524. */
  123525. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  123526. /**
  123527. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  123528. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  123529. */
  123530. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  123531. /** @hidden */
  123532. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  123533. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  123534. };
  123535. return GeometryBufferRenderer;
  123536. }());
  123537. /***/ }),
  123538. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  123539. /*!***********************************************************!*\
  123540. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  123541. \***********************************************************/
  123542. /*! exports provided: GeometryBufferRendererSceneComponent */
  123543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123544. "use strict";
  123545. __webpack_require__.r(__webpack_exports__);
  123546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  123547. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  123548. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  123549. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  123550. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  123551. get: function () {
  123552. this._geometryBufferRenderer;
  123553. },
  123554. set: function (value) {
  123555. if (value && value.isSupported) {
  123556. this._geometryBufferRenderer = value;
  123557. }
  123558. },
  123559. enumerable: true,
  123560. configurable: true
  123561. });
  123562. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  123563. if (ratio === void 0) { ratio = 1; }
  123564. if (this._geometryBufferRenderer) {
  123565. return this._geometryBufferRenderer;
  123566. }
  123567. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  123568. if (!this._geometryBufferRenderer.isSupported) {
  123569. this._geometryBufferRenderer = null;
  123570. }
  123571. return this._geometryBufferRenderer;
  123572. };
  123573. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  123574. if (!this._geometryBufferRenderer) {
  123575. return;
  123576. }
  123577. this._geometryBufferRenderer.dispose();
  123578. this._geometryBufferRenderer = null;
  123579. };
  123580. /**
  123581. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  123582. * in several rendering techniques.
  123583. */
  123584. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  123585. /**
  123586. * Creates a new instance of the component for the given scene
  123587. * @param scene Defines the scene to register the component in
  123588. */
  123589. function GeometryBufferRendererSceneComponent(scene) {
  123590. /**
  123591. * The component name helpful to identify the component in the list of scene components.
  123592. */
  123593. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  123594. this.scene = scene;
  123595. }
  123596. /**
  123597. * Registers the component in a given scene
  123598. */
  123599. GeometryBufferRendererSceneComponent.prototype.register = function () {
  123600. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  123601. };
  123602. /**
  123603. * Rebuilds the elements related to this component in case of
  123604. * context lost for instance.
  123605. */
  123606. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  123607. // Nothing to do for this component
  123608. };
  123609. /**
  123610. * Disposes the component and the associated ressources
  123611. */
  123612. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  123613. // Nothing to do for this component
  123614. };
  123615. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  123616. if (this.scene._geometryBufferRenderer) {
  123617. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  123618. }
  123619. };
  123620. return GeometryBufferRendererSceneComponent;
  123621. }());
  123622. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  123623. // Register the G Buffer component to the scene.
  123624. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  123625. if (!component) {
  123626. component = new GeometryBufferRendererSceneComponent(scene);
  123627. scene._addComponent(component);
  123628. }
  123629. };
  123630. /***/ }),
  123631. /***/ "./Rendering/index.ts":
  123632. /*!****************************!*\
  123633. !*** ./Rendering/index.ts ***!
  123634. \****************************/
  123635. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  123636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123637. "use strict";
  123638. __webpack_require__.r(__webpack_exports__);
  123639. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  123640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  123641. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  123642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  123643. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  123644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  123645. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  123646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  123647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  123648. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  123649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  123650. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  123651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  123652. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  123653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  123654. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  123655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  123656. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  123657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  123658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  123659. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  123660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  123661. /***/ }),
  123662. /***/ "./Rendering/outlineRenderer.ts":
  123663. /*!**************************************!*\
  123664. !*** ./Rendering/outlineRenderer.ts ***!
  123665. \**************************************/
  123666. /*! exports provided: OutlineRenderer */
  123667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123668. "use strict";
  123669. __webpack_require__.r(__webpack_exports__);
  123670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  123671. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  123672. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  123673. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  123674. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123675. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  123676. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  123677. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  123678. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  123679. /**
  123680. * Gets the outline renderer associated with the scene
  123681. * @returns a OutlineRenderer
  123682. */
  123683. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  123684. if (!this._outlineRenderer) {
  123685. this._outlineRenderer = new OutlineRenderer(this);
  123686. }
  123687. return this._outlineRenderer;
  123688. };
  123689. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  123690. get: function () {
  123691. return this._renderOutline;
  123692. },
  123693. set: function (value) {
  123694. if (value) {
  123695. // Lazy Load the component.
  123696. this.getScene().getOutlineRenderer();
  123697. }
  123698. this._renderOutline = value;
  123699. },
  123700. enumerable: true,
  123701. configurable: true
  123702. });
  123703. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  123704. get: function () {
  123705. return this._renderOverlay;
  123706. },
  123707. set: function (value) {
  123708. if (value) {
  123709. // Lazy Load the component.
  123710. this.getScene().getOutlineRenderer();
  123711. }
  123712. this._renderOverlay = value;
  123713. },
  123714. enumerable: true,
  123715. configurable: true
  123716. });
  123717. /**
  123718. * This class is responsible to draw bothe outline/overlay of meshes.
  123719. * It should not be used directly but through the available method on mesh.
  123720. */
  123721. var OutlineRenderer = /** @class */ (function () {
  123722. /**
  123723. * Instantiates a new outline renderer. (There could be only one per scene).
  123724. * @param scene Defines the scene it belongs to
  123725. */
  123726. function OutlineRenderer(scene) {
  123727. /**
  123728. * The name of the component. Each component must have a unique name.
  123729. */
  123730. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  123731. /**
  123732. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  123733. */
  123734. this.zOffset = 1;
  123735. this.scene = scene;
  123736. this._engine = scene.getEngine();
  123737. this.scene._addComponent(this);
  123738. }
  123739. /**
  123740. * Register the component to one instance of a scene.
  123741. */
  123742. OutlineRenderer.prototype.register = function () {
  123743. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  123744. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  123745. };
  123746. /**
  123747. * Rebuilds the elements related to this component in case of
  123748. * context lost for instance.
  123749. */
  123750. OutlineRenderer.prototype.rebuild = function () {
  123751. // Nothing to do here.
  123752. };
  123753. /**
  123754. * Disposes the component and the associated ressources.
  123755. */
  123756. OutlineRenderer.prototype.dispose = function () {
  123757. // Nothing to do here.
  123758. };
  123759. /**
  123760. * Renders the outline in the canvas.
  123761. * @param subMesh Defines the sumesh to render
  123762. * @param batch Defines the batch of meshes in case of instances
  123763. * @param useOverlay Defines if the rendering is for the overlay or the outline
  123764. */
  123765. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  123766. var _this = this;
  123767. if (useOverlay === void 0) { useOverlay = false; }
  123768. var scene = this.scene;
  123769. var engine = scene.getEngine();
  123770. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  123771. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  123772. return;
  123773. }
  123774. var mesh = subMesh.getRenderingMesh();
  123775. var material = subMesh.getMaterial();
  123776. if (!material || !scene.activeCamera) {
  123777. return;
  123778. }
  123779. engine.enableEffect(this._effect);
  123780. // Logarithmic depth
  123781. if (material.useLogarithmicDepth) {
  123782. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  123783. }
  123784. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  123785. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  123786. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  123787. // Bones
  123788. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  123789. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  123790. }
  123791. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  123792. // Alpha test
  123793. if (material && material.needAlphaTesting()) {
  123794. var alphaTexture = material.getAlphaTestTexture();
  123795. if (alphaTexture) {
  123796. this._effect.setTexture("diffuseSampler", alphaTexture);
  123797. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  123798. }
  123799. }
  123800. engine.setZOffset(-this.zOffset);
  123801. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  123802. engine.setZOffset(0);
  123803. };
  123804. /**
  123805. * Returns whether or not the outline renderer is ready for a given submesh.
  123806. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  123807. * @param subMesh Defines the submesh to check readyness for
  123808. * @param useInstances Defines wheter wee are trying to render instances or not
  123809. * @returns true if ready otherwise false
  123810. */
  123811. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  123812. var defines = [];
  123813. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  123814. var mesh = subMesh.getMesh();
  123815. var material = subMesh.getMaterial();
  123816. if (material) {
  123817. // Alpha test
  123818. if (material.needAlphaTesting()) {
  123819. defines.push("#define ALPHATEST");
  123820. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  123821. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  123822. defines.push("#define UV1");
  123823. }
  123824. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  123825. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  123826. defines.push("#define UV2");
  123827. }
  123828. }
  123829. //Logarithmic depth
  123830. if (material.useLogarithmicDepth) {
  123831. defines.push("#define LOGARITHMICDEPTH");
  123832. }
  123833. }
  123834. // Bones
  123835. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  123836. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  123837. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  123838. if (mesh.numBoneInfluencers > 4) {
  123839. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  123840. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  123841. }
  123842. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  123843. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  123844. }
  123845. else {
  123846. defines.push("#define NUM_BONE_INFLUENCERS 0");
  123847. }
  123848. // Instances
  123849. if (useInstances) {
  123850. defines.push("#define INSTANCES");
  123851. attribs.push("world0");
  123852. attribs.push("world1");
  123853. attribs.push("world2");
  123854. attribs.push("world3");
  123855. }
  123856. // Get correct effect
  123857. var join = defines.join("\n");
  123858. if (this._cachedDefines !== join) {
  123859. this._cachedDefines = join;
  123860. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  123861. }
  123862. return this._effect.isReady();
  123863. };
  123864. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  123865. // Outline - step 1
  123866. this._savedDepthWrite = this._engine.getDepthWrite();
  123867. if (mesh.renderOutline) {
  123868. this._engine.setDepthWrite(false);
  123869. this.render(subMesh, batch);
  123870. this._engine.setDepthWrite(this._savedDepthWrite);
  123871. }
  123872. };
  123873. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  123874. // Outline - step 2
  123875. if (mesh.renderOutline && this._savedDepthWrite) {
  123876. this._engine.setDepthWrite(true);
  123877. this._engine.setColorWrite(false);
  123878. this.render(subMesh, batch);
  123879. this._engine.setColorWrite(true);
  123880. }
  123881. // Overlay
  123882. if (mesh.renderOverlay) {
  123883. var currentMode = this._engine.getAlphaMode();
  123884. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  123885. this.render(subMesh, batch, true);
  123886. this._engine.setAlphaMode(currentMode);
  123887. }
  123888. };
  123889. return OutlineRenderer;
  123890. }());
  123891. /***/ }),
  123892. /***/ "./Rendering/renderingGroup.ts":
  123893. /*!*************************************!*\
  123894. !*** ./Rendering/renderingGroup.ts ***!
  123895. \*************************************/
  123896. /*! exports provided: RenderingGroup */
  123897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123898. "use strict";
  123899. __webpack_require__.r(__webpack_exports__);
  123900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  123901. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  123902. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123903. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123904. /**
  123905. * This represents the object necessary to create a rendering group.
  123906. * This is exclusively used and created by the rendering manager.
  123907. * To modify the behavior, you use the available helpers in your scene or meshes.
  123908. * @hidden
  123909. */
  123910. var RenderingGroup = /** @class */ (function () {
  123911. /**
  123912. * Creates a new rendering group.
  123913. * @param index The rendering group index
  123914. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  123915. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  123916. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  123917. */
  123918. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  123919. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  123920. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  123921. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  123922. this.index = index;
  123923. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123924. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123925. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123926. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123927. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123928. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123929. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  123930. this._scene = scene;
  123931. this.opaqueSortCompareFn = opaqueSortCompareFn;
  123932. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  123933. this.transparentSortCompareFn = transparentSortCompareFn;
  123934. }
  123935. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  123936. /**
  123937. * Set the opaque sort comparison function.
  123938. * If null the sub meshes will be render in the order they were created
  123939. */
  123940. set: function (value) {
  123941. this._opaqueSortCompareFn = value;
  123942. if (value) {
  123943. this._renderOpaque = this.renderOpaqueSorted;
  123944. }
  123945. else {
  123946. this._renderOpaque = RenderingGroup.renderUnsorted;
  123947. }
  123948. },
  123949. enumerable: true,
  123950. configurable: true
  123951. });
  123952. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  123953. /**
  123954. * Set the alpha test sort comparison function.
  123955. * If null the sub meshes will be render in the order they were created
  123956. */
  123957. set: function (value) {
  123958. this._alphaTestSortCompareFn = value;
  123959. if (value) {
  123960. this._renderAlphaTest = this.renderAlphaTestSorted;
  123961. }
  123962. else {
  123963. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  123964. }
  123965. },
  123966. enumerable: true,
  123967. configurable: true
  123968. });
  123969. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  123970. /**
  123971. * Set the transparent sort comparison function.
  123972. * If null the sub meshes will be render in the order they were created
  123973. */
  123974. set: function (value) {
  123975. if (value) {
  123976. this._transparentSortCompareFn = value;
  123977. }
  123978. else {
  123979. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  123980. }
  123981. this._renderTransparent = this.renderTransparentSorted;
  123982. },
  123983. enumerable: true,
  123984. configurable: true
  123985. });
  123986. /**
  123987. * Render all the sub meshes contained in the group.
  123988. * @param customRenderFunction Used to override the default render behaviour of the group.
  123989. * @returns true if rendered some submeshes.
  123990. */
  123991. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  123992. if (customRenderFunction) {
  123993. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  123994. return;
  123995. }
  123996. var engine = this._scene.getEngine();
  123997. // Depth only
  123998. if (this._depthOnlySubMeshes.length !== 0) {
  123999. engine.setColorWrite(false);
  124000. this._renderAlphaTest(this._depthOnlySubMeshes);
  124001. engine.setColorWrite(true);
  124002. }
  124003. // Opaque
  124004. if (this._opaqueSubMeshes.length !== 0) {
  124005. this._renderOpaque(this._opaqueSubMeshes);
  124006. }
  124007. // Alpha test
  124008. if (this._alphaTestSubMeshes.length !== 0) {
  124009. this._renderAlphaTest(this._alphaTestSubMeshes);
  124010. }
  124011. var stencilState = engine.getStencilBuffer();
  124012. engine.setStencilBuffer(false);
  124013. // Sprites
  124014. if (renderSprites) {
  124015. this._renderSprites();
  124016. }
  124017. // Particles
  124018. if (renderParticles) {
  124019. this._renderParticles(activeMeshes);
  124020. }
  124021. if (this.onBeforeTransparentRendering) {
  124022. this.onBeforeTransparentRendering();
  124023. }
  124024. // Transparent
  124025. if (this._transparentSubMeshes.length !== 0) {
  124026. this._renderTransparent(this._transparentSubMeshes);
  124027. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  124028. }
  124029. // Set back stencil to false in case it changes before the edge renderer.
  124030. engine.setStencilBuffer(false);
  124031. // Edges
  124032. if (this._edgesRenderers.length) {
  124033. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  124034. this._edgesRenderers.data[edgesRendererIndex].render();
  124035. }
  124036. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  124037. }
  124038. // Restore Stencil state.
  124039. engine.setStencilBuffer(stencilState);
  124040. };
  124041. /**
  124042. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  124043. * @param subMeshes The submeshes to render
  124044. */
  124045. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  124046. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  124047. };
  124048. /**
  124049. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  124050. * @param subMeshes The submeshes to render
  124051. */
  124052. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  124053. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  124054. };
  124055. /**
  124056. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  124057. * @param subMeshes The submeshes to render
  124058. */
  124059. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  124060. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  124061. };
  124062. /**
  124063. * Renders the submeshes in a specified order.
  124064. * @param subMeshes The submeshes to sort before render
  124065. * @param sortCompareFn The comparison function use to sort
  124066. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  124067. * @param transparent Specifies to activate blending if true
  124068. */
  124069. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  124070. var subIndex = 0;
  124071. var subMesh;
  124072. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  124073. for (; subIndex < subMeshes.length; subIndex++) {
  124074. subMesh = subMeshes.data[subIndex];
  124075. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  124076. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  124077. }
  124078. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  124079. if (sortCompareFn) {
  124080. sortedArray.sort(sortCompareFn);
  124081. }
  124082. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  124083. subMesh = sortedArray[subIndex];
  124084. if (transparent) {
  124085. var material = subMesh.getMaterial();
  124086. if (material && material.needDepthPrePass) {
  124087. var engine = material.getScene().getEngine();
  124088. engine.setColorWrite(false);
  124089. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  124090. subMesh.render(false);
  124091. engine.setColorWrite(true);
  124092. }
  124093. }
  124094. subMesh.render(transparent);
  124095. }
  124096. };
  124097. /**
  124098. * Renders the submeshes in the order they were dispatched (no sort applied).
  124099. * @param subMeshes The submeshes to render
  124100. */
  124101. RenderingGroup.renderUnsorted = function (subMeshes) {
  124102. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  124103. var submesh = subMeshes.data[subIndex];
  124104. submesh.render(false);
  124105. }
  124106. };
  124107. /**
  124108. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  124109. * are rendered back to front if in the same alpha index.
  124110. *
  124111. * @param a The first submesh
  124112. * @param b The second submesh
  124113. * @returns The result of the comparison
  124114. */
  124115. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  124116. // Alpha index first
  124117. if (a._alphaIndex > b._alphaIndex) {
  124118. return 1;
  124119. }
  124120. if (a._alphaIndex < b._alphaIndex) {
  124121. return -1;
  124122. }
  124123. // Then distance to camera
  124124. return RenderingGroup.backToFrontSortCompare(a, b);
  124125. };
  124126. /**
  124127. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  124128. * are rendered back to front.
  124129. *
  124130. * @param a The first submesh
  124131. * @param b The second submesh
  124132. * @returns The result of the comparison
  124133. */
  124134. RenderingGroup.backToFrontSortCompare = function (a, b) {
  124135. // Then distance to camera
  124136. if (a._distanceToCamera < b._distanceToCamera) {
  124137. return 1;
  124138. }
  124139. if (a._distanceToCamera > b._distanceToCamera) {
  124140. return -1;
  124141. }
  124142. return 0;
  124143. };
  124144. /**
  124145. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  124146. * are rendered front to back (prevent overdraw).
  124147. *
  124148. * @param a The first submesh
  124149. * @param b The second submesh
  124150. * @returns The result of the comparison
  124151. */
  124152. RenderingGroup.frontToBackSortCompare = function (a, b) {
  124153. // Then distance to camera
  124154. if (a._distanceToCamera < b._distanceToCamera) {
  124155. return -1;
  124156. }
  124157. if (a._distanceToCamera > b._distanceToCamera) {
  124158. return 1;
  124159. }
  124160. return 0;
  124161. };
  124162. /**
  124163. * Resets the different lists of submeshes to prepare a new frame.
  124164. */
  124165. RenderingGroup.prototype.prepare = function () {
  124166. this._opaqueSubMeshes.reset();
  124167. this._transparentSubMeshes.reset();
  124168. this._alphaTestSubMeshes.reset();
  124169. this._depthOnlySubMeshes.reset();
  124170. this._particleSystems.reset();
  124171. this._spriteManagers.reset();
  124172. this._edgesRenderers.reset();
  124173. };
  124174. RenderingGroup.prototype.dispose = function () {
  124175. this._opaqueSubMeshes.dispose();
  124176. this._transparentSubMeshes.dispose();
  124177. this._alphaTestSubMeshes.dispose();
  124178. this._depthOnlySubMeshes.dispose();
  124179. this._particleSystems.dispose();
  124180. this._spriteManagers.dispose();
  124181. this._edgesRenderers.dispose();
  124182. };
  124183. /**
  124184. * Inserts the submesh in its correct queue depending on its material.
  124185. * @param subMesh The submesh to dispatch
  124186. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  124187. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  124188. */
  124189. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  124190. // Get mesh and materials if not provided
  124191. if (mesh === undefined) {
  124192. mesh = subMesh.getMesh();
  124193. }
  124194. if (material === undefined) {
  124195. material = subMesh.getMaterial();
  124196. }
  124197. if (material === null || material === undefined) {
  124198. return;
  124199. }
  124200. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  124201. this._transparentSubMeshes.push(subMesh);
  124202. }
  124203. else if (material.needAlphaTesting()) { // Alpha test
  124204. if (material.needDepthPrePass) {
  124205. this._depthOnlySubMeshes.push(subMesh);
  124206. }
  124207. this._alphaTestSubMeshes.push(subMesh);
  124208. }
  124209. else {
  124210. if (material.needDepthPrePass) {
  124211. this._depthOnlySubMeshes.push(subMesh);
  124212. }
  124213. this._opaqueSubMeshes.push(subMesh); // Opaque
  124214. }
  124215. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  124216. this._edgesRenderers.push(mesh._edgesRenderer);
  124217. }
  124218. };
  124219. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  124220. this._spriteManagers.push(spriteManager);
  124221. };
  124222. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  124223. this._particleSystems.push(particleSystem);
  124224. };
  124225. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  124226. if (this._particleSystems.length === 0) {
  124227. return;
  124228. }
  124229. // Particles
  124230. var activeCamera = this._scene.activeCamera;
  124231. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  124232. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  124233. var particleSystem = this._particleSystems.data[particleIndex];
  124234. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  124235. continue;
  124236. }
  124237. var emitter = particleSystem.emitter;
  124238. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  124239. this._scene._activeParticles.addCount(particleSystem.render(), false);
  124240. }
  124241. }
  124242. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  124243. };
  124244. RenderingGroup.prototype._renderSprites = function () {
  124245. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  124246. return;
  124247. }
  124248. // Sprites
  124249. var activeCamera = this._scene.activeCamera;
  124250. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  124251. for (var id = 0; id < this._spriteManagers.length; id++) {
  124252. var spriteManager = this._spriteManagers.data[id];
  124253. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  124254. spriteManager.render();
  124255. }
  124256. }
  124257. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  124258. };
  124259. return RenderingGroup;
  124260. }());
  124261. /***/ }),
  124262. /***/ "./Rendering/renderingManager.ts":
  124263. /*!***************************************!*\
  124264. !*** ./Rendering/renderingManager.ts ***!
  124265. \***************************************/
  124266. /*! exports provided: RenderingGroupInfo, RenderingManager */
  124267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124268. "use strict";
  124269. __webpack_require__.r(__webpack_exports__);
  124270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  124271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  124272. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  124273. /**
  124274. * This class is used by the onRenderingGroupObservable
  124275. */
  124276. var RenderingGroupInfo = /** @class */ (function () {
  124277. function RenderingGroupInfo() {
  124278. }
  124279. return RenderingGroupInfo;
  124280. }());
  124281. /**
  124282. * This is the manager responsible of all the rendering for meshes sprites and particles.
  124283. * It is enable to manage the different groups as well as the different necessary sort functions.
  124284. * This should not be used directly aside of the few static configurations
  124285. */
  124286. var RenderingManager = /** @class */ (function () {
  124287. /**
  124288. * Instantiates a new rendering group for a particular scene
  124289. * @param scene Defines the scene the groups belongs to
  124290. */
  124291. function RenderingManager(scene) {
  124292. /**
  124293. * @hidden
  124294. */
  124295. this._useSceneAutoClearSetup = false;
  124296. this._renderingGroups = new Array();
  124297. this._autoClearDepthStencil = {};
  124298. this._customOpaqueSortCompareFn = {};
  124299. this._customAlphaTestSortCompareFn = {};
  124300. this._customTransparentSortCompareFn = {};
  124301. this._renderingGroupInfo = new RenderingGroupInfo();
  124302. this._scene = scene;
  124303. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  124304. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  124305. }
  124306. }
  124307. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  124308. if (depth === void 0) { depth = true; }
  124309. if (stencil === void 0) { stencil = true; }
  124310. if (this._depthStencilBufferAlreadyCleaned) {
  124311. return;
  124312. }
  124313. this._scene.getEngine().clear(null, false, depth, stencil);
  124314. this._depthStencilBufferAlreadyCleaned = true;
  124315. };
  124316. /**
  124317. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  124318. * @hidden
  124319. */
  124320. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  124321. // Update the observable context (not null as it only goes away on dispose)
  124322. var info = this._renderingGroupInfo;
  124323. info.scene = this._scene;
  124324. info.camera = this._scene.activeCamera;
  124325. // Dispatch sprites
  124326. if (this._scene.spriteManagers && renderSprites) {
  124327. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  124328. var manager = this._scene.spriteManagers[index];
  124329. this.dispatchSprites(manager);
  124330. }
  124331. }
  124332. // Render
  124333. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  124334. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  124335. var renderingGroup = this._renderingGroups[index];
  124336. if (!renderingGroup) {
  124337. continue;
  124338. }
  124339. var renderingGroupMask = Math.pow(2, index);
  124340. info.renderingGroupId = index;
  124341. // Before Observable
  124342. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  124343. // Clear depth/stencil if needed
  124344. if (RenderingManager.AUTOCLEAR) {
  124345. var autoClear = this._useSceneAutoClearSetup ?
  124346. this._scene.getAutoClearDepthStencilSetup(index) :
  124347. this._autoClearDepthStencil[index];
  124348. if (autoClear && autoClear.autoClear) {
  124349. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  124350. }
  124351. }
  124352. // Render
  124353. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  124354. var step = _a[_i];
  124355. step.action(index);
  124356. }
  124357. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  124358. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  124359. var step = _c[_b];
  124360. step.action(index);
  124361. }
  124362. // After Observable
  124363. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  124364. }
  124365. };
  124366. /**
  124367. * Resets the different information of the group to prepare a new frame
  124368. * @hidden
  124369. */
  124370. RenderingManager.prototype.reset = function () {
  124371. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  124372. var renderingGroup = this._renderingGroups[index];
  124373. if (renderingGroup) {
  124374. renderingGroup.prepare();
  124375. }
  124376. }
  124377. };
  124378. /**
  124379. * Dispose and release the group and its associated resources.
  124380. * @hidden
  124381. */
  124382. RenderingManager.prototype.dispose = function () {
  124383. this.freeRenderingGroups();
  124384. this._renderingGroups.length = 0;
  124385. this._renderingGroupInfo = null;
  124386. };
  124387. /**
  124388. * Clear the info related to rendering groups preventing retention points during dispose.
  124389. */
  124390. RenderingManager.prototype.freeRenderingGroups = function () {
  124391. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  124392. var renderingGroup = this._renderingGroups[index];
  124393. if (renderingGroup) {
  124394. renderingGroup.dispose();
  124395. }
  124396. }
  124397. };
  124398. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  124399. if (this._renderingGroups[renderingGroupId] === undefined) {
  124400. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  124401. }
  124402. };
  124403. /**
  124404. * Add a sprite manager to the rendering manager in order to render it this frame.
  124405. * @param spriteManager Define the sprite manager to render
  124406. */
  124407. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  124408. var renderingGroupId = spriteManager.renderingGroupId || 0;
  124409. this._prepareRenderingGroup(renderingGroupId);
  124410. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  124411. };
  124412. /**
  124413. * Add a particle system to the rendering manager in order to render it this frame.
  124414. * @param particleSystem Define the particle system to render
  124415. */
  124416. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  124417. var renderingGroupId = particleSystem.renderingGroupId || 0;
  124418. this._prepareRenderingGroup(renderingGroupId);
  124419. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  124420. };
  124421. /**
  124422. * Add a submesh to the manager in order to render it this frame
  124423. * @param subMesh The submesh to dispatch
  124424. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  124425. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  124426. */
  124427. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  124428. if (mesh === undefined) {
  124429. mesh = subMesh.getMesh();
  124430. }
  124431. var renderingGroupId = mesh.renderingGroupId || 0;
  124432. this._prepareRenderingGroup(renderingGroupId);
  124433. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  124434. };
  124435. /**
  124436. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  124437. * This allowed control for front to back rendering or reversly depending of the special needs.
  124438. *
  124439. * @param renderingGroupId The rendering group id corresponding to its index
  124440. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  124441. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  124442. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  124443. */
  124444. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  124445. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  124446. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  124447. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  124448. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  124449. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  124450. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  124451. if (this._renderingGroups[renderingGroupId]) {
  124452. var group = this._renderingGroups[renderingGroupId];
  124453. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  124454. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  124455. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  124456. }
  124457. };
  124458. /**
  124459. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  124460. *
  124461. * @param renderingGroupId The rendering group id corresponding to its index
  124462. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124463. * @param depth Automatically clears depth between groups if true and autoClear is true.
  124464. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  124465. */
  124466. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  124467. if (depth === void 0) { depth = true; }
  124468. if (stencil === void 0) { stencil = true; }
  124469. this._autoClearDepthStencil[renderingGroupId] = {
  124470. autoClear: autoClearDepthStencil,
  124471. depth: depth,
  124472. stencil: stencil
  124473. };
  124474. };
  124475. /**
  124476. * Gets the current auto clear configuration for one rendering group of the rendering
  124477. * manager.
  124478. * @param index the rendering group index to get the information for
  124479. * @returns The auto clear setup for the requested rendering group
  124480. */
  124481. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  124482. return this._autoClearDepthStencil[index];
  124483. };
  124484. /**
  124485. * The max id used for rendering groups (not included)
  124486. */
  124487. RenderingManager.MAX_RENDERINGGROUPS = 4;
  124488. /**
  124489. * The min id used for rendering groups (included)
  124490. */
  124491. RenderingManager.MIN_RENDERINGGROUPS = 0;
  124492. /**
  124493. * Used to globally prevent autoclearing scenes.
  124494. */
  124495. RenderingManager.AUTOCLEAR = true;
  124496. return RenderingManager;
  124497. }());
  124498. /***/ }),
  124499. /***/ "./Rendering/utilityLayerRenderer.ts":
  124500. /*!*******************************************!*\
  124501. !*** ./Rendering/utilityLayerRenderer.ts ***!
  124502. \*******************************************/
  124503. /*! exports provided: UtilityLayerRenderer */
  124504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124505. "use strict";
  124506. __webpack_require__.r(__webpack_exports__);
  124507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  124508. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124509. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124510. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  124511. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  124512. /**
  124513. * Renders a layer on top of an existing scene
  124514. */
  124515. var UtilityLayerRenderer = /** @class */ (function () {
  124516. /**
  124517. * Instantiates a UtilityLayerRenderer
  124518. * @param originalScene the original scene that will be rendered on top of
  124519. * @param handleEvents boolean indicating if the utility layer should handle events
  124520. */
  124521. function UtilityLayerRenderer(
  124522. /** the original scene that will be rendered on top of */
  124523. originalScene, handleEvents) {
  124524. if (handleEvents === void 0) { handleEvents = true; }
  124525. var _this = this;
  124526. this.originalScene = originalScene;
  124527. this._pointerCaptures = {};
  124528. this._lastPointerEvents = {};
  124529. /**
  124530. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  124531. */
  124532. this.pickUtilitySceneFirst = true;
  124533. /**
  124534. * If the utility layer should automatically be rendered on top of existing scene
  124535. */
  124536. this.shouldRender = true;
  124537. /**
  124538. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  124539. */
  124540. this.onlyCheckPointerDownEvents = true;
  124541. /**
  124542. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  124543. */
  124544. this.processAllEvents = false;
  124545. /**
  124546. * Observable raised when the pointer move from the utility layer scene to the main scene
  124547. */
  124548. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  124549. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  124550. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  124551. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  124552. this.utilityLayerScene._allowPostProcessClearColor = false;
  124553. originalScene.getEngine().scenes.pop();
  124554. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  124555. this.utilityLayerScene.detachControl();
  124556. if (handleEvents) {
  124557. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  124558. if (!_this.utilityLayerScene.activeCamera) {
  124559. return;
  124560. }
  124561. if (!_this.processAllEvents) {
  124562. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  124563. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  124564. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  124565. return;
  124566. }
  124567. }
  124568. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  124569. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  124570. var pointerEvent = (prePointerInfo.event);
  124571. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  124572. _this._pointerCaptures[pointerEvent.pointerId] = false;
  124573. return;
  124574. }
  124575. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  124576. if (!prePointerInfo.ray && utilityScenePick) {
  124577. prePointerInfo.ray = utilityScenePick.ray;
  124578. }
  124579. // always fire the prepointer oversvable
  124580. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  124581. // allow every non pointer down event to flow to the utility layer
  124582. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  124583. if (!prePointerInfo.skipOnPointerObservable) {
  124584. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  124585. }
  124586. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  124587. _this._pointerCaptures[pointerEvent.pointerId] = false;
  124588. }
  124589. return;
  124590. }
  124591. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  124592. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  124593. if (utilityScenePick && utilityScenePick.hit) {
  124594. if (!prePointerInfo.skipOnPointerObservable) {
  124595. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  124596. }
  124597. prePointerInfo.skipOnPointerObservable = true;
  124598. }
  124599. }
  124600. else {
  124601. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  124602. var pointerEvent_1 = (prePointerInfo.event);
  124603. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  124604. if (originalScenePick && utilityScenePick) {
  124605. // No pick in utility scene
  124606. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  124607. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  124608. // We touched an utility mesh present in the main scene
  124609. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  124610. prePointerInfo.skipOnPointerObservable = true;
  124611. }
  124612. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  124613. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  124614. }
  124615. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  124616. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  124617. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  124618. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  124619. }
  124620. }
  124621. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  124622. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  124623. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  124624. // If a previous utility layer set this, do not unset this
  124625. if (!prePointerInfo.skipOnPointerObservable) {
  124626. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  124627. }
  124628. }
  124629. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  124630. // We have a pick in both scenes but main is closer than utility
  124631. // We touched an utility mesh present in the main scene
  124632. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  124633. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  124634. prePointerInfo.skipOnPointerObservable = true;
  124635. }
  124636. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  124637. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  124638. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  124639. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  124640. }
  124641. }
  124642. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  124643. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  124644. }
  124645. }
  124646. }
  124647. });
  124648. }
  124649. // Render directly on top of existing scene without clearing
  124650. this.utilityLayerScene.autoClear = false;
  124651. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  124652. if (_this.shouldRender) {
  124653. _this.render();
  124654. }
  124655. });
  124656. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  124657. _this.dispose();
  124658. });
  124659. this._updateCamera();
  124660. }
  124661. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  124662. /**
  124663. * 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)
  124664. */
  124665. get: function () {
  124666. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  124667. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  124668. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  124669. UtilityLayerRenderer._DefaultUtilityLayer = null;
  124670. });
  124671. }
  124672. return UtilityLayerRenderer._DefaultUtilityLayer;
  124673. },
  124674. enumerable: true,
  124675. configurable: true
  124676. });
  124677. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  124678. /**
  124679. * 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)
  124680. */
  124681. get: function () {
  124682. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  124683. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  124684. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  124685. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  124686. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  124687. });
  124688. }
  124689. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  124690. },
  124691. enumerable: true,
  124692. configurable: true
  124693. });
  124694. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  124695. if (!prePointerInfo.skipOnPointerObservable) {
  124696. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  124697. this._lastPointerEvents[pointerEvent.pointerId] = true;
  124698. }
  124699. };
  124700. /**
  124701. * Renders the utility layers scene on top of the original scene
  124702. */
  124703. UtilityLayerRenderer.prototype.render = function () {
  124704. this._updateCamera();
  124705. if (this.utilityLayerScene.activeCamera) {
  124706. // Set the camera's scene to utility layers scene
  124707. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  124708. var camera = this.utilityLayerScene.activeCamera;
  124709. camera._scene = this.utilityLayerScene;
  124710. if (camera.leftCamera) {
  124711. camera.leftCamera._scene = this.utilityLayerScene;
  124712. }
  124713. if (camera.rightCamera) {
  124714. camera.rightCamera._scene = this.utilityLayerScene;
  124715. }
  124716. this.utilityLayerScene.render(false);
  124717. // Reset camera's scene back to original
  124718. camera._scene = oldScene;
  124719. if (camera.leftCamera) {
  124720. camera.leftCamera._scene = oldScene;
  124721. }
  124722. if (camera.rightCamera) {
  124723. camera.rightCamera._scene = oldScene;
  124724. }
  124725. }
  124726. };
  124727. /**
  124728. * Disposes of the renderer
  124729. */
  124730. UtilityLayerRenderer.prototype.dispose = function () {
  124731. this.onPointerOutObservable.clear();
  124732. if (this._afterRenderObserver) {
  124733. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  124734. }
  124735. if (this._sceneDisposeObserver) {
  124736. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  124737. }
  124738. if (this._originalPointerObserver) {
  124739. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  124740. }
  124741. this.utilityLayerScene.dispose();
  124742. };
  124743. UtilityLayerRenderer.prototype._updateCamera = function () {
  124744. if (this.originalScene.activeCameras.length > 1) {
  124745. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  124746. }
  124747. else {
  124748. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  124749. }
  124750. };
  124751. UtilityLayerRenderer._DefaultUtilityLayer = null;
  124752. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  124753. return UtilityLayerRenderer;
  124754. }());
  124755. /***/ }),
  124756. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  124757. /*!*****************************************************************!*\
  124758. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  124759. \*****************************************************************/
  124760. /*! exports provided: backgroundFragmentDeclaration */
  124761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124762. "use strict";
  124763. __webpack_require__.r(__webpack_exports__);
  124764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  124765. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124766. var name = 'backgroundFragmentDeclaration';
  124767. 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";
  124768. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124769. /** @hidden */
  124770. var backgroundFragmentDeclaration = { name: name, shader: shader };
  124771. /***/ }),
  124772. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  124773. /*!************************************************************!*\
  124774. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  124775. \************************************************************/
  124776. /*! exports provided: backgroundUboDeclaration */
  124777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124778. "use strict";
  124779. __webpack_require__.r(__webpack_exports__);
  124780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  124781. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124782. var name = 'backgroundUboDeclaration';
  124783. 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};";
  124784. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124785. /** @hidden */
  124786. var backgroundUboDeclaration = { name: name, shader: shader };
  124787. /***/ }),
  124788. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  124789. /*!***************************************************************!*\
  124790. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  124791. \***************************************************************/
  124792. /*! exports provided: backgroundVertexDeclaration */
  124793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124794. "use strict";
  124795. __webpack_require__.r(__webpack_exports__);
  124796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  124797. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124798. var name = 'backgroundVertexDeclaration';
  124799. 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";
  124800. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124801. /** @hidden */
  124802. var backgroundVertexDeclaration = { name: name, shader: shader };
  124803. /***/ }),
  124804. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  124805. /*!****************************************************!*\
  124806. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  124807. \****************************************************/
  124808. /*! exports provided: bonesDeclaration */
  124809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124810. "use strict";
  124811. __webpack_require__.r(__webpack_exports__);
  124812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  124813. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124814. var name = 'bonesDeclaration';
  124815. 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";
  124816. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124817. /** @hidden */
  124818. var bonesDeclaration = { name: name, shader: shader };
  124819. /***/ }),
  124820. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  124821. /*!***********************************************!*\
  124822. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  124823. \***********************************************/
  124824. /*! exports provided: bonesVertex */
  124825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124826. "use strict";
  124827. __webpack_require__.r(__webpack_exports__);
  124828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  124829. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124830. var name = 'bonesVertex';
  124831. 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";
  124832. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124833. /** @hidden */
  124834. var bonesVertex = { name: name, shader: shader };
  124835. /***/ }),
  124836. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  124837. /*!************************************************!*\
  124838. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  124839. \************************************************/
  124840. /*! exports provided: bumpFragment */
  124841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124842. "use strict";
  124843. __webpack_require__.r(__webpack_exports__);
  124844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  124845. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124846. var name = 'bumpFragment';
  124847. 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";
  124848. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124849. /** @hidden */
  124850. var bumpFragment = { name: name, shader: shader };
  124851. /***/ }),
  124852. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  124853. /*!*********************************************************!*\
  124854. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  124855. \*********************************************************/
  124856. /*! exports provided: bumpFragmentFunctions */
  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__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  124861. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124862. var name = 'bumpFragmentFunctions';
  124863. 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";
  124864. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124865. /** @hidden */
  124866. var bumpFragmentFunctions = { name: name, shader: shader };
  124867. /***/ }),
  124868. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  124869. /*!**********************************************!*\
  124870. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  124871. \**********************************************/
  124872. /*! exports provided: bumpVertex */
  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__, "bumpVertex", function() { return bumpVertex; });
  124877. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124878. var name = 'bumpVertex';
  124879. 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";
  124880. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124881. /** @hidden */
  124882. var bumpVertex = { name: name, shader: shader };
  124883. /***/ }),
  124884. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  124885. /*!*********************************************************!*\
  124886. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  124887. \*********************************************************/
  124888. /*! exports provided: bumpVertexDeclaration */
  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__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  124893. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124894. var name = 'bumpVertexDeclaration';
  124895. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  124896. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124897. /** @hidden */
  124898. var bumpVertexDeclaration = { name: name, shader: shader };
  124899. /***/ }),
  124900. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  124901. /*!*****************************************************!*\
  124902. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  124903. \*****************************************************/
  124904. /*! exports provided: clipPlaneFragment */
  124905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124906. "use strict";
  124907. __webpack_require__.r(__webpack_exports__);
  124908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  124909. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124910. var name = 'clipPlaneFragment';
  124911. 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";
  124912. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124913. /** @hidden */
  124914. var clipPlaneFragment = { name: name, shader: shader };
  124915. /***/ }),
  124916. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  124917. /*!****************************************************************!*\
  124918. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  124919. \****************************************************************/
  124920. /*! exports provided: clipPlaneFragmentDeclaration */
  124921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124922. "use strict";
  124923. __webpack_require__.r(__webpack_exports__);
  124924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  124925. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124926. var name = 'clipPlaneFragmentDeclaration';
  124927. 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";
  124928. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124929. /** @hidden */
  124930. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  124931. /***/ }),
  124932. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  124933. /*!*****************************************************************!*\
  124934. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  124935. \*****************************************************************/
  124936. /*! exports provided: clipPlaneFragmentDeclaration2 */
  124937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124938. "use strict";
  124939. __webpack_require__.r(__webpack_exports__);
  124940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  124941. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124942. var name = 'clipPlaneFragmentDeclaration2';
  124943. 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";
  124944. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124945. /** @hidden */
  124946. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  124947. /***/ }),
  124948. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  124949. /*!***************************************************!*\
  124950. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  124951. \***************************************************/
  124952. /*! exports provided: clipPlaneVertex */
  124953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124954. "use strict";
  124955. __webpack_require__.r(__webpack_exports__);
  124956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  124957. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124958. var name = 'clipPlaneVertex';
  124959. 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";
  124960. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124961. /** @hidden */
  124962. var clipPlaneVertex = { name: name, shader: shader };
  124963. /***/ }),
  124964. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  124965. /*!**************************************************************!*\
  124966. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  124967. \**************************************************************/
  124968. /*! exports provided: clipPlaneVertexDeclaration */
  124969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124970. "use strict";
  124971. __webpack_require__.r(__webpack_exports__);
  124972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  124973. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124974. var name = 'clipPlaneVertexDeclaration';
  124975. 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";
  124976. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124977. /** @hidden */
  124978. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  124979. /***/ }),
  124980. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  124981. /*!***************************************************************!*\
  124982. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  124983. \***************************************************************/
  124984. /*! exports provided: clipPlaneVertexDeclaration2 */
  124985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124986. "use strict";
  124987. __webpack_require__.r(__webpack_exports__);
  124988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  124989. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124990. var name = 'clipPlaneVertexDeclaration2';
  124991. 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";
  124992. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124993. /** @hidden */
  124994. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  124995. /***/ }),
  124996. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  124997. /*!**************************************************************!*\
  124998. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  124999. \**************************************************************/
  125000. /*! exports provided: defaultFragmentDeclaration */
  125001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125002. "use strict";
  125003. __webpack_require__.r(__webpack_exports__);
  125004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  125005. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125006. var name = 'defaultFragmentDeclaration';
  125007. 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";
  125008. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125009. /** @hidden */
  125010. var defaultFragmentDeclaration = { name: name, shader: shader };
  125011. /***/ }),
  125012. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  125013. /*!*********************************************************!*\
  125014. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  125015. \*********************************************************/
  125016. /*! exports provided: defaultUboDeclaration */
  125017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125018. "use strict";
  125019. __webpack_require__.r(__webpack_exports__);
  125020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  125021. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125022. var name = 'defaultUboDeclaration';
  125023. 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";
  125024. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125025. /** @hidden */
  125026. var defaultUboDeclaration = { name: name, shader: shader };
  125027. /***/ }),
  125028. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  125029. /*!************************************************************!*\
  125030. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  125031. \************************************************************/
  125032. /*! exports provided: defaultVertexDeclaration */
  125033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125034. "use strict";
  125035. __webpack_require__.r(__webpack_exports__);
  125036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  125037. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125038. var name = 'defaultVertexDeclaration';
  125039. 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";
  125040. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125041. /** @hidden */
  125042. var defaultVertexDeclaration = { name: name, shader: shader };
  125043. /***/ }),
  125044. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  125045. /*!************************************************!*\
  125046. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  125047. \************************************************/
  125048. /*! exports provided: depthPrePass */
  125049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125050. "use strict";
  125051. __webpack_require__.r(__webpack_exports__);
  125052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  125053. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125054. var name = 'depthPrePass';
  125055. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  125056. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125057. /** @hidden */
  125058. var depthPrePass = { name: name, shader: shader };
  125059. /***/ }),
  125060. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  125061. /*!***********************************************!*\
  125062. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  125063. \***********************************************/
  125064. /*! exports provided: fogFragment */
  125065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125066. "use strict";
  125067. __webpack_require__.r(__webpack_exports__);
  125068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  125069. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125070. var name = 'fogFragment';
  125071. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  125072. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125073. /** @hidden */
  125074. var fogFragment = { name: name, shader: shader };
  125075. /***/ }),
  125076. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  125077. /*!**********************************************************!*\
  125078. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  125079. \**********************************************************/
  125080. /*! exports provided: fogFragmentDeclaration */
  125081. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125082. "use strict";
  125083. __webpack_require__.r(__webpack_exports__);
  125084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  125085. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125086. var name = 'fogFragmentDeclaration';
  125087. 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";
  125088. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125089. /** @hidden */
  125090. var fogFragmentDeclaration = { name: name, shader: shader };
  125091. /***/ }),
  125092. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  125093. /*!*********************************************!*\
  125094. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  125095. \*********************************************/
  125096. /*! exports provided: fogVertex */
  125097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125098. "use strict";
  125099. __webpack_require__.r(__webpack_exports__);
  125100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  125101. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125102. var name = 'fogVertex';
  125103. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  125104. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125105. /** @hidden */
  125106. var fogVertex = { name: name, shader: shader };
  125107. /***/ }),
  125108. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  125109. /*!********************************************************!*\
  125110. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  125111. \********************************************************/
  125112. /*! exports provided: fogVertexDeclaration */
  125113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125114. "use strict";
  125115. __webpack_require__.r(__webpack_exports__);
  125116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  125117. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125118. var name = 'fogVertexDeclaration';
  125119. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  125120. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125121. /** @hidden */
  125122. var fogVertexDeclaration = { name: name, shader: shader };
  125123. /***/ }),
  125124. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  125125. /*!***************************************************!*\
  125126. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  125127. \***************************************************/
  125128. /*! exports provided: fresnelFunction */
  125129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125130. "use strict";
  125131. __webpack_require__.r(__webpack_exports__);
  125132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  125133. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125134. var name = 'fresnelFunction';
  125135. 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";
  125136. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125137. /** @hidden */
  125138. var fresnelFunction = { name: name, shader: shader };
  125139. /***/ }),
  125140. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  125141. /*!******************************************************!*\
  125142. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  125143. \******************************************************/
  125144. /*! exports provided: harmonicsFunctions */
  125145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125146. "use strict";
  125147. __webpack_require__.r(__webpack_exports__);
  125148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  125149. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125150. var name = 'harmonicsFunctions';
  125151. 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";
  125152. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125153. /** @hidden */
  125154. var harmonicsFunctions = { name: name, shader: shader };
  125155. /***/ }),
  125156. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  125157. /*!***************************************************!*\
  125158. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  125159. \***************************************************/
  125160. /*! exports provided: helperFunctions */
  125161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125162. "use strict";
  125163. __webpack_require__.r(__webpack_exports__);
  125164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  125165. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125166. var name = 'helperFunctions';
  125167. 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}";
  125168. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125169. /** @hidden */
  125170. var helperFunctions = { name: name, shader: shader };
  125171. /***/ }),
  125172. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  125173. /*!**************************************************************!*\
  125174. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  125175. \**************************************************************/
  125176. /*! exports provided: imageProcessingDeclaration */
  125177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125178. "use strict";
  125179. __webpack_require__.r(__webpack_exports__);
  125180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  125181. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125182. var name = 'imageProcessingDeclaration';
  125183. 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";
  125184. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125185. /** @hidden */
  125186. var imageProcessingDeclaration = { name: name, shader: shader };
  125187. /***/ }),
  125188. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  125189. /*!************************************************************!*\
  125190. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  125191. \************************************************************/
  125192. /*! exports provided: imageProcessingFunctions */
  125193. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125194. "use strict";
  125195. __webpack_require__.r(__webpack_exports__);
  125196. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  125197. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125198. var name = 'imageProcessingFunctions';
  125199. 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}";
  125200. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125201. /** @hidden */
  125202. var imageProcessingFunctions = { name: name, shader: shader };
  125203. /***/ }),
  125204. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  125205. /*!********************************************************!*\
  125206. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  125207. \********************************************************/
  125208. /*! exports provided: instancesDeclaration */
  125209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125210. "use strict";
  125211. __webpack_require__.r(__webpack_exports__);
  125212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  125213. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125214. var name = 'instancesDeclaration';
  125215. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  125216. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125217. /** @hidden */
  125218. var instancesDeclaration = { name: name, shader: shader };
  125219. /***/ }),
  125220. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  125221. /*!***************************************************!*\
  125222. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  125223. \***************************************************/
  125224. /*! exports provided: instancesVertex */
  125225. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125226. "use strict";
  125227. __webpack_require__.r(__webpack_exports__);
  125228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  125229. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125230. var name = 'instancesVertex';
  125231. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  125232. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125233. /** @hidden */
  125234. var instancesVertex = { name: name, shader: shader };
  125235. /***/ }),
  125236. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  125237. /*!******************************************************!*\
  125238. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  125239. \******************************************************/
  125240. /*! exports provided: kernelBlurFragment */
  125241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125242. "use strict";
  125243. __webpack_require__.r(__webpack_exports__);
  125244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  125245. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125246. var name = 'kernelBlurFragment';
  125247. 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";
  125248. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125249. /** @hidden */
  125250. var kernelBlurFragment = { name: name, shader: shader };
  125251. /***/ }),
  125252. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  125253. /*!*******************************************************!*\
  125254. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  125255. \*******************************************************/
  125256. /*! exports provided: kernelBlurFragment2 */
  125257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125258. "use strict";
  125259. __webpack_require__.r(__webpack_exports__);
  125260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  125261. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125262. var name = 'kernelBlurFragment2';
  125263. 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";
  125264. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125265. /** @hidden */
  125266. var kernelBlurFragment2 = { name: name, shader: shader };
  125267. /***/ }),
  125268. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  125269. /*!****************************************************************!*\
  125270. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  125271. \****************************************************************/
  125272. /*! exports provided: kernelBlurVaryingDeclaration */
  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__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  125277. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125278. var name = 'kernelBlurVaryingDeclaration';
  125279. var shader = "varying vec2 sampleCoord{X};";
  125280. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125281. /** @hidden */
  125282. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  125283. /***/ }),
  125284. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  125285. /*!****************************************************!*\
  125286. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  125287. \****************************************************/
  125288. /*! exports provided: kernelBlurVertex */
  125289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125290. "use strict";
  125291. __webpack_require__.r(__webpack_exports__);
  125292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  125293. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125294. var name = 'kernelBlurVertex';
  125295. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  125296. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125297. /** @hidden */
  125298. var kernelBlurVertex = { name: name, shader: shader };
  125299. /***/ }),
  125300. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  125301. /*!*************************************************!*\
  125302. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  125303. \*************************************************/
  125304. /*! exports provided: lightFragment */
  125305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125306. "use strict";
  125307. __webpack_require__.r(__webpack_exports__);
  125308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  125309. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125310. var name = 'lightFragment';
  125311. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\n\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicTangent,anisotropicBitangent,anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\n\npreInfo.roughness=sheenIntensity;\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef CLEARCOAT\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearCoatRoughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearCoatNormalW,clearCoatAARoughnessFactors.x,clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatLightingAbsorption(clearCoatNdotVRefract,preInfo.L,clearCoatNormalW,clearCoatColor,clearCoatThickness,clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\n\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif";
  125312. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125313. /** @hidden */
  125314. var lightFragment = { name: name, shader: shader };
  125315. /***/ }),
  125316. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  125317. /*!************************************************************!*\
  125318. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  125319. \************************************************************/
  125320. /*! exports provided: lightFragmentDeclaration */
  125321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125322. "use strict";
  125323. __webpack_require__.r(__webpack_exports__);
  125324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  125325. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125326. var name = 'lightFragmentDeclaration';
  125327. 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";
  125328. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125329. /** @hidden */
  125330. var lightFragmentDeclaration = { name: name, shader: shader };
  125331. /***/ }),
  125332. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  125333. /*!*******************************************************!*\
  125334. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  125335. \*******************************************************/
  125336. /*! exports provided: lightUboDeclaration */
  125337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125338. "use strict";
  125339. __webpack_require__.r(__webpack_exports__);
  125340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  125341. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125342. var name = 'lightUboDeclaration';
  125343. 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";
  125344. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125345. /** @hidden */
  125346. var lightUboDeclaration = { name: name, shader: shader };
  125347. /***/ }),
  125348. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  125349. /*!***********************************************************!*\
  125350. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  125351. \***********************************************************/
  125352. /*! exports provided: lightsFragmentFunctions */
  125353. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125354. "use strict";
  125355. __webpack_require__.r(__webpack_exports__);
  125356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  125357. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125358. var name = 'lightsFragmentFunctions';
  125359. 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}";
  125360. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125361. /** @hidden */
  125362. var lightsFragmentFunctions = { name: name, shader: shader };
  125363. /***/ }),
  125364. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  125365. /*!*******************************************************!*\
  125366. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  125367. \*******************************************************/
  125368. /*! exports provided: logDepthDeclaration */
  125369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125370. "use strict";
  125371. __webpack_require__.r(__webpack_exports__);
  125372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  125373. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125374. var name = 'logDepthDeclaration';
  125375. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  125376. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125377. /** @hidden */
  125378. var logDepthDeclaration = { name: name, shader: shader };
  125379. /***/ }),
  125380. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  125381. /*!****************************************************!*\
  125382. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  125383. \****************************************************/
  125384. /*! exports provided: logDepthFragment */
  125385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125386. "use strict";
  125387. __webpack_require__.r(__webpack_exports__);
  125388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  125389. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125390. var name = 'logDepthFragment';
  125391. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  125392. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125393. /** @hidden */
  125394. var logDepthFragment = { name: name, shader: shader };
  125395. /***/ }),
  125396. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  125397. /*!**************************************************!*\
  125398. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  125399. \**************************************************/
  125400. /*! exports provided: logDepthVertex */
  125401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125402. "use strict";
  125403. __webpack_require__.r(__webpack_exports__);
  125404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  125405. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125406. var name = 'logDepthVertex';
  125407. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  125408. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125409. /** @hidden */
  125410. var logDepthVertex = { name: name, shader: shader };
  125411. /***/ }),
  125412. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  125413. /*!******************************************************!*\
  125414. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  125415. \******************************************************/
  125416. /*! exports provided: morphTargetsVertex */
  125417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125418. "use strict";
  125419. __webpack_require__.r(__webpack_exports__);
  125420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  125421. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125422. var name = 'morphTargetsVertex';
  125423. 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";
  125424. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125425. /** @hidden */
  125426. var morphTargetsVertex = { name: name, shader: shader };
  125427. /***/ }),
  125428. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  125429. /*!*****************************************************************!*\
  125430. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  125431. \*****************************************************************/
  125432. /*! exports provided: morphTargetsVertexDeclaration */
  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__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  125437. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125438. var name = 'morphTargetsVertexDeclaration';
  125439. 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";
  125440. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125441. /** @hidden */
  125442. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  125443. /***/ }),
  125444. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  125445. /*!***********************************************************************!*\
  125446. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  125447. \***********************************************************************/
  125448. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  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__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  125453. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125454. var name = 'morphTargetsVertexGlobalDeclaration';
  125455. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  125456. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125457. /** @hidden */
  125458. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  125459. /***/ }),
  125460. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  125461. /*!**********************************************************!*\
  125462. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  125463. \**********************************************************/
  125464. /*! exports provided: mrtFragmentDeclaration */
  125465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125466. "use strict";
  125467. __webpack_require__.r(__webpack_exports__);
  125468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  125469. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125470. var name = 'mrtFragmentDeclaration';
  125471. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  125472. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125473. /** @hidden */
  125474. var mrtFragmentDeclaration = { name: name, shader: shader };
  125475. /***/ }),
  125476. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  125477. /*!********************************************!*\
  125478. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  125479. \********************************************/
  125480. /*! exports provided: pbrDebug */
  125481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125482. "use strict";
  125483. __webpack_require__.r(__webpack_exports__);
  125484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  125485. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125486. var name = 'pbrDebug';
  125487. var shader = "#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w<vDebugMode.x) {\nreturn;\n}\n\n#if DEBUGMODE == 1\ngl_FragColor.rgb=vPositionW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 2 && defined(NORMAL)\ngl_FragColor.rgb=vNormalW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 3 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 4 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 5\n\ngl_FragColor.rgb=normalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 6 && defined(MAINUV1)\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\n#elif DEBUGMODE == 7 && defined(MAINUV2)\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\n#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 10 && defined(CLEARCOAT)\n\ngl_FragColor.rgb=clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 12 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicTangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 13 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicBitangent;\n#define DEBUGMODE_NORMALIZE\n\n#elif DEBUGMODE == 20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE == 21 && defined(AMBIENT)\ngl_FragColor.rgb=ambientOcclusionColorMap.rgb;\n#elif DEBUGMODE == 22 && defined(OPACITY)\ngl_FragColor.rgb=opacityMap.rgb;\n#elif DEBUGMODE == 23 && defined(EMISSIVE)\ngl_FragColor.rgb=emissiveColorTex.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 24 && defined(LIGHTMAP)\ngl_FragColor.rgb=lightmapColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=clearCoatMapData.rgb;\n#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearCoatTintMapData.rgb;\n#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\ngl_FragColor.rgb=sheenMapData.rgb;\n#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\ngl_FragColor.rgb=anisotropyMapData.rgb;\n\n#elif DEBUGMODE == 40 && defined(REFRACTION)\n\ngl_FragColor.rgb=environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 41 && defined(REFLECTION)\ngl_FragColor.rgb=environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=environmentClearCoatRadiance;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 53 && defined(SHEEN)\ngl_FragColor.rgb=sheenBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 54 && defined(REFLECTION)\ngl_FragColor.rgb=environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 61\ngl_FragColor.rgb=specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 62\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 65 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 66 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatRoughness);\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatNdotV);\n\n#elif DEBUGMODE == 70 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 71 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 72 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 73 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 74 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 75 && defined(SHEEN)\ngl_FragColor.rgb=sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 76 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 77\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#endif";
  125488. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125489. /** @hidden */
  125490. var pbrDebug = { name: name, shader: shader };
  125491. /***/ }),
  125492. /***/ "./Shaders/ShadersInclude/pbrFalloffLightingFunctions.ts":
  125493. /*!***************************************************************!*\
  125494. !*** ./Shaders/ShadersInclude/pbrFalloffLightingFunctions.ts ***!
  125495. \***************************************************************/
  125496. /*! exports provided: pbrFalloffLightingFunctions */
  125497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125498. "use strict";
  125499. __webpack_require__.r(__webpack_exports__);
  125500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFalloffLightingFunctions", function() { return pbrFalloffLightingFunctions; });
  125501. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125502. var name = 'pbrFalloffLightingFunctions';
  125503. 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}";
  125504. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125505. /** @hidden */
  125506. var pbrFalloffLightingFunctions = { name: name, shader: shader };
  125507. /***/ }),
  125508. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  125509. /*!**********************************************************!*\
  125510. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  125511. \**********************************************************/
  125512. /*! exports provided: pbrFragmentDeclaration */
  125513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125514. "use strict";
  125515. __webpack_require__.r(__webpack_exports__);
  125516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  125517. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125518. var name = 'pbrFragmentDeclaration';
  125519. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif";
  125520. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125521. /** @hidden */
  125522. var pbrFragmentDeclaration = { name: name, shader: shader };
  125523. /***/ }),
  125524. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  125525. /*!************************************************!*\
  125526. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  125527. \************************************************/
  125528. /*! exports provided: pbrFunctions */
  125529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125530. "use strict";
  125531. __webpack_require__.r(__webpack_exports__);
  125532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  125533. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125534. var name = 'pbrFunctions';
  125535. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n#define MINIMUMVARIANCE 0.0005\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#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,vec2 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\nvec2 getBRDFLookup(float NdotV,float perceptualRoughness,sampler2D brdfSampler) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec2 brdfLookup=texture2D(brdfSampler,UV).xy;\nreturn brdfLookup;\n}\n\nvec2 getCharlieSheenAnalyticalBRDFLookup_RomainGuy(float NoV,float roughness) {\nconst vec3 c0=vec3(0.95,1250.0,0.0095);\nconst vec4 c1=vec4(0.04,0.2,0.3,0.2);\nfloat a=1.0-NoV;\nfloat b=1.0-roughness;\nfloat n=pow(c1.x+a,64.0);\nfloat e=b-c0.x;\nfloat g=exp2(-(e*e)*c0.y);\nfloat f=b+c1.y;\nfloat a2=a*a;\nfloat a3=a2*a;\nfloat c=n*g+c1.z*(a+c1.w)*roughness+f*f*a3*a3*a2;\nfloat r=min(c,18.0);\nreturn vec2(r,r*c0.z);\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,vec2 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,float NdotV,float sheenAlphaG) {\nvec2 environmentSheenBrdf=getCharlieSheenAnalyticalBRDFLookup_RomainGuy(NdotV,sheenAlphaG);\nvec3 reflectance=reflectance0*environmentSheenBrdf.x+environmentSheenBrdf.y;\nreturn reflectance;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn clamp(f0*(f0*0.526868+0.529324)-0.0482256,0.,1.);\n#else\nreturn clamp(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998,0.,1.);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\nfloat visibility_Kelemen(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n\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\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotV,float NdotL,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\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}\n\n\n\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn exp(alpha*-(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\n\n\n\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness) {\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);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat visibility=smithVisibility_GGXCorrelated(NdotL,NdotV,alphaG);\n#else\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(NdotL,NdotV,alphaG);\n#endif\nfloat specTerm=max(0.,visibility*distribution);\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\n#ifdef SHEEN\nvec3 computeSheenTerm(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_CharlieSheen(NdotH,alphaG);\nfloat visibility=visibility_Ashikhmin(NdotL,NdotV);\nfloat specTerm=max(0.,visibility*distribution);\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn vec3(specTerm);\n}\n#endif\n#ifdef ANISOTROPIC\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}\n#endif\n#ifdef CLEARCOAT\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=visibility_Kelemen(VdotH);\nfloat clearCoatTerm=max(0.,visibility*distribution);\nfloat fresnel=fresnelSchlickGGX(VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nreturn vec2(fresnel*clearCoatTerm,1.0-fresnel);\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\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}";
  125536. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125537. /** @hidden */
  125538. var pbrFunctions = { name: name, shader: shader };
  125539. /***/ }),
  125540. /***/ "./Shaders/ShadersInclude/pbrLightingFunctions.ts":
  125541. /*!********************************************************!*\
  125542. !*** ./Shaders/ShadersInclude/pbrLightingFunctions.ts ***!
  125543. \********************************************************/
  125544. /*! exports provided: pbrLightingFunctions */
  125545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125546. "use strict";
  125547. __webpack_require__.r(__webpack_exports__);
  125548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightingFunctions", function() { return pbrLightingFunctions; });
  125549. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125550. var name = 'pbrLightingFunctions';
  125551. var shader = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\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}\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=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}\n#endif\n#ifdef CLEARCOAT\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 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=clamp(dot(Ncc,LRefract),0.00000000001,1.0);\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=clamp(dot(N,info.H),0.000000000001,1.0);\nvec3 specTerm=computeSheenTerm(NdotH,info.NdotL,info.NdotV,info.VdotH,info.roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\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";
  125552. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125553. /** @hidden */
  125554. var pbrLightingFunctions = { name: name, shader: shader };
  125555. /***/ }),
  125556. /***/ "./Shaders/ShadersInclude/pbrPreLightingFunctions.ts":
  125557. /*!***********************************************************!*\
  125558. !*** ./Shaders/ShadersInclude/pbrPreLightingFunctions.ts ***!
  125559. \***********************************************************/
  125560. /*! exports provided: pbrPreLightingFunctions */
  125561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125562. "use strict";
  125563. __webpack_require__.r(__webpack_exports__);
  125564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPreLightingFunctions", function() { return pbrPreLightingFunctions; });
  125565. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125566. var name = 'pbrPreLightingFunctions';
  125567. 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}";
  125568. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125569. /** @hidden */
  125570. var pbrPreLightingFunctions = { name: name, shader: shader };
  125571. /***/ }),
  125572. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  125573. /*!*****************************************************!*\
  125574. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  125575. \*****************************************************/
  125576. /*! exports provided: pbrUboDeclaration */
  125577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125578. "use strict";
  125579. __webpack_require__.r(__webpack_exports__);
  125580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  125581. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125582. var name = 'pbrUboDeclaration';
  125583. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  125584. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125585. /** @hidden */
  125586. var pbrUboDeclaration = { name: name, shader: shader };
  125587. /***/ }),
  125588. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  125589. /*!********************************************************!*\
  125590. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  125591. \********************************************************/
  125592. /*! exports provided: pbrVertexDeclaration */
  125593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125594. "use strict";
  125595. __webpack_require__.r(__webpack_exports__);
  125596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  125597. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125598. var name = 'pbrVertexDeclaration';
  125599. var shader = "uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n";
  125600. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125601. /** @hidden */
  125602. var pbrVertexDeclaration = { name: name, shader: shader };
  125603. /***/ }),
  125604. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  125605. /*!****************************************************!*\
  125606. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  125607. \****************************************************/
  125608. /*! exports provided: pointCloudVertex */
  125609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125610. "use strict";
  125611. __webpack_require__.r(__webpack_exports__);
  125612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  125613. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125614. var name = 'pointCloudVertex';
  125615. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  125616. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125617. /** @hidden */
  125618. var pointCloudVertex = { name: name, shader: shader };
  125619. /***/ }),
  125620. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  125621. /*!******************************************************!*\
  125622. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  125623. \******************************************************/
  125624. /*! exports provided: reflectionFunction */
  125625. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125626. "use strict";
  125627. __webpack_require__.r(__webpack_exports__);
  125628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  125629. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125630. var name = 'reflectionFunction';
  125631. 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}";
  125632. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125633. /** @hidden */
  125634. var reflectionFunction = { name: name, shader: shader };
  125635. /***/ }),
  125636. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  125637. /*!************************************************************!*\
  125638. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  125639. \************************************************************/
  125640. /*! exports provided: shadowsFragmentFunctions */
  125641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125642. "use strict";
  125643. __webpack_require__.r(__webpack_exports__);
  125644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  125645. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125646. var name = 'shadowsFragmentFunctions';
  125647. 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";
  125648. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125649. /** @hidden */
  125650. var shadowsFragmentFunctions = { name: name, shader: shader };
  125651. /***/ }),
  125652. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  125653. /*!*************************************************!*\
  125654. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  125655. \*************************************************/
  125656. /*! exports provided: shadowsVertex */
  125657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125658. "use strict";
  125659. __webpack_require__.r(__webpack_exports__);
  125660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  125661. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125662. var name = 'shadowsVertex';
  125663. 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";
  125664. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125665. /** @hidden */
  125666. var shadowsVertex = { name: name, shader: shader };
  125667. /***/ }),
  125668. /***/ "./Shaders/anaglyph.fragment.ts":
  125669. /*!**************************************!*\
  125670. !*** ./Shaders/anaglyph.fragment.ts ***!
  125671. \**************************************/
  125672. /*! exports provided: anaglyphPixelShader */
  125673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125674. "use strict";
  125675. __webpack_require__.r(__webpack_exports__);
  125676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  125677. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125678. var name = 'anaglyphPixelShader';
  125679. 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}";
  125680. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125681. /** @hidden */
  125682. var anaglyphPixelShader = { name: name, shader: shader };
  125683. /***/ }),
  125684. /***/ "./Shaders/background.fragment.ts":
  125685. /*!****************************************!*\
  125686. !*** ./Shaders/background.fragment.ts ***!
  125687. \****************************************/
  125688. /*! exports provided: backgroundPixelShader */
  125689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125690. "use strict";
  125691. __webpack_require__.r(__webpack_exports__);
  125692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  125693. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125694. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  125695. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  125696. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  125697. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  125698. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125699. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125700. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125701. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  125702. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  125703. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  125704. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  125705. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  125706. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  125707. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  125708. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  125709. var name = 'backgroundPixelShader';
  125710. 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";
  125711. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125712. /** @hidden */
  125713. var backgroundPixelShader = { name: name, shader: shader };
  125714. /***/ }),
  125715. /***/ "./Shaders/background.vertex.ts":
  125716. /*!**************************************!*\
  125717. !*** ./Shaders/background.vertex.ts ***!
  125718. \**************************************/
  125719. /*! exports provided: backgroundVertexShader */
  125720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125721. "use strict";
  125722. __webpack_require__.r(__webpack_exports__);
  125723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  125724. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125725. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  125726. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  125727. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125728. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125729. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125730. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  125731. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  125732. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125733. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125734. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125735. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125736. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  125737. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  125738. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  125739. var name = 'backgroundVertexShader';
  125740. 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";
  125741. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125742. /** @hidden */
  125743. var backgroundVertexShader = { name: name, shader: shader };
  125744. /***/ }),
  125745. /***/ "./Shaders/blackAndWhite.fragment.ts":
  125746. /*!*******************************************!*\
  125747. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  125748. \*******************************************/
  125749. /*! exports provided: blackAndWhitePixelShader */
  125750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125751. "use strict";
  125752. __webpack_require__.r(__webpack_exports__);
  125753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  125754. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125755. var name = 'blackAndWhitePixelShader';
  125756. 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}";
  125757. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125758. /** @hidden */
  125759. var blackAndWhitePixelShader = { name: name, shader: shader };
  125760. /***/ }),
  125761. /***/ "./Shaders/bloomMerge.fragment.ts":
  125762. /*!****************************************!*\
  125763. !*** ./Shaders/bloomMerge.fragment.ts ***!
  125764. \****************************************/
  125765. /*! exports provided: bloomMergePixelShader */
  125766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125767. "use strict";
  125768. __webpack_require__.r(__webpack_exports__);
  125769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  125770. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125771. var name = 'bloomMergePixelShader';
  125772. 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";
  125773. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125774. /** @hidden */
  125775. var bloomMergePixelShader = { name: name, shader: shader };
  125776. /***/ }),
  125777. /***/ "./Shaders/chromaticAberration.fragment.ts":
  125778. /*!*************************************************!*\
  125779. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  125780. \*************************************************/
  125781. /*! exports provided: chromaticAberrationPixelShader */
  125782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125783. "use strict";
  125784. __webpack_require__.r(__webpack_exports__);
  125785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  125786. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125787. var name = 'chromaticAberrationPixelShader';
  125788. 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}";
  125789. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125790. /** @hidden */
  125791. var chromaticAberrationPixelShader = { name: name, shader: shader };
  125792. /***/ }),
  125793. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  125794. /*!***********************************************!*\
  125795. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  125796. \***********************************************/
  125797. /*! exports provided: circleOfConfusionPixelShader */
  125798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125799. "use strict";
  125800. __webpack_require__.r(__webpack_exports__);
  125801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  125802. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125803. var name = 'circleOfConfusionPixelShader';
  125804. 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";
  125805. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125806. /** @hidden */
  125807. var circleOfConfusionPixelShader = { name: name, shader: shader };
  125808. /***/ }),
  125809. /***/ "./Shaders/color.fragment.ts":
  125810. /*!***********************************!*\
  125811. !*** ./Shaders/color.fragment.ts ***!
  125812. \***********************************/
  125813. /*! exports provided: colorPixelShader */
  125814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125815. "use strict";
  125816. __webpack_require__.r(__webpack_exports__);
  125817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  125818. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125819. var name = 'colorPixelShader';
  125820. 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}";
  125821. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125822. /** @hidden */
  125823. var colorPixelShader = { name: name, shader: shader };
  125824. /***/ }),
  125825. /***/ "./Shaders/color.vertex.ts":
  125826. /*!*********************************!*\
  125827. !*** ./Shaders/color.vertex.ts ***!
  125828. \*********************************/
  125829. /*! exports provided: colorVertexShader */
  125830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125831. "use strict";
  125832. __webpack_require__.r(__webpack_exports__);
  125833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  125834. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125835. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125836. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125837. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125838. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125839. var name = 'colorVertexShader';
  125840. 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}";
  125841. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125842. /** @hidden */
  125843. var colorVertexShader = { name: name, shader: shader };
  125844. /***/ }),
  125845. /***/ "./Shaders/colorCorrection.fragment.ts":
  125846. /*!*********************************************!*\
  125847. !*** ./Shaders/colorCorrection.fragment.ts ***!
  125848. \*********************************************/
  125849. /*! exports provided: colorCorrectionPixelShader */
  125850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125851. "use strict";
  125852. __webpack_require__.r(__webpack_exports__);
  125853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  125854. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125855. var name = 'colorCorrectionPixelShader';
  125856. 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}";
  125857. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125858. /** @hidden */
  125859. var colorCorrectionPixelShader = { name: name, shader: shader };
  125860. /***/ }),
  125861. /***/ "./Shaders/convolution.fragment.ts":
  125862. /*!*****************************************!*\
  125863. !*** ./Shaders/convolution.fragment.ts ***!
  125864. \*****************************************/
  125865. /*! exports provided: convolutionPixelShader */
  125866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125867. "use strict";
  125868. __webpack_require__.r(__webpack_exports__);
  125869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  125870. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125871. var name = 'convolutionPixelShader';
  125872. 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}";
  125873. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125874. /** @hidden */
  125875. var convolutionPixelShader = { name: name, shader: shader };
  125876. /***/ }),
  125877. /***/ "./Shaders/default.fragment.ts":
  125878. /*!*************************************!*\
  125879. !*** ./Shaders/default.fragment.ts ***!
  125880. \*************************************/
  125881. /*! exports provided: defaultPixelShader */
  125882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125883. "use strict";
  125884. __webpack_require__.r(__webpack_exports__);
  125885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  125886. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125887. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  125888. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  125889. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125890. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125891. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125892. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  125893. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  125894. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  125895. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  125896. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  125897. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  125898. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  125899. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  125900. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  125901. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  125902. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  125903. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  125904. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  125905. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  125906. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  125907. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  125908. var name = 'defaultPixelShader';
  125909. 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";
  125910. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125911. /** @hidden */
  125912. var defaultPixelShader = { name: name, shader: shader };
  125913. /***/ }),
  125914. /***/ "./Shaders/default.vertex.ts":
  125915. /*!***********************************!*\
  125916. !*** ./Shaders/default.vertex.ts ***!
  125917. \***********************************/
  125918. /*! exports provided: defaultVertexShader */
  125919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125920. "use strict";
  125921. __webpack_require__.r(__webpack_exports__);
  125922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  125923. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125924. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  125925. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  125926. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125927. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125928. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125929. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  125930. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  125931. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  125932. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125933. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125934. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  125935. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  125936. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  125937. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  125938. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125939. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125940. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  125941. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  125942. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  125943. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  125944. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  125945. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  125946. var name = 'defaultVertexShader';
  125947. 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";
  125948. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125949. /** @hidden */
  125950. var defaultVertexShader = { name: name, shader: shader };
  125951. /***/ }),
  125952. /***/ "./Shaders/depth.fragment.ts":
  125953. /*!***********************************!*\
  125954. !*** ./Shaders/depth.fragment.ts ***!
  125955. \***********************************/
  125956. /*! exports provided: depthPixelShader */
  125957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125958. "use strict";
  125959. __webpack_require__.r(__webpack_exports__);
  125960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  125961. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125962. var name = 'depthPixelShader';
  125963. 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}";
  125964. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125965. /** @hidden */
  125966. var depthPixelShader = { name: name, shader: shader };
  125967. /***/ }),
  125968. /***/ "./Shaders/depth.vertex.ts":
  125969. /*!*********************************!*\
  125970. !*** ./Shaders/depth.vertex.ts ***!
  125971. \*********************************/
  125972. /*! exports provided: depthVertexShader */
  125973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125974. "use strict";
  125975. __webpack_require__.r(__webpack_exports__);
  125976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  125977. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125978. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125979. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125980. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125981. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125982. var name = 'depthVertexShader';
  125983. 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}";
  125984. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125985. /** @hidden */
  125986. var depthVertexShader = { name: name, shader: shader };
  125987. /***/ }),
  125988. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  125989. /*!******************************************!*\
  125990. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  125991. \******************************************/
  125992. /*! exports provided: depthBoxBlurPixelShader */
  125993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125994. "use strict";
  125995. __webpack_require__.r(__webpack_exports__);
  125996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  125997. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125998. var name = 'depthBoxBlurPixelShader';
  125999. 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}";
  126000. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126001. /** @hidden */
  126002. var depthBoxBlurPixelShader = { name: name, shader: shader };
  126003. /***/ }),
  126004. /***/ "./Shaders/depthOfField.fragment.ts":
  126005. /*!******************************************!*\
  126006. !*** ./Shaders/depthOfField.fragment.ts ***!
  126007. \******************************************/
  126008. /*! exports provided: depthOfFieldPixelShader */
  126009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126010. "use strict";
  126011. __webpack_require__.r(__webpack_exports__);
  126012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  126013. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126014. var name = 'depthOfFieldPixelShader';
  126015. 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";
  126016. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126017. /** @hidden */
  126018. var depthOfFieldPixelShader = { name: name, shader: shader };
  126019. /***/ }),
  126020. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  126021. /*!***********************************************!*\
  126022. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  126023. \***********************************************/
  126024. /*! exports provided: depthOfFieldMergePixelShader */
  126025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126026. "use strict";
  126027. __webpack_require__.r(__webpack_exports__);
  126028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  126029. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126030. var name = 'depthOfFieldMergePixelShader';
  126031. 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";
  126032. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126033. /** @hidden */
  126034. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  126035. /***/ }),
  126036. /***/ "./Shaders/displayPass.fragment.ts":
  126037. /*!*****************************************!*\
  126038. !*** ./Shaders/displayPass.fragment.ts ***!
  126039. \*****************************************/
  126040. /*! exports provided: displayPassPixelShader */
  126041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126042. "use strict";
  126043. __webpack_require__.r(__webpack_exports__);
  126044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  126045. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126046. var name = 'displayPassPixelShader';
  126047. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  126048. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126049. /** @hidden */
  126050. var displayPassPixelShader = { name: name, shader: shader };
  126051. /***/ }),
  126052. /***/ "./Shaders/extractHighlights.fragment.ts":
  126053. /*!***********************************************!*\
  126054. !*** ./Shaders/extractHighlights.fragment.ts ***!
  126055. \***********************************************/
  126056. /*! exports provided: extractHighlightsPixelShader */
  126057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126058. "use strict";
  126059. __webpack_require__.r(__webpack_exports__);
  126060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  126061. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126062. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126063. var name = 'extractHighlightsPixelShader';
  126064. 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}";
  126065. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126066. /** @hidden */
  126067. var extractHighlightsPixelShader = { name: name, shader: shader };
  126068. /***/ }),
  126069. /***/ "./Shaders/filter.fragment.ts":
  126070. /*!************************************!*\
  126071. !*** ./Shaders/filter.fragment.ts ***!
  126072. \************************************/
  126073. /*! exports provided: filterPixelShader */
  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__, "filterPixelShader", function() { return filterPixelShader; });
  126078. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126079. var name = 'filterPixelShader';
  126080. 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}";
  126081. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126082. /** @hidden */
  126083. var filterPixelShader = { name: name, shader: shader };
  126084. /***/ }),
  126085. /***/ "./Shaders/fxaa.fragment.ts":
  126086. /*!**********************************!*\
  126087. !*** ./Shaders/fxaa.fragment.ts ***!
  126088. \**********************************/
  126089. /*! exports provided: fxaaPixelShader */
  126090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126091. "use strict";
  126092. __webpack_require__.r(__webpack_exports__);
  126093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  126094. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126095. var name = 'fxaaPixelShader';
  126096. 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}";
  126097. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126098. /** @hidden */
  126099. var fxaaPixelShader = { name: name, shader: shader };
  126100. /***/ }),
  126101. /***/ "./Shaders/fxaa.vertex.ts":
  126102. /*!********************************!*\
  126103. !*** ./Shaders/fxaa.vertex.ts ***!
  126104. \********************************/
  126105. /*! exports provided: fxaaVertexShader */
  126106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126107. "use strict";
  126108. __webpack_require__.r(__webpack_exports__);
  126109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  126110. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126111. var name = 'fxaaVertexShader';
  126112. 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}";
  126113. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126114. /** @hidden */
  126115. var fxaaVertexShader = { name: name, shader: shader };
  126116. /***/ }),
  126117. /***/ "./Shaders/geometry.fragment.ts":
  126118. /*!**************************************!*\
  126119. !*** ./Shaders/geometry.fragment.ts ***!
  126120. \**************************************/
  126121. /*! exports provided: geometryPixelShader */
  126122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126123. "use strict";
  126124. __webpack_require__.r(__webpack_exports__);
  126125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  126126. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126127. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  126128. var name = 'geometryPixelShader';
  126129. 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}";
  126130. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126131. /** @hidden */
  126132. var geometryPixelShader = { name: name, shader: shader };
  126133. /***/ }),
  126134. /***/ "./Shaders/geometry.vertex.ts":
  126135. /*!************************************!*\
  126136. !*** ./Shaders/geometry.vertex.ts ***!
  126137. \************************************/
  126138. /*! exports provided: geometryVertexShader */
  126139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126140. "use strict";
  126141. __webpack_require__.r(__webpack_exports__);
  126142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  126143. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126144. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  126145. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  126146. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  126147. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  126148. var name = 'geometryVertexShader';
  126149. 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}";
  126150. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126151. /** @hidden */
  126152. var geometryVertexShader = { name: name, shader: shader };
  126153. /***/ }),
  126154. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  126155. /*!*************************************************!*\
  126156. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  126157. \*************************************************/
  126158. /*! exports provided: glowBlurPostProcessPixelShader */
  126159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126160. "use strict";
  126161. __webpack_require__.r(__webpack_exports__);
  126162. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  126163. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126164. var name = 'glowBlurPostProcessPixelShader';
  126165. 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}";
  126166. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126167. /** @hidden */
  126168. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  126169. /***/ }),
  126170. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  126171. /*!***********************************************!*\
  126172. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  126173. \***********************************************/
  126174. /*! exports provided: glowMapGenerationPixelShader */
  126175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126176. "use strict";
  126177. __webpack_require__.r(__webpack_exports__);
  126178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  126179. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126180. var name = 'glowMapGenerationPixelShader';
  126181. 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}";
  126182. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126183. /** @hidden */
  126184. var glowMapGenerationPixelShader = { name: name, shader: shader };
  126185. /***/ }),
  126186. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  126187. /*!*********************************************!*\
  126188. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  126189. \*********************************************/
  126190. /*! exports provided: glowMapGenerationVertexShader */
  126191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126192. "use strict";
  126193. __webpack_require__.r(__webpack_exports__);
  126194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  126195. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126196. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  126197. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  126198. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  126199. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  126200. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  126201. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  126202. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  126203. var name = 'glowMapGenerationVertexShader';
  126204. 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}";
  126205. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126206. /** @hidden */
  126207. var glowMapGenerationVertexShader = { name: name, shader: shader };
  126208. /***/ }),
  126209. /***/ "./Shaders/glowMapMerge.fragment.ts":
  126210. /*!******************************************!*\
  126211. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  126212. \******************************************/
  126213. /*! exports provided: glowMapMergePixelShader */
  126214. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126215. "use strict";
  126216. __webpack_require__.r(__webpack_exports__);
  126217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  126218. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126219. var name = 'glowMapMergePixelShader';
  126220. 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}";
  126221. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126222. /** @hidden */
  126223. var glowMapMergePixelShader = { name: name, shader: shader };
  126224. /***/ }),
  126225. /***/ "./Shaders/glowMapMerge.vertex.ts":
  126226. /*!****************************************!*\
  126227. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  126228. \****************************************/
  126229. /*! exports provided: glowMapMergeVertexShader */
  126230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126231. "use strict";
  126232. __webpack_require__.r(__webpack_exports__);
  126233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  126234. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126235. var name = 'glowMapMergeVertexShader';
  126236. 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}";
  126237. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126238. /** @hidden */
  126239. var glowMapMergeVertexShader = { name: name, shader: shader };
  126240. /***/ }),
  126241. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  126242. /*!************************************************!*\
  126243. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  126244. \************************************************/
  126245. /*! exports provided: gpuRenderParticlesPixelShader */
  126246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126247. "use strict";
  126248. __webpack_require__.r(__webpack_exports__);
  126249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  126250. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126251. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  126252. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  126253. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126254. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  126255. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  126256. var name = 'gpuRenderParticlesPixelShader';
  126257. 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";
  126258. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126259. /** @hidden */
  126260. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  126261. /***/ }),
  126262. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  126263. /*!**********************************************!*\
  126264. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  126265. \**********************************************/
  126266. /*! exports provided: gpuRenderParticlesVertexShader */
  126267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126268. "use strict";
  126269. __webpack_require__.r(__webpack_exports__);
  126270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  126271. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126272. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  126273. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  126274. var name = 'gpuRenderParticlesVertexShader';
  126275. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\nuniform vec3 worldOffset;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn (position+worldOffset)+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn (position+worldOffset)+alignedCorner;\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=(position+worldOffset)-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=(position+worldOffset)-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";
  126276. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126277. /** @hidden */
  126278. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  126279. /***/ }),
  126280. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  126281. /*!************************************************!*\
  126282. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  126283. \************************************************/
  126284. /*! exports provided: gpuUpdateParticlesPixelShader */
  126285. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126286. "use strict";
  126287. __webpack_require__.r(__webpack_exports__);
  126288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  126289. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126290. var name = 'gpuUpdateParticlesPixelShader';
  126291. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  126292. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126293. /** @hidden */
  126294. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  126295. /***/ }),
  126296. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  126297. /*!**********************************************!*\
  126298. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  126299. \**********************************************/
  126300. /*! exports provided: gpuUpdateParticlesVertexShader */
  126301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126302. "use strict";
  126303. __webpack_require__.r(__webpack_exports__);
  126304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  126305. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126306. var name = 'gpuUpdateParticlesVertexShader';
  126307. 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}";
  126308. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126309. /** @hidden */
  126310. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  126311. /***/ }),
  126312. /***/ "./Shaders/grain.fragment.ts":
  126313. /*!***********************************!*\
  126314. !*** ./Shaders/grain.fragment.ts ***!
  126315. \***********************************/
  126316. /*! exports provided: grainPixelShader */
  126317. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126318. "use strict";
  126319. __webpack_require__.r(__webpack_exports__);
  126320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  126321. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126322. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126323. var name = 'grainPixelShader';
  126324. 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}";
  126325. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126326. /** @hidden */
  126327. var grainPixelShader = { name: name, shader: shader };
  126328. /***/ }),
  126329. /***/ "./Shaders/highlights.fragment.ts":
  126330. /*!****************************************!*\
  126331. !*** ./Shaders/highlights.fragment.ts ***!
  126332. \****************************************/
  126333. /*! exports provided: highlightsPixelShader */
  126334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126335. "use strict";
  126336. __webpack_require__.r(__webpack_exports__);
  126337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  126338. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126339. var name = 'highlightsPixelShader';
  126340. 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}";
  126341. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126342. /** @hidden */
  126343. var highlightsPixelShader = { name: name, shader: shader };
  126344. /***/ }),
  126345. /***/ "./Shaders/imageProcessing.fragment.ts":
  126346. /*!*********************************************!*\
  126347. !*** ./Shaders/imageProcessing.fragment.ts ***!
  126348. \*********************************************/
  126349. /*! exports provided: imageProcessingPixelShader */
  126350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126351. "use strict";
  126352. __webpack_require__.r(__webpack_exports__);
  126353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  126354. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126355. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  126356. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126357. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  126358. var name = 'imageProcessingPixelShader';
  126359. 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}";
  126360. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126361. /** @hidden */
  126362. var imageProcessingPixelShader = { name: name, shader: shader };
  126363. /***/ }),
  126364. /***/ "./Shaders/kernelBlur.fragment.ts":
  126365. /*!****************************************!*\
  126366. !*** ./Shaders/kernelBlur.fragment.ts ***!
  126367. \****************************************/
  126368. /*! exports provided: kernelBlurPixelShader */
  126369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126370. "use strict";
  126371. __webpack_require__.r(__webpack_exports__);
  126372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  126373. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126374. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  126375. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  126376. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  126377. var name = 'kernelBlurPixelShader';
  126378. 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}";
  126379. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126380. /** @hidden */
  126381. var kernelBlurPixelShader = { name: name, shader: shader };
  126382. /***/ }),
  126383. /***/ "./Shaders/kernelBlur.vertex.ts":
  126384. /*!**************************************!*\
  126385. !*** ./Shaders/kernelBlur.vertex.ts ***!
  126386. \**************************************/
  126387. /*! exports provided: kernelBlurVertexShader */
  126388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126389. "use strict";
  126390. __webpack_require__.r(__webpack_exports__);
  126391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  126392. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126393. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  126394. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  126395. var name = 'kernelBlurVertexShader';
  126396. 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}";
  126397. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126398. /** @hidden */
  126399. var kernelBlurVertexShader = { name: name, shader: shader };
  126400. /***/ }),
  126401. /***/ "./Shaders/layer.fragment.ts":
  126402. /*!***********************************!*\
  126403. !*** ./Shaders/layer.fragment.ts ***!
  126404. \***********************************/
  126405. /*! exports provided: layerPixelShader */
  126406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126407. "use strict";
  126408. __webpack_require__.r(__webpack_exports__);
  126409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  126410. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126411. var name = 'layerPixelShader';
  126412. 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}";
  126413. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126414. /** @hidden */
  126415. var layerPixelShader = { name: name, shader: shader };
  126416. /***/ }),
  126417. /***/ "./Shaders/layer.vertex.ts":
  126418. /*!*********************************!*\
  126419. !*** ./Shaders/layer.vertex.ts ***!
  126420. \*********************************/
  126421. /*! exports provided: layerVertexShader */
  126422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126423. "use strict";
  126424. __webpack_require__.r(__webpack_exports__);
  126425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  126426. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126427. var name = 'layerVertexShader';
  126428. 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}";
  126429. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126430. /** @hidden */
  126431. var layerVertexShader = { name: name, shader: shader };
  126432. /***/ }),
  126433. /***/ "./Shaders/lensFlare.fragment.ts":
  126434. /*!***************************************!*\
  126435. !*** ./Shaders/lensFlare.fragment.ts ***!
  126436. \***************************************/
  126437. /*! exports provided: lensFlarePixelShader */
  126438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126439. "use strict";
  126440. __webpack_require__.r(__webpack_exports__);
  126441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  126442. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126443. var name = 'lensFlarePixelShader';
  126444. 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}";
  126445. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126446. /** @hidden */
  126447. var lensFlarePixelShader = { name: name, shader: shader };
  126448. /***/ }),
  126449. /***/ "./Shaders/lensFlare.vertex.ts":
  126450. /*!*************************************!*\
  126451. !*** ./Shaders/lensFlare.vertex.ts ***!
  126452. \*************************************/
  126453. /*! exports provided: lensFlareVertexShader */
  126454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126455. "use strict";
  126456. __webpack_require__.r(__webpack_exports__);
  126457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  126458. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126459. var name = 'lensFlareVertexShader';
  126460. 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}";
  126461. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126462. /** @hidden */
  126463. var lensFlareVertexShader = { name: name, shader: shader };
  126464. /***/ }),
  126465. /***/ "./Shaders/lensHighlights.fragment.ts":
  126466. /*!********************************************!*\
  126467. !*** ./Shaders/lensHighlights.fragment.ts ***!
  126468. \********************************************/
  126469. /*! exports provided: lensHighlightsPixelShader */
  126470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126471. "use strict";
  126472. __webpack_require__.r(__webpack_exports__);
  126473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  126474. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126475. var name = 'lensHighlightsPixelShader';
  126476. 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}";
  126477. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126478. /** @hidden */
  126479. var lensHighlightsPixelShader = { name: name, shader: shader };
  126480. /***/ }),
  126481. /***/ "./Shaders/line.fragment.ts":
  126482. /*!**********************************!*\
  126483. !*** ./Shaders/line.fragment.ts ***!
  126484. \**********************************/
  126485. /*! exports provided: linePixelShader */
  126486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126487. "use strict";
  126488. __webpack_require__.r(__webpack_exports__);
  126489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  126490. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126491. var name = 'linePixelShader';
  126492. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  126493. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126494. /** @hidden */
  126495. var linePixelShader = { name: name, shader: shader };
  126496. /***/ }),
  126497. /***/ "./Shaders/line.vertex.ts":
  126498. /*!********************************!*\
  126499. !*** ./Shaders/line.vertex.ts ***!
  126500. \********************************/
  126501. /*! exports provided: lineVertexShader */
  126502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126503. "use strict";
  126504. __webpack_require__.r(__webpack_exports__);
  126505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  126506. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126507. var name = 'lineVertexShader';
  126508. 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}";
  126509. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126510. /** @hidden */
  126511. var lineVertexShader = { name: name, shader: shader };
  126512. /***/ }),
  126513. /***/ "./Shaders/motionBlur.fragment.ts":
  126514. /*!****************************************!*\
  126515. !*** ./Shaders/motionBlur.fragment.ts ***!
  126516. \****************************************/
  126517. /*! exports provided: motionBlurPixelShader */
  126518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126519. "use strict";
  126520. __webpack_require__.r(__webpack_exports__);
  126521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  126522. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126523. var name = 'motionBlurPixelShader';
  126524. 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";
  126525. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126526. /** @hidden */
  126527. var motionBlurPixelShader = { name: name, shader: shader };
  126528. /***/ }),
  126529. /***/ "./Shaders/noise.fragment.ts":
  126530. /*!***********************************!*\
  126531. !*** ./Shaders/noise.fragment.ts ***!
  126532. \***********************************/
  126533. /*! exports provided: noisePixelShader */
  126534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126535. "use strict";
  126536. __webpack_require__.r(__webpack_exports__);
  126537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  126538. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126539. var name = 'noisePixelShader';
  126540. 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";
  126541. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126542. /** @hidden */
  126543. var noisePixelShader = { name: name, shader: shader };
  126544. /***/ }),
  126545. /***/ "./Shaders/outline.fragment.ts":
  126546. /*!*************************************!*\
  126547. !*** ./Shaders/outline.fragment.ts ***!
  126548. \*************************************/
  126549. /*! exports provided: outlinePixelShader */
  126550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126551. "use strict";
  126552. __webpack_require__.r(__webpack_exports__);
  126553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  126554. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126555. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  126556. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  126557. var name = 'outlinePixelShader';
  126558. 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}";
  126559. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126560. /** @hidden */
  126561. var outlinePixelShader = { name: name, shader: shader };
  126562. /***/ }),
  126563. /***/ "./Shaders/outline.vertex.ts":
  126564. /*!***********************************!*\
  126565. !*** ./Shaders/outline.vertex.ts ***!
  126566. \***********************************/
  126567. /*! exports provided: outlineVertexShader */
  126568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126569. "use strict";
  126570. __webpack_require__.r(__webpack_exports__);
  126571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  126572. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126573. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  126574. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  126575. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  126576. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  126577. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  126578. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  126579. var name = 'outlineVertexShader';
  126580. 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";
  126581. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126582. /** @hidden */
  126583. var outlineVertexShader = { name: name, shader: shader };
  126584. /***/ }),
  126585. /***/ "./Shaders/particles.fragment.ts":
  126586. /*!***************************************!*\
  126587. !*** ./Shaders/particles.fragment.ts ***!
  126588. \***************************************/
  126589. /*! exports provided: particlesPixelShader */
  126590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126591. "use strict";
  126592. __webpack_require__.r(__webpack_exports__);
  126593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  126594. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126595. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  126596. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  126597. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126598. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  126599. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  126600. var name = 'particlesPixelShader';
  126601. 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}";
  126602. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126603. /** @hidden */
  126604. var particlesPixelShader = { name: name, shader: shader };
  126605. /***/ }),
  126606. /***/ "./Shaders/particles.vertex.ts":
  126607. /*!*************************************!*\
  126608. !*** ./Shaders/particles.vertex.ts ***!
  126609. \*************************************/
  126610. /*! exports provided: particlesVertexShader */
  126611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126612. "use strict";
  126613. __webpack_require__.r(__webpack_exports__);
  126614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  126615. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126616. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  126617. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  126618. var name = 'particlesVertexShader';
  126619. 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}";
  126620. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126621. /** @hidden */
  126622. var particlesVertexShader = { name: name, shader: shader };
  126623. /***/ }),
  126624. /***/ "./Shaders/pass.fragment.ts":
  126625. /*!**********************************!*\
  126626. !*** ./Shaders/pass.fragment.ts ***!
  126627. \**********************************/
  126628. /*! exports provided: passPixelShader */
  126629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126630. "use strict";
  126631. __webpack_require__.r(__webpack_exports__);
  126632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  126633. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126634. var name = 'passPixelShader';
  126635. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  126636. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126637. /** @hidden */
  126638. var passPixelShader = { name: name, shader: shader };
  126639. /***/ }),
  126640. /***/ "./Shaders/passCube.fragment.ts":
  126641. /*!**************************************!*\
  126642. !*** ./Shaders/passCube.fragment.ts ***!
  126643. \**************************************/
  126644. /*! exports provided: passCubePixelShader */
  126645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126646. "use strict";
  126647. __webpack_require__.r(__webpack_exports__);
  126648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  126649. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126650. var name = 'passCubePixelShader';
  126651. 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}";
  126652. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126653. /** @hidden */
  126654. var passCubePixelShader = { name: name, shader: shader };
  126655. /***/ }),
  126656. /***/ "./Shaders/pbr.fragment.ts":
  126657. /*!*********************************!*\
  126658. !*** ./Shaders/pbr.fragment.ts ***!
  126659. \*********************************/
  126660. /*! exports provided: pbrPixelShader */
  126661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126662. "use strict";
  126663. __webpack_require__.r(__webpack_exports__);
  126664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  126665. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126666. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  126667. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  126668. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  126669. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  126670. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  126671. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  126672. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126673. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  126674. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  126675. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  126676. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  126677. /* harmony import */ var _ShadersInclude_pbrPreLightingFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrPreLightingFunctions */ "./Shaders/ShadersInclude/pbrPreLightingFunctions.ts");
  126678. /* harmony import */ var _ShadersInclude_pbrFalloffLightingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/pbrFalloffLightingFunctions */ "./Shaders/ShadersInclude/pbrFalloffLightingFunctions.ts");
  126679. /* harmony import */ var _ShadersInclude_pbrLightingFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/pbrLightingFunctions */ "./Shaders/ShadersInclude/pbrLightingFunctions.ts");
  126680. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  126681. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  126682. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  126683. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  126684. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  126685. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  126686. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  126687. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  126688. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  126689. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  126690. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  126691. var name = 'pbrPixelShader';
  126692. 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#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\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#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#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=getReflectanceFromAnalyticalBRDFLookup_Jones(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\nfloat anisotropy=vAnisotropy.b;\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\n#ifdef ANISOTROPIC_TEXTURE\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\nanisotropy*=anisotropyMapData.b;\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\n#endif\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\nvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\nvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\nvec3 anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,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 SHEEN\nfloat sheenIntensity=vSheenColor.a;\n#ifdef SHEEN_TEXTURE\nvec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset)*vSheenInfos.y;\nsheenIntensity*=sheenMapData.a;\n#endif\n#ifdef SHEEN_LINKWITHALBEDO\nfloat sheenFactor=pow(1.0-sheenIntensity,5.0);\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\nfloat sheenRoughness=sheenIntensity;\n\nsurfaceAlbedo.rgb*=sheenFactor;\n#else\nvec3 sheenColor=vSheenColor.rgb;\n#ifdef SHEEN_TEXTURE\nsheenColor.rgb*=toLinearSpace(sheenMapData.rgb);\n#endif\nfloat sheenRoughness=roughness;\n\nsheenColor*=sheenIntensity;\nspecularEnvironmentR0*=(1.0-sheenIntensity);\n#endif\n\n#if defined(REFLECTION)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\n\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\n\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG,NdotVUnclamped);\n#else\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nsheenReflectionLOD=sheenReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nenvironmentSheenRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,sheenReflectionLOD);\n#else\nfloat lodSheenReflectionNormalized=clamp(sheenReflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodSheenReflectionNormalizedDoubled=lodSheenReflectionNormalized*2.0;\nvec4 environmentSheenMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodSheenReflectionNormalizedDoubled<1.0){\nenvironmentSheenRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSheenMid,\nlodSheenReflectionNormalizedDoubled\n);\n}else{\nenvironmentSheenRadiance=mix(\nenvironmentSheenMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodSheenReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentSheenRadiance.rgb=fromRGBD(environmentSheenRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentSheenRadiance.rgb=toLinearSpace(environmentSheenRadiance.rgb);\n#endif\n\nenvironmentSheenRadiance.rgb*=vReflectionInfos.x;\nenvironmentSheenRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#ifdef CLEARCOAT\n\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\nclearCoatIntensity*=clearCoatMapData.x;\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\nclearCoatThickness*=clearCoatTintMapData.a;\n#endif\nclearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\n#endif\n\n\n\n\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\nspecularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset).xyz*2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBN,vClearCoatBumpUV+uvOffset,clearCoatBumpSampler,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\n#endif\n#ifdef SPECULARAA\n\nvec2 clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\n#endif\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#ifdef CLEARCOAT_TINT\n\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\nfloat clearCoatNdotVRefract=clamp(dot(clearCoatNormalW,clearCoatVRefract),0.00000000001,1.0);\nvec3 absorption=vec3(0.);\n#endif\n\nenvironmentClearCoatRadiance.rgb*=vReflectionInfos.x;\nenvironmentClearCoatRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#if defined(ENVIRONMENTBRDF)\n\nvec2 environmentBrdf=getBRDFLookup(NdotV,roughness,environmentBrdfSampler);\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef SHEEN\nvec3 sheenBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\n\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(specularEnvironmentR0,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef SHEEN\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,NdotV,sheenAlphaG);\n#ifdef RADIANCEOCCLUSION\nsheenEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nsheenEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#endif\n\n#ifdef CLEARCOAT\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness,environmentBrdfSampler);\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\n\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatAbsorption(clearCoatNdotVRefract,clearCoatNdotVRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#ifdef REFLECTION\nenvironmentIrradiance*=absorption;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=absorption;\n#endif\nspecularEnvironmentReflectance*=absorption;\n#endif\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\nfloat conservationFactor=(1.-fresnelIBLClearCoat);\n#ifdef REFLECTION\nenvironmentIrradiance*=conservationFactor;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\nspecularEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=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#ifndef METALLICWORKFLOW\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\n\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=energyConservationFactor;\n#endif\n\n#ifdef REFLECTION\nvec3 finalClearCoatRadiance=environmentClearCoatRadiance.rgb;\nfinalClearCoatRadiance*=clearCoatEnvironmentReflectance;\n\nvec3 finalClearCoatRadianceScaled=finalClearCoatRadiance*vLightingIntensity.z;\n#endif\n#ifdef REFRACTION\nfinalRefraction*=(conservationFactor*conservationFactor);\n#ifdef CLEARCOAT_TINT\nfinalRefraction*=absorption;\n#endif\n#endif\n#endif\n\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\n\n\n\n#endif\n#ifdef REFLECTION\nvec3 finalSheenRadiance=environmentSheenRadiance.rgb;\nfinalSheenRadiance*=sheenEnvironmentReflectance;\n\nvec3 finalSheenRadianceScaled=finalSheenRadiance*vLightingIntensity.z;\n#endif\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=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 SHEEN\n\n\nfinalSheenScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#ifdef CLEARCOAT\n\n\nfinalClearCoatRadianceScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenRadianceScaled +\n#endif\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n#include<pbrDebug>\n}\n";
  126693. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126694. /** @hidden */
  126695. var pbrPixelShader = { name: name, shader: shader };
  126696. /***/ }),
  126697. /***/ "./Shaders/pbr.vertex.ts":
  126698. /*!*******************************!*\
  126699. !*** ./Shaders/pbr.vertex.ts ***!
  126700. \*******************************/
  126701. /*! exports provided: pbrVertexShader */
  126702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126703. "use strict";
  126704. __webpack_require__.r(__webpack_exports__);
  126705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  126706. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126707. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  126708. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  126709. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126710. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  126711. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  126712. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  126713. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  126714. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  126715. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  126716. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  126717. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  126718. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  126719. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  126720. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  126721. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  126722. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  126723. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  126724. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  126725. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  126726. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  126727. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  126728. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  126729. var name = 'pbrVertexShader';
  126730. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatTintUV;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nvarying vec2 vSheenUV;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nvarying vec2 vAnisotropyUV;\n#endif\n#endif\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nif (vClearCoatInfos.x == 0.)\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nif (vClearCoatBumpInfos.x == 0.)\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nif (vClearCoatTintInfos.x == 0.)\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nif (vSheenInfos.x == 0.)\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nif (vAnisotropyInfos.x == 0.)\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n}";
  126731. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126732. /** @hidden */
  126733. var pbrVertexShader = { name: name, shader: shader };
  126734. /***/ }),
  126735. /***/ "./Shaders/postprocess.vertex.ts":
  126736. /*!***************************************!*\
  126737. !*** ./Shaders/postprocess.vertex.ts ***!
  126738. \***************************************/
  126739. /*! exports provided: postprocessVertexShader */
  126740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126741. "use strict";
  126742. __webpack_require__.r(__webpack_exports__);
  126743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  126744. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126745. var name = 'postprocessVertexShader';
  126746. 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}";
  126747. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126748. /** @hidden */
  126749. var postprocessVertexShader = { name: name, shader: shader };
  126750. /***/ }),
  126751. /***/ "./Shaders/procedural.vertex.ts":
  126752. /*!**************************************!*\
  126753. !*** ./Shaders/procedural.vertex.ts ***!
  126754. \**************************************/
  126755. /*! exports provided: proceduralVertexShader */
  126756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126757. "use strict";
  126758. __webpack_require__.r(__webpack_exports__);
  126759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  126760. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126761. var name = 'proceduralVertexShader';
  126762. 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}";
  126763. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126764. /** @hidden */
  126765. var proceduralVertexShader = { name: name, shader: shader };
  126766. /***/ }),
  126767. /***/ "./Shaders/refraction.fragment.ts":
  126768. /*!****************************************!*\
  126769. !*** ./Shaders/refraction.fragment.ts ***!
  126770. \****************************************/
  126771. /*! exports provided: refractionPixelShader */
  126772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126773. "use strict";
  126774. __webpack_require__.r(__webpack_exports__);
  126775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  126776. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126777. var name = 'refractionPixelShader';
  126778. 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}";
  126779. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126780. /** @hidden */
  126781. var refractionPixelShader = { name: name, shader: shader };
  126782. /***/ }),
  126783. /***/ "./Shaders/rgbdDecode.fragment.ts":
  126784. /*!****************************************!*\
  126785. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  126786. \****************************************/
  126787. /*! exports provided: rgbdDecodePixelShader */
  126788. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126789. "use strict";
  126790. __webpack_require__.r(__webpack_exports__);
  126791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  126792. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126793. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126794. var name = 'rgbdDecodePixelShader';
  126795. 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}";
  126796. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126797. /** @hidden */
  126798. var rgbdDecodePixelShader = { name: name, shader: shader };
  126799. /***/ }),
  126800. /***/ "./Shaders/rgbdEncode.fragment.ts":
  126801. /*!****************************************!*\
  126802. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  126803. \****************************************/
  126804. /*! exports provided: rgbdEncodePixelShader */
  126805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126806. "use strict";
  126807. __webpack_require__.r(__webpack_exports__);
  126808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  126809. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126810. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126811. var name = 'rgbdEncodePixelShader';
  126812. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  126813. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126814. /** @hidden */
  126815. var rgbdEncodePixelShader = { name: name, shader: shader };
  126816. /***/ }),
  126817. /***/ "./Shaders/shadowMap.fragment.ts":
  126818. /*!***************************************!*\
  126819. !*** ./Shaders/shadowMap.fragment.ts ***!
  126820. \***************************************/
  126821. /*! exports provided: shadowMapPixelShader */
  126822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126823. "use strict";
  126824. __webpack_require__.r(__webpack_exports__);
  126825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  126826. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126827. var name = 'shadowMapPixelShader';
  126828. 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}";
  126829. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126830. /** @hidden */
  126831. var shadowMapPixelShader = { name: name, shader: shader };
  126832. /***/ }),
  126833. /***/ "./Shaders/shadowMap.vertex.ts":
  126834. /*!*************************************!*\
  126835. !*** ./Shaders/shadowMap.vertex.ts ***!
  126836. \*************************************/
  126837. /*! exports provided: shadowMapVertexShader */
  126838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126839. "use strict";
  126840. __webpack_require__.r(__webpack_exports__);
  126841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  126842. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126843. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  126844. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  126845. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  126846. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  126847. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126848. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  126849. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  126850. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  126851. var name = 'shadowMapVertexShader';
  126852. 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}";
  126853. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126854. /** @hidden */
  126855. var shadowMapVertexShader = { name: name, shader: shader };
  126856. /***/ }),
  126857. /***/ "./Shaders/sharpen.fragment.ts":
  126858. /*!*************************************!*\
  126859. !*** ./Shaders/sharpen.fragment.ts ***!
  126860. \*************************************/
  126861. /*! exports provided: sharpenPixelShader */
  126862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126863. "use strict";
  126864. __webpack_require__.r(__webpack_exports__);
  126865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  126866. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126867. var name = 'sharpenPixelShader';
  126868. 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}";
  126869. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126870. /** @hidden */
  126871. var sharpenPixelShader = { name: name, shader: shader };
  126872. /***/ }),
  126873. /***/ "./Shaders/sprites.fragment.ts":
  126874. /*!*************************************!*\
  126875. !*** ./Shaders/sprites.fragment.ts ***!
  126876. \*************************************/
  126877. /*! exports provided: spritesPixelShader */
  126878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126879. "use strict";
  126880. __webpack_require__.r(__webpack_exports__);
  126881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  126882. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126883. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  126884. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  126885. var name = 'spritesPixelShader';
  126886. 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}";
  126887. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126888. /** @hidden */
  126889. var spritesPixelShader = { name: name, shader: shader };
  126890. /***/ }),
  126891. /***/ "./Shaders/sprites.vertex.ts":
  126892. /*!***********************************!*\
  126893. !*** ./Shaders/sprites.vertex.ts ***!
  126894. \***********************************/
  126895. /*! exports provided: spritesVertexShader */
  126896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126897. "use strict";
  126898. __webpack_require__.r(__webpack_exports__);
  126899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  126900. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126901. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  126902. var name = 'spritesVertexShader';
  126903. 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}";
  126904. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126905. /** @hidden */
  126906. var spritesVertexShader = { name: name, shader: shader };
  126907. /***/ }),
  126908. /***/ "./Shaders/ssao.fragment.ts":
  126909. /*!**********************************!*\
  126910. !*** ./Shaders/ssao.fragment.ts ***!
  126911. \**********************************/
  126912. /*! exports provided: ssaoPixelShader */
  126913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126914. "use strict";
  126915. __webpack_require__.r(__webpack_exports__);
  126916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  126917. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126918. var name = 'ssaoPixelShader';
  126919. 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";
  126920. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126921. /** @hidden */
  126922. var ssaoPixelShader = { name: name, shader: shader };
  126923. /***/ }),
  126924. /***/ "./Shaders/ssao2.fragment.ts":
  126925. /*!***********************************!*\
  126926. !*** ./Shaders/ssao2.fragment.ts ***!
  126927. \***********************************/
  126928. /*! exports provided: ssao2PixelShader */
  126929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126930. "use strict";
  126931. __webpack_require__.r(__webpack_exports__);
  126932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  126933. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126934. var name = 'ssao2PixelShader';
  126935. 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";
  126936. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126937. /** @hidden */
  126938. var ssao2PixelShader = { name: name, shader: shader };
  126939. /***/ }),
  126940. /***/ "./Shaders/ssaoCombine.fragment.ts":
  126941. /*!*****************************************!*\
  126942. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  126943. \*****************************************/
  126944. /*! exports provided: ssaoCombinePixelShader */
  126945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126946. "use strict";
  126947. __webpack_require__.r(__webpack_exports__);
  126948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  126949. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126950. var name = 'ssaoCombinePixelShader';
  126951. 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";
  126952. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126953. /** @hidden */
  126954. var ssaoCombinePixelShader = { name: name, shader: shader };
  126955. /***/ }),
  126956. /***/ "./Shaders/standard.fragment.ts":
  126957. /*!**************************************!*\
  126958. !*** ./Shaders/standard.fragment.ts ***!
  126959. \**************************************/
  126960. /*! exports provided: standardPixelShader */
  126961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126962. "use strict";
  126963. __webpack_require__.r(__webpack_exports__);
  126964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  126965. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126966. var name = 'standardPixelShader';
  126967. 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";
  126968. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126969. /** @hidden */
  126970. var standardPixelShader = { name: name, shader: shader };
  126971. /***/ }),
  126972. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  126973. /*!***************************************************!*\
  126974. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  126975. \***************************************************/
  126976. /*! exports provided: stereoscopicInterlacePixelShader */
  126977. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126978. "use strict";
  126979. __webpack_require__.r(__webpack_exports__);
  126980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  126981. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126982. var name = 'stereoscopicInterlacePixelShader';
  126983. 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}";
  126984. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126985. /** @hidden */
  126986. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  126987. /***/ }),
  126988. /***/ "./Shaders/tonemap.fragment.ts":
  126989. /*!*************************************!*\
  126990. !*** ./Shaders/tonemap.fragment.ts ***!
  126991. \*************************************/
  126992. /*! exports provided: tonemapPixelShader */
  126993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126994. "use strict";
  126995. __webpack_require__.r(__webpack_exports__);
  126996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  126997. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126998. var name = 'tonemapPixelShader';
  126999. 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}";
  127000. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127001. /** @hidden */
  127002. var tonemapPixelShader = { name: name, shader: shader };
  127003. /***/ }),
  127004. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  127005. /*!*******************************************************!*\
  127006. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  127007. \*******************************************************/
  127008. /*! exports provided: volumetricLightScatteringPixelShader */
  127009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127010. "use strict";
  127011. __webpack_require__.r(__webpack_exports__);
  127012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  127013. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127014. var name = 'volumetricLightScatteringPixelShader';
  127015. 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";
  127016. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127017. /** @hidden */
  127018. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  127019. /***/ }),
  127020. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  127021. /*!***********************************************************!*\
  127022. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  127023. \***********************************************************/
  127024. /*! exports provided: volumetricLightScatteringPassPixelShader */
  127025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127026. "use strict";
  127027. __webpack_require__.r(__webpack_exports__);
  127028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  127029. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127030. var name = 'volumetricLightScatteringPassPixelShader';
  127031. 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";
  127032. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127033. /** @hidden */
  127034. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  127035. /***/ }),
  127036. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  127037. /*!****************************************************!*\
  127038. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  127039. \****************************************************/
  127040. /*! exports provided: vrDistortionCorrectionPixelShader */
  127041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127042. "use strict";
  127043. __webpack_require__.r(__webpack_exports__);
  127044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  127045. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  127046. var name = 'vrDistortionCorrectionPixelShader';
  127047. 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}";
  127048. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  127049. /** @hidden */
  127050. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  127051. /***/ }),
  127052. /***/ "./Sprites/index.ts":
  127053. /*!**************************!*\
  127054. !*** ./Sprites/index.ts ***!
  127055. \**************************/
  127056. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  127057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127058. "use strict";
  127059. __webpack_require__.r(__webpack_exports__);
  127060. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  127061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  127062. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  127063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  127064. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  127065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  127066. /***/ }),
  127067. /***/ "./Sprites/sprite.ts":
  127068. /*!***************************!*\
  127069. !*** ./Sprites/sprite.ts ***!
  127070. \***************************/
  127071. /*! exports provided: Sprite */
  127072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127073. "use strict";
  127074. __webpack_require__.r(__webpack_exports__);
  127075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  127076. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127077. /**
  127078. * Class used to represent a sprite
  127079. * @see http://doc.babylonjs.com/babylon101/sprites
  127080. */
  127081. var Sprite = /** @class */ (function () {
  127082. /**
  127083. * Creates a new Sprite
  127084. * @param name defines the name
  127085. * @param manager defines the manager
  127086. */
  127087. function Sprite(
  127088. /** defines the name */
  127089. name, manager) {
  127090. this.name = name;
  127091. /** Gets or sets the main color */
  127092. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  127093. /** Gets or sets the width */
  127094. this.width = 1.0;
  127095. /** Gets or sets the height */
  127096. this.height = 1.0;
  127097. /** Gets or sets rotation angle */
  127098. this.angle = 0;
  127099. /** Gets or sets the cell index in the sprite sheet */
  127100. this.cellIndex = 0;
  127101. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  127102. this.invertU = 0;
  127103. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  127104. this.invertV = 0;
  127105. /** Gets the list of attached animations */
  127106. this.animations = new Array();
  127107. /** Gets or sets a boolean indicating if the sprite can be picked */
  127108. this.isPickable = false;
  127109. this._animationStarted = false;
  127110. this._loopAnimation = false;
  127111. this._fromIndex = 0;
  127112. this._toIndex = 0;
  127113. this._delay = 0;
  127114. this._direction = 1;
  127115. this._time = 0;
  127116. /**
  127117. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  127118. */
  127119. this.isVisible = true;
  127120. this._manager = manager;
  127121. this._manager.sprites.push(this);
  127122. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  127123. }
  127124. Object.defineProperty(Sprite.prototype, "size", {
  127125. /**
  127126. * Gets or sets the sprite size
  127127. */
  127128. get: function () {
  127129. return this.width;
  127130. },
  127131. set: function (value) {
  127132. this.width = value;
  127133. this.height = value;
  127134. },
  127135. enumerable: true,
  127136. configurable: true
  127137. });
  127138. /**
  127139. * Starts an animation
  127140. * @param from defines the initial key
  127141. * @param to defines the end key
  127142. * @param loop defines if the animation must loop
  127143. * @param delay defines the start delay (in ms)
  127144. * @param onAnimationEnd defines a callback to call when animation ends
  127145. */
  127146. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  127147. this._fromIndex = from;
  127148. this._toIndex = to;
  127149. this._loopAnimation = loop;
  127150. this._delay = delay;
  127151. this._animationStarted = true;
  127152. this._direction = from < to ? 1 : -1;
  127153. this.cellIndex = from;
  127154. this._time = 0;
  127155. this._onAnimationEnd = onAnimationEnd;
  127156. };
  127157. /** Stops current animation (if any) */
  127158. Sprite.prototype.stopAnimation = function () {
  127159. this._animationStarted = false;
  127160. };
  127161. /** @hidden */
  127162. Sprite.prototype._animate = function (deltaTime) {
  127163. if (!this._animationStarted) {
  127164. return;
  127165. }
  127166. this._time += deltaTime;
  127167. if (this._time > this._delay) {
  127168. this._time = this._time % this._delay;
  127169. this.cellIndex += this._direction;
  127170. if (this.cellIndex > this._toIndex) {
  127171. if (this._loopAnimation) {
  127172. this.cellIndex = this._fromIndex;
  127173. }
  127174. else {
  127175. this.cellIndex = this._toIndex;
  127176. this._animationStarted = false;
  127177. if (this._onAnimationEnd) {
  127178. this._onAnimationEnd();
  127179. }
  127180. if (this.disposeWhenFinishedAnimating) {
  127181. this.dispose();
  127182. }
  127183. }
  127184. }
  127185. }
  127186. };
  127187. /** Release associated resources */
  127188. Sprite.prototype.dispose = function () {
  127189. for (var i = 0; i < this._manager.sprites.length; i++) {
  127190. if (this._manager.sprites[i] == this) {
  127191. this._manager.sprites.splice(i, 1);
  127192. }
  127193. }
  127194. };
  127195. return Sprite;
  127196. }());
  127197. /***/ }),
  127198. /***/ "./Sprites/spriteManager.ts":
  127199. /*!**********************************!*\
  127200. !*** ./Sprites/spriteManager.ts ***!
  127201. \**********************************/
  127202. /*! exports provided: SpriteManager */
  127203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127204. "use strict";
  127205. __webpack_require__.r(__webpack_exports__);
  127206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  127207. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127208. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  127209. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127210. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127211. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  127212. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  127213. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  127214. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  127215. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  127216. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127217. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  127218. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  127219. /**
  127220. * Class used to manage multiple sprites on the same spritesheet
  127221. * @see http://doc.babylonjs.com/babylon101/sprites
  127222. */
  127223. var SpriteManager = /** @class */ (function () {
  127224. /**
  127225. * Creates a new sprite manager
  127226. * @param name defines the manager's name
  127227. * @param imgUrl defines the sprite sheet url
  127228. * @param capacity defines the maximum allowed number of sprites
  127229. * @param cellSize defines the size of a sprite cell
  127230. * @param scene defines the hosting scene
  127231. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  127232. * @param samplingMode defines the smapling mode to use with spritesheet
  127233. */
  127234. function SpriteManager(
  127235. /** defines the manager's name */
  127236. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  127237. if (epsilon === void 0) { epsilon = 0.01; }
  127238. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  127239. this.name = name;
  127240. /** Gets the list of sprites */
  127241. this.sprites = new Array();
  127242. /** Gets or sets the rendering group id (0 by default) */
  127243. this.renderingGroupId = 0;
  127244. /** Gets or sets camera layer mask */
  127245. this.layerMask = 0x0FFFFFFF;
  127246. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  127247. this.fogEnabled = true;
  127248. /** Gets or sets a boolean indicating if the sprites are pickable */
  127249. this.isPickable = false;
  127250. /**
  127251. * An event triggered when the manager is disposed.
  127252. */
  127253. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  127254. this._vertexBuffers = {};
  127255. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  127256. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  127257. }
  127258. this._capacity = capacity;
  127259. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  127260. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  127261. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  127262. if (cellSize.width && cellSize.height) {
  127263. this.cellWidth = cellSize.width;
  127264. this.cellHeight = cellSize.height;
  127265. }
  127266. else if (cellSize !== undefined) {
  127267. this.cellWidth = cellSize;
  127268. this.cellHeight = cellSize;
  127269. }
  127270. else {
  127271. return;
  127272. }
  127273. this._epsilon = epsilon;
  127274. this._scene = scene;
  127275. this._scene.spriteManagers.push(this);
  127276. var indices = [];
  127277. var index = 0;
  127278. for (var count = 0; count < capacity; count++) {
  127279. indices.push(index);
  127280. indices.push(index + 1);
  127281. indices.push(index + 2);
  127282. indices.push(index);
  127283. indices.push(index + 2);
  127284. indices.push(index + 3);
  127285. index += 4;
  127286. }
  127287. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  127288. // VBO
  127289. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  127290. this._vertexData = new Float32Array(capacity * 16 * 4);
  127291. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  127292. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  127293. var options = this._buffer.createVertexBuffer("options", 4, 4);
  127294. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  127295. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  127296. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  127297. this._vertexBuffers["options"] = options;
  127298. this._vertexBuffers["cellInfo"] = cellInfo;
  127299. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  127300. // Effects
  127301. 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"], "");
  127302. 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");
  127303. }
  127304. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  127305. /**
  127306. * Callback called when the manager is disposed
  127307. */
  127308. set: function (callback) {
  127309. if (this._onDisposeObserver) {
  127310. this.onDisposeObservable.remove(this._onDisposeObserver);
  127311. }
  127312. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  127313. },
  127314. enumerable: true,
  127315. configurable: true
  127316. });
  127317. Object.defineProperty(SpriteManager.prototype, "texture", {
  127318. /**
  127319. * Gets or sets the spritesheet texture
  127320. */
  127321. get: function () {
  127322. return this._spriteTexture;
  127323. },
  127324. set: function (value) {
  127325. this._spriteTexture = value;
  127326. },
  127327. enumerable: true,
  127328. configurable: true
  127329. });
  127330. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  127331. var arrayOffset = index * 16;
  127332. if (offsetX === 0) {
  127333. offsetX = this._epsilon;
  127334. }
  127335. else if (offsetX === 1) {
  127336. offsetX = 1 - this._epsilon;
  127337. }
  127338. if (offsetY === 0) {
  127339. offsetY = this._epsilon;
  127340. }
  127341. else if (offsetY === 1) {
  127342. offsetY = 1 - this._epsilon;
  127343. }
  127344. this._vertexData[arrayOffset] = sprite.position.x;
  127345. this._vertexData[arrayOffset + 1] = sprite.position.y;
  127346. this._vertexData[arrayOffset + 2] = sprite.position.z;
  127347. this._vertexData[arrayOffset + 3] = sprite.angle;
  127348. this._vertexData[arrayOffset + 4] = sprite.width;
  127349. this._vertexData[arrayOffset + 5] = sprite.height;
  127350. this._vertexData[arrayOffset + 6] = offsetX;
  127351. this._vertexData[arrayOffset + 7] = offsetY;
  127352. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  127353. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  127354. var offset = (sprite.cellIndex / rowSize) >> 0;
  127355. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  127356. this._vertexData[arrayOffset + 11] = offset;
  127357. // Color
  127358. this._vertexData[arrayOffset + 12] = sprite.color.r;
  127359. this._vertexData[arrayOffset + 13] = sprite.color.g;
  127360. this._vertexData[arrayOffset + 14] = sprite.color.b;
  127361. this._vertexData[arrayOffset + 15] = sprite.color.a;
  127362. };
  127363. /**
  127364. * Intersects the sprites with a ray
  127365. * @param ray defines the ray to intersect with
  127366. * @param camera defines the current active camera
  127367. * @param predicate defines a predicate used to select candidate sprites
  127368. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  127369. * @returns null if no hit or a PickingInfo
  127370. */
  127371. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  127372. var count = Math.min(this._capacity, this.sprites.length);
  127373. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  127374. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  127375. var distance = Number.MAX_VALUE;
  127376. var currentSprite = null;
  127377. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  127378. var cameraView = camera.getViewMatrix();
  127379. for (var index = 0; index < count; index++) {
  127380. var sprite = this.sprites[index];
  127381. if (!sprite) {
  127382. continue;
  127383. }
  127384. if (predicate) {
  127385. if (!predicate(sprite)) {
  127386. continue;
  127387. }
  127388. }
  127389. else if (!sprite.isPickable) {
  127390. continue;
  127391. }
  127392. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  127393. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  127394. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  127395. if (ray.intersectsBoxMinMax(min, max)) {
  127396. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  127397. if (distance > currentDistance) {
  127398. distance = currentDistance;
  127399. currentSprite = sprite;
  127400. if (fastCheck) {
  127401. break;
  127402. }
  127403. }
  127404. }
  127405. }
  127406. if (currentSprite) {
  127407. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  127408. result.hit = true;
  127409. result.pickedSprite = currentSprite;
  127410. result.distance = distance;
  127411. return result;
  127412. }
  127413. return null;
  127414. };
  127415. /**
  127416. * Render all child sprites
  127417. */
  127418. SpriteManager.prototype.render = function () {
  127419. // Check
  127420. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  127421. || !this._spriteTexture.isReady() || !this.sprites.length) {
  127422. return;
  127423. }
  127424. var engine = this._scene.getEngine();
  127425. var baseSize = this._spriteTexture.getBaseSize();
  127426. // Sprites
  127427. var deltaTime = engine.getDeltaTime();
  127428. var max = Math.min(this._capacity, this.sprites.length);
  127429. var rowSize = baseSize.width / this.cellWidth;
  127430. var offset = 0;
  127431. for (var index = 0; index < max; index++) {
  127432. var sprite = this.sprites[index];
  127433. if (!sprite || !sprite.isVisible) {
  127434. continue;
  127435. }
  127436. sprite._animate(deltaTime);
  127437. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  127438. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  127439. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  127440. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  127441. }
  127442. this._buffer.update(this._vertexData);
  127443. // Render
  127444. var effect = this._effectBase;
  127445. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  127446. effect = this._effectFog;
  127447. }
  127448. engine.enableEffect(effect);
  127449. var viewMatrix = this._scene.getViewMatrix();
  127450. effect.setTexture("diffuseSampler", this._spriteTexture);
  127451. effect.setMatrix("view", viewMatrix);
  127452. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  127453. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  127454. // Fog
  127455. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  127456. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  127457. effect.setColor3("vFogColor", this._scene.fogColor);
  127458. }
  127459. // VBOs
  127460. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  127461. // Draw order
  127462. engine.setDepthFunctionToLessOrEqual();
  127463. effect.setBool("alphaTest", true);
  127464. engine.setColorWrite(false);
  127465. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  127466. engine.setColorWrite(true);
  127467. effect.setBool("alphaTest", false);
  127468. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  127469. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  127470. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  127471. };
  127472. /**
  127473. * Release associated resources
  127474. */
  127475. SpriteManager.prototype.dispose = function () {
  127476. if (this._buffer) {
  127477. this._buffer.dispose();
  127478. this._buffer = null;
  127479. }
  127480. if (this._indexBuffer) {
  127481. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  127482. this._indexBuffer = null;
  127483. }
  127484. if (this._spriteTexture) {
  127485. this._spriteTexture.dispose();
  127486. this._spriteTexture = null;
  127487. }
  127488. // Remove from scene
  127489. var index = this._scene.spriteManagers.indexOf(this);
  127490. this._scene.spriteManagers.splice(index, 1);
  127491. // Callback
  127492. this.onDisposeObservable.notifyObservers(this);
  127493. this.onDisposeObservable.clear();
  127494. };
  127495. return SpriteManager;
  127496. }());
  127497. /***/ }),
  127498. /***/ "./Sprites/spriteSceneComponent.ts":
  127499. /*!*****************************************!*\
  127500. !*** ./Sprites/spriteSceneComponent.ts ***!
  127501. \*****************************************/
  127502. /*! exports provided: SpriteSceneComponent */
  127503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127504. "use strict";
  127505. __webpack_require__.r(__webpack_exports__);
  127506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  127507. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  127508. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127509. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  127510. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  127511. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  127512. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  127513. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127514. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  127515. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  127516. return null;
  127517. }
  127518. var pickingInfo = null;
  127519. if (!camera) {
  127520. if (!this.activeCamera) {
  127521. return null;
  127522. }
  127523. camera = this.activeCamera;
  127524. }
  127525. if (this.spriteManagers.length > 0) {
  127526. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  127527. var spriteManager = this.spriteManagers[spriteIndex];
  127528. if (!spriteManager.isPickable) {
  127529. continue;
  127530. }
  127531. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  127532. if (!result || !result.hit) {
  127533. continue;
  127534. }
  127535. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  127536. continue;
  127537. }
  127538. pickingInfo = result;
  127539. if (fastCheck) {
  127540. break;
  127541. }
  127542. }
  127543. }
  127544. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  127545. };
  127546. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  127547. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  127548. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  127549. };
  127550. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  127551. if (!this._tempSpritePickingRay) {
  127552. return null;
  127553. }
  127554. if (!camera) {
  127555. if (!this.activeCamera) {
  127556. return null;
  127557. }
  127558. camera = this.activeCamera;
  127559. }
  127560. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  127561. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  127562. };
  127563. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  127564. if (this._pointerOverSprite === sprite) {
  127565. return;
  127566. }
  127567. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  127568. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  127569. }
  127570. this._pointerOverSprite = sprite;
  127571. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  127572. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  127573. }
  127574. };
  127575. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  127576. return this._pointerOverSprite;
  127577. };
  127578. /**
  127579. * Defines the sprite scene component responsible to manage sprites
  127580. * in a given scene.
  127581. */
  127582. var SpriteSceneComponent = /** @class */ (function () {
  127583. /**
  127584. * Creates a new instance of the component for the given scene
  127585. * @param scene Defines the scene to register the component in
  127586. */
  127587. function SpriteSceneComponent(scene) {
  127588. /**
  127589. * The component name helpfull to identify the component in the list of scene components.
  127590. */
  127591. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  127592. this.scene = scene;
  127593. this.scene.spriteManagers = new Array();
  127594. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  127595. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  127596. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  127597. this._spritePredicate = function (sprite) {
  127598. if (!sprite.actionManager) {
  127599. return false;
  127600. }
  127601. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  127602. };
  127603. }
  127604. /**
  127605. * Registers the component in a given scene
  127606. */
  127607. SpriteSceneComponent.prototype.register = function () {
  127608. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  127609. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  127610. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  127611. };
  127612. /**
  127613. * Rebuilds the elements related to this component in case of
  127614. * context lost for instance.
  127615. */
  127616. SpriteSceneComponent.prototype.rebuild = function () {
  127617. /** Nothing to do for sprites */
  127618. };
  127619. /**
  127620. * Disposes the component and the associated ressources.
  127621. */
  127622. SpriteSceneComponent.prototype.dispose = function () {
  127623. this.scene.onBeforeSpritesRenderingObservable.clear();
  127624. this.scene.onAfterSpritesRenderingObservable.clear();
  127625. var spriteManagers = this.scene.spriteManagers;
  127626. while (spriteManagers.length) {
  127627. spriteManagers[0].dispose();
  127628. }
  127629. };
  127630. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  127631. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  127632. if (result) {
  127633. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  127634. }
  127635. return result;
  127636. };
  127637. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  127638. var scene = this.scene;
  127639. if (isMeshPicked) {
  127640. scene.setPointerOverSprite(null);
  127641. }
  127642. else {
  127643. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  127644. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  127645. scene.setPointerOverSprite(pickResult.pickedSprite);
  127646. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  127647. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  127648. }
  127649. else {
  127650. canvas.style.cursor = scene.hoverCursor;
  127651. }
  127652. }
  127653. else {
  127654. scene.setPointerOverSprite(null);
  127655. }
  127656. }
  127657. return pickResult;
  127658. };
  127659. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  127660. var scene = this.scene;
  127661. scene._pickedDownSprite = null;
  127662. if (scene.spriteManagers.length > 0) {
  127663. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  127664. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  127665. if (pickResult.pickedSprite.actionManager) {
  127666. scene._pickedDownSprite = pickResult.pickedSprite;
  127667. switch (evt.button) {
  127668. case 0:
  127669. 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));
  127670. break;
  127671. case 1:
  127672. 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));
  127673. break;
  127674. case 2:
  127675. 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));
  127676. break;
  127677. }
  127678. if (pickResult.pickedSprite.actionManager) {
  127679. 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));
  127680. }
  127681. }
  127682. }
  127683. }
  127684. return pickResult;
  127685. };
  127686. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  127687. var scene = this.scene;
  127688. if (scene.spriteManagers.length > 0) {
  127689. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  127690. if (spritePickResult) {
  127691. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  127692. if (spritePickResult.pickedSprite.actionManager) {
  127693. 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));
  127694. if (spritePickResult.pickedSprite.actionManager) {
  127695. if (!this.scene._isPointerSwiping()) {
  127696. 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));
  127697. }
  127698. }
  127699. }
  127700. }
  127701. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  127702. 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));
  127703. }
  127704. }
  127705. }
  127706. return pickResult;
  127707. };
  127708. return SpriteSceneComponent;
  127709. }());
  127710. /***/ }),
  127711. /***/ "./States/alphaCullingState.ts":
  127712. /*!*************************************!*\
  127713. !*** ./States/alphaCullingState.ts ***!
  127714. \*************************************/
  127715. /*! exports provided: _AlphaState */
  127716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127717. "use strict";
  127718. __webpack_require__.r(__webpack_exports__);
  127719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  127720. /**
  127721. * @hidden
  127722. **/
  127723. var _AlphaState = /** @class */ (function () {
  127724. /**
  127725. * Initializes the state.
  127726. */
  127727. function _AlphaState() {
  127728. this._isAlphaBlendDirty = false;
  127729. this._isBlendFunctionParametersDirty = false;
  127730. this._isBlendEquationParametersDirty = false;
  127731. this._isBlendConstantsDirty = false;
  127732. this._alphaBlend = false;
  127733. this._blendFunctionParameters = new Array(4);
  127734. this._blendEquationParameters = new Array(2);
  127735. this._blendConstants = new Array(4);
  127736. this.reset();
  127737. }
  127738. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  127739. get: function () {
  127740. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  127741. },
  127742. enumerable: true,
  127743. configurable: true
  127744. });
  127745. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  127746. get: function () {
  127747. return this._alphaBlend;
  127748. },
  127749. set: function (value) {
  127750. if (this._alphaBlend === value) {
  127751. return;
  127752. }
  127753. this._alphaBlend = value;
  127754. this._isAlphaBlendDirty = true;
  127755. },
  127756. enumerable: true,
  127757. configurable: true
  127758. });
  127759. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  127760. if (this._blendConstants[0] === r &&
  127761. this._blendConstants[1] === g &&
  127762. this._blendConstants[2] === b &&
  127763. this._blendConstants[3] === a) {
  127764. return;
  127765. }
  127766. this._blendConstants[0] = r;
  127767. this._blendConstants[1] = g;
  127768. this._blendConstants[2] = b;
  127769. this._blendConstants[3] = a;
  127770. this._isBlendConstantsDirty = true;
  127771. };
  127772. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  127773. if (this._blendFunctionParameters[0] === value0 &&
  127774. this._blendFunctionParameters[1] === value1 &&
  127775. this._blendFunctionParameters[2] === value2 &&
  127776. this._blendFunctionParameters[3] === value3) {
  127777. return;
  127778. }
  127779. this._blendFunctionParameters[0] = value0;
  127780. this._blendFunctionParameters[1] = value1;
  127781. this._blendFunctionParameters[2] = value2;
  127782. this._blendFunctionParameters[3] = value3;
  127783. this._isBlendFunctionParametersDirty = true;
  127784. };
  127785. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  127786. if (this._blendEquationParameters[0] === rgb &&
  127787. this._blendEquationParameters[1] === alpha) {
  127788. return;
  127789. }
  127790. this._blendEquationParameters[0] = rgb;
  127791. this._blendEquationParameters[1] = alpha;
  127792. this._isBlendEquationParametersDirty = true;
  127793. };
  127794. _AlphaState.prototype.reset = function () {
  127795. this._alphaBlend = false;
  127796. this._blendFunctionParameters[0] = null;
  127797. this._blendFunctionParameters[1] = null;
  127798. this._blendFunctionParameters[2] = null;
  127799. this._blendFunctionParameters[3] = null;
  127800. this._blendEquationParameters[0] = null;
  127801. this._blendEquationParameters[1] = null;
  127802. this._blendConstants[0] = null;
  127803. this._blendConstants[1] = null;
  127804. this._blendConstants[2] = null;
  127805. this._blendConstants[3] = null;
  127806. this._isAlphaBlendDirty = true;
  127807. this._isBlendFunctionParametersDirty = false;
  127808. this._isBlendEquationParametersDirty = false;
  127809. this._isBlendConstantsDirty = false;
  127810. };
  127811. _AlphaState.prototype.apply = function (gl) {
  127812. if (!this.isDirty) {
  127813. return;
  127814. }
  127815. // Alpha blend
  127816. if (this._isAlphaBlendDirty) {
  127817. if (this._alphaBlend) {
  127818. gl.enable(gl.BLEND);
  127819. }
  127820. else {
  127821. gl.disable(gl.BLEND);
  127822. }
  127823. this._isAlphaBlendDirty = false;
  127824. }
  127825. // Alpha function
  127826. if (this._isBlendFunctionParametersDirty) {
  127827. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  127828. this._isBlendFunctionParametersDirty = false;
  127829. }
  127830. // Alpha equation
  127831. if (this._isBlendEquationParametersDirty) {
  127832. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  127833. this._isBlendEquationParametersDirty = false;
  127834. }
  127835. // Constants
  127836. if (this._isBlendConstantsDirty) {
  127837. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  127838. this._isBlendConstantsDirty = false;
  127839. }
  127840. };
  127841. return _AlphaState;
  127842. }());
  127843. /***/ }),
  127844. /***/ "./States/depthCullingState.ts":
  127845. /*!*************************************!*\
  127846. !*** ./States/depthCullingState.ts ***!
  127847. \*************************************/
  127848. /*! exports provided: _DepthCullingState */
  127849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127850. "use strict";
  127851. __webpack_require__.r(__webpack_exports__);
  127852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  127853. /**
  127854. * @hidden
  127855. **/
  127856. var _DepthCullingState = /** @class */ (function () {
  127857. /**
  127858. * Initializes the state.
  127859. */
  127860. function _DepthCullingState() {
  127861. this._isDepthTestDirty = false;
  127862. this._isDepthMaskDirty = false;
  127863. this._isDepthFuncDirty = false;
  127864. this._isCullFaceDirty = false;
  127865. this._isCullDirty = false;
  127866. this._isZOffsetDirty = false;
  127867. this._isFrontFaceDirty = false;
  127868. this.reset();
  127869. }
  127870. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  127871. get: function () {
  127872. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  127873. },
  127874. enumerable: true,
  127875. configurable: true
  127876. });
  127877. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  127878. get: function () {
  127879. return this._zOffset;
  127880. },
  127881. set: function (value) {
  127882. if (this._zOffset === value) {
  127883. return;
  127884. }
  127885. this._zOffset = value;
  127886. this._isZOffsetDirty = true;
  127887. },
  127888. enumerable: true,
  127889. configurable: true
  127890. });
  127891. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  127892. get: function () {
  127893. return this._cullFace;
  127894. },
  127895. set: function (value) {
  127896. if (this._cullFace === value) {
  127897. return;
  127898. }
  127899. this._cullFace = value;
  127900. this._isCullFaceDirty = true;
  127901. },
  127902. enumerable: true,
  127903. configurable: true
  127904. });
  127905. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  127906. get: function () {
  127907. return this._cull;
  127908. },
  127909. set: function (value) {
  127910. if (this._cull === value) {
  127911. return;
  127912. }
  127913. this._cull = value;
  127914. this._isCullDirty = true;
  127915. },
  127916. enumerable: true,
  127917. configurable: true
  127918. });
  127919. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  127920. get: function () {
  127921. return this._depthFunc;
  127922. },
  127923. set: function (value) {
  127924. if (this._depthFunc === value) {
  127925. return;
  127926. }
  127927. this._depthFunc = value;
  127928. this._isDepthFuncDirty = true;
  127929. },
  127930. enumerable: true,
  127931. configurable: true
  127932. });
  127933. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  127934. get: function () {
  127935. return this._depthMask;
  127936. },
  127937. set: function (value) {
  127938. if (this._depthMask === value) {
  127939. return;
  127940. }
  127941. this._depthMask = value;
  127942. this._isDepthMaskDirty = true;
  127943. },
  127944. enumerable: true,
  127945. configurable: true
  127946. });
  127947. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  127948. get: function () {
  127949. return this._depthTest;
  127950. },
  127951. set: function (value) {
  127952. if (this._depthTest === value) {
  127953. return;
  127954. }
  127955. this._depthTest = value;
  127956. this._isDepthTestDirty = true;
  127957. },
  127958. enumerable: true,
  127959. configurable: true
  127960. });
  127961. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  127962. get: function () {
  127963. return this._frontFace;
  127964. },
  127965. set: function (value) {
  127966. if (this._frontFace === value) {
  127967. return;
  127968. }
  127969. this._frontFace = value;
  127970. this._isFrontFaceDirty = true;
  127971. },
  127972. enumerable: true,
  127973. configurable: true
  127974. });
  127975. _DepthCullingState.prototype.reset = function () {
  127976. this._depthMask = true;
  127977. this._depthTest = true;
  127978. this._depthFunc = null;
  127979. this._cullFace = null;
  127980. this._cull = null;
  127981. this._zOffset = 0;
  127982. this._frontFace = null;
  127983. this._isDepthTestDirty = true;
  127984. this._isDepthMaskDirty = true;
  127985. this._isDepthFuncDirty = false;
  127986. this._isCullFaceDirty = false;
  127987. this._isCullDirty = false;
  127988. this._isZOffsetDirty = false;
  127989. this._isFrontFaceDirty = false;
  127990. };
  127991. _DepthCullingState.prototype.apply = function (gl) {
  127992. if (!this.isDirty) {
  127993. return;
  127994. }
  127995. // Cull
  127996. if (this._isCullDirty) {
  127997. if (this.cull) {
  127998. gl.enable(gl.CULL_FACE);
  127999. }
  128000. else {
  128001. gl.disable(gl.CULL_FACE);
  128002. }
  128003. this._isCullDirty = false;
  128004. }
  128005. // Cull face
  128006. if (this._isCullFaceDirty) {
  128007. gl.cullFace(this.cullFace);
  128008. this._isCullFaceDirty = false;
  128009. }
  128010. // Depth mask
  128011. if (this._isDepthMaskDirty) {
  128012. gl.depthMask(this.depthMask);
  128013. this._isDepthMaskDirty = false;
  128014. }
  128015. // Depth test
  128016. if (this._isDepthTestDirty) {
  128017. if (this.depthTest) {
  128018. gl.enable(gl.DEPTH_TEST);
  128019. }
  128020. else {
  128021. gl.disable(gl.DEPTH_TEST);
  128022. }
  128023. this._isDepthTestDirty = false;
  128024. }
  128025. // Depth func
  128026. if (this._isDepthFuncDirty) {
  128027. gl.depthFunc(this.depthFunc);
  128028. this._isDepthFuncDirty = false;
  128029. }
  128030. // zOffset
  128031. if (this._isZOffsetDirty) {
  128032. if (this.zOffset) {
  128033. gl.enable(gl.POLYGON_OFFSET_FILL);
  128034. gl.polygonOffset(this.zOffset, 0);
  128035. }
  128036. else {
  128037. gl.disable(gl.POLYGON_OFFSET_FILL);
  128038. }
  128039. this._isZOffsetDirty = false;
  128040. }
  128041. // Front face
  128042. if (this._isFrontFaceDirty) {
  128043. gl.frontFace(this.frontFace);
  128044. this._isFrontFaceDirty = false;
  128045. }
  128046. };
  128047. return _DepthCullingState;
  128048. }());
  128049. /***/ }),
  128050. /***/ "./States/index.ts":
  128051. /*!*************************!*\
  128052. !*** ./States/index.ts ***!
  128053. \*************************/
  128054. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  128055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128056. "use strict";
  128057. __webpack_require__.r(__webpack_exports__);
  128058. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  128059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  128060. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  128061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  128062. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  128063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  128064. /***/ }),
  128065. /***/ "./States/stencilState.ts":
  128066. /*!********************************!*\
  128067. !*** ./States/stencilState.ts ***!
  128068. \********************************/
  128069. /*! exports provided: _StencilState */
  128070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128071. "use strict";
  128072. __webpack_require__.r(__webpack_exports__);
  128073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  128074. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  128075. /**
  128076. * @hidden
  128077. **/
  128078. var _StencilState = /** @class */ (function () {
  128079. function _StencilState() {
  128080. this._isStencilTestDirty = false;
  128081. this._isStencilMaskDirty = false;
  128082. this._isStencilFuncDirty = false;
  128083. this._isStencilOpDirty = false;
  128084. this.reset();
  128085. }
  128086. Object.defineProperty(_StencilState.prototype, "isDirty", {
  128087. get: function () {
  128088. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  128089. },
  128090. enumerable: true,
  128091. configurable: true
  128092. });
  128093. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  128094. get: function () {
  128095. return this._stencilFunc;
  128096. },
  128097. set: function (value) {
  128098. if (this._stencilFunc === value) {
  128099. return;
  128100. }
  128101. this._stencilFunc = value;
  128102. this._isStencilFuncDirty = true;
  128103. },
  128104. enumerable: true,
  128105. configurable: true
  128106. });
  128107. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  128108. get: function () {
  128109. return this._stencilFuncRef;
  128110. },
  128111. set: function (value) {
  128112. if (this._stencilFuncRef === value) {
  128113. return;
  128114. }
  128115. this._stencilFuncRef = value;
  128116. this._isStencilFuncDirty = true;
  128117. },
  128118. enumerable: true,
  128119. configurable: true
  128120. });
  128121. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  128122. get: function () {
  128123. return this._stencilFuncMask;
  128124. },
  128125. set: function (value) {
  128126. if (this._stencilFuncMask === value) {
  128127. return;
  128128. }
  128129. this._stencilFuncMask = value;
  128130. this._isStencilFuncDirty = true;
  128131. },
  128132. enumerable: true,
  128133. configurable: true
  128134. });
  128135. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  128136. get: function () {
  128137. return this._stencilOpStencilFail;
  128138. },
  128139. set: function (value) {
  128140. if (this._stencilOpStencilFail === value) {
  128141. return;
  128142. }
  128143. this._stencilOpStencilFail = value;
  128144. this._isStencilOpDirty = true;
  128145. },
  128146. enumerable: true,
  128147. configurable: true
  128148. });
  128149. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  128150. get: function () {
  128151. return this._stencilOpDepthFail;
  128152. },
  128153. set: function (value) {
  128154. if (this._stencilOpDepthFail === value) {
  128155. return;
  128156. }
  128157. this._stencilOpDepthFail = value;
  128158. this._isStencilOpDirty = true;
  128159. },
  128160. enumerable: true,
  128161. configurable: true
  128162. });
  128163. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  128164. get: function () {
  128165. return this._stencilOpStencilDepthPass;
  128166. },
  128167. set: function (value) {
  128168. if (this._stencilOpStencilDepthPass === value) {
  128169. return;
  128170. }
  128171. this._stencilOpStencilDepthPass = value;
  128172. this._isStencilOpDirty = true;
  128173. },
  128174. enumerable: true,
  128175. configurable: true
  128176. });
  128177. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  128178. get: function () {
  128179. return this._stencilMask;
  128180. },
  128181. set: function (value) {
  128182. if (this._stencilMask === value) {
  128183. return;
  128184. }
  128185. this._stencilMask = value;
  128186. this._isStencilMaskDirty = true;
  128187. },
  128188. enumerable: true,
  128189. configurable: true
  128190. });
  128191. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  128192. get: function () {
  128193. return this._stencilTest;
  128194. },
  128195. set: function (value) {
  128196. if (this._stencilTest === value) {
  128197. return;
  128198. }
  128199. this._stencilTest = value;
  128200. this._isStencilTestDirty = true;
  128201. },
  128202. enumerable: true,
  128203. configurable: true
  128204. });
  128205. _StencilState.prototype.reset = function () {
  128206. this._stencilTest = false;
  128207. this._stencilMask = 0xFF;
  128208. this._stencilFunc = _StencilState.ALWAYS;
  128209. this._stencilFuncRef = 1;
  128210. this._stencilFuncMask = 0xFF;
  128211. this._stencilOpStencilFail = _StencilState.KEEP;
  128212. this._stencilOpDepthFail = _StencilState.KEEP;
  128213. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  128214. this._isStencilTestDirty = true;
  128215. this._isStencilMaskDirty = true;
  128216. this._isStencilFuncDirty = true;
  128217. this._isStencilOpDirty = true;
  128218. };
  128219. _StencilState.prototype.apply = function (gl) {
  128220. if (!this.isDirty) {
  128221. return;
  128222. }
  128223. // Stencil test
  128224. if (this._isStencilTestDirty) {
  128225. if (this.stencilTest) {
  128226. gl.enable(gl.STENCIL_TEST);
  128227. }
  128228. else {
  128229. gl.disable(gl.STENCIL_TEST);
  128230. }
  128231. this._isStencilTestDirty = false;
  128232. }
  128233. // Stencil mask
  128234. if (this._isStencilMaskDirty) {
  128235. gl.stencilMask(this.stencilMask);
  128236. this._isStencilMaskDirty = false;
  128237. }
  128238. // Stencil func
  128239. if (this._isStencilFuncDirty) {
  128240. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  128241. this._isStencilFuncDirty = false;
  128242. }
  128243. // Stencil op
  128244. if (this._isStencilOpDirty) {
  128245. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  128246. this._isStencilOpDirty = false;
  128247. }
  128248. };
  128249. /** 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 */
  128250. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  128251. /** Passed to stencilOperation to specify that stencil value must be kept */
  128252. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  128253. /** Passed to stencilOperation to specify that stencil value must be replaced */
  128254. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  128255. return _StencilState;
  128256. }());
  128257. /***/ }),
  128258. /***/ "./abstractScene.ts":
  128259. /*!**************************!*\
  128260. !*** ./abstractScene.ts ***!
  128261. \**************************/
  128262. /*! exports provided: AbstractScene */
  128263. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128264. "use strict";
  128265. __webpack_require__.r(__webpack_exports__);
  128266. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  128267. /**
  128268. * Base class of the scene acting as a container for the different elements composing a scene.
  128269. * This class is dynamically extended by the different components of the scene increasing
  128270. * flexibility and reducing coupling
  128271. */
  128272. var AbstractScene = /** @class */ (function () {
  128273. function AbstractScene() {
  128274. /**
  128275. * Gets the list of root nodes (ie. nodes with no parent)
  128276. */
  128277. this.rootNodes = new Array();
  128278. /** All of the cameras added to this scene
  128279. * @see http://doc.babylonjs.com/babylon101/cameras
  128280. */
  128281. this.cameras = new Array();
  128282. /**
  128283. * All of the lights added to this scene
  128284. * @see http://doc.babylonjs.com/babylon101/lights
  128285. */
  128286. this.lights = new Array();
  128287. /**
  128288. * All of the (abstract) meshes added to this scene
  128289. */
  128290. this.meshes = new Array();
  128291. /**
  128292. * The list of skeletons added to the scene
  128293. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  128294. */
  128295. this.skeletons = new Array();
  128296. /**
  128297. * All of the particle systems added to this scene
  128298. * @see http://doc.babylonjs.com/babylon101/particles
  128299. */
  128300. this.particleSystems = new Array();
  128301. /**
  128302. * Gets a list of Animations associated with the scene
  128303. */
  128304. this.animations = [];
  128305. /**
  128306. * All of the animation groups added to this scene
  128307. * @see http://doc.babylonjs.com/how_to/group
  128308. */
  128309. this.animationGroups = new Array();
  128310. /**
  128311. * All of the multi-materials added to this scene
  128312. * @see http://doc.babylonjs.com/how_to/multi_materials
  128313. */
  128314. this.multiMaterials = new Array();
  128315. /**
  128316. * All of the materials added to this scene
  128317. * In the context of a Scene, it is not supposed to be modified manually.
  128318. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  128319. * Note also that the order of the Material wihin the array is not significant and might change.
  128320. * @see http://doc.babylonjs.com/babylon101/materials
  128321. */
  128322. this.materials = new Array();
  128323. /**
  128324. * The list of morph target managers added to the scene
  128325. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  128326. */
  128327. this.morphTargetManagers = new Array();
  128328. /**
  128329. * The list of geometries used in the scene.
  128330. */
  128331. this.geometries = new Array();
  128332. /**
  128333. * All of the tranform nodes added to this scene
  128334. * In the context of a Scene, it is not supposed to be modified manually.
  128335. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  128336. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  128337. * @see http://doc.babylonjs.com/how_to/transformnode
  128338. */
  128339. this.transformNodes = new Array();
  128340. /**
  128341. * ActionManagers available on the scene.
  128342. */
  128343. this.actionManagers = new Array();
  128344. /**
  128345. * Textures to keep.
  128346. */
  128347. this.textures = new Array();
  128348. }
  128349. /**
  128350. * Adds a parser in the list of available ones
  128351. * @param name Defines the name of the parser
  128352. * @param parser Defines the parser to add
  128353. */
  128354. AbstractScene.AddParser = function (name, parser) {
  128355. this._BabylonFileParsers[name] = parser;
  128356. };
  128357. /**
  128358. * Gets a general parser from the list of avaialble ones
  128359. * @param name Defines the name of the parser
  128360. * @returns the requested parser or null
  128361. */
  128362. AbstractScene.GetParser = function (name) {
  128363. if (this._BabylonFileParsers[name]) {
  128364. return this._BabylonFileParsers[name];
  128365. }
  128366. return null;
  128367. };
  128368. /**
  128369. * Adds n individual parser in the list of available ones
  128370. * @param name Defines the name of the parser
  128371. * @param parser Defines the parser to add
  128372. */
  128373. AbstractScene.AddIndividualParser = function (name, parser) {
  128374. this._IndividualBabylonFileParsers[name] = parser;
  128375. };
  128376. /**
  128377. * Gets an individual parser from the list of avaialble ones
  128378. * @param name Defines the name of the parser
  128379. * @returns the requested parser or null
  128380. */
  128381. AbstractScene.GetIndividualParser = function (name) {
  128382. if (this._IndividualBabylonFileParsers[name]) {
  128383. return this._IndividualBabylonFileParsers[name];
  128384. }
  128385. return null;
  128386. };
  128387. /**
  128388. * Parser json data and populate both a scene and its associated container object
  128389. * @param jsonData Defines the data to parse
  128390. * @param scene Defines the scene to parse the data for
  128391. * @param container Defines the container attached to the parsing sequence
  128392. * @param rootUrl Defines the root url of the data
  128393. */
  128394. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  128395. for (var parserName in this._BabylonFileParsers) {
  128396. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  128397. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  128398. }
  128399. }
  128400. };
  128401. /**
  128402. * Stores the list of available parsers in the application.
  128403. */
  128404. AbstractScene._BabylonFileParsers = {};
  128405. /**
  128406. * Stores the list of available individual parsers in the application.
  128407. */
  128408. AbstractScene._IndividualBabylonFileParsers = {};
  128409. return AbstractScene;
  128410. }());
  128411. /***/ }),
  128412. /***/ "./assetContainer.ts":
  128413. /*!***************************!*\
  128414. !*** ./assetContainer.ts ***!
  128415. \***************************/
  128416. /*! exports provided: KeepAssets, AssetContainer */
  128417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128418. "use strict";
  128419. __webpack_require__.r(__webpack_exports__);
  128420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  128421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  128422. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  128423. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  128424. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  128425. /**
  128426. * Set of assets to keep when moving a scene into an asset container.
  128427. */
  128428. var KeepAssets = /** @class */ (function (_super) {
  128429. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  128430. function KeepAssets() {
  128431. return _super !== null && _super.apply(this, arguments) || this;
  128432. }
  128433. return KeepAssets;
  128434. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  128435. /**
  128436. * Container with a set of assets that can be added or removed from a scene.
  128437. */
  128438. var AssetContainer = /** @class */ (function (_super) {
  128439. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  128440. /**
  128441. * Instantiates an AssetContainer.
  128442. * @param scene The scene the AssetContainer belongs to.
  128443. */
  128444. function AssetContainer(scene) {
  128445. var _this = _super.call(this) || this;
  128446. _this.scene = scene;
  128447. _this["sounds"] = [];
  128448. _this["effectLayers"] = [];
  128449. _this["layers"] = [];
  128450. _this["lensFlareSystems"] = [];
  128451. _this["proceduralTextures"] = [];
  128452. _this["reflectionProbes"] = [];
  128453. return _this;
  128454. }
  128455. /**
  128456. * Adds all the assets from the container to the scene.
  128457. */
  128458. AssetContainer.prototype.addAllToScene = function () {
  128459. var _this = this;
  128460. this.cameras.forEach(function (o) {
  128461. _this.scene.addCamera(o);
  128462. });
  128463. this.lights.forEach(function (o) {
  128464. _this.scene.addLight(o);
  128465. });
  128466. this.meshes.forEach(function (o) {
  128467. _this.scene.addMesh(o);
  128468. });
  128469. this.skeletons.forEach(function (o) {
  128470. _this.scene.addSkeleton(o);
  128471. });
  128472. this.animations.forEach(function (o) {
  128473. _this.scene.addAnimation(o);
  128474. });
  128475. this.animationGroups.forEach(function (o) {
  128476. _this.scene.addAnimationGroup(o);
  128477. });
  128478. this.multiMaterials.forEach(function (o) {
  128479. _this.scene.addMultiMaterial(o);
  128480. });
  128481. this.materials.forEach(function (o) {
  128482. _this.scene.addMaterial(o);
  128483. });
  128484. this.morphTargetManagers.forEach(function (o) {
  128485. _this.scene.addMorphTargetManager(o);
  128486. });
  128487. this.geometries.forEach(function (o) {
  128488. _this.scene.addGeometry(o);
  128489. });
  128490. this.transformNodes.forEach(function (o) {
  128491. _this.scene.addTransformNode(o);
  128492. });
  128493. this.actionManagers.forEach(function (o) {
  128494. _this.scene.addActionManager(o);
  128495. });
  128496. this.textures.forEach(function (o) {
  128497. _this.scene.addTexture(o);
  128498. });
  128499. this.reflectionProbes.forEach(function (o) {
  128500. _this.scene.addReflectionProbe(o);
  128501. });
  128502. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  128503. var component = _a[_i];
  128504. component.addFromContainer(this);
  128505. }
  128506. };
  128507. /**
  128508. * Removes all the assets in the container from the scene
  128509. */
  128510. AssetContainer.prototype.removeAllFromScene = function () {
  128511. var _this = this;
  128512. this.cameras.forEach(function (o) {
  128513. _this.scene.removeCamera(o);
  128514. });
  128515. this.lights.forEach(function (o) {
  128516. _this.scene.removeLight(o);
  128517. });
  128518. this.meshes.forEach(function (o) {
  128519. _this.scene.removeMesh(o);
  128520. });
  128521. this.skeletons.forEach(function (o) {
  128522. _this.scene.removeSkeleton(o);
  128523. });
  128524. this.animations.forEach(function (o) {
  128525. _this.scene.removeAnimation(o);
  128526. });
  128527. this.animationGroups.forEach(function (o) {
  128528. _this.scene.removeAnimationGroup(o);
  128529. });
  128530. this.multiMaterials.forEach(function (o) {
  128531. _this.scene.removeMultiMaterial(o);
  128532. });
  128533. this.materials.forEach(function (o) {
  128534. _this.scene.removeMaterial(o);
  128535. });
  128536. this.morphTargetManagers.forEach(function (o) {
  128537. _this.scene.removeMorphTargetManager(o);
  128538. });
  128539. this.geometries.forEach(function (o) {
  128540. _this.scene.removeGeometry(o);
  128541. });
  128542. this.transformNodes.forEach(function (o) {
  128543. _this.scene.removeTransformNode(o);
  128544. });
  128545. this.actionManagers.forEach(function (o) {
  128546. _this.scene.removeActionManager(o);
  128547. });
  128548. this.textures.forEach(function (o) {
  128549. _this.scene.removeTexture(o);
  128550. });
  128551. this.reflectionProbes.forEach(function (o) {
  128552. _this.scene.removeReflectionProbe(o);
  128553. });
  128554. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  128555. var component = _a[_i];
  128556. component.removeFromContainer(this);
  128557. }
  128558. };
  128559. /**
  128560. * Disposes all the assets in the container
  128561. */
  128562. AssetContainer.prototype.dispose = function () {
  128563. this.cameras.forEach(function (o) {
  128564. o.dispose();
  128565. });
  128566. this.lights.forEach(function (o) {
  128567. o.dispose();
  128568. });
  128569. this.meshes.forEach(function (o) {
  128570. o.dispose();
  128571. });
  128572. this.skeletons.forEach(function (o) {
  128573. o.dispose();
  128574. });
  128575. this.animationGroups.forEach(function (o) {
  128576. o.dispose();
  128577. });
  128578. this.multiMaterials.forEach(function (o) {
  128579. o.dispose();
  128580. });
  128581. this.materials.forEach(function (o) {
  128582. o.dispose();
  128583. });
  128584. this.geometries.forEach(function (o) {
  128585. o.dispose();
  128586. });
  128587. this.transformNodes.forEach(function (o) {
  128588. o.dispose();
  128589. });
  128590. this.actionManagers.forEach(function (o) {
  128591. o.dispose();
  128592. });
  128593. this.textures.forEach(function (o) {
  128594. o.dispose();
  128595. });
  128596. this.reflectionProbes.forEach(function (o) {
  128597. o.dispose();
  128598. });
  128599. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  128600. var component = _a[_i];
  128601. component.dispose();
  128602. }
  128603. };
  128604. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  128605. if (!sourceAssets) {
  128606. return;
  128607. }
  128608. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  128609. var asset = sourceAssets_1[_i];
  128610. var move = true;
  128611. if (keepAssets) {
  128612. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  128613. var keepAsset = keepAssets_1[_a];
  128614. if (asset === keepAsset) {
  128615. move = false;
  128616. break;
  128617. }
  128618. }
  128619. }
  128620. if (move) {
  128621. targetAssets.push(asset);
  128622. }
  128623. }
  128624. };
  128625. /**
  128626. * Removes all the assets contained in the scene and adds them to the container.
  128627. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  128628. */
  128629. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  128630. if (keepAssets === undefined) {
  128631. keepAssets = new KeepAssets();
  128632. }
  128633. for (var key in this) {
  128634. if (this.hasOwnProperty(key)) {
  128635. this[key] = this[key] || [];
  128636. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  128637. }
  128638. }
  128639. this.removeAllFromScene();
  128640. };
  128641. /**
  128642. * 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.
  128643. * @returns the root mesh
  128644. */
  128645. AssetContainer.prototype.createRootMesh = function () {
  128646. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  128647. this.meshes.forEach(function (m) {
  128648. if (!m.parent) {
  128649. rootMesh.addChild(m);
  128650. }
  128651. });
  128652. this.meshes.unshift(rootMesh);
  128653. return rootMesh;
  128654. };
  128655. return AssetContainer;
  128656. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  128657. /***/ }),
  128658. /***/ "./index.ts":
  128659. /*!******************!*\
  128660. !*** ./index.ts ***!
  128661. \******************/
  128662. /*! 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, AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, 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, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  128663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128664. "use strict";
  128665. __webpack_require__.r(__webpack_exports__);
  128666. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  128667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  128668. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  128669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  128670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  128671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  128672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  128673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  128674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  128675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  128676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  128677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  128678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  128679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  128680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  128681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  128682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  128683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  128684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  128685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  128686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  128687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  128688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  128689. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  128690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  128691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  128692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  128693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  128694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  128695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  128696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  128697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  128698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  128699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  128700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  128701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  128702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  128703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  128704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  128705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  128706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  128707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  128708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  128709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  128710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  128711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  128712. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  128713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  128714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  128715. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  128716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  128717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  128718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  128719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  128720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  128721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  128722. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  128723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  128724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  128725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  128726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  128727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  128728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  128729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  128730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  128731. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  128732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  128733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  128734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  128735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  128736. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  128737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  128738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  128739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  128740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  128741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  128742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  128743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  128744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  128745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  128746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  128747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  128748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  128749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  128750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  128751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  128752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  128753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  128754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  128755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  128756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  128757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  128758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  128759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  128760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  128761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  128762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  128763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  128764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  128765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  128766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  128767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  128768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  128769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  128770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  128771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  128772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  128773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  128774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  128775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  128776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  128777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  128778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  128779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  128780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  128781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  128782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  128783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  128784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  128785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  128786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  128787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  128788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  128789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  128790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  128791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  128792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  128793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  128794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  128795. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  128796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  128797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  128798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  128799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  128800. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  128801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  128802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  128803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  128804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  128805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  128806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  128807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  128808. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  128809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  128810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  128811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  128812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  128813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  128814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  128815. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  128816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  128817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  128818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  128819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  128820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  128821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  128822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  128823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  128824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  128825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  128826. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  128827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  128828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  128829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  128830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  128831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  128832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  128833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  128834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  128835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  128836. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  128837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  128838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  128839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  128840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  128841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  128842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  128843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  128844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  128845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  128846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  128847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  128848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  128849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  128850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  128851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  128852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  128853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  128854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  128855. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  128856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  128857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  128858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  128859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  128860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  128861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  128862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  128863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  128864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  128865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  128866. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  128867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  128868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  128869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  128870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  128871. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  128872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  128873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  128874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  128875. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  128876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  128877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  128878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  128879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  128880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  128881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  128882. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  128883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  128884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  128885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  128886. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  128887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  128888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  128889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  128890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  128891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  128892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  128893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  128894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  128895. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  128896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  128897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  128898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  128899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  128900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  128901. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  128902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  128903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  128904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  128905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  128906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  128907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  128908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  128909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  128910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  128911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  128912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  128913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  128914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  128915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  128916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  128917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  128918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  128919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  128920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  128921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  128922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  128923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  128924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  128925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  128926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  128927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  128928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  128929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  128930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  128931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  128932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  128933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  128934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  128935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  128936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  128937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  128938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  128939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  128940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  128941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  128942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  128943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  128944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  128945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  128946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  128947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  128948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  128949. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  128950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  128951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  128952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  128953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  128954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  128955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  128956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  128957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  128958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  128959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  128960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  128961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  128962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  128963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  128964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  128965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  128966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  128967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  128968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  128969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  128970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  128971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  128972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  128973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  128974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  128975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  128976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  128977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  128978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  128979. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  128980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  128981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  128982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  128983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  128984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  128985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  128986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  128987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  128988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  128989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  128990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  128991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  128992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  128993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  128994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  128995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  128996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  128997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  128998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  128999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  129000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  129001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  129002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  129003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  129004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  129005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  129006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  129007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  129008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  129009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  129010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  129011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  129012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  129013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  129014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  129015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  129016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  129017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  129018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  129019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  129020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  129021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  129022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  129023. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  129024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  129025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  129026. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  129027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  129028. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  129029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  129030. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  129031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  129032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  129033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  129034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  129035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  129036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  129037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  129038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  129039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  129040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  129041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  129042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  129043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  129044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  129045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  129046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  129047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  129048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  129049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  129050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  129051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  129052. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  129053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  129054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  129055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  129056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  129057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  129058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  129059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  129060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  129061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  129062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  129063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  129064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  129065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  129066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  129067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  129068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  129069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  129070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  129071. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  129072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  129073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  129074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  129075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  129076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  129077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  129078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  129079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  129080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  129081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  129082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  129083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  129084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  129085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  129086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  129087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  129088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  129089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  129090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  129091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  129092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  129093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  129094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  129095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  129096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  129097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  129098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  129099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  129100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  129101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  129102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  129103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  129104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  129105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  129106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  129107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  129108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  129109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  129110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  129111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  129112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  129113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  129114. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  129115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  129116. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  129117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  129118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  129119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  129120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  129121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  129122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  129123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  129124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  129125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  129126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  129127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  129128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  129129. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  129130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  129131. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  129132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  129133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  129134. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  129135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  129136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  129137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  129138. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  129139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  129140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  129141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  129142. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  129143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  129144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  129145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  129146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  129147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  129148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  129149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  129150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  129151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  129152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  129153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  129154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  129155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  129156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  129157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  129158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  129159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  129160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  129161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  129162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  129163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  129164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  129165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  129166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  129167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  129168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  129169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  129170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  129171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  129172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  129173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  129174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  129175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  129176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  129177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  129178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  129179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  129180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  129181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  129182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  129183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  129184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  129185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  129186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  129187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  129188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  129189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  129190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  129191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  129192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  129193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  129194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  129195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  129196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  129197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  129198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  129199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  129200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  129201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  129202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  129203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  129204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  129205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  129206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  129207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  129208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  129209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  129210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  129211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  129212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  129213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  129214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  129215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  129216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  129217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  129218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  129219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  129220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  129221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  129222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  129223. /***/ }),
  129224. /***/ "./node.ts":
  129225. /*!*****************!*\
  129226. !*** ./node.ts ***!
  129227. \*****************/
  129228. /*! exports provided: Node */
  129229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129230. "use strict";
  129231. __webpack_require__.r(__webpack_exports__);
  129232. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  129233. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  129234. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  129235. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  129236. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  129237. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  129238. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  129239. /**
  129240. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  129241. */
  129242. var Node = /** @class */ (function () {
  129243. /**
  129244. * Creates a new Node
  129245. * @param name the name and id to be given to this node
  129246. * @param scene the scene this node will be added to
  129247. * @param addToRootNodes the node will be added to scene.rootNodes
  129248. */
  129249. function Node(name, scene, addToRootNodes) {
  129250. if (scene === void 0) { scene = null; }
  129251. if (addToRootNodes === void 0) { addToRootNodes = true; }
  129252. /**
  129253. * Gets or sets a string used to store user defined state for the node
  129254. */
  129255. this.state = "";
  129256. /**
  129257. * Gets or sets an object used to store user defined information for the node
  129258. */
  129259. this.metadata = null;
  129260. /**
  129261. * For internal use only. Please do not use.
  129262. */
  129263. this.reservedDataStore = null;
  129264. /**
  129265. * Gets or sets a boolean used to define if the node must be serialized
  129266. */
  129267. this.doNotSerialize = false;
  129268. /** @hidden */
  129269. this._isDisposed = false;
  129270. /**
  129271. * Gets a list of Animations associated with the node
  129272. */
  129273. this.animations = new Array();
  129274. this._ranges = {};
  129275. this._isEnabled = true;
  129276. this._isParentEnabled = true;
  129277. this._isReady = true;
  129278. /** @hidden */
  129279. this._currentRenderId = -1;
  129280. this._parentRenderId = -1;
  129281. this._childRenderId = -1;
  129282. /** @hidden */
  129283. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  129284. /** @hidden */
  129285. this._worldMatrixDeterminant = 0;
  129286. /** @hidden */
  129287. this._sceneRootNodesIndex = -1;
  129288. this._animationPropertiesOverride = null;
  129289. /** @hidden */
  129290. this._isNode = true;
  129291. /**
  129292. * An event triggered when the mesh is disposed
  129293. */
  129294. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129295. // Behaviors
  129296. this._behaviors = new Array();
  129297. this.name = name;
  129298. this.id = name;
  129299. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  129300. this.uniqueId = this._scene.getUniqueId();
  129301. this._initCache();
  129302. if (addToRootNodes) {
  129303. this.addToSceneRootNodes();
  129304. }
  129305. }
  129306. /**
  129307. * Add a new node constructor
  129308. * @param type defines the type name of the node to construct
  129309. * @param constructorFunc defines the constructor function
  129310. */
  129311. Node.AddNodeConstructor = function (type, constructorFunc) {
  129312. this._NodeConstructors[type] = constructorFunc;
  129313. };
  129314. /**
  129315. * Returns a node constructor based on type name
  129316. * @param type defines the type name
  129317. * @param name defines the new node name
  129318. * @param scene defines the hosting scene
  129319. * @param options defines optional options to transmit to constructors
  129320. * @returns the new constructor or null
  129321. */
  129322. Node.Construct = function (type, name, scene, options) {
  129323. var constructorFunc = this._NodeConstructors[type];
  129324. if (!constructorFunc) {
  129325. return null;
  129326. }
  129327. return constructorFunc(name, scene, options);
  129328. };
  129329. /**
  129330. * Gets a boolean indicating if the node has been disposed
  129331. * @returns true if the node was disposed
  129332. */
  129333. Node.prototype.isDisposed = function () {
  129334. return this._isDisposed;
  129335. };
  129336. Object.defineProperty(Node.prototype, "parent", {
  129337. get: function () {
  129338. return this._parentNode;
  129339. },
  129340. /**
  129341. * Gets or sets the parent of the node
  129342. */
  129343. set: function (parent) {
  129344. if (this._parentNode === parent) {
  129345. return;
  129346. }
  129347. var previousParentNode = this._parentNode;
  129348. // Remove self from list of children of parent
  129349. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  129350. var index = this._parentNode._children.indexOf(this);
  129351. if (index !== -1) {
  129352. this._parentNode._children.splice(index, 1);
  129353. }
  129354. if (!parent && !this._isDisposed) {
  129355. this.addToSceneRootNodes();
  129356. }
  129357. }
  129358. // Store new parent
  129359. this._parentNode = parent;
  129360. // Add as child to new parent
  129361. if (this._parentNode) {
  129362. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  129363. this._parentNode._children = new Array();
  129364. }
  129365. this._parentNode._children.push(this);
  129366. if (!previousParentNode) {
  129367. this.removeFromSceneRootNodes();
  129368. }
  129369. }
  129370. // Enabled state
  129371. this._syncParentEnabledState();
  129372. },
  129373. enumerable: true,
  129374. configurable: true
  129375. });
  129376. Node.prototype.addToSceneRootNodes = function () {
  129377. if (this._sceneRootNodesIndex === -1) {
  129378. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  129379. this._scene.rootNodes.push(this);
  129380. }
  129381. };
  129382. Node.prototype.removeFromSceneRootNodes = function () {
  129383. if (this._sceneRootNodesIndex !== -1) {
  129384. var rootNodes = this._scene.rootNodes;
  129385. var lastIdx = rootNodes.length - 1;
  129386. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  129387. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  129388. this._scene.rootNodes.pop();
  129389. this._sceneRootNodesIndex = -1;
  129390. }
  129391. };
  129392. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  129393. /**
  129394. * Gets or sets the animation properties override
  129395. */
  129396. get: function () {
  129397. if (!this._animationPropertiesOverride) {
  129398. return this._scene.animationPropertiesOverride;
  129399. }
  129400. return this._animationPropertiesOverride;
  129401. },
  129402. set: function (value) {
  129403. this._animationPropertiesOverride = value;
  129404. },
  129405. enumerable: true,
  129406. configurable: true
  129407. });
  129408. /**
  129409. * Gets a string idenfifying the name of the class
  129410. * @returns "Node" string
  129411. */
  129412. Node.prototype.getClassName = function () {
  129413. return "Node";
  129414. };
  129415. Object.defineProperty(Node.prototype, "onDispose", {
  129416. /**
  129417. * Sets a callback that will be raised when the node will be disposed
  129418. */
  129419. set: function (callback) {
  129420. if (this._onDisposeObserver) {
  129421. this.onDisposeObservable.remove(this._onDisposeObserver);
  129422. }
  129423. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  129424. },
  129425. enumerable: true,
  129426. configurable: true
  129427. });
  129428. /**
  129429. * Gets the scene of the node
  129430. * @returns a scene
  129431. */
  129432. Node.prototype.getScene = function () {
  129433. return this._scene;
  129434. };
  129435. /**
  129436. * Gets the engine of the node
  129437. * @returns a Engine
  129438. */
  129439. Node.prototype.getEngine = function () {
  129440. return this._scene.getEngine();
  129441. };
  129442. /**
  129443. * Attach a behavior to the node
  129444. * @see http://doc.babylonjs.com/features/behaviour
  129445. * @param behavior defines the behavior to attach
  129446. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  129447. * @returns the current Node
  129448. */
  129449. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  129450. var _this = this;
  129451. if (attachImmediately === void 0) { attachImmediately = false; }
  129452. var index = this._behaviors.indexOf(behavior);
  129453. if (index !== -1) {
  129454. return this;
  129455. }
  129456. behavior.init();
  129457. if (this._scene.isLoading && !attachImmediately) {
  129458. // We defer the attach when the scene will be loaded
  129459. this._scene.onDataLoadedObservable.addOnce(function () {
  129460. behavior.attach(_this);
  129461. });
  129462. }
  129463. else {
  129464. behavior.attach(this);
  129465. }
  129466. this._behaviors.push(behavior);
  129467. return this;
  129468. };
  129469. /**
  129470. * Remove an attached behavior
  129471. * @see http://doc.babylonjs.com/features/behaviour
  129472. * @param behavior defines the behavior to attach
  129473. * @returns the current Node
  129474. */
  129475. Node.prototype.removeBehavior = function (behavior) {
  129476. var index = this._behaviors.indexOf(behavior);
  129477. if (index === -1) {
  129478. return this;
  129479. }
  129480. this._behaviors[index].detach();
  129481. this._behaviors.splice(index, 1);
  129482. return this;
  129483. };
  129484. Object.defineProperty(Node.prototype, "behaviors", {
  129485. /**
  129486. * Gets the list of attached behaviors
  129487. * @see http://doc.babylonjs.com/features/behaviour
  129488. */
  129489. get: function () {
  129490. return this._behaviors;
  129491. },
  129492. enumerable: true,
  129493. configurable: true
  129494. });
  129495. /**
  129496. * Gets an attached behavior by name
  129497. * @param name defines the name of the behavior to look for
  129498. * @see http://doc.babylonjs.com/features/behaviour
  129499. * @returns null if behavior was not found else the requested behavior
  129500. */
  129501. Node.prototype.getBehaviorByName = function (name) {
  129502. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  129503. var behavior = _a[_i];
  129504. if (behavior.name === name) {
  129505. return behavior;
  129506. }
  129507. }
  129508. return null;
  129509. };
  129510. /**
  129511. * Returns the latest update of the World matrix
  129512. * @returns a Matrix
  129513. */
  129514. Node.prototype.getWorldMatrix = function () {
  129515. if (this._currentRenderId !== this._scene.getRenderId()) {
  129516. this.computeWorldMatrix();
  129517. }
  129518. return this._worldMatrix;
  129519. };
  129520. /** @hidden */
  129521. Node.prototype._getWorldMatrixDeterminant = function () {
  129522. return this._worldMatrixDeterminant;
  129523. };
  129524. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  129525. /**
  129526. * Returns directly the latest state of the mesh World matrix.
  129527. * A Matrix is returned.
  129528. */
  129529. get: function () {
  129530. return this._worldMatrix;
  129531. },
  129532. enumerable: true,
  129533. configurable: true
  129534. });
  129535. // override it in derived class if you add new variables to the cache
  129536. // and call the parent class method
  129537. /** @hidden */
  129538. Node.prototype._initCache = function () {
  129539. this._cache = {};
  129540. this._cache.parent = undefined;
  129541. };
  129542. /** @hidden */
  129543. Node.prototype.updateCache = function (force) {
  129544. if (!force && this.isSynchronized()) {
  129545. return;
  129546. }
  129547. this._cache.parent = this.parent;
  129548. this._updateCache();
  129549. };
  129550. /** @hidden */
  129551. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  129552. if (initialCall === void 0) { initialCall = true; }
  129553. if (!this.parent) {
  129554. return null;
  129555. }
  129556. return this.parent._getActionManagerForTrigger(trigger, false);
  129557. };
  129558. // override it in derived class if you add new variables to the cache
  129559. // and call the parent class method if !ignoreParentClass
  129560. /** @hidden */
  129561. Node.prototype._updateCache = function (ignoreParentClass) {
  129562. };
  129563. // override it in derived class if you add new variables to the cache
  129564. /** @hidden */
  129565. Node.prototype._isSynchronized = function () {
  129566. return true;
  129567. };
  129568. /** @hidden */
  129569. Node.prototype._markSyncedWithParent = function () {
  129570. if (this._parentNode) {
  129571. this._parentRenderId = this._parentNode._childRenderId;
  129572. }
  129573. };
  129574. /** @hidden */
  129575. Node.prototype.isSynchronizedWithParent = function () {
  129576. if (!this._parentNode) {
  129577. return true;
  129578. }
  129579. if (this._parentRenderId !== this._parentNode._childRenderId) {
  129580. return false;
  129581. }
  129582. return this._parentNode.isSynchronized();
  129583. };
  129584. /** @hidden */
  129585. Node.prototype.isSynchronized = function () {
  129586. if (this._cache.parent != this._parentNode) {
  129587. this._cache.parent = this._parentNode;
  129588. return false;
  129589. }
  129590. if (this._parentNode && !this.isSynchronizedWithParent()) {
  129591. return false;
  129592. }
  129593. return this._isSynchronized();
  129594. };
  129595. /**
  129596. * Is this node ready to be used/rendered
  129597. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  129598. * @return true if the node is ready
  129599. */
  129600. Node.prototype.isReady = function (completeCheck) {
  129601. if (completeCheck === void 0) { completeCheck = false; }
  129602. return this._isReady;
  129603. };
  129604. /**
  129605. * Is this node enabled?
  129606. * 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
  129607. * @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
  129608. * @return whether this node (and its parent) is enabled
  129609. */
  129610. Node.prototype.isEnabled = function (checkAncestors) {
  129611. if (checkAncestors === void 0) { checkAncestors = true; }
  129612. if (checkAncestors === false) {
  129613. return this._isEnabled;
  129614. }
  129615. if (!this._isEnabled) {
  129616. return false;
  129617. }
  129618. return this._isParentEnabled;
  129619. };
  129620. /** @hidden */
  129621. Node.prototype._syncParentEnabledState = function () {
  129622. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  129623. if (this._children) {
  129624. this._children.forEach(function (c) {
  129625. c._syncParentEnabledState(); // Force children to update accordingly
  129626. });
  129627. }
  129628. };
  129629. /**
  129630. * Set the enabled state of this node
  129631. * @param value defines the new enabled state
  129632. */
  129633. Node.prototype.setEnabled = function (value) {
  129634. this._isEnabled = value;
  129635. this._syncParentEnabledState();
  129636. };
  129637. /**
  129638. * Is this node a descendant of the given node?
  129639. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  129640. * @param ancestor defines the parent node to inspect
  129641. * @returns a boolean indicating if this node is a descendant of the given node
  129642. */
  129643. Node.prototype.isDescendantOf = function (ancestor) {
  129644. if (this.parent) {
  129645. if (this.parent === ancestor) {
  129646. return true;
  129647. }
  129648. return this.parent.isDescendantOf(ancestor);
  129649. }
  129650. return false;
  129651. };
  129652. /** @hidden */
  129653. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  129654. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  129655. if (!this._children) {
  129656. return;
  129657. }
  129658. for (var index = 0; index < this._children.length; index++) {
  129659. var item = this._children[index];
  129660. if (!predicate || predicate(item)) {
  129661. results.push(item);
  129662. }
  129663. if (!directDescendantsOnly) {
  129664. item._getDescendants(results, false, predicate);
  129665. }
  129666. }
  129667. };
  129668. /**
  129669. * Will return all nodes that have this node as ascendant
  129670. * @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
  129671. * @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
  129672. * @return all children nodes of all types
  129673. */
  129674. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  129675. var results = new Array();
  129676. this._getDescendants(results, directDescendantsOnly, predicate);
  129677. return results;
  129678. };
  129679. /**
  129680. * Get all child-meshes of this node
  129681. * @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)
  129682. * @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
  129683. * @returns an array of AbstractMesh
  129684. */
  129685. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  129686. var results = [];
  129687. this._getDescendants(results, directDescendantsOnly, function (node) {
  129688. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  129689. });
  129690. return results;
  129691. };
  129692. /**
  129693. * Get all direct children of this node
  129694. * @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
  129695. * @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)
  129696. * @returns an array of Node
  129697. */
  129698. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  129699. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  129700. return this.getDescendants(directDescendantsOnly, predicate);
  129701. };
  129702. /** @hidden */
  129703. Node.prototype._setReady = function (state) {
  129704. if (state === this._isReady) {
  129705. return;
  129706. }
  129707. if (!state) {
  129708. this._isReady = false;
  129709. return;
  129710. }
  129711. if (this.onReady) {
  129712. this.onReady(this);
  129713. }
  129714. this._isReady = true;
  129715. };
  129716. /**
  129717. * Get an animation by name
  129718. * @param name defines the name of the animation to look for
  129719. * @returns null if not found else the requested animation
  129720. */
  129721. Node.prototype.getAnimationByName = function (name) {
  129722. for (var i = 0; i < this.animations.length; i++) {
  129723. var animation = this.animations[i];
  129724. if (animation.name === name) {
  129725. return animation;
  129726. }
  129727. }
  129728. return null;
  129729. };
  129730. /**
  129731. * Creates an animation range for this node
  129732. * @param name defines the name of the range
  129733. * @param from defines the starting key
  129734. * @param to defines the end key
  129735. */
  129736. Node.prototype.createAnimationRange = function (name, from, to) {
  129737. // check name not already in use
  129738. if (!this._ranges[name]) {
  129739. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  129740. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  129741. if (this.animations[i]) {
  129742. this.animations[i].createRange(name, from, to);
  129743. }
  129744. }
  129745. }
  129746. };
  129747. /**
  129748. * Delete a specific animation range
  129749. * @param name defines the name of the range to delete
  129750. * @param deleteFrames defines if animation frames from the range must be deleted as well
  129751. */
  129752. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  129753. if (deleteFrames === void 0) { deleteFrames = true; }
  129754. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  129755. if (this.animations[i]) {
  129756. this.animations[i].deleteRange(name, deleteFrames);
  129757. }
  129758. }
  129759. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  129760. };
  129761. /**
  129762. * Get an animation range by name
  129763. * @param name defines the name of the animation range to look for
  129764. * @returns null if not found else the requested animation range
  129765. */
  129766. Node.prototype.getAnimationRange = function (name) {
  129767. return this._ranges[name];
  129768. };
  129769. /**
  129770. * Gets the list of all animation ranges defined on this node
  129771. * @returns an array
  129772. */
  129773. Node.prototype.getAnimationRanges = function () {
  129774. var animationRanges = [];
  129775. var name;
  129776. for (name in this._ranges) {
  129777. animationRanges.push(this._ranges[name]);
  129778. }
  129779. return animationRanges;
  129780. };
  129781. /**
  129782. * Will start the animation sequence
  129783. * @param name defines the range frames for animation sequence
  129784. * @param loop defines if the animation should loop (false by default)
  129785. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  129786. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  129787. * @returns the object created for this animation. If range does not exist, it will return null
  129788. */
  129789. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  129790. var range = this.getAnimationRange(name);
  129791. if (!range) {
  129792. return null;
  129793. }
  129794. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  129795. };
  129796. /**
  129797. * Serialize animation ranges into a JSON compatible object
  129798. * @returns serialization object
  129799. */
  129800. Node.prototype.serializeAnimationRanges = function () {
  129801. var serializationRanges = [];
  129802. for (var name in this._ranges) {
  129803. var localRange = this._ranges[name];
  129804. if (!localRange) {
  129805. continue;
  129806. }
  129807. var range = {};
  129808. range.name = name;
  129809. range.from = localRange.from;
  129810. range.to = localRange.to;
  129811. serializationRanges.push(range);
  129812. }
  129813. return serializationRanges;
  129814. };
  129815. /**
  129816. * Computes the world matrix of the node
  129817. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  129818. * @returns the world matrix
  129819. */
  129820. Node.prototype.computeWorldMatrix = function (force) {
  129821. if (!this._worldMatrix) {
  129822. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  129823. }
  129824. return this._worldMatrix;
  129825. };
  129826. /**
  129827. * Releases resources associated with this node.
  129828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  129829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  129830. */
  129831. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  129832. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  129833. this._isDisposed = true;
  129834. if (!doNotRecurse) {
  129835. var nodes = this.getDescendants(true);
  129836. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  129837. var node = nodes_1[_i];
  129838. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  129839. }
  129840. }
  129841. if (!this.parent) {
  129842. this.removeFromSceneRootNodes();
  129843. }
  129844. else {
  129845. this.parent = null;
  129846. }
  129847. // Callback
  129848. this.onDisposeObservable.notifyObservers(this);
  129849. this.onDisposeObservable.clear();
  129850. // Behaviors
  129851. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  129852. var behavior = _b[_a];
  129853. behavior.detach();
  129854. }
  129855. this._behaviors = [];
  129856. };
  129857. /**
  129858. * Parse animation range data from a serialization object and store them into a given node
  129859. * @param node defines where to store the animation ranges
  129860. * @param parsedNode defines the serialization object to read data from
  129861. * @param scene defines the hosting scene
  129862. */
  129863. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  129864. if (parsedNode.ranges) {
  129865. for (var index = 0; index < parsedNode.ranges.length; index++) {
  129866. var data = parsedNode.ranges[index];
  129867. node.createAnimationRange(data.name, data.from, data.to);
  129868. }
  129869. }
  129870. };
  129871. /** @hidden */
  129872. Node._AnimationRangeFactory = function (name, from, to) {
  129873. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  129874. };
  129875. Node._NodeConstructors = {};
  129876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129878. ], Node.prototype, "name", void 0);
  129879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129881. ], Node.prototype, "id", void 0);
  129882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129884. ], Node.prototype, "uniqueId", void 0);
  129885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129887. ], Node.prototype, "state", void 0);
  129888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129890. ], Node.prototype, "metadata", void 0);
  129891. return Node;
  129892. }());
  129893. /***/ }),
  129894. /***/ "./scene.ts":
  129895. /*!******************!*\
  129896. !*** ./scene.ts ***!
  129897. \******************/
  129898. /*! exports provided: Scene */
  129899. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129900. "use strict";
  129901. __webpack_require__.r(__webpack_exports__);
  129902. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  129903. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  129904. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  129905. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  129906. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  129907. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  129908. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  129909. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  129910. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  129911. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  129912. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  129913. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  129914. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  129915. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  129916. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  129917. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  129918. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  129919. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  129920. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  129921. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  129922. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  129923. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  129924. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  129925. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  129926. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  129927. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  129928. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  129929. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  129930. /** @hidden */
  129931. var ClickInfo = /** @class */ (function () {
  129932. function ClickInfo() {
  129933. this._singleClick = false;
  129934. this._doubleClick = false;
  129935. this._hasSwiped = false;
  129936. this._ignore = false;
  129937. }
  129938. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  129939. get: function () {
  129940. return this._singleClick;
  129941. },
  129942. set: function (b) {
  129943. this._singleClick = b;
  129944. },
  129945. enumerable: true,
  129946. configurable: true
  129947. });
  129948. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  129949. get: function () {
  129950. return this._doubleClick;
  129951. },
  129952. set: function (b) {
  129953. this._doubleClick = b;
  129954. },
  129955. enumerable: true,
  129956. configurable: true
  129957. });
  129958. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  129959. get: function () {
  129960. return this._hasSwiped;
  129961. },
  129962. set: function (b) {
  129963. this._hasSwiped = b;
  129964. },
  129965. enumerable: true,
  129966. configurable: true
  129967. });
  129968. Object.defineProperty(ClickInfo.prototype, "ignore", {
  129969. get: function () {
  129970. return this._ignore;
  129971. },
  129972. set: function (b) {
  129973. this._ignore = b;
  129974. },
  129975. enumerable: true,
  129976. configurable: true
  129977. });
  129978. return ClickInfo;
  129979. }());
  129980. /**
  129981. * Represents a scene to be rendered by the engine.
  129982. * @see http://doc.babylonjs.com/features/scene
  129983. */
  129984. var Scene = /** @class */ (function (_super) {
  129985. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  129986. /**
  129987. * Creates a new Scene
  129988. * @param engine defines the engine to use to render this scene
  129989. * @param options defines the scene options
  129990. */
  129991. function Scene(engine, options) {
  129992. var _this = _super.call(this) || this;
  129993. // Members
  129994. /** @hidden */
  129995. _this._isScene = true;
  129996. /**
  129997. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  129998. */
  129999. _this.autoClear = true;
  130000. /**
  130001. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  130002. */
  130003. _this.autoClearDepthAndStencil = true;
  130004. /**
  130005. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  130006. */
  130007. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  130008. /**
  130009. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  130010. */
  130011. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  130012. _this._forceWireframe = false;
  130013. _this._forcePointsCloud = false;
  130014. /**
  130015. * Gets or sets a boolean indicating if animations are enabled
  130016. */
  130017. _this.animationsEnabled = true;
  130018. _this._animationPropertiesOverride = null;
  130019. /**
  130020. * Gets or sets a boolean indicating if a constant deltatime has to be used
  130021. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  130022. */
  130023. _this.useConstantAnimationDeltaTime = false;
  130024. /**
  130025. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  130026. * Please note that it requires to run a ray cast through the scene on every frame
  130027. */
  130028. _this.constantlyUpdateMeshUnderPointer = false;
  130029. /**
  130030. * Defines the HTML cursor to use when hovering over interactive elements
  130031. */
  130032. _this.hoverCursor = "pointer";
  130033. /**
  130034. * Defines the HTML default cursor to use (empty by default)
  130035. */
  130036. _this.defaultCursor = "";
  130037. /**
  130038. * This is used to call preventDefault() on pointer down
  130039. * in order to block unwanted artifacts like system double clicks
  130040. */
  130041. _this.preventDefaultOnPointerDown = true;
  130042. /**
  130043. * This is used to call preventDefault() on pointer up
  130044. * in order to block unwanted artifacts like system double clicks
  130045. */
  130046. _this.preventDefaultOnPointerUp = true;
  130047. // Metadata
  130048. /**
  130049. * Gets or sets user defined metadata
  130050. */
  130051. _this.metadata = null;
  130052. /**
  130053. * For internal use only. Please do not use.
  130054. */
  130055. _this.reservedDataStore = null;
  130056. /**
  130057. * Use this array to add regular expressions used to disable offline support for specific urls
  130058. */
  130059. _this.disableOfflineSupportExceptionRules = new Array();
  130060. /**
  130061. * An event triggered when the scene is disposed.
  130062. */
  130063. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130064. _this._onDisposeObserver = null;
  130065. /**
  130066. * An event triggered before rendering the scene (right after animations and physics)
  130067. */
  130068. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130069. _this._onBeforeRenderObserver = null;
  130070. /**
  130071. * An event triggered after rendering the scene
  130072. */
  130073. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130074. _this._onAfterRenderObserver = null;
  130075. /**
  130076. * An event triggered before animating the scene
  130077. */
  130078. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130079. /**
  130080. * An event triggered after animations processing
  130081. */
  130082. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130083. /**
  130084. * An event triggered before draw calls are ready to be sent
  130085. */
  130086. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130087. /**
  130088. * An event triggered after draw calls have been sent
  130089. */
  130090. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130091. /**
  130092. * An event triggered when the scene is ready
  130093. */
  130094. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130095. /**
  130096. * An event triggered before rendering a camera
  130097. */
  130098. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130099. _this._onBeforeCameraRenderObserver = null;
  130100. /**
  130101. * An event triggered after rendering a camera
  130102. */
  130103. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130104. _this._onAfterCameraRenderObserver = null;
  130105. /**
  130106. * An event triggered when active meshes evaluation is about to start
  130107. */
  130108. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130109. /**
  130110. * An event triggered when active meshes evaluation is done
  130111. */
  130112. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130113. /**
  130114. * An event triggered when particles rendering is about to start
  130115. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  130116. */
  130117. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130118. /**
  130119. * An event triggered when particles rendering is done
  130120. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  130121. */
  130122. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130123. /**
  130124. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  130125. */
  130126. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130127. /**
  130128. * An event triggered when a camera is created
  130129. */
  130130. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130131. /**
  130132. * An event triggered when a camera is removed
  130133. */
  130134. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130135. /**
  130136. * An event triggered when a light is created
  130137. */
  130138. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130139. /**
  130140. * An event triggered when a light is removed
  130141. */
  130142. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130143. /**
  130144. * An event triggered when a geometry is created
  130145. */
  130146. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130147. /**
  130148. * An event triggered when a geometry is removed
  130149. */
  130150. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130151. /**
  130152. * An event triggered when a transform node is created
  130153. */
  130154. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130155. /**
  130156. * An event triggered when a transform node is removed
  130157. */
  130158. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130159. /**
  130160. * An event triggered when a mesh is created
  130161. */
  130162. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130163. /**
  130164. * An event triggered when a mesh is removed
  130165. */
  130166. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130167. /**
  130168. * An event triggered when a material is created
  130169. */
  130170. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130171. /**
  130172. * An event triggered when a material is removed
  130173. */
  130174. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130175. /**
  130176. * An event triggered when a texture is created
  130177. */
  130178. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130179. /**
  130180. * An event triggered when a texture is removed
  130181. */
  130182. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130183. /**
  130184. * An event triggered when render targets are about to be rendered
  130185. * Can happen multiple times per frame.
  130186. */
  130187. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130188. /**
  130189. * An event triggered when render targets were rendered.
  130190. * Can happen multiple times per frame.
  130191. */
  130192. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130193. /**
  130194. * An event triggered before calculating deterministic simulation step
  130195. */
  130196. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130197. /**
  130198. * An event triggered after calculating deterministic simulation step
  130199. */
  130200. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130201. /**
  130202. * An event triggered when the activeCamera property is updated
  130203. */
  130204. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130205. /**
  130206. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  130207. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  130208. * 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)
  130209. */
  130210. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130211. /**
  130212. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  130213. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  130214. * 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)
  130215. */
  130216. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130217. /**
  130218. * This Observable will when a mesh has been imported into the scene.
  130219. */
  130220. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130221. // Animations
  130222. /** @hidden */
  130223. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  130224. /**
  130225. * 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).
  130226. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  130227. */
  130228. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130229. /**
  130230. * Observable event triggered each time an input event is received from the rendering canvas
  130231. */
  130232. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130233. _this._meshPickProceed = false;
  130234. _this._currentPickResult = null;
  130235. _this._previousPickResult = null;
  130236. _this._totalPointersPressed = 0;
  130237. _this._doubleClickOccured = false;
  130238. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  130239. _this.cameraToUseForPointers = null;
  130240. _this._pointerX = 0;
  130241. _this._pointerY = 0;
  130242. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  130243. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  130244. _this._startingPointerTime = 0;
  130245. _this._previousStartingPointerTime = 0;
  130246. _this._pointerCaptures = {};
  130247. // Deterministic lockstep
  130248. _this._timeAccumulator = 0;
  130249. _this._currentStepId = 0;
  130250. _this._currentInternalStep = 0;
  130251. // Keyboard
  130252. /**
  130253. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  130254. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  130255. */
  130256. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130257. /**
  130258. * Observable event triggered each time an keyboard event is received from the hosting window
  130259. */
  130260. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  130261. // Coordinates system
  130262. _this._useRightHandedSystem = false;
  130263. // Fog
  130264. _this._fogEnabled = true;
  130265. _this._fogMode = Scene.FOGMODE_NONE;
  130266. /**
  130267. * Gets or sets the fog color to use
  130268. * @see http://doc.babylonjs.com/babylon101/environment#fog
  130269. * (Default is Color3(0.2, 0.2, 0.3))
  130270. */
  130271. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  130272. /**
  130273. * Gets or sets the fog density to use
  130274. * @see http://doc.babylonjs.com/babylon101/environment#fog
  130275. * (Default is 0.1)
  130276. */
  130277. _this.fogDensity = 0.1;
  130278. /**
  130279. * Gets or sets the fog start distance to use
  130280. * @see http://doc.babylonjs.com/babylon101/environment#fog
  130281. * (Default is 0)
  130282. */
  130283. _this.fogStart = 0;
  130284. /**
  130285. * Gets or sets the fog end distance to use
  130286. * @see http://doc.babylonjs.com/babylon101/environment#fog
  130287. * (Default is 1000)
  130288. */
  130289. _this.fogEnd = 1000.0;
  130290. // Lights
  130291. _this._shadowsEnabled = true;
  130292. _this._lightsEnabled = true;
  130293. /** All of the active cameras added to this scene. */
  130294. _this.activeCameras = new Array();
  130295. // Textures
  130296. _this._texturesEnabled = true;
  130297. // Particles
  130298. /**
  130299. * Gets or sets a boolean indicating if particles are enabled on this scene
  130300. */
  130301. _this.particlesEnabled = true;
  130302. // Sprites
  130303. /**
  130304. * Gets or sets a boolean indicating if sprites are enabled on this scene
  130305. */
  130306. _this.spritesEnabled = true;
  130307. // Skeletons
  130308. _this._skeletonsEnabled = true;
  130309. // Lens flares
  130310. /**
  130311. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  130312. */
  130313. _this.lensFlaresEnabled = true;
  130314. // Collisions
  130315. /**
  130316. * Gets or sets a boolean indicating if collisions are enabled on this scene
  130317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  130318. */
  130319. _this.collisionsEnabled = true;
  130320. /**
  130321. * Defines the gravity applied to this scene (used only for collisions)
  130322. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  130323. */
  130324. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  130325. // Postprocesses
  130326. /**
  130327. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  130328. */
  130329. _this.postProcessesEnabled = true;
  130330. /**
  130331. * The list of postprocesses added to the scene
  130332. */
  130333. _this.postProcesses = new Array();
  130334. // Customs render targets
  130335. /**
  130336. * Gets or sets a boolean indicating if render targets are enabled on this scene
  130337. */
  130338. _this.renderTargetsEnabled = true;
  130339. /**
  130340. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  130341. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  130342. */
  130343. _this.dumpNextRenderTargets = false;
  130344. /**
  130345. * The list of user defined render targets added to the scene
  130346. */
  130347. _this.customRenderTargets = new Array();
  130348. /**
  130349. * Gets the list of meshes imported to the scene through SceneLoader
  130350. */
  130351. _this.importedMeshesFiles = new Array();
  130352. // Probes
  130353. /**
  130354. * Gets or sets a boolean indicating if probes are enabled on this scene
  130355. */
  130356. _this.probesEnabled = true;
  130357. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  130358. // Procedural textures
  130359. /**
  130360. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  130361. */
  130362. _this.proceduralTexturesEnabled = true;
  130363. // Performance counters
  130364. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  130365. /** @hidden */
  130366. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  130367. /** @hidden */
  130368. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  130369. /** @hidden */
  130370. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  130371. /** @hidden */
  130372. _this._animationTime = 0;
  130373. /**
  130374. * Gets or sets a general scale for animation speed
  130375. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  130376. */
  130377. _this.animationTimeScale = 1;
  130378. _this._renderId = 0;
  130379. _this._frameId = 0;
  130380. _this._executeWhenReadyTimeoutId = -1;
  130381. _this._intermediateRendering = false;
  130382. _this._viewUpdateFlag = -1;
  130383. _this._projectionUpdateFlag = -1;
  130384. _this._alternateViewUpdateFlag = -1;
  130385. _this._alternateProjectionUpdateFlag = -1;
  130386. /** @hidden */
  130387. _this._toBeDisposed = new Array(256);
  130388. _this._activeRequests = new Array();
  130389. /** @hidden */
  130390. _this._pendingData = new Array();
  130391. _this._isDisposed = false;
  130392. /**
  130393. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  130394. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  130395. */
  130396. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  130397. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  130398. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  130399. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  130400. /** @hidden */
  130401. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  130402. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  130403. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  130404. /** @hidden */
  130405. _this._activeAnimatables = new Array();
  130406. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  130407. _this._useAlternateCameraConfiguration = false;
  130408. _this._alternateRendering = false;
  130409. _this._wheelEventName = "";
  130410. /**
  130411. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  130412. * This is useful if there are more lights that the maximum simulteanous authorized
  130413. */
  130414. _this.requireLightSorting = false;
  130415. /**
  130416. * @hidden
  130417. * Backing store of defined scene components.
  130418. */
  130419. _this._components = [];
  130420. /**
  130421. * @hidden
  130422. * Backing store of defined scene components.
  130423. */
  130424. _this._serializableComponents = [];
  130425. /**
  130426. * List of components to register on the next registration step.
  130427. */
  130428. _this._transientComponents = [];
  130429. /**
  130430. * @hidden
  130431. * Defines the actions happening before camera updates.
  130432. */
  130433. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130434. /**
  130435. * @hidden
  130436. * Defines the actions happening before clear the canvas.
  130437. */
  130438. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130439. /**
  130440. * @hidden
  130441. * Defines the actions when collecting render targets for the frame.
  130442. */
  130443. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130444. /**
  130445. * @hidden
  130446. * Defines the actions happening for one camera in the frame.
  130447. */
  130448. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130449. /**
  130450. * @hidden
  130451. * Defines the actions happening during the per mesh ready checks.
  130452. */
  130453. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130454. /**
  130455. * @hidden
  130456. * Defines the actions happening before evaluate active mesh checks.
  130457. */
  130458. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130459. /**
  130460. * @hidden
  130461. * Defines the actions happening during the evaluate sub mesh checks.
  130462. */
  130463. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130464. /**
  130465. * @hidden
  130466. * Defines the actions happening during the active mesh stage.
  130467. */
  130468. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130469. /**
  130470. * @hidden
  130471. * Defines the actions happening during the per camera render target step.
  130472. */
  130473. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130474. /**
  130475. * @hidden
  130476. * Defines the actions happening just before the active camera is drawing.
  130477. */
  130478. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130479. /**
  130480. * @hidden
  130481. * Defines the actions happening just before a render target is drawing.
  130482. */
  130483. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130484. /**
  130485. * @hidden
  130486. * Defines the actions happening just before a rendering group is drawing.
  130487. */
  130488. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130489. /**
  130490. * @hidden
  130491. * Defines the actions happening just before a mesh is drawing.
  130492. */
  130493. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130494. /**
  130495. * @hidden
  130496. * Defines the actions happening just after a mesh has been drawn.
  130497. */
  130498. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130499. /**
  130500. * @hidden
  130501. * Defines the actions happening just after a rendering group has been drawn.
  130502. */
  130503. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130504. /**
  130505. * @hidden
  130506. * Defines the actions happening just after the active camera has been drawn.
  130507. */
  130508. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130509. /**
  130510. * @hidden
  130511. * Defines the actions happening just after a render target has been drawn.
  130512. */
  130513. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130514. /**
  130515. * @hidden
  130516. * Defines the actions happening just after rendering all cameras and computing intersections.
  130517. */
  130518. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130519. /**
  130520. * @hidden
  130521. * Defines the actions happening when a pointer move event happens.
  130522. */
  130523. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130524. /**
  130525. * @hidden
  130526. * Defines the actions happening when a pointer down event happens.
  130527. */
  130528. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130529. /**
  130530. * @hidden
  130531. * Defines the actions happening when a pointer up event happens.
  130532. */
  130533. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130534. /**
  130535. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  130536. */
  130537. _this.geometriesByUniqueId = null;
  130538. _this._defaultMeshCandidates = {
  130539. data: [],
  130540. length: 0
  130541. };
  130542. _this._defaultSubMeshCandidates = {
  130543. data: [],
  130544. length: 0
  130545. };
  130546. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  130547. _this._activeMeshesFrozen = false;
  130548. /** @hidden */
  130549. _this._allowPostProcessClearColor = true;
  130550. /**
  130551. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  130552. */
  130553. _this.getDeterministicFrameTime = function () {
  130554. return 1000.0 / 60.0; // frame time in ms
  130555. };
  130556. _this._blockMaterialDirtyMechanism = false;
  130557. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  130558. _this._engine.scenes.push(_this);
  130559. _this._uid = null;
  130560. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  130561. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  130562. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  130563. }
  130564. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  130565. _this.attachControl();
  130566. }
  130567. // Uniform Buffer
  130568. _this._createUbo();
  130569. // Default Image processing definition
  130570. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  130571. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  130572. }
  130573. _this.setDefaultCandidateProviders();
  130574. if (options && options.useGeometryUniqueIdsMap === true) {
  130575. _this.geometriesByUniqueId = {};
  130576. }
  130577. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  130578. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  130579. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  130580. return _this;
  130581. }
  130582. /**
  130583. * Factory used to create the default material.
  130584. * @param name The name of the material to create
  130585. * @param scene The scene to create the material for
  130586. * @returns The default material
  130587. */
  130588. Scene.DefaultMaterialFactory = function (scene) {
  130589. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  130590. };
  130591. /**
  130592. * Factory used to create the a collision coordinator.
  130593. * @returns The collision coordinator
  130594. */
  130595. Scene.CollisionCoordinatorFactory = function () {
  130596. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  130597. };
  130598. Object.defineProperty(Scene.prototype, "environmentTexture", {
  130599. /**
  130600. * Texture used in all pbr material as the reflection texture.
  130601. * As in the majority of the scene they are the same (exception for multi room and so on),
  130602. * this is easier to reference from here than from all the materials.
  130603. */
  130604. get: function () {
  130605. return this._environmentTexture;
  130606. },
  130607. /**
  130608. * Texture used in all pbr material as the reflection texture.
  130609. * As in the majority of the scene they are the same (exception for multi room and so on),
  130610. * this is easier to set here than in all the materials.
  130611. */
  130612. set: function (value) {
  130613. if (this._environmentTexture === value) {
  130614. return;
  130615. }
  130616. this._environmentTexture = value;
  130617. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  130618. },
  130619. enumerable: true,
  130620. configurable: true
  130621. });
  130622. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  130623. /**
  130624. * Default image processing configuration used either in the rendering
  130625. * Forward main pass or through the imageProcessingPostProcess if present.
  130626. * As in the majority of the scene they are the same (exception for multi camera),
  130627. * this is easier to reference from here than from all the materials and post process.
  130628. *
  130629. * No setter as we it is a shared configuration, you can set the values instead.
  130630. */
  130631. get: function () {
  130632. return this._imageProcessingConfiguration;
  130633. },
  130634. enumerable: true,
  130635. configurable: true
  130636. });
  130637. Object.defineProperty(Scene.prototype, "forceWireframe", {
  130638. get: function () {
  130639. return this._forceWireframe;
  130640. },
  130641. /**
  130642. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  130643. */
  130644. set: function (value) {
  130645. if (this._forceWireframe === value) {
  130646. return;
  130647. }
  130648. this._forceWireframe = value;
  130649. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130650. },
  130651. enumerable: true,
  130652. configurable: true
  130653. });
  130654. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  130655. get: function () {
  130656. return this._forcePointsCloud;
  130657. },
  130658. /**
  130659. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  130660. */
  130661. set: function (value) {
  130662. if (this._forcePointsCloud === value) {
  130663. return;
  130664. }
  130665. this._forcePointsCloud = value;
  130666. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130667. },
  130668. enumerable: true,
  130669. configurable: true
  130670. });
  130671. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  130672. /**
  130673. * Gets or sets the animation properties override
  130674. */
  130675. get: function () {
  130676. return this._animationPropertiesOverride;
  130677. },
  130678. set: function (value) {
  130679. this._animationPropertiesOverride = value;
  130680. },
  130681. enumerable: true,
  130682. configurable: true
  130683. });
  130684. Object.defineProperty(Scene.prototype, "onDispose", {
  130685. /** Sets a function to be executed when this scene is disposed. */
  130686. set: function (callback) {
  130687. if (this._onDisposeObserver) {
  130688. this.onDisposeObservable.remove(this._onDisposeObserver);
  130689. }
  130690. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  130691. },
  130692. enumerable: true,
  130693. configurable: true
  130694. });
  130695. Object.defineProperty(Scene.prototype, "beforeRender", {
  130696. /** Sets a function to be executed before rendering this scene */
  130697. set: function (callback) {
  130698. if (this._onBeforeRenderObserver) {
  130699. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  130700. }
  130701. if (callback) {
  130702. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  130703. }
  130704. },
  130705. enumerable: true,
  130706. configurable: true
  130707. });
  130708. Object.defineProperty(Scene.prototype, "afterRender", {
  130709. /** Sets a function to be executed after rendering this scene */
  130710. set: function (callback) {
  130711. if (this._onAfterRenderObserver) {
  130712. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  130713. }
  130714. if (callback) {
  130715. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  130716. }
  130717. },
  130718. enumerable: true,
  130719. configurable: true
  130720. });
  130721. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  130722. /** Sets a function to be executed before rendering a camera*/
  130723. set: function (callback) {
  130724. if (this._onBeforeCameraRenderObserver) {
  130725. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  130726. }
  130727. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  130728. },
  130729. enumerable: true,
  130730. configurable: true
  130731. });
  130732. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  130733. /** Sets a function to be executed after rendering a camera*/
  130734. set: function (callback) {
  130735. if (this._onAfterCameraRenderObserver) {
  130736. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  130737. }
  130738. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  130739. },
  130740. enumerable: true,
  130741. configurable: true
  130742. });
  130743. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  130744. /**
  130745. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  130746. */
  130747. get: function () {
  130748. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  130749. },
  130750. enumerable: true,
  130751. configurable: true
  130752. });
  130753. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  130754. get: function () {
  130755. return this._useRightHandedSystem;
  130756. },
  130757. /**
  130758. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  130759. */
  130760. set: function (value) {
  130761. if (this._useRightHandedSystem === value) {
  130762. return;
  130763. }
  130764. this._useRightHandedSystem = value;
  130765. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130766. },
  130767. enumerable: true,
  130768. configurable: true
  130769. });
  130770. /**
  130771. * Sets the step Id used by deterministic lock step
  130772. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130773. * @param newStepId defines the step Id
  130774. */
  130775. Scene.prototype.setStepId = function (newStepId) {
  130776. this._currentStepId = newStepId;
  130777. };
  130778. /**
  130779. * Gets the step Id used by deterministic lock step
  130780. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130781. * @returns the step Id
  130782. */
  130783. Scene.prototype.getStepId = function () {
  130784. return this._currentStepId;
  130785. };
  130786. /**
  130787. * Gets the internal step used by deterministic lock step
  130788. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130789. * @returns the internal step
  130790. */
  130791. Scene.prototype.getInternalStep = function () {
  130792. return this._currentInternalStep;
  130793. };
  130794. Object.defineProperty(Scene.prototype, "fogEnabled", {
  130795. get: function () {
  130796. return this._fogEnabled;
  130797. },
  130798. /**
  130799. * Gets or sets a boolean indicating if fog is enabled on this scene
  130800. * @see http://doc.babylonjs.com/babylon101/environment#fog
  130801. * (Default is true)
  130802. */
  130803. set: function (value) {
  130804. if (this._fogEnabled === value) {
  130805. return;
  130806. }
  130807. this._fogEnabled = value;
  130808. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130809. },
  130810. enumerable: true,
  130811. configurable: true
  130812. });
  130813. Object.defineProperty(Scene.prototype, "fogMode", {
  130814. get: function () {
  130815. return this._fogMode;
  130816. },
  130817. /**
  130818. * Gets or sets the fog mode to use
  130819. * @see http://doc.babylonjs.com/babylon101/environment#fog
  130820. * | mode | value |
  130821. * | --- | --- |
  130822. * | FOGMODE_NONE | 0 |
  130823. * | FOGMODE_EXP | 1 |
  130824. * | FOGMODE_EXP2 | 2 |
  130825. * | FOGMODE_LINEAR | 3 |
  130826. */
  130827. set: function (value) {
  130828. if (this._fogMode === value) {
  130829. return;
  130830. }
  130831. this._fogMode = value;
  130832. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130833. },
  130834. enumerable: true,
  130835. configurable: true
  130836. });
  130837. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  130838. get: function () {
  130839. return this._shadowsEnabled;
  130840. },
  130841. /**
  130842. * Gets or sets a boolean indicating if shadows are enabled on this scene
  130843. */
  130844. set: function (value) {
  130845. if (this._shadowsEnabled === value) {
  130846. return;
  130847. }
  130848. this._shadowsEnabled = value;
  130849. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  130850. },
  130851. enumerable: true,
  130852. configurable: true
  130853. });
  130854. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  130855. get: function () {
  130856. return this._lightsEnabled;
  130857. },
  130858. /**
  130859. * Gets or sets a boolean indicating if lights are enabled on this scene
  130860. */
  130861. set: function (value) {
  130862. if (this._lightsEnabled === value) {
  130863. return;
  130864. }
  130865. this._lightsEnabled = value;
  130866. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  130867. },
  130868. enumerable: true,
  130869. configurable: true
  130870. });
  130871. Object.defineProperty(Scene.prototype, "activeCamera", {
  130872. /** Gets or sets the current active camera */
  130873. get: function () {
  130874. return this._activeCamera;
  130875. },
  130876. set: function (value) {
  130877. if (value === this._activeCamera) {
  130878. return;
  130879. }
  130880. this._activeCamera = value;
  130881. this.onActiveCameraChanged.notifyObservers(this);
  130882. },
  130883. enumerable: true,
  130884. configurable: true
  130885. });
  130886. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  130887. /** The default material used on meshes when no material is affected */
  130888. get: function () {
  130889. if (!this._defaultMaterial) {
  130890. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  130891. }
  130892. return this._defaultMaterial;
  130893. },
  130894. /** The default material used on meshes when no material is affected */
  130895. set: function (value) {
  130896. this._defaultMaterial = value;
  130897. },
  130898. enumerable: true,
  130899. configurable: true
  130900. });
  130901. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  130902. get: function () {
  130903. return this._texturesEnabled;
  130904. },
  130905. /**
  130906. * Gets or sets a boolean indicating if textures are enabled on this scene
  130907. */
  130908. set: function (value) {
  130909. if (this._texturesEnabled === value) {
  130910. return;
  130911. }
  130912. this._texturesEnabled = value;
  130913. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  130914. },
  130915. enumerable: true,
  130916. configurable: true
  130917. });
  130918. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  130919. get: function () {
  130920. return this._skeletonsEnabled;
  130921. },
  130922. /**
  130923. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  130924. */
  130925. set: function (value) {
  130926. if (this._skeletonsEnabled === value) {
  130927. return;
  130928. }
  130929. this._skeletonsEnabled = value;
  130930. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  130931. },
  130932. enumerable: true,
  130933. configurable: true
  130934. });
  130935. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  130936. /** @hidden */
  130937. get: function () {
  130938. if (!this._collisionCoordinator) {
  130939. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  130940. this._collisionCoordinator.init(this);
  130941. }
  130942. return this._collisionCoordinator;
  130943. },
  130944. enumerable: true,
  130945. configurable: true
  130946. });
  130947. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  130948. /** @hidden */
  130949. get: function () {
  130950. return this._alternateRendering;
  130951. },
  130952. enumerable: true,
  130953. configurable: true
  130954. });
  130955. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  130956. /**
  130957. * Gets the list of frustum planes (built from the active camera)
  130958. */
  130959. get: function () {
  130960. return this._frustumPlanes;
  130961. },
  130962. enumerable: true,
  130963. configurable: true
  130964. });
  130965. /**
  130966. * Registers the transient components if needed.
  130967. */
  130968. Scene.prototype._registerTransientComponents = function () {
  130969. // Register components that have been associated lately to the scene.
  130970. if (this._transientComponents.length > 0) {
  130971. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  130972. var component = _a[_i];
  130973. component.register();
  130974. }
  130975. this._transientComponents = [];
  130976. }
  130977. };
  130978. /**
  130979. * @hidden
  130980. * Add a component to the scene.
  130981. * Note that the ccomponent could be registered on th next frame if this is called after
  130982. * the register component stage.
  130983. * @param component Defines the component to add to the scene
  130984. */
  130985. Scene.prototype._addComponent = function (component) {
  130986. this._components.push(component);
  130987. this._transientComponents.push(component);
  130988. var serializableComponent = component;
  130989. if (serializableComponent.addFromContainer) {
  130990. this._serializableComponents.push(serializableComponent);
  130991. }
  130992. };
  130993. /**
  130994. * @hidden
  130995. * Gets a component from the scene.
  130996. * @param name defines the name of the component to retrieve
  130997. * @returns the component or null if not present
  130998. */
  130999. Scene.prototype._getComponent = function (name) {
  131000. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  131001. var component = _a[_i];
  131002. if (component.name === name) {
  131003. return component;
  131004. }
  131005. }
  131006. return null;
  131007. };
  131008. /**
  131009. * @hidden
  131010. */
  131011. Scene.prototype._getDefaultMeshCandidates = function () {
  131012. this._defaultMeshCandidates.data = this.meshes;
  131013. this._defaultMeshCandidates.length = this.meshes.length;
  131014. return this._defaultMeshCandidates;
  131015. };
  131016. /**
  131017. * @hidden
  131018. */
  131019. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  131020. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  131021. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  131022. return this._defaultSubMeshCandidates;
  131023. };
  131024. /**
  131025. * Sets the default candidate providers for the scene.
  131026. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  131027. * and getCollidingSubMeshCandidates to their default function
  131028. */
  131029. Scene.prototype.setDefaultCandidateProviders = function () {
  131030. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  131031. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  131032. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  131033. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  131034. };
  131035. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  131036. /**
  131037. * Gets the mesh that is currently under the pointer
  131038. */
  131039. get: function () {
  131040. return this._pointerOverMesh;
  131041. },
  131042. enumerable: true,
  131043. configurable: true
  131044. });
  131045. Object.defineProperty(Scene.prototype, "pointerX", {
  131046. /**
  131047. * Gets or sets the current on-screen X position of the pointer
  131048. */
  131049. get: function () {
  131050. return this._pointerX;
  131051. },
  131052. set: function (value) {
  131053. this._pointerX = value;
  131054. },
  131055. enumerable: true,
  131056. configurable: true
  131057. });
  131058. Object.defineProperty(Scene.prototype, "pointerY", {
  131059. /**
  131060. * Gets or sets the current on-screen Y position of the pointer
  131061. */
  131062. get: function () {
  131063. return this._pointerY;
  131064. },
  131065. set: function (value) {
  131066. this._pointerY = value;
  131067. },
  131068. enumerable: true,
  131069. configurable: true
  131070. });
  131071. /**
  131072. * Gets the cached material (ie. the latest rendered one)
  131073. * @returns the cached material
  131074. */
  131075. Scene.prototype.getCachedMaterial = function () {
  131076. return this._cachedMaterial;
  131077. };
  131078. /**
  131079. * Gets the cached effect (ie. the latest rendered one)
  131080. * @returns the cached effect
  131081. */
  131082. Scene.prototype.getCachedEffect = function () {
  131083. return this._cachedEffect;
  131084. };
  131085. /**
  131086. * Gets the cached visibility state (ie. the latest rendered one)
  131087. * @returns the cached visibility state
  131088. */
  131089. Scene.prototype.getCachedVisibility = function () {
  131090. return this._cachedVisibility;
  131091. };
  131092. /**
  131093. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  131094. * @param material defines the current material
  131095. * @param effect defines the current effect
  131096. * @param visibility defines the current visibility state
  131097. * @returns true if one parameter is not cached
  131098. */
  131099. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  131100. if (visibility === void 0) { visibility = 1; }
  131101. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  131102. };
  131103. /**
  131104. * Gets the engine associated with the scene
  131105. * @returns an Engine
  131106. */
  131107. Scene.prototype.getEngine = function () {
  131108. return this._engine;
  131109. };
  131110. /**
  131111. * Gets the total number of vertices rendered per frame
  131112. * @returns the total number of vertices rendered per frame
  131113. */
  131114. Scene.prototype.getTotalVertices = function () {
  131115. return this._totalVertices.current;
  131116. };
  131117. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  131118. /**
  131119. * Gets the performance counter for total vertices
  131120. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131121. */
  131122. get: function () {
  131123. return this._totalVertices;
  131124. },
  131125. enumerable: true,
  131126. configurable: true
  131127. });
  131128. /**
  131129. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  131130. * @returns the total number of active indices rendered per frame
  131131. */
  131132. Scene.prototype.getActiveIndices = function () {
  131133. return this._activeIndices.current;
  131134. };
  131135. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  131136. /**
  131137. * Gets the performance counter for active indices
  131138. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131139. */
  131140. get: function () {
  131141. return this._activeIndices;
  131142. },
  131143. enumerable: true,
  131144. configurable: true
  131145. });
  131146. /**
  131147. * Gets the total number of active particles rendered per frame
  131148. * @returns the total number of active particles rendered per frame
  131149. */
  131150. Scene.prototype.getActiveParticles = function () {
  131151. return this._activeParticles.current;
  131152. };
  131153. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  131154. /**
  131155. * Gets the performance counter for active particles
  131156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131157. */
  131158. get: function () {
  131159. return this._activeParticles;
  131160. },
  131161. enumerable: true,
  131162. configurable: true
  131163. });
  131164. /**
  131165. * Gets the total number of active bones rendered per frame
  131166. * @returns the total number of active bones rendered per frame
  131167. */
  131168. Scene.prototype.getActiveBones = function () {
  131169. return this._activeBones.current;
  131170. };
  131171. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  131172. /**
  131173. * Gets the performance counter for active bones
  131174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131175. */
  131176. get: function () {
  131177. return this._activeBones;
  131178. },
  131179. enumerable: true,
  131180. configurable: true
  131181. });
  131182. /**
  131183. * Gets the array of active meshes
  131184. * @returns an array of AbstractMesh
  131185. */
  131186. Scene.prototype.getActiveMeshes = function () {
  131187. return this._activeMeshes;
  131188. };
  131189. /**
  131190. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  131191. * @returns a number
  131192. */
  131193. Scene.prototype.getAnimationRatio = function () {
  131194. return this._animationRatio !== undefined ? this._animationRatio : 1;
  131195. };
  131196. /**
  131197. * Gets an unique Id for the current render phase
  131198. * @returns a number
  131199. */
  131200. Scene.prototype.getRenderId = function () {
  131201. return this._renderId;
  131202. };
  131203. /**
  131204. * Gets an unique Id for the current frame
  131205. * @returns a number
  131206. */
  131207. Scene.prototype.getFrameId = function () {
  131208. return this._frameId;
  131209. };
  131210. /** Call this function if you want to manually increment the render Id*/
  131211. Scene.prototype.incrementRenderId = function () {
  131212. this._renderId++;
  131213. };
  131214. Scene.prototype._updatePointerPosition = function (evt) {
  131215. var canvasRect = this._engine.getRenderingCanvasClientRect();
  131216. if (!canvasRect) {
  131217. return;
  131218. }
  131219. this._pointerX = evt.clientX - canvasRect.left;
  131220. this._pointerY = evt.clientY - canvasRect.top;
  131221. this._unTranslatedPointerX = this._pointerX;
  131222. this._unTranslatedPointerY = this._pointerY;
  131223. };
  131224. Scene.prototype._createUbo = function () {
  131225. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  131226. this._sceneUbo.addUniform("viewProjection", 16);
  131227. this._sceneUbo.addUniform("view", 16);
  131228. };
  131229. Scene.prototype._createAlternateUbo = function () {
  131230. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  131231. this._alternateSceneUbo.addUniform("viewProjection", 16);
  131232. this._alternateSceneUbo.addUniform("view", 16);
  131233. };
  131234. // Pointers handling
  131235. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  131236. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  131237. if (!pointerInfo.pickInfo.ray) {
  131238. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  131239. }
  131240. }
  131241. };
  131242. /**
  131243. * Use this method to simulate a pointer move on a mesh
  131244. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131245. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131246. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131247. * @returns the current scene
  131248. */
  131249. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  131250. var evt = new PointerEvent("pointermove", pointerEventInit);
  131251. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  131252. return this;
  131253. }
  131254. return this._processPointerMove(pickResult, evt);
  131255. };
  131256. Scene.prototype._processPointerMove = function (pickResult, evt) {
  131257. var canvas = this._engine.getRenderingCanvas();
  131258. if (!canvas) {
  131259. return this;
  131260. }
  131261. // Restore pointer
  131262. canvas.style.cursor = this.defaultCursor;
  131263. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  131264. if (isMeshPicked) {
  131265. this.setPointerOverMesh(pickResult.pickedMesh);
  131266. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  131267. if (this._pointerOverMesh.actionManager.hoverCursor) {
  131268. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  131269. }
  131270. else {
  131271. canvas.style.cursor = this.hoverCursor;
  131272. }
  131273. }
  131274. }
  131275. else {
  131276. this.setPointerOverMesh(null);
  131277. }
  131278. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  131279. var step = _a[_i];
  131280. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  131281. }
  131282. if (pickResult) {
  131283. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  131284. if (this.onPointerMove) {
  131285. this.onPointerMove(evt, pickResult, type);
  131286. }
  131287. if (this.onPointerObservable.hasObservers()) {
  131288. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  131289. this._setRayOnPointerInfo(pi);
  131290. this.onPointerObservable.notifyObservers(pi, type);
  131291. }
  131292. }
  131293. return this;
  131294. };
  131295. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  131296. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  131297. if (pickResult) {
  131298. pi.ray = pickResult.ray;
  131299. }
  131300. this.onPrePointerObservable.notifyObservers(pi, type);
  131301. if (pi.skipOnPointerObservable) {
  131302. return true;
  131303. }
  131304. else {
  131305. return false;
  131306. }
  131307. };
  131308. /**
  131309. * Use this method to simulate a pointer down on a mesh
  131310. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131311. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131312. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131313. * @returns the current scene
  131314. */
  131315. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  131316. var evt = new PointerEvent("pointerdown", pointerEventInit);
  131317. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  131318. return this;
  131319. }
  131320. return this._processPointerDown(pickResult, evt);
  131321. };
  131322. Scene.prototype._processPointerDown = function (pickResult, evt) {
  131323. var _this = this;
  131324. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  131325. this._pickedDownMesh = pickResult.pickedMesh;
  131326. var actionManager = pickResult.pickedMesh.actionManager;
  131327. if (actionManager) {
  131328. if (actionManager.hasPickTriggers) {
  131329. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  131330. switch (evt.button) {
  131331. case 0:
  131332. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  131333. break;
  131334. case 1:
  131335. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  131336. break;
  131337. case 2:
  131338. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  131339. break;
  131340. }
  131341. }
  131342. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  131343. window.setTimeout(function () {
  131344. 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);
  131345. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  131346. if (_this._totalPointersPressed !== 0 &&
  131347. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  131348. !_this._isPointerSwiping()) {
  131349. _this._startingPointerTime = 0;
  131350. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  131351. }
  131352. }
  131353. }, Scene.LongPressDelay);
  131354. }
  131355. }
  131356. }
  131357. else {
  131358. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  131359. var step = _a[_i];
  131360. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  131361. }
  131362. }
  131363. if (pickResult) {
  131364. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  131365. if (this.onPointerDown) {
  131366. this.onPointerDown(evt, pickResult, type);
  131367. }
  131368. if (this.onPointerObservable.hasObservers()) {
  131369. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  131370. this._setRayOnPointerInfo(pi);
  131371. this.onPointerObservable.notifyObservers(pi, type);
  131372. }
  131373. }
  131374. return this;
  131375. };
  131376. /**
  131377. * Use this method to simulate a pointer up on a mesh
  131378. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131379. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131380. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131381. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  131382. * @returns the current scene
  131383. */
  131384. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  131385. var evt = new PointerEvent("pointerup", pointerEventInit);
  131386. var clickInfo = new ClickInfo();
  131387. if (doubleTap) {
  131388. clickInfo.doubleClick = true;
  131389. }
  131390. else {
  131391. clickInfo.singleClick = true;
  131392. }
  131393. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  131394. return this;
  131395. }
  131396. return this._processPointerUp(pickResult, evt, clickInfo);
  131397. };
  131398. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  131399. if (pickResult && pickResult && pickResult.pickedMesh) {
  131400. this._pickedUpMesh = pickResult.pickedMesh;
  131401. if (this._pickedDownMesh === this._pickedUpMesh) {
  131402. if (this.onPointerPick) {
  131403. this.onPointerPick(evt, pickResult);
  131404. }
  131405. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  131406. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  131407. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  131408. this._setRayOnPointerInfo(pi);
  131409. this.onPointerObservable.notifyObservers(pi, type_1);
  131410. }
  131411. }
  131412. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  131413. if (actionManager && !clickInfo.ignore) {
  131414. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  131415. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  131416. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  131417. }
  131418. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  131419. if (clickInfo.doubleClick && doubleClickActionManager) {
  131420. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  131421. }
  131422. }
  131423. }
  131424. else {
  131425. if (!clickInfo.ignore) {
  131426. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  131427. var step = _a[_i];
  131428. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  131429. }
  131430. }
  131431. }
  131432. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  131433. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger);
  131434. if (pickedDownActionManager) {
  131435. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  131436. }
  131437. }
  131438. var type = 0;
  131439. if (this.onPointerObservable.hasObservers()) {
  131440. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  131441. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  131442. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  131443. }
  131444. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  131445. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  131446. }
  131447. if (type) {
  131448. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  131449. this._setRayOnPointerInfo(pi);
  131450. this.onPointerObservable.notifyObservers(pi, type);
  131451. }
  131452. }
  131453. if (!clickInfo.ignore) {
  131454. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  131455. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  131456. this._setRayOnPointerInfo(pi);
  131457. this.onPointerObservable.notifyObservers(pi, type);
  131458. }
  131459. }
  131460. if (this.onPointerUp && !clickInfo.ignore) {
  131461. this.onPointerUp(evt, pickResult, type);
  131462. }
  131463. return this;
  131464. };
  131465. /**
  131466. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  131467. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  131468. * @returns true if the pointer was captured
  131469. */
  131470. Scene.prototype.isPointerCaptured = function (pointerId) {
  131471. if (pointerId === void 0) { pointerId = 0; }
  131472. return this._pointerCaptures[pointerId];
  131473. };
  131474. /** @hidden */
  131475. Scene.prototype._isPointerSwiping = function () {
  131476. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  131477. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  131478. };
  131479. /**
  131480. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  131481. * @param attachUp defines if you want to attach events to pointerup
  131482. * @param attachDown defines if you want to attach events to pointerdown
  131483. * @param attachMove defines if you want to attach events to pointermove
  131484. */
  131485. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  131486. var _this = this;
  131487. if (attachUp === void 0) { attachUp = true; }
  131488. if (attachDown === void 0) { attachDown = true; }
  131489. if (attachMove === void 0) { attachMove = true; }
  131490. this._initActionManager = function (act, clickInfo) {
  131491. if (!_this._meshPickProceed) {
  131492. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  131493. _this._currentPickResult = pickResult;
  131494. if (pickResult) {
  131495. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  131496. }
  131497. _this._meshPickProceed = true;
  131498. }
  131499. return act;
  131500. };
  131501. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  131502. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  131503. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  131504. btn !== _this._previousButtonPressed) {
  131505. _this._doubleClickOccured = false;
  131506. clickInfo.singleClick = true;
  131507. clickInfo.ignore = false;
  131508. cb(clickInfo, _this._currentPickResult);
  131509. }
  131510. };
  131511. this._initClickEvent = function (obs1, obs2, evt, cb) {
  131512. var clickInfo = new ClickInfo();
  131513. _this._currentPickResult = null;
  131514. var act = null;
  131515. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  131516. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  131517. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  131518. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  131519. act = _this._initActionManager(act, clickInfo);
  131520. if (act) {
  131521. checkPicking = act.hasPickTriggers;
  131522. }
  131523. }
  131524. var needToIgnoreNext = false;
  131525. if (checkPicking) {
  131526. var btn = evt.button;
  131527. clickInfo.hasSwiped = _this._isPointerSwiping();
  131528. if (!clickInfo.hasSwiped) {
  131529. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  131530. if (!checkSingleClickImmediately) {
  131531. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  131532. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  131533. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  131534. act = _this._initActionManager(act, clickInfo);
  131535. if (act) {
  131536. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  131537. }
  131538. }
  131539. }
  131540. if (checkSingleClickImmediately) {
  131541. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  131542. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  131543. btn !== _this._previousButtonPressed) {
  131544. clickInfo.singleClick = true;
  131545. cb(clickInfo, _this._currentPickResult);
  131546. needToIgnoreNext = true;
  131547. }
  131548. }
  131549. // at least one double click is required to be check and exclusive double click is enabled
  131550. else {
  131551. // wait that no double click has been raised during the double click delay
  131552. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  131553. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  131554. }
  131555. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  131556. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  131557. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  131558. act = _this._initActionManager(act, clickInfo);
  131559. if (act) {
  131560. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  131561. }
  131562. }
  131563. if (checkDoubleClick) {
  131564. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  131565. if (btn === _this._previousButtonPressed &&
  131566. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  131567. !_this._doubleClickOccured) {
  131568. // pointer has not moved for 2 clicks, it's a double click
  131569. if (!clickInfo.hasSwiped &&
  131570. !_this._isPointerSwiping()) {
  131571. _this._previousStartingPointerTime = 0;
  131572. _this._doubleClickOccured = true;
  131573. clickInfo.doubleClick = true;
  131574. clickInfo.ignore = false;
  131575. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  131576. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  131577. }
  131578. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  131579. cb(clickInfo, _this._currentPickResult);
  131580. }
  131581. // if the two successive clicks are too far, it's just two simple clicks
  131582. else {
  131583. _this._doubleClickOccured = false;
  131584. _this._previousStartingPointerTime = _this._startingPointerTime;
  131585. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  131586. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  131587. _this._previousButtonPressed = btn;
  131588. if (Scene.ExclusiveDoubleClickMode) {
  131589. if (_this._previousDelayedSimpleClickTimeout) {
  131590. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  131591. }
  131592. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  131593. cb(clickInfo, _this._previousPickResult);
  131594. }
  131595. else {
  131596. cb(clickInfo, _this._currentPickResult);
  131597. }
  131598. }
  131599. needToIgnoreNext = true;
  131600. }
  131601. // just the first click of the double has been raised
  131602. else {
  131603. _this._doubleClickOccured = false;
  131604. _this._previousStartingPointerTime = _this._startingPointerTime;
  131605. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  131606. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  131607. _this._previousButtonPressed = btn;
  131608. }
  131609. }
  131610. }
  131611. }
  131612. if (!needToIgnoreNext) {
  131613. cb(clickInfo, _this._currentPickResult);
  131614. }
  131615. };
  131616. this._onPointerMove = function (evt) {
  131617. _this._updatePointerPosition(evt);
  131618. // PreObservable support
  131619. 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)) {
  131620. return;
  131621. }
  131622. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  131623. return;
  131624. }
  131625. if (!_this.pointerMovePredicate) {
  131626. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  131627. }
  131628. // Meshes
  131629. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  131630. _this._processPointerMove(pickResult, evt);
  131631. };
  131632. this._onPointerDown = function (evt) {
  131633. _this._totalPointersPressed++;
  131634. _this._pickedDownMesh = null;
  131635. _this._meshPickProceed = false;
  131636. _this._updatePointerPosition(evt);
  131637. if (_this.preventDefaultOnPointerDown && canvas) {
  131638. evt.preventDefault();
  131639. canvas.focus();
  131640. }
  131641. _this._startingPointerPosition.x = _this._pointerX;
  131642. _this._startingPointerPosition.y = _this._pointerY;
  131643. _this._startingPointerTime = Date.now();
  131644. // PreObservable support
  131645. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  131646. return;
  131647. }
  131648. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  131649. return;
  131650. }
  131651. _this._pointerCaptures[evt.pointerId] = true;
  131652. if (!_this.pointerDownPredicate) {
  131653. _this.pointerDownPredicate = function (mesh) {
  131654. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  131655. };
  131656. }
  131657. // Meshes
  131658. _this._pickedDownMesh = null;
  131659. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  131660. _this._processPointerDown(pickResult, evt);
  131661. };
  131662. this._onPointerUp = function (evt) {
  131663. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  131664. return; // So we need to test it the pointer down was pressed before.
  131665. }
  131666. _this._totalPointersPressed--;
  131667. _this._pickedUpMesh = null;
  131668. _this._meshPickProceed = false;
  131669. _this._updatePointerPosition(evt);
  131670. if (_this.preventDefaultOnPointerUp && canvas) {
  131671. evt.preventDefault();
  131672. canvas.focus();
  131673. }
  131674. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  131675. // PreObservable support
  131676. if (_this.onPrePointerObservable.hasObservers()) {
  131677. if (!clickInfo.ignore) {
  131678. if (!clickInfo.hasSwiped) {
  131679. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  131680. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  131681. return;
  131682. }
  131683. }
  131684. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  131685. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  131686. return;
  131687. }
  131688. }
  131689. }
  131690. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  131691. return;
  131692. }
  131693. }
  131694. }
  131695. _this._pointerCaptures[evt.pointerId] = false;
  131696. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  131697. return;
  131698. }
  131699. if (!_this.pointerUpPredicate) {
  131700. _this.pointerUpPredicate = function (mesh) {
  131701. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  131702. };
  131703. }
  131704. // Meshes
  131705. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  131706. _this._initActionManager(null, clickInfo);
  131707. }
  131708. if (!pickResult) {
  131709. pickResult = _this._currentPickResult;
  131710. }
  131711. _this._processPointerUp(pickResult, evt, clickInfo);
  131712. _this._previousPickResult = _this._currentPickResult;
  131713. });
  131714. };
  131715. this._onKeyDown = function (evt) {
  131716. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  131717. if (_this.onPreKeyboardObservable.hasObservers()) {
  131718. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  131719. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  131720. if (pi.skipOnPointerObservable) {
  131721. return;
  131722. }
  131723. }
  131724. if (_this.onKeyboardObservable.hasObservers()) {
  131725. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  131726. _this.onKeyboardObservable.notifyObservers(pi, type);
  131727. }
  131728. if (_this.actionManager) {
  131729. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  131730. }
  131731. };
  131732. this._onKeyUp = function (evt) {
  131733. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  131734. if (_this.onPreKeyboardObservable.hasObservers()) {
  131735. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  131736. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  131737. if (pi.skipOnPointerObservable) {
  131738. return;
  131739. }
  131740. }
  131741. if (_this.onKeyboardObservable.hasObservers()) {
  131742. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  131743. _this.onKeyboardObservable.notifyObservers(pi, type);
  131744. }
  131745. if (_this.actionManager) {
  131746. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  131747. }
  131748. };
  131749. var engine = this.getEngine();
  131750. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  131751. if (!canvas) {
  131752. return;
  131753. }
  131754. canvas.addEventListener("keydown", _this._onKeyDown, false);
  131755. canvas.addEventListener("keyup", _this._onKeyUp, false);
  131756. });
  131757. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  131758. if (!canvas) {
  131759. return;
  131760. }
  131761. canvas.removeEventListener("keydown", _this._onKeyDown);
  131762. canvas.removeEventListener("keyup", _this._onKeyUp);
  131763. });
  131764. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  131765. var canvas = this._engine.getRenderingCanvas();
  131766. if (!canvas) {
  131767. return;
  131768. }
  131769. if (attachMove) {
  131770. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  131771. // Wheel
  131772. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  131773. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  131774. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  131775. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  131776. }
  131777. if (attachDown) {
  131778. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  131779. }
  131780. if (attachUp) {
  131781. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  131782. }
  131783. canvas.tabIndex = 1;
  131784. };
  131785. /** Detaches all event handlers*/
  131786. Scene.prototype.detachControl = function () {
  131787. var engine = this.getEngine();
  131788. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  131789. var canvas = engine.getRenderingCanvas();
  131790. if (!canvas) {
  131791. return;
  131792. }
  131793. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  131794. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  131795. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  131796. if (this._onCanvasBlurObserver) {
  131797. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  131798. }
  131799. if (this._onCanvasFocusObserver) {
  131800. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  131801. }
  131802. // Wheel
  131803. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  131804. // Keyboard
  131805. canvas.removeEventListener("keydown", this._onKeyDown);
  131806. canvas.removeEventListener("keyup", this._onKeyUp);
  131807. // Observables
  131808. this.onKeyboardObservable.clear();
  131809. this.onPreKeyboardObservable.clear();
  131810. this.onPointerObservable.clear();
  131811. this.onPrePointerObservable.clear();
  131812. };
  131813. /**
  131814. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  131815. * Delay loaded resources are not taking in account
  131816. * @return true if all required resources are ready
  131817. */
  131818. Scene.prototype.isReady = function () {
  131819. if (this._isDisposed) {
  131820. return false;
  131821. }
  131822. var index;
  131823. var engine = this.getEngine();
  131824. // Effects
  131825. if (!engine.areAllEffectsReady()) {
  131826. return false;
  131827. }
  131828. // Pending data
  131829. if (this._pendingData.length > 0) {
  131830. return false;
  131831. }
  131832. // Meshes
  131833. for (index = 0; index < this.meshes.length; index++) {
  131834. var mesh = this.meshes[index];
  131835. if (!mesh.isEnabled()) {
  131836. continue;
  131837. }
  131838. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  131839. continue;
  131840. }
  131841. if (!mesh.isReady(true)) {
  131842. return false;
  131843. }
  131844. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  131845. // Is Ready For Mesh
  131846. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  131847. var step = _a[_i];
  131848. if (!step.action(mesh, hardwareInstancedRendering)) {
  131849. return false;
  131850. }
  131851. }
  131852. }
  131853. // Geometries
  131854. for (index = 0; index < this.geometries.length; index++) {
  131855. var geometry = this.geometries[index];
  131856. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  131857. return false;
  131858. }
  131859. }
  131860. // Post-processes
  131861. if (this.activeCameras && this.activeCameras.length > 0) {
  131862. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  131863. var camera = _c[_b];
  131864. if (!camera.isReady(true)) {
  131865. return false;
  131866. }
  131867. }
  131868. }
  131869. else if (this.activeCamera) {
  131870. if (!this.activeCamera.isReady(true)) {
  131871. return false;
  131872. }
  131873. }
  131874. // Particles
  131875. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  131876. var particleSystem = _e[_d];
  131877. if (!particleSystem.isReady()) {
  131878. return false;
  131879. }
  131880. }
  131881. return true;
  131882. };
  131883. /** Resets all cached information relative to material (including effect and visibility) */
  131884. Scene.prototype.resetCachedMaterial = function () {
  131885. this._cachedMaterial = null;
  131886. this._cachedEffect = null;
  131887. this._cachedVisibility = null;
  131888. };
  131889. /**
  131890. * Registers a function to be called before every frame render
  131891. * @param func defines the function to register
  131892. */
  131893. Scene.prototype.registerBeforeRender = function (func) {
  131894. this.onBeforeRenderObservable.add(func);
  131895. };
  131896. /**
  131897. * Unregisters a function called before every frame render
  131898. * @param func defines the function to unregister
  131899. */
  131900. Scene.prototype.unregisterBeforeRender = function (func) {
  131901. this.onBeforeRenderObservable.removeCallback(func);
  131902. };
  131903. /**
  131904. * Registers a function to be called after every frame render
  131905. * @param func defines the function to register
  131906. */
  131907. Scene.prototype.registerAfterRender = function (func) {
  131908. this.onAfterRenderObservable.add(func);
  131909. };
  131910. /**
  131911. * Unregisters a function called after every frame render
  131912. * @param func defines the function to unregister
  131913. */
  131914. Scene.prototype.unregisterAfterRender = function (func) {
  131915. this.onAfterRenderObservable.removeCallback(func);
  131916. };
  131917. Scene.prototype._executeOnceBeforeRender = function (func) {
  131918. var _this = this;
  131919. var execFunc = function () {
  131920. func();
  131921. setTimeout(function () {
  131922. _this.unregisterBeforeRender(execFunc);
  131923. });
  131924. };
  131925. this.registerBeforeRender(execFunc);
  131926. };
  131927. /**
  131928. * The provided function will run before render once and will be disposed afterwards.
  131929. * A timeout delay can be provided so that the function will be executed in N ms.
  131930. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  131931. * @param func The function to be executed.
  131932. * @param timeout optional delay in ms
  131933. */
  131934. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  131935. var _this = this;
  131936. if (timeout !== undefined) {
  131937. setTimeout(function () {
  131938. _this._executeOnceBeforeRender(func);
  131939. }, timeout);
  131940. }
  131941. else {
  131942. this._executeOnceBeforeRender(func);
  131943. }
  131944. };
  131945. /** @hidden */
  131946. Scene.prototype._addPendingData = function (data) {
  131947. this._pendingData.push(data);
  131948. };
  131949. /** @hidden */
  131950. Scene.prototype._removePendingData = function (data) {
  131951. var wasLoading = this.isLoading;
  131952. var index = this._pendingData.indexOf(data);
  131953. if (index !== -1) {
  131954. this._pendingData.splice(index, 1);
  131955. }
  131956. if (wasLoading && !this.isLoading) {
  131957. this.onDataLoadedObservable.notifyObservers(this);
  131958. }
  131959. };
  131960. /**
  131961. * Returns the number of items waiting to be loaded
  131962. * @returns the number of items waiting to be loaded
  131963. */
  131964. Scene.prototype.getWaitingItemsCount = function () {
  131965. return this._pendingData.length;
  131966. };
  131967. Object.defineProperty(Scene.prototype, "isLoading", {
  131968. /**
  131969. * Returns a boolean indicating if the scene is still loading data
  131970. */
  131971. get: function () {
  131972. return this._pendingData.length > 0;
  131973. },
  131974. enumerable: true,
  131975. configurable: true
  131976. });
  131977. /**
  131978. * Registers a function to be executed when the scene is ready
  131979. * @param {Function} func - the function to be executed
  131980. */
  131981. Scene.prototype.executeWhenReady = function (func) {
  131982. var _this = this;
  131983. this.onReadyObservable.add(func);
  131984. if (this._executeWhenReadyTimeoutId !== -1) {
  131985. return;
  131986. }
  131987. this._executeWhenReadyTimeoutId = setTimeout(function () {
  131988. _this._checkIsReady();
  131989. }, 150);
  131990. };
  131991. /**
  131992. * Returns a promise that resolves when the scene is ready
  131993. * @returns A promise that resolves when the scene is ready
  131994. */
  131995. Scene.prototype.whenReadyAsync = function () {
  131996. var _this = this;
  131997. return new Promise(function (resolve) {
  131998. _this.executeWhenReady(function () {
  131999. resolve();
  132000. });
  132001. });
  132002. };
  132003. /** @hidden */
  132004. Scene.prototype._checkIsReady = function () {
  132005. var _this = this;
  132006. this._registerTransientComponents();
  132007. if (this.isReady()) {
  132008. this.onReadyObservable.notifyObservers(this);
  132009. this.onReadyObservable.clear();
  132010. this._executeWhenReadyTimeoutId = -1;
  132011. return;
  132012. }
  132013. this._executeWhenReadyTimeoutId = setTimeout(function () {
  132014. _this._checkIsReady();
  132015. }, 150);
  132016. };
  132017. Object.defineProperty(Scene.prototype, "animatables", {
  132018. /**
  132019. * Gets all animatable attached to the scene
  132020. */
  132021. get: function () {
  132022. return this._activeAnimatables;
  132023. },
  132024. enumerable: true,
  132025. configurable: true
  132026. });
  132027. /**
  132028. * Resets the last animation time frame.
  132029. * Useful to override when animations start running when loading a scene for the first time.
  132030. */
  132031. Scene.prototype.resetLastAnimationTimeFrame = function () {
  132032. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  132033. };
  132034. // Matrix
  132035. /** @hidden */
  132036. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  132037. this._useAlternateCameraConfiguration = active;
  132038. };
  132039. /**
  132040. * Gets the current view matrix
  132041. * @returns a Matrix
  132042. */
  132043. Scene.prototype.getViewMatrix = function () {
  132044. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  132045. };
  132046. /**
  132047. * Gets the current projection matrix
  132048. * @returns a Matrix
  132049. */
  132050. Scene.prototype.getProjectionMatrix = function () {
  132051. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  132052. };
  132053. /**
  132054. * Gets the current transform matrix
  132055. * @returns a Matrix made of View * Projection
  132056. */
  132057. Scene.prototype.getTransformMatrix = function () {
  132058. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  132059. };
  132060. /**
  132061. * Sets the current transform matrix
  132062. * @param view defines the View matrix to use
  132063. * @param projection defines the Projection matrix to use
  132064. */
  132065. Scene.prototype.setTransformMatrix = function (view, projection) {
  132066. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  132067. return;
  132068. }
  132069. this._viewUpdateFlag = view.updateFlag;
  132070. this._projectionUpdateFlag = projection.updateFlag;
  132071. this._viewMatrix = view;
  132072. this._projectionMatrix = projection;
  132073. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  132074. // Update frustum
  132075. if (!this._frustumPlanes) {
  132076. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  132077. }
  132078. else {
  132079. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  132080. }
  132081. if (this.activeCamera && this.activeCamera._alternateCamera) {
  132082. var otherCamera = this.activeCamera._alternateCamera;
  132083. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  132084. _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
  132085. }
  132086. if (this._sceneUbo.useUbo) {
  132087. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  132088. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  132089. this._sceneUbo.update();
  132090. }
  132091. };
  132092. /** @hidden */
  132093. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  132094. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  132095. return;
  132096. }
  132097. this._alternateViewUpdateFlag = view.updateFlag;
  132098. this._alternateProjectionUpdateFlag = projection.updateFlag;
  132099. this._alternateViewMatrix = view;
  132100. this._alternateProjectionMatrix = projection;
  132101. if (!this._alternateTransformMatrix) {
  132102. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  132103. }
  132104. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  132105. if (!this._alternateSceneUbo) {
  132106. this._createAlternateUbo();
  132107. }
  132108. if (this._alternateSceneUbo.useUbo) {
  132109. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  132110. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  132111. this._alternateSceneUbo.update();
  132112. }
  132113. };
  132114. /**
  132115. * Gets the uniform buffer used to store scene data
  132116. * @returns a UniformBuffer
  132117. */
  132118. Scene.prototype.getSceneUniformBuffer = function () {
  132119. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  132120. };
  132121. /**
  132122. * Gets an unique (relatively to the current scene) Id
  132123. * @returns an unique number for the scene
  132124. */
  132125. Scene.prototype.getUniqueId = function () {
  132126. var result = Scene._uniqueIdCounter;
  132127. Scene._uniqueIdCounter++;
  132128. return result;
  132129. };
  132130. /**
  132131. * Add a mesh to the list of scene's meshes
  132132. * @param newMesh defines the mesh to add
  132133. * @param recursive if all child meshes should also be added to the scene
  132134. */
  132135. Scene.prototype.addMesh = function (newMesh, recursive) {
  132136. var _this = this;
  132137. if (recursive === void 0) { recursive = false; }
  132138. this.meshes.push(newMesh);
  132139. newMesh._resyncLightSources();
  132140. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  132141. if (recursive) {
  132142. newMesh.getChildMeshes().forEach(function (m) {
  132143. _this.addMesh(m);
  132144. });
  132145. }
  132146. };
  132147. /**
  132148. * Remove a mesh for the list of scene's meshes
  132149. * @param toRemove defines the mesh to remove
  132150. * @param recursive if all child meshes should also be removed from the scene
  132151. * @returns the index where the mesh was in the mesh list
  132152. */
  132153. Scene.prototype.removeMesh = function (toRemove, recursive) {
  132154. var _this = this;
  132155. if (recursive === void 0) { recursive = false; }
  132156. var index = this.meshes.indexOf(toRemove);
  132157. if (index !== -1) {
  132158. // Remove from the scene if mesh found
  132159. this.meshes[index] = this.meshes[this.meshes.length - 1];
  132160. this.meshes.pop();
  132161. }
  132162. this.onMeshRemovedObservable.notifyObservers(toRemove);
  132163. if (recursive) {
  132164. toRemove.getChildMeshes().forEach(function (m) {
  132165. _this.removeMesh(m);
  132166. });
  132167. }
  132168. return index;
  132169. };
  132170. /**
  132171. * Add a transform node to the list of scene's transform nodes
  132172. * @param newTransformNode defines the transform node to add
  132173. */
  132174. Scene.prototype.addTransformNode = function (newTransformNode) {
  132175. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  132176. this.transformNodes.push(newTransformNode);
  132177. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  132178. };
  132179. /**
  132180. * Remove a transform node for the list of scene's transform nodes
  132181. * @param toRemove defines the transform node to remove
  132182. * @returns the index where the transform node was in the transform node list
  132183. */
  132184. Scene.prototype.removeTransformNode = function (toRemove) {
  132185. var index = toRemove._indexInSceneTransformNodesArray;
  132186. if (index !== -1) {
  132187. if (index !== this.transformNodes.length - 1) {
  132188. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  132189. this.transformNodes[index] = lastNode;
  132190. lastNode._indexInSceneTransformNodesArray = index;
  132191. }
  132192. toRemove._indexInSceneTransformNodesArray = -1;
  132193. this.transformNodes.pop();
  132194. }
  132195. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  132196. return index;
  132197. };
  132198. /**
  132199. * Remove a skeleton for the list of scene's skeletons
  132200. * @param toRemove defines the skeleton to remove
  132201. * @returns the index where the skeleton was in the skeleton list
  132202. */
  132203. Scene.prototype.removeSkeleton = function (toRemove) {
  132204. var index = this.skeletons.indexOf(toRemove);
  132205. if (index !== -1) {
  132206. // Remove from the scene if found
  132207. this.skeletons.splice(index, 1);
  132208. }
  132209. return index;
  132210. };
  132211. /**
  132212. * Remove a morph target for the list of scene's morph targets
  132213. * @param toRemove defines the morph target to remove
  132214. * @returns the index where the morph target was in the morph target list
  132215. */
  132216. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  132217. var index = this.morphTargetManagers.indexOf(toRemove);
  132218. if (index !== -1) {
  132219. // Remove from the scene if found
  132220. this.morphTargetManagers.splice(index, 1);
  132221. }
  132222. return index;
  132223. };
  132224. /**
  132225. * Remove a light for the list of scene's lights
  132226. * @param toRemove defines the light to remove
  132227. * @returns the index where the light was in the light list
  132228. */
  132229. Scene.prototype.removeLight = function (toRemove) {
  132230. var index = this.lights.indexOf(toRemove);
  132231. if (index !== -1) {
  132232. // Remove from meshes
  132233. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  132234. var mesh = _a[_i];
  132235. mesh._removeLightSource(toRemove);
  132236. }
  132237. // Remove from the scene if mesh found
  132238. this.lights.splice(index, 1);
  132239. this.sortLightsByPriority();
  132240. }
  132241. this.onLightRemovedObservable.notifyObservers(toRemove);
  132242. return index;
  132243. };
  132244. /**
  132245. * Remove a camera for the list of scene's cameras
  132246. * @param toRemove defines the camera to remove
  132247. * @returns the index where the camera was in the camera list
  132248. */
  132249. Scene.prototype.removeCamera = function (toRemove) {
  132250. var index = this.cameras.indexOf(toRemove);
  132251. if (index !== -1) {
  132252. // Remove from the scene if mesh found
  132253. this.cameras.splice(index, 1);
  132254. }
  132255. // Remove from activeCameras
  132256. var index2 = this.activeCameras.indexOf(toRemove);
  132257. if (index2 !== -1) {
  132258. // Remove from the scene if mesh found
  132259. this.activeCameras.splice(index2, 1);
  132260. }
  132261. // Reset the activeCamera
  132262. if (this.activeCamera === toRemove) {
  132263. if (this.cameras.length > 0) {
  132264. this.activeCamera = this.cameras[0];
  132265. }
  132266. else {
  132267. this.activeCamera = null;
  132268. }
  132269. }
  132270. this.onCameraRemovedObservable.notifyObservers(toRemove);
  132271. return index;
  132272. };
  132273. /**
  132274. * Remove a particle system for the list of scene's particle systems
  132275. * @param toRemove defines the particle system to remove
  132276. * @returns the index where the particle system was in the particle system list
  132277. */
  132278. Scene.prototype.removeParticleSystem = function (toRemove) {
  132279. var index = this.particleSystems.indexOf(toRemove);
  132280. if (index !== -1) {
  132281. this.particleSystems.splice(index, 1);
  132282. }
  132283. return index;
  132284. };
  132285. /**
  132286. * Remove a animation for the list of scene's animations
  132287. * @param toRemove defines the animation to remove
  132288. * @returns the index where the animation was in the animation list
  132289. */
  132290. Scene.prototype.removeAnimation = function (toRemove) {
  132291. var index = this.animations.indexOf(toRemove);
  132292. if (index !== -1) {
  132293. this.animations.splice(index, 1);
  132294. }
  132295. return index;
  132296. };
  132297. /**
  132298. * Removes the given animation group from this scene.
  132299. * @param toRemove The animation group to remove
  132300. * @returns The index of the removed animation group
  132301. */
  132302. Scene.prototype.removeAnimationGroup = function (toRemove) {
  132303. var index = this.animationGroups.indexOf(toRemove);
  132304. if (index !== -1) {
  132305. this.animationGroups.splice(index, 1);
  132306. }
  132307. return index;
  132308. };
  132309. /**
  132310. * Removes the given multi-material from this scene.
  132311. * @param toRemove The multi-material to remove
  132312. * @returns The index of the removed multi-material
  132313. */
  132314. Scene.prototype.removeMultiMaterial = function (toRemove) {
  132315. var index = this.multiMaterials.indexOf(toRemove);
  132316. if (index !== -1) {
  132317. this.multiMaterials.splice(index, 1);
  132318. }
  132319. return index;
  132320. };
  132321. /**
  132322. * Removes the given material from this scene.
  132323. * @param toRemove The material to remove
  132324. * @returns The index of the removed material
  132325. */
  132326. Scene.prototype.removeMaterial = function (toRemove) {
  132327. var index = toRemove._indexInSceneMaterialArray;
  132328. if (index !== -1 && index < this.materials.length) {
  132329. if (index !== this.materials.length - 1) {
  132330. var lastMaterial = this.materials[this.materials.length - 1];
  132331. this.materials[index] = lastMaterial;
  132332. lastMaterial._indexInSceneMaterialArray = index;
  132333. }
  132334. toRemove._indexInSceneMaterialArray = -1;
  132335. this.materials.pop();
  132336. }
  132337. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  132338. return index;
  132339. };
  132340. /**
  132341. * Removes the given action manager from this scene.
  132342. * @param toRemove The action manager to remove
  132343. * @returns The index of the removed action manager
  132344. */
  132345. Scene.prototype.removeActionManager = function (toRemove) {
  132346. var index = this.actionManagers.indexOf(toRemove);
  132347. if (index !== -1) {
  132348. this.actionManagers.splice(index, 1);
  132349. }
  132350. return index;
  132351. };
  132352. /**
  132353. * Removes the given texture from this scene.
  132354. * @param toRemove The texture to remove
  132355. * @returns The index of the removed texture
  132356. */
  132357. Scene.prototype.removeTexture = function (toRemove) {
  132358. var index = this.textures.indexOf(toRemove);
  132359. if (index !== -1) {
  132360. this.textures.splice(index, 1);
  132361. }
  132362. this.onTextureRemovedObservable.notifyObservers(toRemove);
  132363. return index;
  132364. };
  132365. /**
  132366. * Adds the given light to this scene
  132367. * @param newLight The light to add
  132368. */
  132369. Scene.prototype.addLight = function (newLight) {
  132370. this.lights.push(newLight);
  132371. this.sortLightsByPriority();
  132372. // Add light to all meshes (To support if the light is removed and then readded)
  132373. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  132374. var mesh = _a[_i];
  132375. if (mesh._lightSources.indexOf(newLight) === -1) {
  132376. mesh._lightSources.push(newLight);
  132377. mesh._resyncLightSources();
  132378. }
  132379. }
  132380. this.onNewLightAddedObservable.notifyObservers(newLight);
  132381. };
  132382. /**
  132383. * Sorts the list list based on light priorities
  132384. */
  132385. Scene.prototype.sortLightsByPriority = function () {
  132386. if (this.requireLightSorting) {
  132387. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  132388. }
  132389. };
  132390. /**
  132391. * Adds the given camera to this scene
  132392. * @param newCamera The camera to add
  132393. */
  132394. Scene.prototype.addCamera = function (newCamera) {
  132395. this.cameras.push(newCamera);
  132396. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  132397. };
  132398. /**
  132399. * Adds the given skeleton to this scene
  132400. * @param newSkeleton The skeleton to add
  132401. */
  132402. Scene.prototype.addSkeleton = function (newSkeleton) {
  132403. this.skeletons.push(newSkeleton);
  132404. };
  132405. /**
  132406. * Adds the given particle system to this scene
  132407. * @param newParticleSystem The particle system to add
  132408. */
  132409. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  132410. this.particleSystems.push(newParticleSystem);
  132411. };
  132412. /**
  132413. * Adds the given animation to this scene
  132414. * @param newAnimation The animation to add
  132415. */
  132416. Scene.prototype.addAnimation = function (newAnimation) {
  132417. this.animations.push(newAnimation);
  132418. };
  132419. /**
  132420. * Adds the given animation group to this scene.
  132421. * @param newAnimationGroup The animation group to add
  132422. */
  132423. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  132424. this.animationGroups.push(newAnimationGroup);
  132425. };
  132426. /**
  132427. * Adds the given multi-material to this scene
  132428. * @param newMultiMaterial The multi-material to add
  132429. */
  132430. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  132431. this.multiMaterials.push(newMultiMaterial);
  132432. };
  132433. /**
  132434. * Adds the given material to this scene
  132435. * @param newMaterial The material to add
  132436. */
  132437. Scene.prototype.addMaterial = function (newMaterial) {
  132438. newMaterial._indexInSceneMaterialArray = this.materials.length;
  132439. this.materials.push(newMaterial);
  132440. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  132441. };
  132442. /**
  132443. * Adds the given morph target to this scene
  132444. * @param newMorphTargetManager The morph target to add
  132445. */
  132446. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  132447. this.morphTargetManagers.push(newMorphTargetManager);
  132448. };
  132449. /**
  132450. * Adds the given geometry to this scene
  132451. * @param newGeometry The geometry to add
  132452. */
  132453. Scene.prototype.addGeometry = function (newGeometry) {
  132454. if (this.geometriesByUniqueId) {
  132455. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  132456. }
  132457. this.geometries.push(newGeometry);
  132458. };
  132459. /**
  132460. * Adds the given action manager to this scene
  132461. * @param newActionManager The action manager to add
  132462. */
  132463. Scene.prototype.addActionManager = function (newActionManager) {
  132464. this.actionManagers.push(newActionManager);
  132465. };
  132466. /**
  132467. * Adds the given texture to this scene.
  132468. * @param newTexture The texture to add
  132469. */
  132470. Scene.prototype.addTexture = function (newTexture) {
  132471. this.textures.push(newTexture);
  132472. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  132473. };
  132474. /**
  132475. * Switch active camera
  132476. * @param newCamera defines the new active camera
  132477. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  132478. */
  132479. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  132480. if (attachControl === void 0) { attachControl = true; }
  132481. var canvas = this._engine.getRenderingCanvas();
  132482. if (!canvas) {
  132483. return;
  132484. }
  132485. if (this.activeCamera) {
  132486. this.activeCamera.detachControl(canvas);
  132487. }
  132488. this.activeCamera = newCamera;
  132489. if (attachControl) {
  132490. newCamera.attachControl(canvas);
  132491. }
  132492. };
  132493. /**
  132494. * sets the active camera of the scene using its ID
  132495. * @param id defines the camera's ID
  132496. * @return the new active camera or null if none found.
  132497. */
  132498. Scene.prototype.setActiveCameraByID = function (id) {
  132499. var camera = this.getCameraByID(id);
  132500. if (camera) {
  132501. this.activeCamera = camera;
  132502. return camera;
  132503. }
  132504. return null;
  132505. };
  132506. /**
  132507. * sets the active camera of the scene using its name
  132508. * @param name defines the camera's name
  132509. * @returns the new active camera or null if none found.
  132510. */
  132511. Scene.prototype.setActiveCameraByName = function (name) {
  132512. var camera = this.getCameraByName(name);
  132513. if (camera) {
  132514. this.activeCamera = camera;
  132515. return camera;
  132516. }
  132517. return null;
  132518. };
  132519. /**
  132520. * get an animation group using its name
  132521. * @param name defines the material's name
  132522. * @return the animation group or null if none found.
  132523. */
  132524. Scene.prototype.getAnimationGroupByName = function (name) {
  132525. for (var index = 0; index < this.animationGroups.length; index++) {
  132526. if (this.animationGroups[index].name === name) {
  132527. return this.animationGroups[index];
  132528. }
  132529. }
  132530. return null;
  132531. };
  132532. /**
  132533. * get a material using its id
  132534. * @param id defines the material's ID
  132535. * @return the material or null if none found.
  132536. */
  132537. Scene.prototype.getMaterialByID = function (id) {
  132538. for (var index = 0; index < this.materials.length; index++) {
  132539. if (this.materials[index].id === id) {
  132540. return this.materials[index];
  132541. }
  132542. }
  132543. return null;
  132544. };
  132545. /**
  132546. * Gets a material using its name
  132547. * @param name defines the material's name
  132548. * @return the material or null if none found.
  132549. */
  132550. Scene.prototype.getMaterialByName = function (name) {
  132551. for (var index = 0; index < this.materials.length; index++) {
  132552. if (this.materials[index].name === name) {
  132553. return this.materials[index];
  132554. }
  132555. }
  132556. return null;
  132557. };
  132558. /**
  132559. * Gets a camera using its id
  132560. * @param id defines the id to look for
  132561. * @returns the camera or null if not found
  132562. */
  132563. Scene.prototype.getCameraByID = function (id) {
  132564. for (var index = 0; index < this.cameras.length; index++) {
  132565. if (this.cameras[index].id === id) {
  132566. return this.cameras[index];
  132567. }
  132568. }
  132569. return null;
  132570. };
  132571. /**
  132572. * Gets a camera using its unique id
  132573. * @param uniqueId defines the unique id to look for
  132574. * @returns the camera or null if not found
  132575. */
  132576. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  132577. for (var index = 0; index < this.cameras.length; index++) {
  132578. if (this.cameras[index].uniqueId === uniqueId) {
  132579. return this.cameras[index];
  132580. }
  132581. }
  132582. return null;
  132583. };
  132584. /**
  132585. * Gets a camera using its name
  132586. * @param name defines the camera's name
  132587. * @return the camera or null if none found.
  132588. */
  132589. Scene.prototype.getCameraByName = function (name) {
  132590. for (var index = 0; index < this.cameras.length; index++) {
  132591. if (this.cameras[index].name === name) {
  132592. return this.cameras[index];
  132593. }
  132594. }
  132595. return null;
  132596. };
  132597. /**
  132598. * Gets a bone using its id
  132599. * @param id defines the bone's id
  132600. * @return the bone or null if not found
  132601. */
  132602. Scene.prototype.getBoneByID = function (id) {
  132603. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  132604. var skeleton = this.skeletons[skeletonIndex];
  132605. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  132606. if (skeleton.bones[boneIndex].id === id) {
  132607. return skeleton.bones[boneIndex];
  132608. }
  132609. }
  132610. }
  132611. return null;
  132612. };
  132613. /**
  132614. * Gets a bone using its id
  132615. * @param name defines the bone's name
  132616. * @return the bone or null if not found
  132617. */
  132618. Scene.prototype.getBoneByName = function (name) {
  132619. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  132620. var skeleton = this.skeletons[skeletonIndex];
  132621. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  132622. if (skeleton.bones[boneIndex].name === name) {
  132623. return skeleton.bones[boneIndex];
  132624. }
  132625. }
  132626. }
  132627. return null;
  132628. };
  132629. /**
  132630. * Gets a light node using its name
  132631. * @param name defines the the light's name
  132632. * @return the light or null if none found.
  132633. */
  132634. Scene.prototype.getLightByName = function (name) {
  132635. for (var index = 0; index < this.lights.length; index++) {
  132636. if (this.lights[index].name === name) {
  132637. return this.lights[index];
  132638. }
  132639. }
  132640. return null;
  132641. };
  132642. /**
  132643. * Gets a light node using its id
  132644. * @param id defines the light's id
  132645. * @return the light or null if none found.
  132646. */
  132647. Scene.prototype.getLightByID = function (id) {
  132648. for (var index = 0; index < this.lights.length; index++) {
  132649. if (this.lights[index].id === id) {
  132650. return this.lights[index];
  132651. }
  132652. }
  132653. return null;
  132654. };
  132655. /**
  132656. * Gets a light node using its scene-generated unique ID
  132657. * @param uniqueId defines the light's unique id
  132658. * @return the light or null if none found.
  132659. */
  132660. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  132661. for (var index = 0; index < this.lights.length; index++) {
  132662. if (this.lights[index].uniqueId === uniqueId) {
  132663. return this.lights[index];
  132664. }
  132665. }
  132666. return null;
  132667. };
  132668. /**
  132669. * Gets a particle system by id
  132670. * @param id defines the particle system id
  132671. * @return the corresponding system or null if none found
  132672. */
  132673. Scene.prototype.getParticleSystemByID = function (id) {
  132674. for (var index = 0; index < this.particleSystems.length; index++) {
  132675. if (this.particleSystems[index].id === id) {
  132676. return this.particleSystems[index];
  132677. }
  132678. }
  132679. return null;
  132680. };
  132681. /**
  132682. * Gets a geometry using its ID
  132683. * @param id defines the geometry's id
  132684. * @return the geometry or null if none found.
  132685. */
  132686. Scene.prototype.getGeometryByID = function (id) {
  132687. for (var index = 0; index < this.geometries.length; index++) {
  132688. if (this.geometries[index].id === id) {
  132689. return this.geometries[index];
  132690. }
  132691. }
  132692. return null;
  132693. };
  132694. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  132695. if (this.geometriesByUniqueId) {
  132696. var index_1 = this.geometriesByUniqueId[uniqueId];
  132697. if (index_1 !== undefined) {
  132698. return this.geometries[index_1];
  132699. }
  132700. }
  132701. else {
  132702. for (var index = 0; index < this.geometries.length; index++) {
  132703. if (this.geometries[index].uniqueId === uniqueId) {
  132704. return this.geometries[index];
  132705. }
  132706. }
  132707. }
  132708. return null;
  132709. };
  132710. /**
  132711. * Add a new geometry to this scene
  132712. * @param geometry defines the geometry to be added to the scene.
  132713. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  132714. * @return a boolean defining if the geometry was added or not
  132715. */
  132716. Scene.prototype.pushGeometry = function (geometry, force) {
  132717. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  132718. return false;
  132719. }
  132720. this.addGeometry(geometry);
  132721. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  132722. return true;
  132723. };
  132724. /**
  132725. * Removes an existing geometry
  132726. * @param geometry defines the geometry to be removed from the scene
  132727. * @return a boolean defining if the geometry was removed or not
  132728. */
  132729. Scene.prototype.removeGeometry = function (geometry) {
  132730. var index;
  132731. if (this.geometriesByUniqueId) {
  132732. index = this.geometriesByUniqueId[geometry.uniqueId];
  132733. if (index === undefined) {
  132734. return false;
  132735. }
  132736. }
  132737. else {
  132738. index = this.geometries.indexOf(geometry);
  132739. if (index < 0) {
  132740. return false;
  132741. }
  132742. }
  132743. if (index !== this.geometries.length - 1) {
  132744. var lastGeometry = this.geometries[this.geometries.length - 1];
  132745. this.geometries[index] = lastGeometry;
  132746. if (this.geometriesByUniqueId) {
  132747. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  132748. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  132749. }
  132750. }
  132751. this.geometries.pop();
  132752. this.onGeometryRemovedObservable.notifyObservers(geometry);
  132753. return true;
  132754. };
  132755. /**
  132756. * Gets the list of geometries attached to the scene
  132757. * @returns an array of Geometry
  132758. */
  132759. Scene.prototype.getGeometries = function () {
  132760. return this.geometries;
  132761. };
  132762. /**
  132763. * Gets the first added mesh found of a given ID
  132764. * @param id defines the id to search for
  132765. * @return the mesh found or null if not found at all
  132766. */
  132767. Scene.prototype.getMeshByID = function (id) {
  132768. for (var index = 0; index < this.meshes.length; index++) {
  132769. if (this.meshes[index].id === id) {
  132770. return this.meshes[index];
  132771. }
  132772. }
  132773. return null;
  132774. };
  132775. /**
  132776. * Gets a list of meshes using their id
  132777. * @param id defines the id to search for
  132778. * @returns a list of meshes
  132779. */
  132780. Scene.prototype.getMeshesByID = function (id) {
  132781. return this.meshes.filter(function (m) {
  132782. return m.id === id;
  132783. });
  132784. };
  132785. /**
  132786. * Gets the first added transform node found of a given ID
  132787. * @param id defines the id to search for
  132788. * @return the found transform node or null if not found at all.
  132789. */
  132790. Scene.prototype.getTransformNodeByID = function (id) {
  132791. for (var index = 0; index < this.transformNodes.length; index++) {
  132792. if (this.transformNodes[index].id === id) {
  132793. return this.transformNodes[index];
  132794. }
  132795. }
  132796. return null;
  132797. };
  132798. /**
  132799. * Gets a list of transform nodes using their id
  132800. * @param id defines the id to search for
  132801. * @returns a list of transform nodes
  132802. */
  132803. Scene.prototype.getTransformNodesByID = function (id) {
  132804. return this.transformNodes.filter(function (m) {
  132805. return m.id === id;
  132806. });
  132807. };
  132808. /**
  132809. * Gets a mesh with its auto-generated unique id
  132810. * @param uniqueId defines the unique id to search for
  132811. * @return the found mesh or null if not found at all.
  132812. */
  132813. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  132814. for (var index = 0; index < this.meshes.length; index++) {
  132815. if (this.meshes[index].uniqueId === uniqueId) {
  132816. return this.meshes[index];
  132817. }
  132818. }
  132819. return null;
  132820. };
  132821. /**
  132822. * Gets a the last added mesh using a given id
  132823. * @param id defines the id to search for
  132824. * @return the found mesh or null if not found at all.
  132825. */
  132826. Scene.prototype.getLastMeshByID = function (id) {
  132827. for (var index = this.meshes.length - 1; index >= 0; index--) {
  132828. if (this.meshes[index].id === id) {
  132829. return this.meshes[index];
  132830. }
  132831. }
  132832. return null;
  132833. };
  132834. /**
  132835. * Gets a the last added node (Mesh, Camera, Light) using a given id
  132836. * @param id defines the id to search for
  132837. * @return the found node or null if not found at all
  132838. */
  132839. Scene.prototype.getLastEntryByID = function (id) {
  132840. var index;
  132841. for (index = this.meshes.length - 1; index >= 0; index--) {
  132842. if (this.meshes[index].id === id) {
  132843. return this.meshes[index];
  132844. }
  132845. }
  132846. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  132847. if (this.transformNodes[index].id === id) {
  132848. return this.transformNodes[index];
  132849. }
  132850. }
  132851. for (index = this.cameras.length - 1; index >= 0; index--) {
  132852. if (this.cameras[index].id === id) {
  132853. return this.cameras[index];
  132854. }
  132855. }
  132856. for (index = this.lights.length - 1; index >= 0; index--) {
  132857. if (this.lights[index].id === id) {
  132858. return this.lights[index];
  132859. }
  132860. }
  132861. return null;
  132862. };
  132863. /**
  132864. * Gets a node (Mesh, Camera, Light) using a given id
  132865. * @param id defines the id to search for
  132866. * @return the found node or null if not found at all
  132867. */
  132868. Scene.prototype.getNodeByID = function (id) {
  132869. var mesh = this.getMeshByID(id);
  132870. if (mesh) {
  132871. return mesh;
  132872. }
  132873. var transformNode = this.getTransformNodeByID(id);
  132874. if (transformNode) {
  132875. return transformNode;
  132876. }
  132877. var light = this.getLightByID(id);
  132878. if (light) {
  132879. return light;
  132880. }
  132881. var camera = this.getCameraByID(id);
  132882. if (camera) {
  132883. return camera;
  132884. }
  132885. var bone = this.getBoneByID(id);
  132886. if (bone) {
  132887. return bone;
  132888. }
  132889. return null;
  132890. };
  132891. /**
  132892. * Gets a node (Mesh, Camera, Light) using a given name
  132893. * @param name defines the name to search for
  132894. * @return the found node or null if not found at all.
  132895. */
  132896. Scene.prototype.getNodeByName = function (name) {
  132897. var mesh = this.getMeshByName(name);
  132898. if (mesh) {
  132899. return mesh;
  132900. }
  132901. var transformNode = this.getTransformNodeByName(name);
  132902. if (transformNode) {
  132903. return transformNode;
  132904. }
  132905. var light = this.getLightByName(name);
  132906. if (light) {
  132907. return light;
  132908. }
  132909. var camera = this.getCameraByName(name);
  132910. if (camera) {
  132911. return camera;
  132912. }
  132913. var bone = this.getBoneByName(name);
  132914. if (bone) {
  132915. return bone;
  132916. }
  132917. return null;
  132918. };
  132919. /**
  132920. * Gets a mesh using a given name
  132921. * @param name defines the name to search for
  132922. * @return the found mesh or null if not found at all.
  132923. */
  132924. Scene.prototype.getMeshByName = function (name) {
  132925. for (var index = 0; index < this.meshes.length; index++) {
  132926. if (this.meshes[index].name === name) {
  132927. return this.meshes[index];
  132928. }
  132929. }
  132930. return null;
  132931. };
  132932. /**
  132933. * Gets a transform node using a given name
  132934. * @param name defines the name to search for
  132935. * @return the found transform node or null if not found at all.
  132936. */
  132937. Scene.prototype.getTransformNodeByName = function (name) {
  132938. for (var index = 0; index < this.transformNodes.length; index++) {
  132939. if (this.transformNodes[index].name === name) {
  132940. return this.transformNodes[index];
  132941. }
  132942. }
  132943. return null;
  132944. };
  132945. /**
  132946. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  132947. * @param id defines the id to search for
  132948. * @return the found skeleton or null if not found at all.
  132949. */
  132950. Scene.prototype.getLastSkeletonByID = function (id) {
  132951. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  132952. if (this.skeletons[index].id === id) {
  132953. return this.skeletons[index];
  132954. }
  132955. }
  132956. return null;
  132957. };
  132958. /**
  132959. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  132960. * @param id defines the id to search for
  132961. * @return the found skeleton or null if not found at all.
  132962. */
  132963. Scene.prototype.getSkeletonById = function (id) {
  132964. for (var index = 0; index < this.skeletons.length; index++) {
  132965. if (this.skeletons[index].id === id) {
  132966. return this.skeletons[index];
  132967. }
  132968. }
  132969. return null;
  132970. };
  132971. /**
  132972. * Gets a skeleton using a given name
  132973. * @param name defines the name to search for
  132974. * @return the found skeleton or null if not found at all.
  132975. */
  132976. Scene.prototype.getSkeletonByName = function (name) {
  132977. for (var index = 0; index < this.skeletons.length; index++) {
  132978. if (this.skeletons[index].name === name) {
  132979. return this.skeletons[index];
  132980. }
  132981. }
  132982. return null;
  132983. };
  132984. /**
  132985. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  132986. * @param id defines the id to search for
  132987. * @return the found morph target manager or null if not found at all.
  132988. */
  132989. Scene.prototype.getMorphTargetManagerById = function (id) {
  132990. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  132991. if (this.morphTargetManagers[index].uniqueId === id) {
  132992. return this.morphTargetManagers[index];
  132993. }
  132994. }
  132995. return null;
  132996. };
  132997. /**
  132998. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  132999. * @param id defines the id to search for
  133000. * @return the found morph target or null if not found at all.
  133001. */
  133002. Scene.prototype.getMorphTargetById = function (id) {
  133003. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  133004. var morphTargetManager = this.morphTargetManagers[managerIndex];
  133005. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  133006. var target = morphTargetManager.getTarget(index);
  133007. if (target.id === id) {
  133008. return target;
  133009. }
  133010. }
  133011. }
  133012. return null;
  133013. };
  133014. /**
  133015. * Gets a boolean indicating if the given mesh is active
  133016. * @param mesh defines the mesh to look for
  133017. * @returns true if the mesh is in the active list
  133018. */
  133019. Scene.prototype.isActiveMesh = function (mesh) {
  133020. return (this._activeMeshes.indexOf(mesh) !== -1);
  133021. };
  133022. Object.defineProperty(Scene.prototype, "uid", {
  133023. /**
  133024. * Return a unique id as a string which can serve as an identifier for the scene
  133025. */
  133026. get: function () {
  133027. if (!this._uid) {
  133028. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  133029. }
  133030. return this._uid;
  133031. },
  133032. enumerable: true,
  133033. configurable: true
  133034. });
  133035. /**
  133036. * Add an externaly attached data from its key.
  133037. * This method call will fail and return false, if such key already exists.
  133038. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  133039. * @param key the unique key that identifies the data
  133040. * @param data the data object to associate to the key for this Engine instance
  133041. * @return true if no such key were already present and the data was added successfully, false otherwise
  133042. */
  133043. Scene.prototype.addExternalData = function (key, data) {
  133044. if (!this._externalData) {
  133045. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  133046. }
  133047. return this._externalData.add(key, data);
  133048. };
  133049. /**
  133050. * Get an externaly attached data from its key
  133051. * @param key the unique key that identifies the data
  133052. * @return the associated data, if present (can be null), or undefined if not present
  133053. */
  133054. Scene.prototype.getExternalData = function (key) {
  133055. if (!this._externalData) {
  133056. return null;
  133057. }
  133058. return this._externalData.get(key);
  133059. };
  133060. /**
  133061. * Get an externaly attached data from its key, create it using a factory if it's not already present
  133062. * @param key the unique key that identifies the data
  133063. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  133064. * @return the associated data, can be null if the factory returned null.
  133065. */
  133066. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  133067. if (!this._externalData) {
  133068. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  133069. }
  133070. return this._externalData.getOrAddWithFactory(key, factory);
  133071. };
  133072. /**
  133073. * Remove an externaly attached data from the Engine instance
  133074. * @param key the unique key that identifies the data
  133075. * @return true if the data was successfully removed, false if it doesn't exist
  133076. */
  133077. Scene.prototype.removeExternalData = function (key) {
  133078. return this._externalData.remove(key);
  133079. };
  133080. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  133081. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  133082. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  133083. var step = _a[_i];
  133084. step.action(mesh, subMesh);
  133085. }
  133086. var material = subMesh.getMaterial();
  133087. if (material !== null && material !== undefined) {
  133088. // Render targets
  133089. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  133090. if (this._processedMaterials.indexOf(material) === -1) {
  133091. this._processedMaterials.push(material);
  133092. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  133093. }
  133094. }
  133095. // Dispatch
  133096. this._activeIndices.addCount(subMesh.indexCount, false);
  133097. this._renderingManager.dispatch(subMesh, mesh, material);
  133098. }
  133099. }
  133100. };
  133101. /**
  133102. * Clear the processed materials smart array preventing retention point in material dispose.
  133103. */
  133104. Scene.prototype.freeProcessedMaterials = function () {
  133105. this._processedMaterials.dispose();
  133106. };
  133107. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  133108. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  133109. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  133110. * when disposing several meshes in a row or a hierarchy of meshes.
  133111. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  133112. */
  133113. get: function () {
  133114. return this._preventFreeActiveMeshesAndRenderingGroups;
  133115. },
  133116. set: function (value) {
  133117. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  133118. return;
  133119. }
  133120. if (value) {
  133121. this.freeActiveMeshes();
  133122. this.freeRenderingGroups();
  133123. }
  133124. this._preventFreeActiveMeshesAndRenderingGroups = value;
  133125. },
  133126. enumerable: true,
  133127. configurable: true
  133128. });
  133129. /**
  133130. * Clear the active meshes smart array preventing retention point in mesh dispose.
  133131. */
  133132. Scene.prototype.freeActiveMeshes = function () {
  133133. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  133134. return;
  133135. }
  133136. this._activeMeshes.dispose();
  133137. if (this.activeCamera && this.activeCamera._activeMeshes) {
  133138. this.activeCamera._activeMeshes.dispose();
  133139. }
  133140. if (this.activeCameras) {
  133141. for (var i = 0; i < this.activeCameras.length; i++) {
  133142. var activeCamera = this.activeCameras[i];
  133143. if (activeCamera && activeCamera._activeMeshes) {
  133144. activeCamera._activeMeshes.dispose();
  133145. }
  133146. }
  133147. }
  133148. };
  133149. /**
  133150. * Clear the info related to rendering groups preventing retention points during dispose.
  133151. */
  133152. Scene.prototype.freeRenderingGroups = function () {
  133153. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  133154. return;
  133155. }
  133156. if (this._renderingManager) {
  133157. this._renderingManager.freeRenderingGroups();
  133158. }
  133159. if (this.textures) {
  133160. for (var i = 0; i < this.textures.length; i++) {
  133161. var texture = this.textures[i];
  133162. if (texture && texture.renderList) {
  133163. texture.freeRenderingGroups();
  133164. }
  133165. }
  133166. }
  133167. };
  133168. /** @hidden */
  133169. Scene.prototype._isInIntermediateRendering = function () {
  133170. return this._intermediateRendering;
  133171. };
  133172. /**
  133173. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  133174. * @returns the current scene
  133175. */
  133176. Scene.prototype.freezeActiveMeshes = function () {
  133177. if (!this.activeCamera) {
  133178. return this;
  133179. }
  133180. if (!this._frustumPlanes) {
  133181. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  133182. }
  133183. this._evaluateActiveMeshes();
  133184. this._activeMeshesFrozen = true;
  133185. return this;
  133186. };
  133187. /**
  133188. * Use this function to restart evaluating active meshes on every frame
  133189. * @returns the current scene
  133190. */
  133191. Scene.prototype.unfreezeActiveMeshes = function () {
  133192. this._activeMeshesFrozen = false;
  133193. return this;
  133194. };
  133195. Scene.prototype._evaluateActiveMeshes = function () {
  133196. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  133197. return;
  133198. }
  133199. if (!this.activeCamera) {
  133200. return;
  133201. }
  133202. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  133203. this.activeCamera._activeMeshes.reset();
  133204. this._activeMeshes.reset();
  133205. this._renderingManager.reset();
  133206. this._processedMaterials.reset();
  133207. this._activeParticleSystems.reset();
  133208. this._activeSkeletons.reset();
  133209. this._softwareSkinnedMeshes.reset();
  133210. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  133211. var step = _a[_i];
  133212. step.action();
  133213. }
  133214. // Determine mesh candidates
  133215. var meshes = this.getActiveMeshCandidates();
  133216. // Check each mesh
  133217. var len = meshes.length;
  133218. for (var i = 0; i < len; i++) {
  133219. var mesh = meshes.data[i];
  133220. if (mesh.isBlocked) {
  133221. continue;
  133222. }
  133223. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  133224. if (!mesh.isReady() || !mesh.isEnabled()) {
  133225. continue;
  133226. }
  133227. mesh.computeWorldMatrix();
  133228. // Intersections
  133229. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  133230. this._meshesForIntersections.pushNoDuplicate(mesh);
  133231. }
  133232. // Switch to current LOD
  133233. var meshLOD = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  133234. if (meshLOD === undefined || meshLOD === null) {
  133235. continue;
  133236. }
  133237. mesh._preActivate();
  133238. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  133239. this._activeMeshes.push(mesh);
  133240. this.activeCamera._activeMeshes.push(mesh);
  133241. mesh._activate(this._renderId);
  133242. if (meshLOD !== mesh) {
  133243. meshLOD._activate(this._renderId);
  133244. }
  133245. this._activeMesh(mesh, meshLOD);
  133246. }
  133247. }
  133248. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  133249. // Particle systems
  133250. if (this.particlesEnabled) {
  133251. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  133252. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  133253. var particleSystem = this.particleSystems[particleIndex];
  133254. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  133255. continue;
  133256. }
  133257. var emitter = particleSystem.emitter;
  133258. if (!emitter.position || emitter.isEnabled()) {
  133259. this._activeParticleSystems.push(particleSystem);
  133260. particleSystem.animate();
  133261. this._renderingManager.dispatchParticles(particleSystem);
  133262. }
  133263. }
  133264. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  133265. }
  133266. };
  133267. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  133268. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  133269. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  133270. mesh.skeleton.prepare();
  133271. }
  133272. if (!mesh.computeBonesUsingShaders) {
  133273. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  133274. }
  133275. }
  133276. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  133277. var step = _a[_i];
  133278. step.action(sourceMesh, mesh);
  133279. }
  133280. if (mesh !== undefined && mesh !== null
  133281. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  133282. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  133283. var len = subMeshes.length;
  133284. for (var i = 0; i < len; i++) {
  133285. var subMesh = subMeshes.data[i];
  133286. this._evaluateSubMesh(subMesh, mesh);
  133287. }
  133288. }
  133289. };
  133290. /**
  133291. * Update the transform matrix to update from the current active camera
  133292. * @param force defines a boolean used to force the update even if cache is up to date
  133293. */
  133294. Scene.prototype.updateTransformMatrix = function (force) {
  133295. if (!this.activeCamera) {
  133296. return;
  133297. }
  133298. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  133299. };
  133300. /**
  133301. * 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)
  133302. * @param alternateCamera defines the camera to use
  133303. */
  133304. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  133305. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  133306. };
  133307. Scene.prototype._renderForCamera = function (camera, rigParent) {
  133308. if (camera && camera._skipRendering) {
  133309. return;
  133310. }
  133311. var engine = this._engine;
  133312. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  133313. this._activeCamera = camera;
  133314. if (!this.activeCamera) {
  133315. throw new Error("Active camera not set");
  133316. }
  133317. // Viewport
  133318. engine.setViewport(this.activeCamera.viewport);
  133319. // Camera
  133320. this.resetCachedMaterial();
  133321. this._renderId++;
  133322. this.updateTransformMatrix();
  133323. if (camera._alternateCamera) {
  133324. this.updateAlternateTransformMatrix(camera._alternateCamera);
  133325. this._alternateRendering = true;
  133326. }
  133327. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  133328. // Meshes
  133329. this._evaluateActiveMeshes();
  133330. // Software skinning
  133331. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  133332. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  133333. mesh.applySkeleton(mesh.skeleton);
  133334. }
  133335. // Render targets
  133336. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  133337. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  133338. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  133339. }
  133340. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  133341. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  133342. }
  133343. // Collects render targets from external components.
  133344. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  133345. var step = _a[_i];
  133346. step.action(this._renderTargets);
  133347. }
  133348. if (this.renderTargetsEnabled) {
  133349. this._intermediateRendering = true;
  133350. if (this._renderTargets.length > 0) {
  133351. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  133352. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  133353. var renderTarget = this._renderTargets.data[renderIndex];
  133354. if (renderTarget._shouldRender()) {
  133355. this._renderId++;
  133356. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  133357. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  133358. }
  133359. }
  133360. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  133361. this._renderId++;
  133362. }
  133363. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  133364. var step = _c[_b];
  133365. step.action(this.activeCamera);
  133366. }
  133367. this._intermediateRendering = false;
  133368. if (this.activeCamera.outputRenderTarget) {
  133369. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  133370. if (internalTexture) {
  133371. engine.bindFramebuffer(internalTexture);
  133372. }
  133373. else {
  133374. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  133375. }
  133376. }
  133377. else {
  133378. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  133379. }
  133380. }
  133381. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  133382. // Prepare Frame
  133383. if (this.postProcessManager) {
  133384. this.postProcessManager._prepareFrame();
  133385. }
  133386. // Before Camera Draw
  133387. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  133388. var step = _e[_d];
  133389. step.action(this.activeCamera);
  133390. }
  133391. // Render
  133392. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  133393. this._renderingManager.render(null, null, true, true);
  133394. this.onAfterDrawPhaseObservable.notifyObservers(this);
  133395. // After Camera Draw
  133396. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  133397. var step = _g[_f];
  133398. step.action(this.activeCamera);
  133399. }
  133400. // Finalize frame
  133401. if (this.postProcessManager) {
  133402. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  133403. }
  133404. // Reset some special arrays
  133405. this._renderTargets.reset();
  133406. this._alternateRendering = false;
  133407. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  133408. };
  133409. Scene.prototype._processSubCameras = function (camera) {
  133410. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  133411. this._renderForCamera(camera);
  133412. return;
  133413. }
  133414. // rig cameras
  133415. for (var index = 0; index < camera._rigCameras.length; index++) {
  133416. this._renderForCamera(camera._rigCameras[index], camera);
  133417. }
  133418. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  133419. this._activeCamera = camera;
  133420. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  133421. };
  133422. Scene.prototype._checkIntersections = function () {
  133423. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  133424. var sourceMesh = this._meshesForIntersections.data[index];
  133425. if (!sourceMesh.actionManager) {
  133426. continue;
  133427. }
  133428. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  133429. var action = sourceMesh.actionManager.actions[actionIndex];
  133430. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  133431. var parameters = action.getTriggerParameter();
  133432. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  133433. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  133434. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  133435. if (areIntersecting && currentIntersectionInProgress === -1) {
  133436. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  133437. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  133438. sourceMesh._intersectionsInProgress.push(otherMesh);
  133439. }
  133440. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  133441. sourceMesh._intersectionsInProgress.push(otherMesh);
  133442. }
  133443. }
  133444. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  133445. //They intersected, and now they don't.
  133446. //is this trigger an exit trigger? execute an event.
  133447. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  133448. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  133449. }
  133450. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  133451. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  133452. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  133453. return otherMesh === parameterMesh;
  133454. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  133455. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  133456. }
  133457. }
  133458. }
  133459. }
  133460. }
  133461. };
  133462. /** @hidden */
  133463. Scene.prototype._advancePhysicsEngineStep = function (step) {
  133464. // Do nothing. Code will be replaced if physics engine component is referenced
  133465. };
  133466. /** @hidden */
  133467. Scene.prototype._animate = function () {
  133468. // Nothing to do as long as Animatable have not been imported.
  133469. };
  133470. /**
  133471. * Render the scene
  133472. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  133473. */
  133474. Scene.prototype.render = function (updateCameras) {
  133475. if (updateCameras === void 0) { updateCameras = true; }
  133476. if (this.isDisposed) {
  133477. return;
  133478. }
  133479. this._frameId++;
  133480. // Register components that have been associated lately to the scene.
  133481. this._registerTransientComponents();
  133482. this._activeParticles.fetchNewFrame();
  133483. this._totalVertices.fetchNewFrame();
  133484. this._activeIndices.fetchNewFrame();
  133485. this._activeBones.fetchNewFrame();
  133486. this._meshesForIntersections.reset();
  133487. this.resetCachedMaterial();
  133488. this.onBeforeAnimationsObservable.notifyObservers(this);
  133489. // Actions
  133490. if (this.actionManager) {
  133491. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  133492. }
  133493. if (this._engine.isDeterministicLockStep()) {
  133494. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  133495. var defaultFPS = (60.0 / 1000.0);
  133496. var defaultFrameTime = this.getDeterministicFrameTime();
  133497. var stepsTaken = 0;
  133498. var maxSubSteps = this._engine.getLockstepMaxSteps();
  133499. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  133500. internalSteps = Math.min(internalSteps, maxSubSteps);
  133501. do {
  133502. this.onBeforeStepObservable.notifyObservers(this);
  133503. // Animations
  133504. this._animationRatio = defaultFrameTime * defaultFPS;
  133505. this._animate();
  133506. this.onAfterAnimationsObservable.notifyObservers(this);
  133507. // Physics
  133508. this._advancePhysicsEngineStep(defaultFrameTime);
  133509. this.onAfterStepObservable.notifyObservers(this);
  133510. this._currentStepId++;
  133511. stepsTaken++;
  133512. deltaTime -= defaultFrameTime;
  133513. } while (deltaTime > 0 && stepsTaken < internalSteps);
  133514. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  133515. }
  133516. else {
  133517. // Animations
  133518. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  133519. this._animationRatio = deltaTime * (60.0 / 1000.0);
  133520. this._animate();
  133521. this.onAfterAnimationsObservable.notifyObservers(this);
  133522. // Physics
  133523. this._advancePhysicsEngineStep(deltaTime);
  133524. }
  133525. // Before camera update steps
  133526. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  133527. var step = _a[_i];
  133528. step.action();
  133529. }
  133530. // Update Cameras
  133531. if (updateCameras) {
  133532. if (this.activeCameras.length > 0) {
  133533. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  133534. var camera = this.activeCameras[cameraIndex];
  133535. camera.update();
  133536. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  133537. // rig cameras
  133538. for (var index = 0; index < camera._rigCameras.length; index++) {
  133539. camera._rigCameras[index].update();
  133540. }
  133541. }
  133542. }
  133543. }
  133544. else if (this.activeCamera) {
  133545. this.activeCamera.update();
  133546. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  133547. // rig cameras
  133548. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  133549. this.activeCamera._rigCameras[index].update();
  133550. }
  133551. }
  133552. }
  133553. }
  133554. // Before render
  133555. this.onBeforeRenderObservable.notifyObservers(this);
  133556. // Customs render targets
  133557. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  133558. var engine = this.getEngine();
  133559. var currentActiveCamera = this.activeCamera;
  133560. if (this.renderTargetsEnabled) {
  133561. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  133562. this._intermediateRendering = true;
  133563. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  133564. var renderTarget = this.customRenderTargets[customIndex];
  133565. if (renderTarget._shouldRender()) {
  133566. this._renderId++;
  133567. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  133568. if (!this.activeCamera) {
  133569. throw new Error("Active camera not set");
  133570. }
  133571. // Viewport
  133572. engine.setViewport(this.activeCamera.viewport);
  133573. // Camera
  133574. this.updateTransformMatrix();
  133575. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  133576. }
  133577. }
  133578. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  133579. this._intermediateRendering = false;
  133580. this._renderId++;
  133581. }
  133582. // Restore back buffer
  133583. if (this.customRenderTargets.length > 0) {
  133584. engine.restoreDefaultFramebuffer();
  133585. }
  133586. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  133587. this.activeCamera = currentActiveCamera;
  133588. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  133589. var step = _c[_b];
  133590. step.action();
  133591. }
  133592. // Clear
  133593. if (this.autoClearDepthAndStencil || this.autoClear) {
  133594. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  133595. }
  133596. // Collects render targets from external components.
  133597. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  133598. var step = _e[_d];
  133599. step.action(this._renderTargets);
  133600. }
  133601. // Multi-cameras?
  133602. if (this.activeCameras.length > 0) {
  133603. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  133604. if (cameraIndex > 0) {
  133605. this._engine.clear(null, false, true, true);
  133606. }
  133607. this._processSubCameras(this.activeCameras[cameraIndex]);
  133608. }
  133609. }
  133610. else {
  133611. if (!this.activeCamera) {
  133612. throw new Error("No camera defined");
  133613. }
  133614. this._processSubCameras(this.activeCamera);
  133615. }
  133616. // Intersection checks
  133617. this._checkIntersections();
  133618. // Executes the after render stage actions.
  133619. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  133620. var step = _g[_f];
  133621. step.action();
  133622. }
  133623. // After render
  133624. if (this.afterRender) {
  133625. this.afterRender();
  133626. }
  133627. this.onAfterRenderObservable.notifyObservers(this);
  133628. // Cleaning
  133629. if (this._toBeDisposed.length) {
  133630. for (var index = 0; index < this._toBeDisposed.length; index++) {
  133631. var data = this._toBeDisposed[index];
  133632. if (data) {
  133633. data.dispose();
  133634. }
  133635. }
  133636. this._toBeDisposed = [];
  133637. }
  133638. if (this.dumpNextRenderTargets) {
  133639. this.dumpNextRenderTargets = false;
  133640. }
  133641. this._activeBones.addCount(0, true);
  133642. this._activeIndices.addCount(0, true);
  133643. this._activeParticles.addCount(0, true);
  133644. };
  133645. /**
  133646. * Freeze all materials
  133647. * A frozen material will not be updatable but should be faster to render
  133648. */
  133649. Scene.prototype.freezeMaterials = function () {
  133650. for (var i = 0; i < this.materials.length; i++) {
  133651. this.materials[i].freeze();
  133652. }
  133653. };
  133654. /**
  133655. * Unfreeze all materials
  133656. * A frozen material will not be updatable but should be faster to render
  133657. */
  133658. Scene.prototype.unfreezeMaterials = function () {
  133659. for (var i = 0; i < this.materials.length; i++) {
  133660. this.materials[i].unfreeze();
  133661. }
  133662. };
  133663. /**
  133664. * Releases all held ressources
  133665. */
  133666. Scene.prototype.dispose = function () {
  133667. this.beforeRender = null;
  133668. this.afterRender = null;
  133669. this.skeletons = [];
  133670. this.morphTargetManagers = [];
  133671. this._transientComponents = [];
  133672. this._isReadyForMeshStage.clear();
  133673. this._beforeEvaluateActiveMeshStage.clear();
  133674. this._evaluateSubMeshStage.clear();
  133675. this._activeMeshStage.clear();
  133676. this._cameraDrawRenderTargetStage.clear();
  133677. this._beforeCameraDrawStage.clear();
  133678. this._beforeRenderTargetDrawStage.clear();
  133679. this._beforeRenderingGroupDrawStage.clear();
  133680. this._beforeRenderingMeshStage.clear();
  133681. this._afterRenderingMeshStage.clear();
  133682. this._afterRenderingGroupDrawStage.clear();
  133683. this._afterCameraDrawStage.clear();
  133684. this._afterRenderTargetDrawStage.clear();
  133685. this._afterRenderStage.clear();
  133686. this._beforeCameraUpdateStage.clear();
  133687. this._beforeClearStage.clear();
  133688. this._gatherRenderTargetsStage.clear();
  133689. this._gatherActiveCameraRenderTargetsStage.clear();
  133690. this._pointerMoveStage.clear();
  133691. this._pointerDownStage.clear();
  133692. this._pointerUpStage.clear();
  133693. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  133694. var component = _a[_i];
  133695. component.dispose();
  133696. }
  133697. this.importedMeshesFiles = new Array();
  133698. this.stopAllAnimations();
  133699. this.resetCachedMaterial();
  133700. // Smart arrays
  133701. if (this.activeCamera) {
  133702. this.activeCamera._activeMeshes.dispose();
  133703. this.activeCamera = null;
  133704. }
  133705. this._activeMeshes.dispose();
  133706. this._renderingManager.dispose();
  133707. this._processedMaterials.dispose();
  133708. this._activeParticleSystems.dispose();
  133709. this._activeSkeletons.dispose();
  133710. this._softwareSkinnedMeshes.dispose();
  133711. this._renderTargets.dispose();
  133712. this._registeredForLateAnimationBindings.dispose();
  133713. this._meshesForIntersections.dispose();
  133714. this._toBeDisposed = [];
  133715. // Abort active requests
  133716. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  133717. var request = _c[_b];
  133718. request.abort();
  133719. }
  133720. // Events
  133721. this.onDisposeObservable.notifyObservers(this);
  133722. this.onDisposeObservable.clear();
  133723. this.onBeforeRenderObservable.clear();
  133724. this.onAfterRenderObservable.clear();
  133725. this.onBeforeRenderTargetsRenderObservable.clear();
  133726. this.onAfterRenderTargetsRenderObservable.clear();
  133727. this.onAfterStepObservable.clear();
  133728. this.onBeforeStepObservable.clear();
  133729. this.onBeforeActiveMeshesEvaluationObservable.clear();
  133730. this.onAfterActiveMeshesEvaluationObservable.clear();
  133731. this.onBeforeParticlesRenderingObservable.clear();
  133732. this.onAfterParticlesRenderingObservable.clear();
  133733. this.onBeforeDrawPhaseObservable.clear();
  133734. this.onAfterDrawPhaseObservable.clear();
  133735. this.onBeforeAnimationsObservable.clear();
  133736. this.onAfterAnimationsObservable.clear();
  133737. this.onDataLoadedObservable.clear();
  133738. this.onBeforeRenderingGroupObservable.clear();
  133739. this.onAfterRenderingGroupObservable.clear();
  133740. this.onMeshImportedObservable.clear();
  133741. this.onBeforeCameraRenderObservable.clear();
  133742. this.onAfterCameraRenderObservable.clear();
  133743. this.onReadyObservable.clear();
  133744. this.onNewCameraAddedObservable.clear();
  133745. this.onCameraRemovedObservable.clear();
  133746. this.onNewLightAddedObservable.clear();
  133747. this.onLightRemovedObservable.clear();
  133748. this.onNewGeometryAddedObservable.clear();
  133749. this.onGeometryRemovedObservable.clear();
  133750. this.onNewTransformNodeAddedObservable.clear();
  133751. this.onTransformNodeRemovedObservable.clear();
  133752. this.onNewMeshAddedObservable.clear();
  133753. this.onMeshRemovedObservable.clear();
  133754. this.onNewMaterialAddedObservable.clear();
  133755. this.onMaterialRemovedObservable.clear();
  133756. this.onNewTextureAddedObservable.clear();
  133757. this.onTextureRemovedObservable.clear();
  133758. this.onPrePointerObservable.clear();
  133759. this.onPointerObservable.clear();
  133760. this.onPreKeyboardObservable.clear();
  133761. this.onKeyboardObservable.clear();
  133762. this.onActiveCameraChanged.clear();
  133763. this.detachControl();
  133764. // Detach cameras
  133765. var canvas = this._engine.getRenderingCanvas();
  133766. if (canvas) {
  133767. var index;
  133768. for (index = 0; index < this.cameras.length; index++) {
  133769. this.cameras[index].detachControl(canvas);
  133770. }
  133771. }
  133772. // Release animation groups
  133773. while (this.animationGroups.length) {
  133774. this.animationGroups[0].dispose();
  133775. }
  133776. // Release lights
  133777. while (this.lights.length) {
  133778. this.lights[0].dispose();
  133779. }
  133780. // Release meshes
  133781. while (this.meshes.length) {
  133782. this.meshes[0].dispose(true);
  133783. }
  133784. while (this.transformNodes.length) {
  133785. this.transformNodes[0].dispose(true);
  133786. }
  133787. // Release cameras
  133788. while (this.cameras.length) {
  133789. this.cameras[0].dispose();
  133790. }
  133791. // Release materials
  133792. if (this.defaultMaterial) {
  133793. this.defaultMaterial.dispose();
  133794. }
  133795. while (this.multiMaterials.length) {
  133796. this.multiMaterials[0].dispose();
  133797. }
  133798. while (this.materials.length) {
  133799. this.materials[0].dispose();
  133800. }
  133801. // Release particles
  133802. while (this.particleSystems.length) {
  133803. this.particleSystems[0].dispose();
  133804. }
  133805. // Release postProcesses
  133806. while (this.postProcesses.length) {
  133807. this.postProcesses[0].dispose();
  133808. }
  133809. // Release textures
  133810. while (this.textures.length) {
  133811. this.textures[0].dispose();
  133812. }
  133813. // Release UBO
  133814. this._sceneUbo.dispose();
  133815. if (this._alternateSceneUbo) {
  133816. this._alternateSceneUbo.dispose();
  133817. }
  133818. // Post-processes
  133819. this.postProcessManager.dispose();
  133820. // Remove from engine
  133821. index = this._engine.scenes.indexOf(this);
  133822. if (index > -1) {
  133823. this._engine.scenes.splice(index, 1);
  133824. }
  133825. this._engine.wipeCaches(true);
  133826. this._isDisposed = true;
  133827. };
  133828. Object.defineProperty(Scene.prototype, "isDisposed", {
  133829. /**
  133830. * Gets if the scene is already disposed
  133831. */
  133832. get: function () {
  133833. return this._isDisposed;
  133834. },
  133835. enumerable: true,
  133836. configurable: true
  133837. });
  133838. /**
  133839. * Call this function to reduce memory footprint of the scene.
  133840. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  133841. */
  133842. Scene.prototype.clearCachedVertexData = function () {
  133843. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  133844. var mesh = this.meshes[meshIndex];
  133845. var geometry = mesh.geometry;
  133846. if (geometry) {
  133847. geometry._indices = [];
  133848. for (var vbName in geometry._vertexBuffers) {
  133849. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  133850. continue;
  133851. }
  133852. geometry._vertexBuffers[vbName]._buffer._data = null;
  133853. }
  133854. }
  133855. }
  133856. };
  133857. /**
  133858. * This function will remove the local cached buffer data from texture.
  133859. * It will save memory but will prevent the texture from being rebuilt
  133860. */
  133861. Scene.prototype.cleanCachedTextureBuffer = function () {
  133862. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  133863. var baseTexture = _a[_i];
  133864. var buffer = baseTexture._buffer;
  133865. if (buffer) {
  133866. baseTexture._buffer = null;
  133867. }
  133868. }
  133869. };
  133870. /**
  133871. * Get the world extend vectors with an optional filter
  133872. *
  133873. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  133874. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  133875. */
  133876. Scene.prototype.getWorldExtends = function (filterPredicate) {
  133877. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  133878. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  133879. filterPredicate = filterPredicate || (function () { return true; });
  133880. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  133881. mesh.computeWorldMatrix(true);
  133882. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  133883. return;
  133884. }
  133885. var boundingInfo = mesh.getBoundingInfo();
  133886. var minBox = boundingInfo.boundingBox.minimumWorld;
  133887. var maxBox = boundingInfo.boundingBox.maximumWorld;
  133888. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  133889. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  133890. });
  133891. return {
  133892. min: min,
  133893. max: max
  133894. };
  133895. };
  133896. // Picking
  133897. /**
  133898. * Creates a ray that can be used to pick in the scene
  133899. * @param x defines the x coordinate of the origin (on-screen)
  133900. * @param y defines the y coordinate of the origin (on-screen)
  133901. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  133902. * @param camera defines the camera to use for the picking
  133903. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  133904. * @returns a Ray
  133905. */
  133906. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  133907. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  133908. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133909. };
  133910. /**
  133911. * Creates a ray that can be used to pick in the scene
  133912. * @param x defines the x coordinate of the origin (on-screen)
  133913. * @param y defines the y coordinate of the origin (on-screen)
  133914. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  133915. * @param result defines the ray where to store the picking ray
  133916. * @param camera defines the camera to use for the picking
  133917. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  133918. * @returns the current scene
  133919. */
  133920. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  133921. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  133922. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133923. };
  133924. /**
  133925. * Creates a ray that can be used to pick in the scene
  133926. * @param x defines the x coordinate of the origin (on-screen)
  133927. * @param y defines the y coordinate of the origin (on-screen)
  133928. * @param camera defines the camera to use for the picking
  133929. * @returns a Ray
  133930. */
  133931. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  133932. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133933. };
  133934. /**
  133935. * Creates a ray that can be used to pick in the scene
  133936. * @param x defines the x coordinate of the origin (on-screen)
  133937. * @param y defines the y coordinate of the origin (on-screen)
  133938. * @param result defines the ray where to store the picking ray
  133939. * @param camera defines the camera to use for the picking
  133940. * @returns the current scene
  133941. */
  133942. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  133943. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133944. };
  133945. /** Launch a ray to try to pick a mesh in the scene
  133946. * @param x position on screen
  133947. * @param y position on screen
  133948. * @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
  133949. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  133950. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  133951. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133952. * @returns a PickingInfo
  133953. */
  133954. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  133955. // Dummy info if picking as not been imported
  133956. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  133957. pi._pickingUnavailable = true;
  133958. return pi;
  133959. };
  133960. /** Use the given ray to pick a mesh in the scene
  133961. * @param ray The ray to use to pick meshes
  133962. * @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
  133963. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  133964. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133965. * @returns a PickingInfo
  133966. */
  133967. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  133968. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133969. };
  133970. /**
  133971. * Launch a ray to try to pick a mesh in the scene
  133972. * @param x X position on screen
  133973. * @param y Y position on screen
  133974. * @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
  133975. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  133976. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133977. * @returns an array of PickingInfo
  133978. */
  133979. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  133980. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133981. };
  133982. /**
  133983. * Launch a ray to try to pick a mesh in the scene
  133984. * @param ray Ray to use
  133985. * @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
  133986. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133987. * @returns an array of PickingInfo
  133988. */
  133989. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  133990. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133991. };
  133992. /**
  133993. * Force the value of meshUnderPointer
  133994. * @param mesh defines the mesh to use
  133995. */
  133996. Scene.prototype.setPointerOverMesh = function (mesh) {
  133997. if (this._pointerOverMesh === mesh) {
  133998. return;
  133999. }
  134000. var actionManager;
  134001. if (this._pointerOverMesh) {
  134002. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger);
  134003. if (actionManager) {
  134004. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  134005. }
  134006. }
  134007. this._pointerOverMesh = mesh;
  134008. if (this._pointerOverMesh) {
  134009. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger);
  134010. if (actionManager) {
  134011. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  134012. }
  134013. }
  134014. };
  134015. /**
  134016. * Gets the mesh under the pointer
  134017. * @returns a Mesh or null if no mesh is under the pointer
  134018. */
  134019. Scene.prototype.getPointerOverMesh = function () {
  134020. return this._pointerOverMesh;
  134021. };
  134022. // Misc.
  134023. /** @hidden */
  134024. Scene.prototype._rebuildGeometries = function () {
  134025. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  134026. var geometry = _a[_i];
  134027. geometry._rebuild();
  134028. }
  134029. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  134030. var mesh = _c[_b];
  134031. mesh._rebuild();
  134032. }
  134033. if (this.postProcessManager) {
  134034. this.postProcessManager._rebuild();
  134035. }
  134036. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  134037. var component = _e[_d];
  134038. component.rebuild();
  134039. }
  134040. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  134041. var system = _g[_f];
  134042. system.rebuild();
  134043. }
  134044. };
  134045. /** @hidden */
  134046. Scene.prototype._rebuildTextures = function () {
  134047. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  134048. var texture = _a[_i];
  134049. texture._rebuild();
  134050. }
  134051. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  134052. };
  134053. // Tags
  134054. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  134055. if (tagsQuery === undefined) {
  134056. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  134057. return list;
  134058. }
  134059. var listByTags = [];
  134060. forEach = forEach || (function (item) { return; });
  134061. for (var i in list) {
  134062. var item = list[i];
  134063. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  134064. listByTags.push(item);
  134065. forEach(item);
  134066. }
  134067. }
  134068. return listByTags;
  134069. };
  134070. /**
  134071. * Get a list of meshes by tags
  134072. * @param tagsQuery defines the tags query to use
  134073. * @param forEach defines a predicate used to filter results
  134074. * @returns an array of Mesh
  134075. */
  134076. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  134077. return this._getByTags(this.meshes, tagsQuery, forEach);
  134078. };
  134079. /**
  134080. * Get a list of cameras by tags
  134081. * @param tagsQuery defines the tags query to use
  134082. * @param forEach defines a predicate used to filter results
  134083. * @returns an array of Camera
  134084. */
  134085. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  134086. return this._getByTags(this.cameras, tagsQuery, forEach);
  134087. };
  134088. /**
  134089. * Get a list of lights by tags
  134090. * @param tagsQuery defines the tags query to use
  134091. * @param forEach defines a predicate used to filter results
  134092. * @returns an array of Light
  134093. */
  134094. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  134095. return this._getByTags(this.lights, tagsQuery, forEach);
  134096. };
  134097. /**
  134098. * Get a list of materials by tags
  134099. * @param tagsQuery defines the tags query to use
  134100. * @param forEach defines a predicate used to filter results
  134101. * @returns an array of Material
  134102. */
  134103. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  134104. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  134105. };
  134106. /**
  134107. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  134108. * This allowed control for front to back rendering or reversly depending of the special needs.
  134109. *
  134110. * @param renderingGroupId The rendering group id corresponding to its index
  134111. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  134112. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  134113. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  134114. */
  134115. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  134116. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  134117. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  134118. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  134119. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  134120. };
  134121. /**
  134122. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  134123. *
  134124. * @param renderingGroupId The rendering group id corresponding to its index
  134125. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  134126. * @param depth Automatically clears depth between groups if true and autoClear is true.
  134127. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  134128. */
  134129. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  134130. if (depth === void 0) { depth = true; }
  134131. if (stencil === void 0) { stencil = true; }
  134132. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  134133. };
  134134. /**
  134135. * Gets the current auto clear configuration for one rendering group of the rendering
  134136. * manager.
  134137. * @param index the rendering group index to get the information for
  134138. * @returns The auto clear setup for the requested rendering group
  134139. */
  134140. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  134141. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  134142. };
  134143. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  134144. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  134145. get: function () {
  134146. return this._blockMaterialDirtyMechanism;
  134147. },
  134148. set: function (value) {
  134149. if (this._blockMaterialDirtyMechanism === value) {
  134150. return;
  134151. }
  134152. this._blockMaterialDirtyMechanism = value;
  134153. if (!value) { // Do a complete update
  134154. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  134155. }
  134156. },
  134157. enumerable: true,
  134158. configurable: true
  134159. });
  134160. /**
  134161. * Will flag all materials as dirty to trigger new shader compilation
  134162. * @param flag defines the flag used to specify which material part must be marked as dirty
  134163. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  134164. */
  134165. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  134166. if (this._blockMaterialDirtyMechanism) {
  134167. return;
  134168. }
  134169. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  134170. var material = _a[_i];
  134171. if (predicate && !predicate(material)) {
  134172. continue;
  134173. }
  134174. material.markAsDirty(flag);
  134175. }
  134176. };
  134177. /** @hidden */
  134178. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  134179. var _this = this;
  134180. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  134181. this._activeRequests.push(request);
  134182. request.onCompleteObservable.add(function (request) {
  134183. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  134184. });
  134185. return request;
  134186. };
  134187. /** @hidden */
  134188. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  134189. var _this = this;
  134190. return new Promise(function (resolve, reject) {
  134191. _this._loadFile(url, function (data) {
  134192. resolve(data);
  134193. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  134194. reject(exception);
  134195. });
  134196. });
  134197. };
  134198. // Statics
  134199. Scene._uniqueIdCounter = 0;
  134200. /** The fog is deactivated */
  134201. Scene.FOGMODE_NONE = 0;
  134202. /** The fog density is following an exponential function */
  134203. Scene.FOGMODE_EXP = 1;
  134204. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  134205. Scene.FOGMODE_EXP2 = 2;
  134206. /** The fog density is following a linear function. */
  134207. Scene.FOGMODE_LINEAR = 3;
  134208. /**
  134209. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  134210. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134211. */
  134212. Scene.MinDeltaTime = 1.0;
  134213. /**
  134214. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  134215. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134216. */
  134217. Scene.MaxDeltaTime = 1000.0;
  134218. /** The distance in pixel that you have to move to prevent some events */
  134219. Scene.DragMovementThreshold = 10; // in pixels
  134220. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  134221. Scene.LongPressDelay = 500; // in milliseconds
  134222. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  134223. Scene.DoubleClickDelay = 300; // in milliseconds
  134224. /** If you need to check double click without raising a single click at first click, enable this flag */
  134225. Scene.ExclusiveDoubleClickMode = false;
  134226. return Scene;
  134227. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  134228. /***/ }),
  134229. /***/ "./sceneComponent.ts":
  134230. /*!***************************!*\
  134231. !*** ./sceneComponent.ts ***!
  134232. \***************************/
  134233. /*! exports provided: SceneComponentConstants, Stage */
  134234. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134235. "use strict";
  134236. __webpack_require__.r(__webpack_exports__);
  134237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  134238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  134239. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  134240. /**
  134241. * Groups all the scene component constants in one place to ease maintenance.
  134242. * @hidden
  134243. */
  134244. var SceneComponentConstants = /** @class */ (function () {
  134245. function SceneComponentConstants() {
  134246. }
  134247. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  134248. SceneComponentConstants.NAME_LAYER = "Layer";
  134249. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  134250. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  134251. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  134252. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  134253. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  134254. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  134255. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  134256. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  134257. SceneComponentConstants.NAME_SPRITE = "Sprite";
  134258. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  134259. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  134260. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  134261. SceneComponentConstants.NAME_OCTREE = "Octree";
  134262. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  134263. SceneComponentConstants.NAME_AUDIO = "Audio";
  134264. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  134265. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  134266. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  134267. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  134268. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  134269. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  134270. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  134271. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  134272. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  134273. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  134274. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  134275. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  134276. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  134277. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  134278. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  134279. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  134280. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  134281. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  134282. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  134283. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  134284. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  134285. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  134286. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  134287. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  134288. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  134289. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  134290. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  134291. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  134292. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  134293. return SceneComponentConstants;
  134294. }());
  134295. /**
  134296. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  134297. * @hidden
  134298. */
  134299. var Stage = /** @class */ (function (_super) {
  134300. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  134301. /**
  134302. * Hide ctor from the rest of the world.
  134303. * @param items The items to add.
  134304. */
  134305. function Stage(items) {
  134306. return _super.apply(this, items) || this;
  134307. }
  134308. /**
  134309. * Creates a new Stage.
  134310. * @returns A new instance of a Stage
  134311. */
  134312. Stage.Create = function () {
  134313. return Object.create(Stage.prototype);
  134314. };
  134315. /**
  134316. * Registers a step in an ordered way in the targeted stage.
  134317. * @param index Defines the position to register the step in
  134318. * @param component Defines the component attached to the step
  134319. * @param action Defines the action to launch during the step
  134320. */
  134321. Stage.prototype.registerStep = function (index, component, action) {
  134322. var i = 0;
  134323. var maxIndex = Number.MAX_VALUE;
  134324. for (; i < this.length; i++) {
  134325. var step = this[i];
  134326. maxIndex = step.index;
  134327. if (index < maxIndex) {
  134328. break;
  134329. }
  134330. }
  134331. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  134332. };
  134333. /**
  134334. * Clears all the steps from the stage.
  134335. */
  134336. Stage.prototype.clear = function () {
  134337. this.length = 0;
  134338. };
  134339. return Stage;
  134340. }(Array));
  134341. /***/ })
  134342. /******/ });
  134343. });
  134344. //# sourceMappingURL=babylon.max.js.map